You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A function to get a list of all the fonts used in the current style would be helpful. This function does most of it, although it won't find font names referred to in a ['format', ... { 'text-font': ... }] block.
functiongetFonts(map)functionfindLiterals(expr){if(Array.isArray(expr)){if(expr[0]==='literal'){///fonts.push(...expr[1]);}else{expr.forEach(findLiterals);}}}letfonts=[];constfontExprs=map.getStyle().layers.map((l)=>l.layout&&l.layout['text-font']).filter(Boolean);for(constfontExproffontExprs){// if top level expression is an array of strings, it's hopefully ['Arial', ...] and not ['get', 'font']if(fontExpr.every((f)=>typeoff==='string')){fonts.push(...fontExpr);}else{findLiterals(fontExpr);}}return[...newSet(fonts)];}
The text was updated successfully, but these errors were encountered:
A function to get a list of all the fonts used in the current style would be helpful. This function does most of it, although it won't find font names referred to in a
['format', ... { 'text-font': ... }]
block.The text was updated successfully, but these errors were encountered: