Why the new font are not loaded?

micro

Well-Known Member
Licensed User
Longtime User
Hi to all,
font displayed is always the default, Why?
This is my simple code:
B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Dim myfont As Typeface
End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim Label1 As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Label1.Initialize("Label1")
   Activity.LoadLayout("Main")
   change_font
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
Sub change_font
   myfont = Typeface.LoadFromAssets("Ozone.ttf")
   myfont = Typeface.DEFAULT
   Label1.Typeface = myfont
   If myfont.IsInitialized = False Then Msgbox("Error", "Error")
End Sub

Thanks
 

rbsoft

Active Member
Licensed User
Longtime User
Did you add the font to the files folder so that it gets installed to the assets folder of your application?

Rolf
 
Upvote 0

rbsoft

Active Member
Licensed User
Longtime User
It works without problem in my app. But I have the code in Activity_Create:

B4X:
Sub Activity_Create(FirstTime As Boolean)
  myfont = Typeface.LoadFromAssets("Ozone.ttf")
  myfont = Typeface.DEFAULT
  Label1.Typeface = myfont
  ...
Did you try that?

Rolf
 
Upvote 0

rbsoft

Active Member
Licensed User
Longtime User
Works for me fine in the emulator too.

Rolf
 
Upvote 0

joseluis

Active Member
Licensed User
Longtime User
Try to rename the font to use only lowercase characters. And reference it lowercase everywhere.
 
Upvote 0

micro

Well-Known Member
Licensed User
Longtime User
Try to rename the font to use only lowercase characters. And reference it lowercase everywhere.

ok, but does not work.
can you post an example that works for you?
because if it not work can be a problem of settings.
Erel is right?
 
Upvote 0

rbsoft

Active Member
Licensed User
Longtime User
Here is a little project that works in the emulator as well as on a machine.

A click on the time label changes the font back and forward.

Rolf
 

Attachments

  • FontTest.zip
    25.4 KB · Views: 191
Upvote 0

micro

Well-Known Member
Licensed User
Longtime User
Thanks to all, now work.
This my error:
Label1.Initialize("Label1")
and Activity.LoadLayout("Main").
Activity.LoadLayout("Main") in first line in Activity_Create
 
Upvote 0
Top