Select to view content in your preferred language

TextSymbol on GraphicsLayer doesn't support most fonts compared to esri 3

625
3
Jump to solution
10-20-2023 02:35 PM
JacksonQiu
Emerging Contributor

Hello, our team displays esri Graphics on a GraphicsLayer and we have a second GraphicsLayer with textSymbols on them that represent labels of the graphics. In esri 3, we were able to set the family of esri.Font to be any font, including fonts that might be acquired through the browser from a third party like google fonts.

From the new esri 4 API https://developers.arcgis.com/javascript/latest/labeling/#custom-fonts-and-disconnected-environments it sounds like "In 2D MapViews, the fonts files used are pbf for all non-MapImageLayer layers and for TextSymbol, and woff2 for renderPreviewHTML." describes our situation.

This would be a breaking change for us as we've found that setting font family in the same way in most cases leads to a fallback case being hit. The only font that supports all our needs from the current font server is Arial. Does anyone have any suggestions?

0 Kudos
1 Solution

Accepted Solutions
Noah-Sager
Esri Regular Contributor

I think both @JoelBennett and @JonathanTiu are correct.

For additional information, we changed the implementation of how we handle font resources at version 4.8: https://www.esri.com/arcgis-blog/products/js-api-arcgis/mapping/labeling-in-2d/

 

View solution in original post

0 Kudos
3 Replies
JoelBennett
MVP Regular Contributor

When using a GraphicsLayer, only the fonts listed in the Non-MapImageLayer fonts section are supported by default.  Technically any font in pbf format is supported, but last I checked (which was awhile ago), there didn't seem to be a way to convert ttf fonts to pbf format.  If there was such a way, that could solve the problem, since one could set up their own repository with their own pbf files.

If you could find ttf versions of the fonts listed in the aforementioned section of the documentation, you could install them on the machine hosting ArcGIS Server, and they would then be supported both on client and server.  Otherwise, yes, Arial is pretty much the only font supported by both the server and the JavaScript SDK.

0 Kudos
JonathanTiu
Emerging Contributor

I think what Jackson is asking is that in esri 3 for GraphicLayer, you could specify any font for esri.Font including any user browser installed font. But in esri 4, according to https://developers.arcgis.com/javascript/latest/labeling/#custom-fonts-and-disconnected-environments

you can't do that anymore in the GraphicsLayer.  Only MapImageLayer and 3D scene view seem to support user browser installed fonts. That appears to be the breaking change from esri 3 to 4.

 

JonathanTiu_0-1697852118297.png

 

0 Kudos
Noah-Sager
Esri Regular Contributor

I think both @JoelBennett and @JonathanTiu are correct.

For additional information, we changed the implementation of how we handle font resources at version 4.8: https://www.esri.com/arcgis-blog/products/js-api-arcgis/mapping/labeling-in-2d/

 

0 Kudos