Android special Unicode characters - android

I am currently developing an app which displays special unicode characters (e.g. ꁴ)
Now I encountered that on older devices those symbols can not be displayed.
How can I know if it works on the current device or not?
Do I have to create an Virtual Android Device for each SDK-Version and test?
Would it be possible to bundle the current Roboto Font into my apk and deliver it to older devices so that the characters will be displayed?

if place your custom font in assets folder and address when used you will not have an issue
place your Roboto.ttf in assests folder
Created an entry in strings.xml for each icon. Eg for a "Yi Syllable Bby":
<string name="icon_note">ꁴ</string>
Referenced said entry in the view of my xml layout:
<Button
android:id="#+id/like"
style="?android:attr/buttonStyleSmall"
...
android:text="#string/icon_note" />
Loaded the font in my onCreate method and set it for the appropriate Views:
Typeface font = Typeface.createFromAsset( getAssets(), "Roboto.ttf" );
...
Button button = (Button)findViewById( R.id.like );
button.setTypeface(font);
it can be used to use icon lib as font check here How to use icons and symbols from "Font Awesome" on Native Android Application

Related

Custom font not showing on device

I am trying to add a custom font following the "Fonts in XML" tutorial on this site. I followed the tutorial to the letter and checked many times to find something I missed but I just can't see it. The font I added is a TTF file.
In the designer, I can select my font family and the text in the TextView changes to the custom font I added. However, when I run the app on my device, the text is defaulted to the regular font. This doesn't happen with the fonts included in Android Studio.
Additional question: when I tried yet another custom font, the text in the TextView changed to the custom font, but the text itself (the content) also changed to some gibberish. Is this an indication of a bad font or something else?
sv_regular.xml
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
<font
android:fontStyle="normal"
android:fontWeight="400"
android:font="#font/sv_font_regular" />
</font-family>
TextView
<TextView
android:id="#+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="#font/sv_regular"
android:text="#string/app_name" />
You can do this programmatically
Add external fonts in your assets folder
1. Go to the (project folder)
2. Then app>src>main
3. Create folder 'assets>fonts' into the main folder.
4. Put your 'abc.ttf' into the fonts folder.
TextView tx = (TextView)findViewById(R.id.textview1);
Typeface custom_font = Typeface.createFromAsset(getAssets(),"fonts/abc.ttf");
tx.setTypeface(custom_font);
I have encountered such a problem when the font is displayed in Android Studio but does not work on a physical device.
So if you want a custom font from Android Studio to be displayed on your phone screen, you need to add this font to your project as follows:
Open res folder.
Create Android Resource Directory. Resource type - font. You can also name your new folder font.
Then simply drag and drop your ttf font into the font folder. Important: The font name must not contain prohibited characters, and all letters in the name must be lowercase. The name of my font in this example: kopenhagen
(you may have a different font name).
Open your xml file, find the text in which you want to change the font, and just add the following:
android:fontFamily="#font/kopenhagen"
*Instead of the word kopenhagen, use the name of your font
Does your font exactly support the language of the text? This problem occurs when the font does not support certain characters, such as Cyrillic. And one more: try use sv_font_regular in TextView
android:fontFamily="#font/sv_font_regular"
Example

Font- Awesome are not working in android app

I am using a custom font named AwesomeFont in Android App. This help us to produce scalable vector icon. Now the font file get applied on the view (both TextView and EditText) if the application launches from beginning but if the application is in background and get open after few minutes the font-file from the views get removed.
I also try to set typeface from onResume() method but it doesn't help me to get rid of the problem.
Please suggest a solution.
I found that that this problem exist for every custom font that I am using in the application. Custom font get applied throughout the application if is starts from launcher-icon(splash screen), but not if app launches from background after few minutes.
1- Copy fontawesome-webfont.ttf into my assests folder
2-Create an entry in strings.xml for each icon. Eg for a fa-bell:
<string name="bell"></string>
3-create entry in the view of my xml layout:
<Button
android:id="#+id/bells"
style="?android:attr/buttonStyleSmall"
...
android:text="#string/bell" />
4-Loaded the font in my onCreate method and set it for the appropriate Views:
Typeface font = Typeface.createFromAsset( getAssets(), "fontawesome-webfont.ttf" );
Button button = (Button)findViewById( R.id.bells);
button.setTypeface(font);
For more See this

Custom Fonts not working in lollipop?

I have developed a handwriting app .And one of the main feature of this is that we can change the fonts from default font to 4 other custom fonts ie, to
Vicmorg (Vic Modern Cursive)
Cursive Writing 7
Dnealiancursive
Print-Regular
And this is working fine in all devices.Yesterday I updated my nexus 10 to lollipop .Now the fonts are not taken correctly, vicmorg.ttf and Dnealiancursive.ttf are now not working but Print-Regular and Cursive Writing 7 are working .No issues in other phones though. Is there a fix for this ? Please help.
re-convert your whatever fonts to .ttf from this link works for me.
http://www.freefontconverter.com/
I did it in following way:
I have updated TextView with androidx.appcompat.widget.AppCompatTextViewand it works for each device.
Example
From
<TextView
To
<androidx.appcompat.widget.AppCompatTextView
Hope it helps you.
Error on lollipoop
test files .otf run correctly but .ttf not.
my solution for files .ttf was convert to .otf
http://www.files-conversion.com/font-converter.php
or
http://www.font2web.com/
for custom font for example, inside assets folder (../assets/fonts/birdman-webfont.otf):
Typeface birdman = Typeface.createFromAsset(getAssets(), "fonts/birdman-webfont.ttf");
TextView text= (TextView) findViewById(R.id.text);
text.setTypeface(birdman);
note: if your file is .ttf and show ERROR in the convertion, change the extension to .otf manually and convert with http://www.files-conversion.com/font-converter.php

Font issue in TextView

I have a TextView which contains just one letter. The size of the text is calibrated so that the letter occupies entire TextView area. Now one of my users reported a problem that the letter does not fit properly into the TextView. From the attached screenshot I can see that she uses some kind of custom font on her Samsung S4 device. I am sure that's the problem. Here are some snapshots:
Custom font in a TextView over ImageView:
Custom font in the Status Bar:
Distorted letter N in my TextView:
Is there any way to make a TextView use standard android font ignoring any custom fonts that users applies? How can I install custom fonts on the emulator or Sony phone (do not have Samsung) and replicate the behavior?
Yes you can set custom fonts to your app. Make use TypeFace class.
Create a folder called fonts under assets folder and place all your fonts in it (Font format ttc or ttf. Folder name can be anything)
Within you onCreate method add the below code.
TextView mytextview= (TextView) findViewById(R.id.text_view_id);
// Loading Font Face. Replace with your font file name
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/your_custom_font.ttf");
// Applying font
mytextview.setTypeface(tf);
Similar way you can have as many as TypeFace you require and also use the same TypeFace declared on as many as TextView you want.
This tutorial below very well explains your requirement and also provides screenshot for better assistance.
http://www.androidhive.info/2012/02/android-using-external-fonts/
Also kindly note that TypeFace has a lot of other options that you can play around with. You can refer the android docs to get an idea about them.
I hope it helped you.
Thanks!!
My advise:
Create a subfolder in your asset folder called fonts.
Put there the fonts you want to use (for example ttc, or ttf) Set
your TextView typeface. For example:
yourTextView.setTypeface(Typeface.createFromAsset(getContext().getAssets(), "fonts/yourFont.ttc"));
I hope it helps!!

Android Arabic/Farsi Fonts

I am developing an Android aap that uses Arabic Fonts.
I have successfully display Arabic text by using "tahoma.ttf"
But problem is that these Arabic Fonts Didn't give a cool look.
So i wanted to change that Font Style. Is there any way of doing this ?
If you want to use external font do :
First step is to pick a font that you want to use.
Create a fonts folder in your assets directory and copy your font there.
To access your custom font,use the Typeface class in the Android SDK to create a typeface that Android can use, then set any display elements that need to use your custom font appropriately.
Unfortunately, you can no longer use layout XML for this, since the XML does not know about any fonts you may have tucked away as an application asset.You can do like this in your code:
Typeface tf = Typeface.createFromAsset(getAssets(),"fonts/BPreplay.otf");
TextView tv = (TextView) findViewById(R.id.CustomFontText);
tv.setTypeface(tf);
Note: Android does not seem to like all TrueType fonts.So, if you try to use a different font and it does not seem to be working, it may be that the font is incompatible with Android, for whatever reason.
You can see more details in these pages:
Fun with Fonts
Musings of the Bare Bones Coder/using custom fonts

Categories

Resources