I've done quite a lot of digging around the 1.6 SDK source code for
this one. My aim is simply to have 2 StyleSpans within a TextView, one
containing bold text, the other normal, both using a custom font.

I'm setting the typeface to a custom font which was created in this
fashion:

// utility class
public static Typeface getTypewriter(Context context) {
        if(typewriter == null)
                typewriter = Typeface.createFromAsset(context.getAssets(), 
"fonts/
americantypewriter-medium.otf");
        return typewriter;
}
... similar function for for getting bold face ...

// usage
textView.setTypeface(Typefaces.getTypewriter(mContext),
Typeface.NORMAL);
textView.setTypeface(Typefaces.getTypewriterBold(mContext),
Typeface.BOLD);
SpannableStringBuilder builder = new SpannableStringBuilder("Hello
World");
builder.setSpan(new StyleSpan(Typeface.BOLD), 0, 4,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.setSpan(new StyleSpan(Typeface.NORMAL), 5, 9,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
textView.setText(builder);


Based on the source, I can see that calling setTypeface() twice just
overwrites the previous call, even when the style param is different.
So in my case the entire TextView appears in bold. I'm kind of hoping
there's a way to do it given you can use BOLD and NORMAL when using a
built-in font.

Does anyone have any workarounds?

-- 
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