Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about Android development and PDF

TOPIC:

trouble with fallback fonts 5 years 8 months ago #14082

  • arlomedia
  • arlomedia's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
  • Posts: 56
  • Thank you received: 1
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.

Please Log in or Create an account to join the conversation.

trouble with fallback fonts 5 years 8 months ago #14083

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
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.

Please Log in or Create an account to join the conversation.

trouble with fallback fonts 5 years 8 months ago #14084

  • arlomedia
  • arlomedia's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
  • Posts: 56
  • Thank you received: 1
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.

Please Log in or Create an account to join the conversation.

Last edit: by arlomedia.

trouble with fallback fonts 5 years 8 months ago #14085

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
//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.
The following user(s) said Thank You: support

Please Log in or Create an account to join the conversation.

trouble with fallback fonts 5 years 8 months ago #14086

  • arlomedia
  • arlomedia's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
  • Posts: 56
  • Thank you received: 1
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:
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.

Please Log in or Create an account to join the conversation.

Last edit: by arlomedia.

trouble with fallback fonts 5 years 7 months ago #14121

  • arlomedia
  • arlomedia's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
  • Posts: 56
  • Thank you received: 1
One of the users who first reported this has confirmed that the change described above fixes the problem.
The following user(s) said Thank You: support

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum