Android Question How to make custom font bold

AR_B4X

Member
Licensed User
Hi,

I am trying to use a ttf file in my app.
Apart from using it, I would also like the text to be bold.

So I have something like this
B4X:
Dim Minya As Typeface

Minya = Typeface.LoadFromAssets("minya.ttf")

NameLbl.Initialize("")
NameLbl.Text = Name
NameLbl.TextColor = Colors.Black
NameLbl.Typeface = Typeface.CreateNew(Minya, Typeface.DEFAULT_BOLD) ' Errors out

Thank you
 

asales

Expert
Licensed User
Longtime User
I use this code with libertysans font and works (the font style is changed from default to bold):

B4X:
Dim FontName As Typeface
FontName = Typeface.CreateNew(Typeface.LoadFromAssets("libertysans.ttf"), Typeface.STYLE_BOLD)
Label1.Typeface = FontName

If don't work with your font, probably the font file doesn't have a bold variant.
 
Upvote 0
Top