any answer on this subject because it's a pain .......

Le mercredi 26 janvier 2011 18:35:23 UTC+1, Eric a écrit :
>
> Hello, 
>
> I have been searching the APIs for a way, ANY way, to define a custom 
> (developer installed) font on a style, but it does not appear this is 
> possible.  It appears you have to resort to using: 
>
>     Typeface.createFromAsset() 
>
> to load a font file stored in your assets directory, and then 
> programmatically set that font on every single text view you want it 
> used on, with 'setTypeface'.  This is not an acceptable solution for 
> our application, which is very complex, and we just want to define a 
> single theme using our custom font that can easily be applied on an 
> application, or at the very least, an activity wide level. 
>
> I discovered another possible way to set the typeface through the use 
> of SpannableString.  It seems you can use SpannableStringBuilder to 
> build a String that has styles defined over its contents.  However, of 
> the two types of Spans that allow you to style the text, StyleSpan and 
> TypefaceSpace, neither of them allow you to specify a CUSTOM font. 
> StyleSpan lets you pick a "style", but the choices are limited to 
> 'bold, italic, etc (which is font-independent).  TypefaceSpan does 
> allow you to specify a typeface 'family' name, however, as far as I 
> know, a USER installed custom font is unknown to the 
> Typeface.create(String family) method, and therefore, the system will 
> not be able to find my custom font.  *IF* TypefaceSpan had a 
> constructor that took a Typeface, I might be able to use that, but it 
> doesn't. 
>
> It looks like I might have to resort to writing my own Typeface span, 
> or somehow write custom code that plugs into the Android Style/Theme 
> system to allow me to apply a custom typeface to my application. 
>
> Any advice would be appreciated! 
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to