Custom Fonts not working in lollipop? - android

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

Related

Custom ttf fonts are not showing properly in TextView on Android 4.4 KitKat

I have some text which has some bolded parts. Until KitKat this strategy (as mentioned in this post) worked perfectly well
My strings resources file:
<string name="multi_style_text">NON-BOLD TEXT \n<b>BOLD</b></string>
My application code in fragment:
txtView.setTypeface(FontUtils.getOstrichRegular(this.getActivity()));
...
public static Typeface getOstrichRegular(Context context) {
return Typeface.createFromAsset(context.getAssets(),
"fonts/ostrich_regular.ttf");
}
Currently (in KitKat), the bolded part is not shown in the custom font, the non-bolded part is shown in the custom font. In previous versions of Android, all of the text was shown in the custom font.
What gives?
So, after being frustrated by this bug, I searched around and found a solution to the problem.
In my current project we use calibri.ttf font. that was working fine up to 4.4. Once i got the update to my nexus 4, All the TextViews with Calibri font were showing "ff" instead of the entire text.
THE FIX - get an .otf (open type font) version of your font, and put in the project, works like a charm. Too bad google didn't inform the developers on this and there's very little documentation on the matter.
Apparently this is a bug in KitKat and has been fixed in an internal tree.
Put your custom font in android assets under folder name "font" or whatever you want
Try this
myTypeface = Typeface.createFromAsset(this.getAssets(),
"fonts/<<your font>>.ttf");
in onCreate() then
[use youcontroll].setTypeface(myTypeface);
Best of Luck...
I resolved the problem by converting my file.ttf to file.otf
remplace :
Typeface typeface = Typeface.createFromAsset(activity.getAssets(), "fonts/ostrich_regular.ttf");
yourTextView.setTypeface(typeface);
by :
Typeface typeface = Typeface.createFromAsset(activity.getAssets(), "fonts/ostrich_regular.otf");
yourTextView.setTypeface(typeface);
FYI : the .otf format work for all android version (not only on kitkat)
After many hours searching for roboto.otf (2014 year) I understood that it was a mistake. Simply download a normal ttf font from https://www.fontsquirrel.com/fonts/roboto-2014 and copy to assets folder, then use setTypeface.
Also you may convert it to otf with any web-site.

Custom Font Not supporting in Android Device

Hi am developing One Android App in which am using Custom font .TTF file.The problem is i tested with same Branded Device with Different Build Version.the Older Version Device supporting Custom Font But new version Device not taking Custom Font.
i have one suggestion add those font in assets and make your text in html thus you can add it in Web View android
Hope it will work for your case:
WebView view = new WebView(this);
view.setVerticalScrollBarEnabled(true);
view.loadUrl("file:///android_asset/demo/intro.html");
((LinearLayout)findViewById(R.id.introLayout1)).addView(view);
view.setBackgroundColor(Color.BLACK)
first download the needed the ttf file (Font style which you want ). and put that it in the assets folder in android project. then add the following code in java file..
TextView txt = (TextView) findViewById(R.id.custom_font);
Typeface font = Typeface.createFromAsset(getAssets(), "Eltpan-n.ttf");
txt.setTypeface(font);
hope it will help you.. its worked like a charm for me .. if you satisfied vote for my answer

Use hindi in android

I want to create an android application in which the user should be able to select a language of his choice(English/ Hindi/ Marathi).
I have checked some android forums and found that android does not support Devanagari fonts.
Is there a solution? Also, is there a solution without rooting the device?
As Devanagari fonts are not supported by Android, you can still give that support to your Application.
For Hindi font copy font file (saral.ttf or Shusha.ttf or any font hindi file) to your asset folder. then use the following code.
TextView text_view = new TextView(this);
Typeface font = Typeface.createFromAsset(getAssets(), "saral.TTF");
text_view.setTypeface(font);
text_view.setText("हिंदी");
the same way u can give support for marathi....
you can use following i18n solution for different languages
http://www.vogella.de/blog/2011/01/17/translating-android-applications-i18n/
http://www.kobu.com/i18n/android/index-en.htm

how to show punjabi text in my android application? [duplicate]

hi
i want to develop an application in which i Want to use punjabi text. But my emmulator does not show Punjabi text. Is there any api or something else so that my emulator can show the punjabi text or suggest me any other way to implement punjabi language in my application.
Thanks in advance.
Typeface font = Typeface.createFromAsset(getAssets(), "bulara_5.ttf");
text.setTypeface(font);
text.setText("ਪੰਜਾਬੀ");
This worked for me on non rooted phone OSv 2.1
Link for font file I used: http://homepage.ntlworld.com/paul-grosse/bulara.zip
You can use custom TrueType fonts by copying the .ttf file into your projects's 'assets' folder.
Then in your application you can use the font like this;
final Typeface customF = Typeface.createFromAsset(this.getAssets(), "custom.ttf");
final TextView textV = (TextView) findViewById(...);
textV.setTypeface(customF);
However i've had so many problems trying to use TrueType fonts so you might want to do some real life testing with your (pubjabi) font.
I don't think that android 2.3 supports the punjabi font. Hence you see those boxes.
Follow this thread to know when your favourite language will be supported. I've heard that Samsung android devices support some Indian regional fonts.

how to use punjabi font in the android application?

hi
i want to develop an application in which i Want to use punjabi text. But my emmulator does not show Punjabi text. Is there any api or something else so that my emulator can show the punjabi text or suggest me any other way to implement punjabi language in my application.
Thanks in advance.
Typeface font = Typeface.createFromAsset(getAssets(), "bulara_5.ttf");
text.setTypeface(font);
text.setText("ਪੰਜਾਬੀ");
This worked for me on non rooted phone OSv 2.1
Link for font file I used: http://homepage.ntlworld.com/paul-grosse/bulara.zip
You can use custom TrueType fonts by copying the .ttf file into your projects's 'assets' folder.
Then in your application you can use the font like this;
final Typeface customF = Typeface.createFromAsset(this.getAssets(), "custom.ttf");
final TextView textV = (TextView) findViewById(...);
textV.setTypeface(customF);
However i've had so many problems trying to use TrueType fonts so you might want to do some real life testing with your (pubjabi) font.
I don't think that android 2.3 supports the punjabi font. Hence you see those boxes.
Follow this thread to know when your favourite language will be supported. I've heard that Samsung android devices support some Indian regional fonts.

Categories

Resources