openlayers / ol-mapbox-style

Use Mapbox Style objects with OpenLayers
https://unpkg.com/ol-mapbox-style/dist/examples/index.html
BSD 2-Clause "Simplified" License
344 stars 121 forks source link

Requests to third-party server for fonts #1030

Open simonseyock opened 11 months ago

simonseyock commented 11 months ago

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

https://github.com/openlayers/ol-mapbox-style/blob/f85e5ff3e06a6d96a9b832f03c93406049ee5c22/src/text.js#L158-L161

https://github.com/openlayers/ol-mapbox-style/blob/f85e5ff3e06a6d96a9b832f03c93406049ee5c22/src/stylefunction.js#L1209-L1218

https://github.com/openlayers/ol-mapbox-style/blob/f85e5ff3e06a6d96a9b832f03c93406049ee5c22/src/apply.js#L356-L365

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.

ahocevar commented 11 months ago

@simonseyock If that's made opt-in, 99% of all maps will be displayed with incorrect fonts. So I don't think this would be practical. Especially given the fact that most users will be using maps that also come from a 3rd party server.

If you have a suggestion for a doc improvement, feel free to create a pull request.

simonseyock commented 11 months ago

Ok, you are probably right. I see if I can improve the docs here.

ahocevar commented 10 months ago

Note: Ideally, map publishers like MapTiler or basemap.de should include an ol:webfonts entry in their style jsons, and provide web fonts next to their map tiles. The ol:webfonts metadata option was added after FOSS4G 2022, to give map publishers a direct way to avoid having to use 3rd party font servers.

@simonseyock, I think you're closer to basemap.de than I am, so maybe you can remind them to update their style jsons. And maybe @klokan can help to get the same done at MapTiler. For reference, here is the documentation: https://github.com/openlayers/ol-mapbox-style#font-handling.

jdnarvaez commented 10 months ago

how is this supposed to work when used in conjunction directly with a mapbox url? I cannot seem to find where I would be able to intercept the style object or style object request to inject the webfonts attribute

ahocevar commented 10 months ago

You cannot, but I think ot would make sense to ads an option for that.

simonseyock commented 10 months ago

@simonseyock, I think you're closer to basemap.de than I am, so maybe you can remind them to update their style jsons. And maybe @klokan can help to get the same done at MapTiler. For reference, here is the documentation: https://github.com/openlayers/ol-mapbox-style#font-handling.

I try to establish a contact here :+1:

marcjansen commented 10 months ago

I mention some people close to the basemap.de Team: @stenderg @sratjens @TheCartographerDev

ahocevar commented 6 months ago

See #1058