iOS Question Custom Font not working

db0070

Active Member
Licensed User
Longtime User
I tried your tutorial https://www.b4x.com/android/forum/threads/custom-fonts.46461/
I am able to see your custom fonts, but I cannot change size of the font in the labels.

Then I tried to use my own font and I get the error below. My code is like this and I have attached the font file:

B4X:
#Region  Project Attributes 
    #ApplicationLabel: B4i Example
    #Version: 1.0.0 
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
    #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
    #AppFont: al_mushaf.ttf
    #AppFont: vermidirouge 1.0.ttf
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page

    Private Label2 As Label
    Private Label1 As Label
End Sub

Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.Title = "Page 1"
    Page1.RootPanel.Color = Colors.White
    NavControl.ShowPage(Page1)
    Page1.RootPanel.LoadLayout("1")
    Label1.Font = Font.CreateNew2("vermidiRouge", 20)
    Label2.Font = Font.CreateNew2("Al_Mushaf", 20)
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)

End Sub

Private Sub Application_Background
   
End Sub

Copying updated assets files (2)
Application_Start
Error occurred on line: 31 (Main)
Object was not initialized (UIFont)
Stack Trace: (
CoreFoundation <redacted> + 150
libobjc.A.dylib objc_exception_throw + 38
CoreFoundation <redacted> + 0
B4i Example -[B4IObjectWrapper object] + 200
B4i Example -[B4ILabelWrapper setFont:] + 112
CoreFoundation <redacted> + 68
CoreFoundation <redacted> + 292
B4i Example +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1788
B4i Example -[B4IShell runMethod:] + 496
B4i Example -[B4IShell raiseEventImpl:method:args::] + 1768
B4i Example -[B4IShellBI raiseEvent:event:params:] + 1332
B4i Example __33-[B4I raiseUIEvent:event:params:]_block_invoke + 74
libdispatch.dylib <redacted> + 10
libdispatch.dylib <redacted> + 22
libdispatch.dylib _dispatch_main_queue_callback_4CF + 1532
CoreFoundation <redacted> + 8
CoreFoundation <redacted> + 1590
CoreFoundation CFRunLoopRunSpecific + 516
CoreFoundation CFRunLoopRunInMode + 108
GraphicsServices GSEventRunModal + 160
UIKit UIApplicationMain + 144
B4i Example main + 108
libdyld.dylib <redacted> + 2
)
 

Attachments

  • al_mushaf.zip
    107 KB · Views: 204

db0070

Active Member
Licensed User
Longtime User
Scratch some of that - I restarted B4i, and now there is no error. But I still cannot set font size
 
Upvote 0
Top