Reputation: 9429
is there any way to modify font in runtime for android or combine two font file. I need to add one more character support to a font.
because, if a char does not exist in font file, device show a square for that character.
Upvotes: 0
Views: 115
Reputation: 3846
If you know what characters are causing you trouble, then you may want to try this :
Then do something like :
String yourString = "Some Text Here"; // this is you string
Spannable spannable = new SpannableString(yourString);
// you can also iterate, instead of next few steps
// typeface1 and typeface2 are your two different font styles
spannable.setSpan(typeface1, 0, i-1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
spannable.setSpan(typeface2, i, i+1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
spannable.setSpan(typeface1, i+1, j-1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
spannable.setSpan(typeface2, j, j+1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
spannable.setSpan(typeface1, j+1, k-1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
spannable.setSpan(typeface2, k, k+1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); // and so on
spannable.setSpan(typeface1, k+1, N, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
textview1.setText(spannable); // this is your textview and setting of font
Or you can create your custome typeface and apply it to the view you want. In that you can apply first font forall characters except for the ones it cant handle. For those, you can apply the second one. I dont know how much feasible is that. I will try it out and let you know.
See if this is of any use.
Upvotes: 1