android-fonts

How to read kerning pairs table from TTF file in Android

纵然是瞬间 提交于 2021-02-04 13:36:12
问题 I am currently drawing text on Canvas while using external (non-standard) font, loaded from TTF file. I want to enable kerning for the text I am displaying. What I want to know is if there is a possibility to read kerning pairs from typeface using Android API. 回答1: What I want to know is if there is a possibility to read kerning pairs from typeface using Android API. There is no public API to read kerning pairs from a TTF file. However, I pulled the relevant code from Apache FOP and you can

How to use specified weights for fonts in XML

南楼画角 提交于 2020-05-24 08:09:07
问题 Using the Fonts in XML feature you can specify various font weights for a font family. For example: <?xml version="1.0" encoding="utf-8"?> <font-family xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <font android:font="@font/archivo_narrow_regular" android:fontWeight="400" android:fontStyle="normal" app:font="@font/archivo_narrow_regular" app:fontWeight="400" app:fontStyle="normal"/> <font android:font="@font/archivo_narrow

Crash when using bundled ttf font on Android 10 / Android Q

半腔热情 提交于 2020-05-15 04:32:26
问题 After I updated the target level for my Android app from 28 to 29 (Android 10) the app crashes on a Pixel 3 (with Android 10). Versions used Android Gradle Plugin 3.5.0 Gradle 5.5.1 Question: Is this a known issue? Details The crash happens on various layouts using different tags (TextView, androidx.appcompat.widget.AppCompatTextView, etc) I use the attribute "android:fontFamily" and reference a font bundled in one of my external libraries. The font file, opensans_regular.ttf , is placed in

Crash on calligraphy library by chris Jenx for Android Q

≡放荡痞女 提交于 2020-01-14 09:10:32
问题 I have a calligraphy library I am using for custom fonts which seems to work on all versions except for android Q , where it crashes my app right on launch.Any one else has had to deal with the same issue lately? Here's my crash report : Caused by: android.view.InflateException: Binary XML file line #17 in com.myapp.dev:layout/abc_screen_simple: Binary XML file line #17 in com.myapp.dev:layout/abc_screen_simple: Error inflating class android.support.v7.widget.FitWindowsLinearLayout Caused by:

how to add font in Android Application

可紊 提交于 2020-01-13 02:43:19
问题 i am making one application in Android 2.2 in that application i want to show hindi text in TextView in Android application. (how to add "मैं छात्र हूँ" word in Text view) Please help me.. 回答1: Add your font to assets folder in your project and use the below snippet TextView hindiTextView=(TextView)findViewById(R.id.txtbx); Typeface hindiFont=Typeface.createFromAsset(getAssets(),"fonts/fontname.ttf"); mytextView.setTypeface(hindiFont); Hope its helpful. 回答2: 1) add "fonts" folder inside of

How to change font type and color in this listview

徘徊边缘 提交于 2020-01-06 03:15:26
问题 I have two string arrays: array1 and array2 . How can I change the font type? How can I change the color for some element of the array (for example the first and the fifth element)? My font type is in raw/price.ttf. ListView listView1=(ListView) findViewById(R.id.listView1); List<Map<String, String>> data = new ArrayList<Map<String, String>>(); for (int i=0; i<array2.length; i++) { Map<String, String> datum = new HashMap<String, String>(2); datum.put("title", array1[i]); datum.put("subtitle",

how to use font file

匆匆过客 提交于 2020-01-04 08:20:23
问题 I wanna use custom font file. For that below is my code XML file: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:id="@+id/custom_font" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="This is the Chantelli Antiqua font." /> </LinearLayout> Java code: TextView txt =

Set font size on phone and tablet

萝らか妹 提交于 2019-12-31 07:07:44
问题 How to set the font size for a textview in a phone and a tablet. The posts I've referred suggested to creating dimen.xml and placing them in different folders namely values-mdpi , values-hdpi , values-ldpi . The tablet (1024x600) resolution picks from the values-mdpi folder and so does the the phone (320x480) also picks from the values-mdpi folder, this makes the font look really big and distorted on the phone, whereas it looks fine on the tablet. Is there any way to specify a font size for

Change the font of tab text in android design support TabLayout

一笑奈何 提交于 2019-12-27 13:37:37
问题 I'm trying to work on the new TabLayout from the android design library. I want to change tab text to custom font . And,I tried to search some styling related to TabLayout ,but ended up to this. Please guide how can I change the tab text fonts. 回答1: Create a TextView from Java Code or XML like this <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@android:id/text1"

Downloadable Fonts Exception

送分小仙女□ 提交于 2019-12-23 20:23:15
问题 I decided to use Downloadable fonts in my project. I implemented everything as recommened in the guide. The following problem occured, when i tried to get font from ResourcesCompat next way: ResourcesCompat.getFont(MainActivity.this, R.font.roboto_bold) After that, i always get this exeption: Font resource ID #0x7f090005 could not be retrieved How to solve this problem? PS: support-compat library v27 min sdk 16 solution via ResourcesCompat.FontCallback is not a good way in my case problem