Do Custom Fonts on Android decrease performance? - android

I'm planning to make an android app and want to use custom fonts to match the style guide provided by the brand who wants the app.
I have found this library Caligraphy to use custom fonts.
Is there an issue regarding performance of the app by using custom
fonts with this library?
Is there another option to add custom fonts painlessly?
Also, is there a guideline that prevents from using custom fonts in android apps, or is it a bad practice?

Is there an issue regarding performance of the app by using custom fonts with this library?
There generally isn't any issue with custom fonts, there is no reason this library would hit the performance of the app
Is there another option to add custom fonts painlessly?
Yes you can easily achieve this with simple coding
TextView txt = (TextView) findViewById(R.id.textview);
Typeface font = Typeface.createFromAsset(getAssets(), "your_font.ttf");
txt.setTypeface(font);
Also, is there a guideline that prevents from using custom fonts in android apps, or is it a bad practice?
No it is not a bad practice. Infact google recently added an option to use custom fonts with support library v26. You wont have to add ttf file to the apk, google will download that for you itself

Related

Is it possible to add custom language by adding custom font in android devices?

Is it possible to add my language(ladakhi) support in android because I don't see my language in android system by default so I wanted to add it manually. The way I am trying to do was by adding custom font (.tff) in my app and add to the android system.
But I am quite not sure whether it is possible or not ? If so please share me a resource or link where I can look up to.
[Expected Result]
Just like how we change android system language to hindi, kannada etc.I wanted to add my language support in android system.
Regards
A similar question is asked here. The answer is you can't unless you download the android source and add a new language translation. For more you can #Romain Guy answer here

Set fallback fonts android app

I'm developing an app that needs to support multiple languages, including some for which fonts are not included in some older Android versions.
The same TextView can have content in multiple languages, so setting a single TypeFace does not help, I need to have a list of fall-back fonts to use when some characters are not available in preferred fonts.
Extending to this, I also need to use the same set of fonts for other elements also (not only TextViews) if possible.
I had a workaround for this. I extended the Application class for the app and set the fonts globally there.
For the fallback fonts, I read the Android API code for Typeface and going from there, I found some hidden APIs. Doing all sorts of hacking (reflections, getting private/hidden classes or methods, setting private fields etc.), I finally made it working for Android API versions 21 to 23. Not sure about the newer APIs and it doesn't work for the older ones.
You can check my code at https://gist.github.com/nisargjhaveri/47acc83e66dcb347e05685ccfd3038e8
It is working, but even I don't recommend using it!
The better solution for this may be to use TypefaceSpans, after detecting the best typeface for each character, everytime you show text to user. I did not try this.
Also, I just have been playing with android for past two months, so think twice before you take my advice! :P

How to preview Custom Font Android Studio (using Calligraphy)

Currently I'm using the Calligraphy library to use custom fonts, it's awesome https://github.com/chrisjenx/Calligraphy
But i can't preview the new fonts, is there any way to preview the custom fonts in Android Studio?
In order to view the Custom fonts you have to run the code and check in the mobile.
**Note :**ALL Fonts may not be accurate in emulator,Better to run in mobile for best experiance.

Preview custom fonts in Android Studio

Currently I'm using the pixlui library to use custom fonts, and it's great!
https://github.com/neopixl/PixlUI
Is there any way to preview the custom fonts in Android Studio?
I have created a Library called Smart Fonts for Android. It allows you to preview the custom fonts in the Layout Editor of Android Studio.
The fonts are cached in memory so that they are loaded once.
Smart Fonts is easy to integrate with gradle, it is documented and available on GitHub:
https://github.com/smart-fun/SmartFonts
enjoy!
Unfortunately no. The way that PixelUI is setting the font doesn't work in the previewer.
They are only setting font in one constructor as is visible here:
https://github.com/neopixl/PixlUI/blob/master/Library/src/com/neopixl/pixlui/components/textview/TextView.java
The constructor the editor is using is the second one, and the font is not set when the TextView is constructed this way.

android custom fonts in xml

We can change fonts using java code as described here:
Roboto font in my android app
My question: Is there a way to specify the fonts in the xml layout file itself? Or better still, can we specify the font in the AndroidManifest.xml, so that it reflects across the app?
Thanks,
Rahim.
You can use a theme that contains all the styles you want to use in your app (included fonts). The use of the schema is declared in the manifest
http://developer.android.com/guide/topics/ui/themes.html
If you want to manage custom fonts without headache, I suggest you to use a library that handles the hard part, like caching the fonts in memory and allows to preview the display in the Layout Editor. Then you can focus on creating the styles for your titles or texts.
I have done such a library called Smart Fonts for Android.
It is easy to install with gradle, and it is well documented.
It is available on GitHub:
https://github.com/smart-fun/SmartFonts
enjoy!

Categories

Resources