iOS Question New Font...

ivanomonti

Well-Known Member
Licensed User
Hi community,

how can I use a font just installed on the system.

error Object was not initialized (UIFont)

2014-11-28_154714.jpg
 

ivanomonti

Well-Known Member
Licensed User
B4X:
    #AppFont: 28-Days-Later.ttf
    #AppFont: a-song-for-jennifer-bold.ttf
    #AppFont: a-song for-jennifer.ttf

B4X:
Application_Start
Application_Active
Error occurred on line: 0 (classmenuday)
Object was not initialized (UIFont)
Stack Trace: (
  CoreFoundation  <redacted> + 150
  libobjc.A.dylib  objc_exception_throw + 38
  CoreFoundation  <redacted> + 0
  BarAndRestaurant  -[B4IObjectWrapper object] + 180
  BarAndRestaurant  -[B4ILabelWrapper setFont:] + 116
  CoreFoundation  <redacted> + 68
  CoreFoundation  <redacted> + 300
  BarAndRestaurant  +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1928
  BarAndRestaurant  -[B4IShell runMethod:] + 496
  BarAndRestaurant  -[B4IShell raiseEventImpl:method:args::] + 1846
BarAndRestaurant  -[B4IShellBI raiseEvent:event:params:] + 1280
BarAndRestaurant  __33-[B4I raiseUIEvent:event:params:]_block_invoke + 74
libdispatch.dylib  <redacted> + 10
libdispatch.dylib  <redacted> + 22
libdispatch.dylib  <redacted> + 712
CoreFoundation  <redacted> + 8
CoreFoundation  <redacted> + 1512
CoreFoundation  CFRunLoopRunSpecific + 476
CoreFoundation  CFRunLoopRunInMode + 106
GraphicsServices  GSEventRunModal + 136
UIKit  UIApplicationMain + 1440
BarAndRestaurant  main + 116
libdyld.dylib  <redacted> + 2
)
 
Upvote 0

stevel05

Expert
Licensed User
The file name has spaces, as does the family name. You need to ignore these when creating the font. Also as the layout is reloaded in page _resize (unless you turn it off) you need to re-apply the font there.

The font in the example was downloaded from here:http://www.dafont.com/28-days-later.font , please check the license if you want to use it.
 

Attachments

  • 28Font.zip
    194.5 KB · Views: 120
Upvote 0

stevel05

Expert
Licensed User
Only views sizes and positions are set at that point. Other properties are ignored.
Could you check this one please @Erel, the font does not appear on the label if it is applied in Application_Start. It does when moved to Page1_Resize.

Thanks
 
Upvote 0

Ramezanpour

Active Member
Licensed User
You are correct. There is a bug in AutoScaleAll that causes the designer font to be loaded. It will be fixed for the next update.

Note that you will still need to set the correct size in the designer.

I have this problem :(

B4X:
Copying updated assets files (4)
Application_Start
Application_Active
Error occurred on line: 55 (first)
Object was not initialized (UIFont)
Stack Trace: (
  CoreFoundation       <redacted> + 150
  libobjc.A.dylib      objc_exception_throw + 38
  CoreFoundation       <redacted> + 0
  i                    -[B4IObjectWrapper object] + 180
  i                    -[B4ITabBarItemItemWrapper SetFont:] + 132
  i                    -[b4i_first _sethome::] + 752
  i                    -[b4i_first _showpageme] + 1404
  i                    -[b4i_main _t_tick] + 366
  CoreFoundation       <redacted> + 68
  CoreFoundation       <redacted> + 300
i                    +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1928
i                    -[B4IShell runMethod:] + 496
i                    -[B4IShell raiseEventImpl:method:args::] + 1846
i                    -[B4IShellBI raiseEvent:event:params:] + 1316
i                    __24-[B4ITimer startTicking]_block_invoke + 298
libdispatch.dylib    <redacted> + 10
libdispatch.dylib    <redacted> + 66
libdispatch.dylib    <redacted> + 22
libdispatch.dylib    <redacted> + 1606
libdispatch.dylib    <redacted> + 212
libdispatch.dylib    _dispatch_main_queue_callback_4CF + 396
CoreFoundation       <redacted> + 8
CoreFoundation       <redacted> + 1512
CoreFoundation       CFRunLoopRunSpecific + 476
CoreFoundation       CFRunLoopRunInMode + 106
GraphicsServices     GSEventRunModal + 136
UIKit                UIApplicationMain + 1440
i                    main + 116
libdyld.dylib        <redacted> + 2
)

I add this to Project Attributes
B4X:
    #AppFont: tahoma.ttf

And Add this to seccond Process_Globals

B4X:
    Dim ta15 As Font
    ta15 = Font.CreateNew2("tahoma",15)

And use in :

B4X:
Sub Setone(p As Page, title As String)

    Dim tb As TabBarItem
    tb.Initialize(title,LoadBitmap(File.DirAssets,"a.png"), Null)
    tb.SetFont(ta15)
    tb.SetTitleOffset(0, 0)
    p.TabBarItem = tb
   
End Sub
 
Upvote 0

Andrea Falcucci

Member
Licensed User
Hi!

I'm using a custom font on B4i and I'm creating all the labels via code without designer.

I'm unable to let the createnew2 procedure works.

#AppFont: lcddot.ttf in the Project Attributes

later in the code

Label1.initialize("Label1")
Label1.Text = "Test"
Label1.TextColor = Colors.White
Label1.TextAlignment = Label1.ALIGNMENT_LEFT
Label1.Font = Font.CreateNew2("LCDDot",10)
MyPage.RootPanel.AddView(Label1, 0dip, 0dip, 100dip, 100dip)

doesn't work

if I use Label1.Font = Font.CreateNew(10) everything works fine.

Thank you.
 
Upvote 0
Top