I can't find the way to set Roboto condensed (thin) instead of the default one. Is it possible?
Asked
Active
Viewed 7,118 times
1 Answers
18
Download the full Roboto family
Copy
Roboto-Condensed.ttf
into your project'sassets
folderIn code, get a reference to your
Typeface
withTypeface robotoCond = Typeface.createFromAsset(context.getAssets(), "Roboto-Condensed.ttf")
Use this in any widget, e.g.
textView.setTypeface(robotoCond);
???
PROFIT!

Kevin Coppock
- 133,643
- 45
- 263
- 274
-
This works for the application. But I forgot I'd have also to use it inside an homescreen Widget. There I run in the homescreen process and I've no access to my assets folder to summon the Font. And in the homescreen widget I can't use a custom TextView with the condensed font in it. Is there any way to use it inside an homescreen widget? The font is in the system/font folder, so why do I have to put the ttf file inside my asset folder instead of using the system one? – Santacrab Sep 21 '12 at 08:43
-
In Jelly Beans the condensed font is present (not in ICS as I previousely said), but in API 16 they didn't upgrade the enums for the android:typeface attribute, so the sans-serif-condensed is not available via XML. So I can natively use the Typeface inside my application, but not in the homescreen widget. Is there a workaround for this? – Santacrab Sep 21 '12 at 10:52
-
From what I understand there's no way to use a custom font in a widget. [This question](http://stackoverflow.com/q/4318572/321697) has some workaround answers that you may find useful. – Kevin Coppock Sep 21 '12 at 16:05
-
2Can't we use it without importing? I mean come on, It's ICS/JB. It should be already available... :/ – Sheharyar Jan 18 '13 at 09:44
-
@kcoppock - Thankyou! That's what I was looking for. Another short question; How to use them in webview (in ICS+)? – Sheharyar Jan 24 '13 at 19:13
-
@SheharyarNaseer I have near-zero experience with WebViews -- this looks like what you need, though: http://droidista.blogspot.com/2011/02/using-custom-font-in-webview.html – Kevin Coppock Jan 24 '13 at 20:14
-
@kcoppock - But that's the thing, I want to do it without importing Roboto into my assets. That should be possible in Android 4.0.0 onwards. Anyways, thanks a lot for your help. Cheers! :D – Sheharyar Jan 24 '13 at 20:39