Microsoft Windows Phone 8.1 support ends (13 Jul 2017)

Microsoft has ended support for Windows Phone 8.1

Questions about Android development and PDF

trouble with fallback fonts

More
IP: 97.115.135.13 7 years 6 months ago #14082 by arlomedia
It looks like the forum software resized the screen shot. Here's the original file:

www.arlomedia.com/apps/setlistmaker/radaee.png

Both my apps have android.permission.READ_EXTERNAL_STORAGE and android.permission.WRITE_EXTERNAL_STORAGE.

With that logging code enabled, the app with the problem displays "----face name = Ascender - Droid Sans Fallback." The other app that is working displays "----face name = Amiri." This is on the same device, displaying the same document.
More
IP: 111.196.245.2 7 years 6 months ago #14083 by radaee
Replied by radaee on topic trouble with fallback fonts
if font "Amiri" is not on your font list.
you can debug function call:
load_truetype_font( res, R.raw.arimo, new File(files, "arimo.ttf") );//load from APP resource
in load_truetype_font() there is function call: load_file()
i think exception happen in this function.
More
IP: 97.115.135.13 7 years 6 months ago - 7 years 6 months ago #14084 by arlomedia
I added breakpoints to load_file and found that it wasn't running because all the files already existed. I commented out the first line (save_file.exists) to force the fonts to load, and now the fonts are displaying in the app!

It seems that a bad set of fonts was included in an earlier version, and now the app won't load the new font files because it thinks they're already installed. Reinstalling the app would fix that, but then users would lose all their app data. Is there a better way to reset the saved fonts one time?

Is the rdtmp directory supposed to remain across app restarts? If so, I could update my app to delete it the first time it runs with the next update, then Global.java can recreate it. Let me know if you have a better idea, or if there are any functions built into the library to help with this.
Last edit: 7 years 6 months ago by arlomedia.
More
IP: 111.196.245.2 7 years 6 months ago #14085 by radaee
Replied by radaee on topic trouble with fallback fonts
//File sdDir = Environment.getExternalStorageDirectory();
changed to:
File sdDir = act.getExternalFilesDir("");
codes become to:
File sdDir = act.getExternalFilesDir("");
//File sdDir = Environment.getExternalStorageDirectory();
File ftmp;
if (sdDir != null)
ftmp = new File(sdDir, "rdtmp");
else
ftmp = new File(act.getFilesDir(), "rdtmp");
if (!ftmp.exists())// not exist? make it!
ftmp.mkdir();
tmp_path = ftmp.getPath();
this make sure all resources are not in same directory.
at last, load_file() function remove code to check file exists, it overwrite each time when app start.
More
IP: 97.115.135.13 7 years 6 months ago - 7 years 6 months ago #14086 by arlomedia
I like the change away from Environment.getExternalStorageDirectory. But actually I was mistaken, the bad fonts that need to be replaced are in rdres, not rdtmp. Still, we could change the setup of rdtmp to be consistent with rdres:
Code:
File ftmp = new File(act.getFilesDir(), "rdtmp"); if (!ftmp.exists())// not exist? make it! ftmp.mkdir(); tmp_path = ftmp.getPath();

Anyway, my app already has a mechanism for running code the first time a new version is installed, so I added code to delete the rdres directory one time. That will reinstall the fonts, but doesn't require them to be reinstalled every time the app runs. This is working now on my devices. I'll release it to users soon and follow up when it's confirmed resolved.
Last edit: 7 years 6 months ago by arlomedia.
More
IP: 97.115.135.13 7 years 6 months ago #14121 by arlomedia
One of the users who first reported this has confirmed that the change described above fixes the problem.
Time to create page: 0.402 seconds
Powered by Kunena Forum