diff options
author | Anton Tananaev <anton@traccar.org> | 2022-07-21 15:27:35 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-07-21 18:31:07 -0700 |
commit | 1225454024a42697dbb1721685f3066a05f5eac8 (patch) | |
tree | 70ed20abab7a562345154985f5935c42a68b826a /modern/src/map/core | |
parent | 4cdda2a42d673a901f39ecf6a24478ec683654a2 (diff) | |
download | trackermap-web-1225454024a42697dbb1721685f3066a05f5eac8.tar.gz trackermap-web-1225454024a42697dbb1721685f3066a05f5eac8.tar.bz2 trackermap-web-1225454024a42697dbb1721685f3066a05f5eac8.zip |
Prefer the style fonts
Diffstat (limited to 'modern/src/map/core')
-rw-r--r-- | modern/src/map/core/mapUtil.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/modern/src/map/core/mapUtil.js b/modern/src/map/core/mapUtil.js index 087c499b..1f8d5d8a 100644 --- a/modern/src/map/core/mapUtil.js +++ b/modern/src/map/core/mapUtil.js @@ -89,3 +89,21 @@ export const geofenceToFeature = (theme, item) => { }; export const geometryToArea = (geometry) => stringify(reverseCoordinates(geometry)); + +export const findFonts = (map) => { + const fontSet = new Set(); + const { layers } = map.getStyle(); + layers?.forEach?.((layer) => { + layer.layout?.['text-font']?.forEach?.(fontSet.add, fontSet); + }); + const availableFonts = [...fontSet]; + const regularFont = availableFonts.find((it) => it.includes('Regular')); + if (regularFont) { + return [regularFont]; + } + const anyFont = availableFonts.find(Boolean); + if (anyFont) { + return [anyFont]; + } + return ['Roboto Regular']; +}; |