cannot install other font

Cor

Active Member
Licensed User
Longtime User
tried several fonts

always not initialized, what's going wrong?

sample project is attached

B4X:
  myfont.LoadFromAssets("mufont.ttf")
  If myFont.IsInitialized Then
    Label1.Typeface=myFont
    label1.Text=Asc(69)
  Else
    ToastMessageShow("font not initialized",True)
  End If
 

Attachments

  • font.zip
    45.6 KB · Views: 359

Erel

B4X founder
Staff member
Licensed User
Longtime User
Typeface.LoadFromAssets returns a new Typeface. See the example code:
B4X:
[COLOR=#0000ff]Dim[/COLOR][COLOR=#000000] MyFont  [/COLOR][COLOR=#0000ff]As[/COLOR][COLOR=#008b8b]Typeface[/COLOR][COLOR=#000000]
MyFont = [/COLOR][COLOR=#008b8b]Typeface[/COLOR][COLOR=#000000].LoadFromAssets([/COLOR][COLOR=#800000]"[/COLOR][COLOR=#800000]MyFont.ttf[/COLOR][COLOR=#800000]"[/COLOR][COLOR=#000000])
EditText1.Typeface = MyFont[/COLOR]
 
Upvote 0

Cor

Active Member
Licensed User
Longtime User
I want to show the attached char in a label text.

I cannot manage to show this char.

code project is attached

B4X:
   MyFont=Typeface.LoadFromAssets("tef265.ttf")
   If MyFont.IsInitialized =True Then
     Label1.Typeface=MyFont
     Button1.Typeface=MyFont
     EditText1.Typeface=MyFont
    Else
     ToastMessageShow("not initialized",True)
    End If
    label1.Text=Chr(69)  ' shows only E char instead of graphics char
 

Attachments

  • test.png
    test.png
    914 bytes · Views: 518
Upvote 0

agraham

Expert
Licensed User
Longtime User
It seems to not be loading the font but using the default font without throwing an error. I can't tell why it is not loading it as the Typeface.LoadFromAssets never seems to generate an error, even if you give it a non-existent filename! The times font you included loads OK so I can only surmise that Android doesn't like that font for some reason. I found this comment on the web

Note that Android does not seem to like all TrueType fonts. I spent a lot of time trying to figure out what I was doing wrong with this sample, before switching to a different font, and everything “just worked”. When Android dislikes a custom font, rather than raise an Exception, it seems to substitute Droid Sans (”sans”) quietly. So, if you try to use a different font and it does not seem to be working, it may be that the font in question is incompatible with Android, for whatever reason.
 
Upvote 0

Cor

Active Member
Licensed User
Longtime User
thanks, that sould be the problem

I now adjusted a known working font, and change the char with a fonteditor

grCor
 
Upvote 0
Top