unity system fonts in android - android

I want to use android system font to show Chinese text.
I use
var fonts = Font.GetOSInstalledFontNames();
to log what fonts are in device. I find this Noto Sans CJK TC.
But I called
font = (Font)Resources.GetBuiltinResource(typeof(Font), "NotoSansTC-Black.ttf");
It always shows The resource NotoSansTC-Black.ttf could not be loaded from the resource file!
How can I use this font in android device.
Thanks

I think what you want is Font.CreateDynamicFontFromOSFont
font = Font.CreateDynamicFontFromOSFont("NotoSansTC-Black", 12);

Related

Problem with loading fonts in html on UITextView in iOS

I have an HTML script that needs to be displayed inside of a webview in Android and in an UITextView in iOS. This script uses multiple fonts.
When declaring the fonts in Android I used the following script:
#font-face {
font-family: 'myfont';
src:url("file:///android_asset/fonts/myfont.ttf")
}
and it worked perfectly fine.
In ios, however, I was unable to find the correct solution for setting the source path for the fonts.
I tried the following:
src:url("myfont.ttf")
src:url("myfont.ttf")
src:url("file:///fonts/myfont.ttf")
src:url("file:myfont.ttf")
Do you know how it should be set for iOS
You need to mention the correct font family name and that's it. No need to specify the src. Just make sure to add it in your Info.plist file under key <key>UIAppFonts</key> like so:
<key>UIAppFonts</key>
<array>
<string>Lato-Black.ttf</string>
</array>
How to find font family name?
You might think that the font family name is the name of the file itself. But it is not. Have a look at the below screenshot
The file name is different but the font book shows something else. The title in the font book application is your font family name. To denote different weights of the font, use -Regular, -Bold, etc.
Then in your css you can directly use
span {
font-family: "MathJax_Math-Regular"
}
and your font should be applied

NativeScript: font-family not loading on Android

I imported a set of files for Galano Grotesque xxx.otf font (xxx=Alt Black, Alt Black Bold, etc), and it works like a charm on iOS but not on Android. When I run the app on Android the font is not loaded.
I'm using this:
Label {
font-family: "Galano Grotesque";
color: #5b5b5f;
}
I found this post - Android Not Showing Font Icon In NativeScript - and I tried this
Label {
font-family: "Galano Grotesque", galano grotesque;
color: #5b5b5f;
}
but without success :(
Does anybody knows what I can do to solve it?
Thanks
There is one primary consideration when working with fonts in iOS and Android.
For the font to work on iOS it should use the exact font name (notice that this is not the file name!) where in Android the font should be referenced with its particular file name.
Example:
Let's assume you are using the Galano Grotesque DEMO Bold font from here (this one is free for demonstration purposes)
When downloaded you will see that the file name is as follows
Rene Bieder - Galano Grotesque DEMO Bold.otf
But the font name is (in Mac open with FontBook app to see the font-name at the top of the pop-up.. for Windows open the font with Windows Font Viewer and look for font name)
Galano Grotesque DEMO
So to use it in iOS, you should use
font-family: "Galano Grotesque DEMO";
And for Android, you should use
font-family: "Rene Bieder - Galano Grotesque DEMO Bold";
Of course, the best practice is to see what is the actual font name and rename the file with the exact name so you can reuse it in both iOS and Android with no different CSS files.
All that said check your file name under Android and make sure that reference in the CSS file is the same

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

To change Android Default Font Size

Can anyone please tell me where exactly the Default Text Font size is set in the android framework.When I change the font size using Spare Parts package and reboot my android device, the font size sets to Normal style by default.But I want it to be Extremely Large by default.
Thanks,
Riyaz
If you just want to set font size for the whole phone. Try going to
Settings (Phone) > Accessibility.
Choose Large Text there.
NOTE: I am assuming you just want the font for the phone and not via an app.
You can't change a default font size. You can define a theme, and define a font size in your theme. You can read about defining themes and styles in the android developer reference documentation.
You can change font size, style etc in your application, but not for whole device. To do that i guess you need to root your phone and provide custom fonts with specified font size in it.
For andriod 2.3.5 go to SMS click on Menu-> Settings scroll down until you see Font Setting and select Font Size Setting
According to http://recombu.com/mobile/article/changing-font-size_M18292.html there is no native option for that, up to Android 3.0.
You have to install some third party app. "Big Font" appears to be a popular one.

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