Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7620719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:00:21+00:00 2026-05-31T04:00:21+00:00

I am maintaining an Android app that people use to display strings in various

  • 0

I am maintaining an Android app that people use to display strings in various exotic languages like Tibetan or old Greek. Because Android devices come with very few fonts, users can put font files on the SD card, and the app will use them.

QUESTION: Given a string, how can I automatically decide which font file is the most appropriate, so that this string appears without characters being replaced with squares/boxes?

Notes:

  • Each string is in one language.
  • Strings are displayed in a WebView.
  • Custom fonts work, the only problem is deciding which font file to use.
  • Instead of a single font, it could provide a list of fonts that are acceptable for that string.


Unnecessary context, for the curious: I am trying to develop this feature:
http://code.google.com/p/ankidroid/issues/detail?id=779


UPDATE: I ended up creating the Antisquare Open Source library based on Mostafa’s idea.
It has a getSuitableFonts method which is blazingly fast.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:00:23+00:00Added an answer on May 31, 2026 at 4:00 am

    Android by itself does not provide enough for such a task. Loading and rendering fonts in Android happens in Skia, which is written in C. Skia detects if a character can’t be found in a font and falls back to another font for such characters (not the whole string). That’s how Japanese, Hebrew, or Arabic text is shown in Android and that’s exactly why these scripts don’t have bold face! (Their font is selected through fallback and fallback only selects one font file.)

    Unfortunately, this mechanism is not provided in APIs and you have to build similar thing on your own. It seems complicated, but is easier than it looks. All you have to do is:

    1. Prepare lists of characters available in each font file.
    2. For every string find the font that has more characters of the string.

    Getting list of characters in each font

    You don’t have to do this on-the-fly in your Android app. You can prepare the list of characters in each font and put these lists in your app. I say that because this is way easier with tools that may not be available in Android. I would do that through Python scripting in a font app (most serious font tools have awesome Python scripting environments), but these apps are expensive and are for serious type designers. Since you’re an Android developer, I recommend using sfntly, a library in Java and C++. Doing what you need (getting a list of Unicode characters available in a font file) is easy with sfntly. This sample works with CMap tables (tables that hold character to glyph mapping) and should be a good starting point for you.

    Now the interesting part is that snftly is in Java and you may be able to include that in your Android app and do everything automatically. That’s awesome by I recommend you start by getting familiar with snftly.

    Selecting the font

    After the previous part you’ll have a list of Unicode character for every font, and based on these lists selecting the font file that provides most characters of every string is trivial.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am maintaining an app for a client that is used in two locations.
I've written an Android app that needs the short timezone name in which the
While maintaining an old product, I came across an error that results in the
I recently started maintaining an old EJB2 application running on OC4J. That includes EJB
I just read about maintaining state of my android app and stumbled upon onRetainNonConfigurationInstance.
I'm maintaining an old VB6 application, that uses some Sheridan 3D controls (SSPanel and
I'm developing an Android app that receives the ougoing call event and extract the
I am maintaining a few web applications. The development and qa environments use invalid/outdated
I'm maintaining some code that uses a *= operator in a query to a
I am using Log4j API for maintaining logs in my Android Application. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.