Skip to content

Requests to third-party server for fonts #1030

@simonseyock

Description

@simonseyock

This lines will cause requests to a third-party server:

ol-mapbox-style/src/text.js

Lines 158 to 161 in f85e5ff

export function getFonts(
fonts,
templateUrl = 'https://cdn.jsdelivr.net/npm/@fontsource/{font-family}/{fontweight}{-fontstyle}.css'
) {

font = mb2css(
getFonts
? getFonts(
fontArray,
glStyle.metadata ? glStyle.metadata['ol:webfonts'] : undefined
)
: fontArray,
textSize,
textLineHeight
);

style = applyStyleFunction(
layer,
glStyle,
sourceOrLayers,
resolutions,
spriteData,
spriteImageUrl,
getFonts,
options.getImage
);

This is not really documented, in the stylefunction docs you find this:

Function that receives a font stack and the url template from the GL style's metadata['ol:webfonts'] property (if set) as arguments, and returns a (modified) font stack that is available. Font names are the names used in the Mapbox Style object. If not provided, the font stack will be used as-is. This function can also be used for loading web fonts.

In the fonts part of the docs you find this:

If no metadata['ol:webfonts'] property is available on the Style object, Fontsource Fonts will be used. It is also possible for the application to load other fonts. If a font is already available in the browser, ol-mapbox-style will not load it.

This does not make it clear that by default a third-party server will be requested.

Also in my personal opinion this should be an opt-in feature instead of the default behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions