3

Some hardware manufacturers (e.g. Samsung) allow the user to set a custom font at a system level. This affects all default TextView instances (in system apps or installed apps):

screenshot of samsung font style page, radio group shows a list of font styles, with default selected

I want to customize the font for my TextView with a custom font in my app, but also respect the user's setting.

i.e. if the user has chosen "Default" above, then I want my TextView to use my custom font, but if they've selected any of the others, then I want my TextView to use whatever they've selected.

Using textView.typeface == Typeface.DEFAULT seems to return true regardless of the user's system setting. Is there a way to differentiate between "Default" and any of these custom settings, even if it's manufacturer specific?

ataulm
  • 15,195
  • 7
  • 50
  • 92
Royce Raju Beena
  • 711
  • 4
  • 20
  • I don't need to prevent the custom font in samsung devices. I need to keep it as per user's choice but set to Roboto n other devices .Please help .I looked at that question doesn't really help – Royce Raju Beena Oct 08 '14 at 05:30
  • Have you tried that it's not working? For me, this was authomatically – Juan Aguilar Guisado Oct 08 '14 at 06:53
  • 1
    it's working in the sense that it's showing custom font when I use typeface.DEFAULT but I need to use Roboto as shown above in all other cases . In short all I need to do is to check whether the device has custom font sets and based on that return default or return roboto . – Royce Raju Beena Oct 08 '14 at 07:15
  • 2
    It doesn't have an answer there guys . Please help – Royce Raju Beena Oct 08 '14 at 09:53

1 Answers1

0

Use this way to set fonts into textviews

Typeface tf = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Light.ttf"));
TextView textView = (TextView) findViewById(R.id.textView1);
textView.setTypeface(tf);
  • 2
    I know that . I have done that . I need to check if custom fonts are set by user in devices like samsung and if yes switch to typeface.DEFAULT . My question was how I test that condition ? – Royce Raju Beena Oct 08 '14 at 08:13