-
Notifications
You must be signed in to change notification settings - Fork 240
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
No system fonts fallback on Android 12 #2303
Comments
If I remember correctly we access system font files for part of our label rendering pipeline. Since it's working on android 11 but not on android 12, it would be good to verify if font file (fallback) exists and at the correct location on android 12. Maybe comparing font.xml on 11 and 12 should provide some hint. |
@tallytalwar thank you a lot. I have checked fonts.xml on Android 11 (Samsung Galaxy Tab A) and on Android 12 (Google Pixel 3a) and there is a difference. It seems that parser cannot parse fonts.xml on Android 12 because it contains text and also inner tags:
this is from Android 11:
Here are complete fonts.xml files: Google Pixel 3a (Android 12) fonts.xml: Samsung Galaxy Tab A (Android 11) fonts.xml: I am not sure what do to with this, as I have discovered that FontConfig.java file which is parsing this fonts.xml file is using XmlPullParser and it throws exception due to this (incorrect?) fonts.xml file. |
Method nextText() of XmlPullParser throws exception on line: tangram-es/platforms/android/tangram/src/main/java/com/mapzen/tangram/FontConfig.java Line 238 in fb6c83b
with message: In Android documentation for nextText() - https://developer.android.com/reference/org/xmlpull/v1/XmlPullParser#nextText() method there is written |
Our approach for locating system fonts has been unfortunately limited by the fact that the font XML files are both un-documented and non-standardized. App developers are not supposed to parse them. Our code is able to handle many font XML files, but it often breaks when new Android versions are released. Fortunately, in API level 29 Android added an interface for accessing system fonts programmatically: https://developer.android.com/reference/android/graphics/fonts/SystemFonts We still want to support older versions of Android, but when Tangram ES is running on a new enough version we could use this API to locate the available system fonts (including CJK fonts) without parsing XML at all. This change will require some time to implement and test. In the meantime, you can work around these font errors by bundling your own font with support for Chinese scripts and referencing it in your Tangram scene: https://tangrams.readthedocs.io/en/main/Syntax-Reference/fonts/ |
Thank you. Now I can see that this is not that easy to implement. I have tried to make use of SystemFonts, but unfortunately I cannot find a way to get importance of font fallbacks. It is only returning system fonts. At least I have tried to modify
But it is really a "hack" and I assume that it will work only on my device model Google Pixel 3a or in better case on all models from Google or Android One. @matteblair do you have some hints on how to improve this "hack"? |
Users of StreetComplete report that no text is displayed at all on Android 12. I use a style which sets the font family of every label to a custom font ("Roboto", Android's default font). If this is indeed the same bug, I'd propose to change the title. |
Yes, to me it seems that it is the same bug. Maybe changing title to something like "No system fonts fallback on Android 12"? |
Sorry I've been slow to follow up on this - my job has been keeping me busy! Since the current approach to locating fonts is clearly causing problems on Android 12, I think the Android font loading logic should add a completely new code path for API level 29 or newer that builds both I don't expect this to be terribly complicated but it will require a bit of time to implement and test. |
@matteblair thank you for your answer. Is there some way I can help with this to be implemented sooner? |
I've started working on this. Unfortunately there is more to the problem than I initially understood. I've run into two issues:
I'm still researching answers to these problems - just wanted to give a status update. |
@rwrx @westnordost This issue was auto-closed because I believe #2306 resolves it, but please give this latest change a try and let me know what you see! |
A user of our app reported that on Android 12 labels with Chinese characters are not shown on the map. I have checked it and unfortunately, it is the case that on Android 12 (Pixel 3a device) labels with Chinese characters are not shown. On Android 11 and older it is working properly. I have also tried to target Android 12 in our app and it did not helped. I have not digged into Tangram-ES what could be the case yet, I am just reporting it now. I am also attaching screenshots from our app (Walkabout style) and I have also noticed that it is not working in StreetComplete app too (@westnordost). Screenshots are showing Taiwan.
The text was updated successfully, but these errors were encountered: