From 1225454024a42697dbb1721685f3066a05f5eac8 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 21 Jul 2022 15:27:35 -0700 Subject: Prefer the style fonts --- modern/src/map/core/mapUtil.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'modern/src/map/core/mapUtil.js') 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']; +}; -- cgit v1.2.3