Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android different font for each language

Tags:

android

fonts

Is there anyway to make different font for each language? There is the values-en, values-fr ...etc, but can we do something like font-fr, font-ar ...etc?

PS, i'm talking about res/font, not about assets/fonts, i would like to be able to set one font in XML, and then get the changes with each language, without setting the Typeface programmatically.

like image 468
Amine Messabhia Avatar asked Feb 22 '19 23:02

Amine Messabhia


People also ask

Is there a font that supports all languages?

Taking its name from its goal to see 'no more tofu', Google Noto is a font which aims to 'support all languages with a harmonious look and feel'. The core Noto Sans font supports up to 582 languages across 237 regions, and even comes in 72 styles.

Can you get different fonts on Android?

Open Settings. Tap Display. Tap Font and screen zoom. Select your choice of Font Style and you're done.

Does Roboto support all languages?

Roboto supports Latin, Greek (partial) and Cyrillic scripts. On Android, the Noto font is used for languages not supported by Roboto, including Chinese (simplified and traditional), Japanese, Korean, Thai and Hindi.


1 Answers

Try this:

  1. add all of your font files in res/font
  2. localize style.xml (create values/style.xml && values-ln/style.xml)
  3. in AppTheme for every style.xml add <item name="android:fontFamily">@font/your_desired_font</item>
  4. that's all

if you have more than one font for a language (let's say regular, bold, light, etc.) then add it to each style.xml, example:

 <style name="FontLocalizedBold">
        <item name="android:fontFamily">@font/your_desired_font</item>
    </style>

usage:

<TextView
        android:id="@+id/textViewId"
        android:layout_width="100dp"
        android:layout_height="100dp"
        style="@style/FontLocalizedBold"
        android:gravity="center"
        tools:text="XX"/>
like image 130
ghita Avatar answered Oct 15 '22 23:10

ghita