maplibre / maplibre-native

MapLibre Native - Interactive vector tile maps for iOS, Android and other platforms.
https://maplibre.org
BSD 2-Clause "Simplified" License
1.09k stars 322 forks source link

Respect accessibility font scale #3057

Open westnordost opened 3 days ago

westnordost commented 3 days ago

Operating systems generally offer a system-wide font-scaling setting for accessibility. MapLibre should respect this setting and scale fonts with this value, just as it respects the device's display density.

https://github.com/user-attachments/assets/165d49a0-86bf-4c69-8872-a8244cc5b02b

Use case

When I have bad eyes or generally just a display that displays text too small, I want the accessibility setting to apply to all text in all apps.

Solution I'd like

Alternatives I've considered

It is possible to implement this oneself as a developer by iterating through all symbol layers with text and change the font size by multiplying it oneself. But this is awkward and complex especially when the font size is an expression and needs to be done by developers of every app that uses MapLibre, so support for this, at best, would forever be spotty.

Additional context

The Google Maps SDK does correctly scale all text by the system-wide font-scaling setting.

The MapBox SDK does not.

For Android, the setting can be found in Configuration::fontScale

For iOS, the information seems to be in UIFontMetrics.

louwers commented 3 days ago

I think it's a good idea to implement this, but we should probably make it opt-in to be backwards compatible.

Note: Please do not use this to hardcode font size equations. The equation for font scaling is now non-linear; this coefficient is no longer used as a direct multiplier to determine font size. It exists for informational purposes only.