Android different font for each language

android change language in app example
android multi language
android typeface
android set font family programmatically
android supporting languages
change app language android
android font family list
android use custom font in xml

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.

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"/>

Stylizing your multilingual app with a variety of fonts, Setting a custom font in android used to be quite a headache, there was no way to successfully inflate different fonts in the app for different languages, and it's� Note: Android Studio can automatically populate the values for the Google Play services provider if you use the font selector tool in Android Studio. For more information about using Android Studio for downloading fonts, go to the Using Downloadable Fonts via Android Studio and Google Play services section.

It is possible.

  1. Put your localized otf file in your font folder (not localized)
  2. Duplicate your styles.xml in your localized values folder (values-fr) without any change with <item name="android:fontFamily">@font/app_font</item>.
  3. Create localized font folder (font-fr).
  4. In your new font folder create app_font.xml with android:font="@font/your_localized_otf_file"

Your localized font folder will be used by the localized styles file in your localized values folder. But otf/ttf file should be in general font folder.

Update:

Above answer was just to make use of font-xx folder (it is requested in the question) but since we are using localized styles.xml, there is a simpler solution without font-xx folder.

  1. Put your localized otf file in your font folder
  2. Create different_language_font.xml in your font folder with android:font="@font/your_localized_otf_file"
  3. In your styles.xml in your localized values folder (values-fr) <item name="android:fontFamily">@font/different_language_font</item>

Support different languages and cultures, Change Language — For this we use String.xml for all Layout Xml text. Every Language have its own code to define Language for example if� Give your text extra pimp by using fonts in android apps. The typeface API of textview allows us to apply any font to it. We can also apply different language fonts.

You can have different styles.xml file for each localization. and there you can define fontFamily under each style file.

And to declare font family you can create an xml file like below where you can referent otf or ttf files.

You can create .xml files under font directory. and define all the fonts there.

<!--  bukra.xml file which contains all the font families -->

<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android">

<font
    android:font="@font/bukra_semi_condensed_extra_light_normal"
    android:fontStyle="normal" />

<font
    android:font="@font/bukra_semi_condense_light_slanted"
    android:fontStyle="italic" />

</font-family>

And define two different fonts for your app based on localization like this.

This styles.xml file is under my values-ar file.

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimary</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="fontFamily">@font/bukra</item>
    </style>

Change Language & Font in Android | by Kunal Kumar, Android Tutorial for using different language custom fonts Take your app to the top keyword Duration: 4:35 Posted: 6 Jul 2013 Is it possible to have texts with different sizes, font-types or styles in the Rich-Style Formatting of an Android English Language Learners; Japanese

Android Tutorial for using different language custom fonts, Hi, I used both English and Korean on my phone. I would like to use the default font for English, but change the font of Korean. Is there any way� Fonts by Language. Search for fonts for multilingual fonts by language or script.

Possible to use different fonts for different languages?, Whichever solution you use for language switching, I am sure it sets a meta tag with the language (see case 1) or adds a class to the html or� It is not possible to set different fonts for different languages without distinguishing pieces of text by language at the markup level. You would normally use <span> tags with a class attribute or a lang attribute or both.

How to set different font family based on text language?, Font Height. If we're selecting different fonts for the different languages our software supports, we need to look at the characteristics of our fonts to� A font resource defines a custom font that you can use in your app. Fonts can be individual font files or a collection of font files, known as a font family and defined in XML. Also see how to define fonts in XML or instead use downloadable fonts .

Comments