my font size is 0 byte after launching the app - android

I have trouble with my font.
I need to display plain, bold and italic text in a specific font in the same textView.
I use html.fromHtml and with the regular android font it works fine.
I want helvetica instead, so I built a single font file witch contained the three fonts (plain bold italic), and used setTypeFace on my textView. I built it from 3 otf files with fontBuilder.
But when I call Typeface.createFromAsset(getAssets(), "fonts/HelveticaNeue.dfont");
i saw that my font file size was 0 bytes, and indeed in my project I can't import it well,
when i go in the folder fonts i see that the size is ok, but from eclipse point of view, 0 bytes.
Does somebody have an idea ?
ANSWER:
The problem was that my font didn't had dataFork, it's a thing that you have to add to your font for it to be understood by PC's, and Unix OS.

is it correct format .dfont
i think fonts should be with .ttf
Typeface.createFromAsset(getAssets(), "fonts/HelveticaNeue.ttf")

Related

Oriya font to be displayed in Android app (Lenovo K3)

I want to display certain text in Oriya font in my android app. There is no default support in android for Oriya language. I tried different ttf files for Oriya font but not able to display the content. Can anyone help me in this?
I have tried the following code keeping the oriya.ttf file in my assets folder.
Typeface typeFace=Typeface.createFromAsset(getActivity().getApplicationContext().getAssets(),"fonts/oriya.ttf");
tvSoft.setTypeface(typeFace);
If you want change font in android this is the best solution:
https://github.com/chrisjenx/Calligraphy

Varying font sizes when using different .ttf fonts with no change to the sp

Problem: When implementing a custom font I notice quite a big change in the font size. (Without any altering to the font size in the XML file)
This is causing a significant variation between the Actual font size in comparison to the size shown in the Graphical layout in ADT. (Visually about 20sp smaller)
I am building a timer application and want to use a Digital Looking font.
Question: Can a .ttf file affect the font size relative to a constant 'sp' ?
To answer my own question.
YES. a .ttf file does have a 'base font size' and this may vary from one .ttf to another.
As stated in my comment above:
I figured out how to change the base size of a .ttf using FontForge (fontforge.org) There is a great tutorial on how to do this here: forum.xda-developers.com/showthread.php?t=990853 I did have to play around with more options then noted in the tutorial to get my font just right but it works perfect!

Tamil fonts in Android

I developed a Tamil news application in android version 2.3.3. However, Tamil fonts have only been properly developed in android versions 4.0 and beyond. I want to display them in all versions of android mobile.
I tried to solve the problem with some Tamil fonts, such as bamini and mylai, but they only worked in higher android versions.
First of all you have to understand that there is no Tamil Language support in Android OS (except few Samsung & SE mobiles) till ICS(4.0). Even then it had bugs and full support is provided with Jelly Bean (4.2).
You will only see boxes if you use Unicode Tamil font in your app. Reason is there are no Tamil fonts in the system.
1. Manual way of doing
There is a work around for this solution. All you have to do is, download the Bamini font and place it in your assets folder. And create TypeFace with the font Bamini and set it to the TextView.
Typeface font1 = Typeface.createFromAsset(getAssets(), "fonts/Bamini.ttf");
customText1.setTypeface(font1);
Now use a converter to convert Unicode font into Bamini encoding. instead of the Unicode text provide the converted Bamini encoded script into the setText method.
2. Using the Library
If you hate all these manual encoding conversion then check out this library
As I said in above line, if you like to change the encoding dynamically while running the application then consider using the library I wrote for Android. This library will help you to convert Unicode String to Bamini, TSCII, TAB, TAM and Anjal.
Set up is very simple. All you have to do is simply import the library into your Android project and call the library as below.
// Initialise the Typeface (assumes TSCII, Bamini, Anjal, TAB or TAM font located inside assets/fonts folder)
Typeface tf = Typeface.createFromAsset(getAssets(),"fonts/mylai.ttf");
// Initialises the TextView
TextView tv = (TextView)findViewById(R.id.textView1);
//Setting the Typeface
tv.setTypeface(tf);
//Magic happens here ;) encoding conversion
String TSCIIString = TamilUtil.convertToTamil(TamilUtil.TSCII, "வணக்கம் அன்ரொயிட்");
//Setting the new string to TextView
tv.setText(TSCIIString);
There is a sample app available along with the library. Check out the app on how the library is utilised to convert the Unicode String to Bamini, TAB, TAM, TSCII and Anjal.
You would get something like this when you use the library.
You need to make use of the TypeFace class available in Android. You can use either Bamini or TSCII encoding (Mylai is a TSCII font).
Disclaimer : I wrote this library.
3. For WebView
If you are developing using html and CSS wraped inside a WebView then take a look at this application's source. You gonna have to make use of fontface feature of CSS3.
First you need to have style declared as this
#font-face {
font-family: MyCustomFont;
src: url("Bamini.ttf") /* TTF file for CSS3 browsers */
}
Then you gotta use the MyCustomFont in your tags. For example if you wanna set it to the whole body (which is much easier in this case)
body {
font-family: MyCustomFont, Verdana, Arial, sans-serif;
font-size: medium;
color: black
}
Hope this would give you the heads up you deserve. Hope to see more Tamil apps in Play Store.
TAb dont need embedd, now we have unicode
Please use this Tamil unicode fonts
http://visualmediatech.com.fonts

Do we have to copy Font TTF everytime we want to change font in application

Previously, to make my app workable in Gingerbread device and above, I have to copy the Robotto font resource into asset folder. This is because Gingerbread doesn't come with Robotto font itself.
However, let say, I decide to deploy my app to Jelly Bean device only.
Do I still need to copy font resources into my asset folder manually? Can I use font resources from system itself? Is it something encourage-able? I was thinking, without supplying my own font files, I can make my app smaller.
This is the code to get TypeFace from asset folder.
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Regular.ttf");
If I want to get TypeFace directly from system itself, how?
The good news is, if you're supporting 4.1, it's dead simple. Check out this link and scroll down to fonts for the full details, but basically, you'll have three font families (Roboto, Roboto Light, RobotoCondensed) to choose from, and four styles for each (normal, bold, italic, bold italic).
In XML, you can just use the standard text attributes:
android:fontFamily="sans-serif"
android:fontFamily="sans-serif-light"
android:fontFamily="sans-serif-condensed"
android:textStyle="bold"
android:textStyle="italic"
android:textStyle="bold|italic"
Or programatically you can acquire them like so:
Typeface robotoLightItalic = Typeface.create("sans-serif-light", Typeface.ITALIC);

Hindi Marathi font on Android

which font is most suitable for Android application developed in Marathi/ Hindi indian language. I tried with mangal and droidsansfallback but still the words dont appear as they should. I don't see the boxes or some special characters after using above font which is good, but still the marathi/hindi words doesnt have exacts alphabets. Any help/guidance will be appreciated. Thanks....
As Devanagari fonts are not supported by Android, you can still give that support to your Application.
For Marathi font copy font file to your asset folder. then use the following code.
TextView text_view = new TextView(this);
Typeface font = Typeface.createFromAsset(getAssets(), MarathiFont);
text_view.setTypeface(font);
text_view.setText("मराठी");
the same way u can give support for hindi....
Marathifont = any marathi or devanagari font
e.g
Marathifont = "kiran.ttf"
Devnagari fonts are not supported in older devices. You can replace the default font after rooting the device. mangal font worked pretty well for me.
Fontoosh can be helpful for installing devnagari font or replacing the font.
I think you should use Google Noto Fonts.
Just search for Hindi/Marathi and you will get fonts for it.
Noto Sans Devanagari is good.

Categories

Resources