-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TiledVectorLayer: Couldn't load font name: Frutiger #632
Comments
Same crash happens on iOS with style url |
Hi @danielz-42 and @rostopira, Please excuse the (extremely) late reply and the non-existent documentation regarding the font handling in vector layers. At the current state, the layer does not load the glyph data from the url specified in the style.json, but instead relies on a FontLoader to provide a texture atlas and json with all the relevant symbols. While the support for the former might be added in the future, it is not worked actively on at the moment. In your case on Android @danielz-42, there is the option to specify the path to an asset folder, from which the FontLoader tries to load the textures and glyph descriptions (png and json, respectively). When no such path is provided (such as with the constructor you used), this data can be added manually when loaded from a different source. Regarding the format of this glyph data: In OpenMobileMaps we use multi-channel signed distance fields of the symbols to render them. A tool like msdf-bmfont can be used to create such a packed sprite atlas texture and descriptive json from a font file. Please note that while the default FontLoader on Android expects the json to match the structure of the class FontGlyphJsonData (which corresponds to the output of msdf-bmfont), it can easily be extended to load and provide the necessary Bitmap and FontData (only a subset msdf-bmfonts information) from another source format. Of course, a fully custom implementation of the FontLoaderInterface can be provided as well. In short, the most convenient way to support the fonts specified would be to create the font texture and json via:
where chars.txt might contain:
Ensure that all the symbols fit on one texture page. On Android, the resulting OpenSansRegular.png/.json can then be added to the projects asset folder (e.g. at the path "fonts/") and the TiledVectorLayer can be created with:
Please note, that the swisstopo style uses feature-dependent fonts, e.g. in the layer On iOS (@rostopira), the MCFontLoader can be used to load the font image and data from the project resources. I hope I was able to clear up the confusion you had about the vector layer font support. If not, please let me know. |
can you give us example of how we can achieve that on iOS ? |
Hi @liodali, To achieve this on iOS, the font texture atlases and json files need to be included in your app’s bundle. The MCFontLoader.swift can then load the font image and data directly from these resources. Regarding languages like Arabic or Chinese, support is possible as long as the provided font texture atlas includes the required characters for those scripts. You’ll need to ensure the atlas contains all glyphs needed for the language in question. |
thnx but i need more help if possible for sure since i dont have lot of experience with it |
As mentioned above, msdf-bmfont can be used to generate both the texture atlas and the JSON file required for the vector layer. This is the same for both Android and iOS. The README on their repository provides instructions on how to install it. |
I tried to use the TiledVectorLayer by:
App crashed and in logcat I found the issue:
Any hints to resolve that?
The text was updated successfully, but these errors were encountered: