Custom Font

  1. last year

    So I'm using a custom font and I have added it to Info.plist and I used the

    Dim cusFont as new iOSFont("Bebas Neue", 32)
    Label1.TextFont = cusFont

    and it worked correctly with the emulators and the devices I had (all 64-bit), until I tried it in an iPhone 5c 32-bit device which crushes immediately.
    If I comment out the code and build it, the app has no problem.

    Is there another method or a different way to go about using the font?

    I tried using fontWithName and I can get a ptr to point there but I have no idea how to continue.

    So it was that I was not copying the tff file after the build. I just had the file drag and drop into the project and it worked for most phones but not for this. Now it works great.

  2. Jeremie L

    21 Apr 2017 Pre-Release Testers, XDC Speakers Europe (France)

    Did you check the crashlogs from the iPhone 5c ?

    fontWithName is useful for setting a custom font to a TableCell Label and DetailLabel.

    Declare Function getTextLabel Lib "UIKit" selector "textLabel" (obj_ref As ptr) As ptr
    Declare Function getDetailTextLabel Lib "UIKit" selector "detailTextLabel" (obj_ref As ptr) As ptr
    Declare sub setFont lib UIKitLib selector "setFont:" (obj_ref as ptr, fontRef as ptr)
    Dim label As Ptr
    label = getTextLabel(cell.Handle)
    setFont(label, fontRef)
  3. I just want to set the font on iOSLabels

    It's the first time I'm making an iPhone app so I cannot fully understand the crashlog. I googled a lot, tried various things and then I went with commenting everything out and seeing where it crashes.

    The crash log in the iPhone 5c shows this

    Exception Type:  EXC_CRASH (SIGABRT)
    Exception Codes: 0x0000000000000000, 0x0000000000000000
    Exception Note:  EXC_CORPSE_NOTIFY
    Triggered by Thread:  0
    Filtered syslog:
    None found
    Global Trace Buffer (reverse chronological seconds):
    0.724652     AppleJPEG                 	0x0000000023295ec5 [0x16ace000] Created session
    6.127774     CFNetwork                 	0x00000000220309d5 TCP Conn 0x1657c830 SSL Handshake DONE
    6.723491     CFNetwork                 	0x000000002203090f TCP Conn 0x1657c830 starting SSL negotiation
    6.724592     CFNetwork                 	0x00000000220b0a2d TCP Conn 0x1657c830 complete. fd: 6, err: 0
    6.726484     CFNetwork                 	0x00000000220b1b2f TCP Conn 0x1657c830 event 1. err: 0
    6.984090     CFNetwork                 	0x00000000220b1bad TCP Conn 0x1657c830 started
    7.001829     CFNetwork                 	0x00000000220f7387 Creating default cookie storage with default identifier
    7.002065     CFNetwork                 	0x00000000220f7363 Faulting in CFHTTPCookieStorage singleton
    7.002065     CFNetwork                 	0x00000000221398ff Faulting in NSHTTPCookieStorage singleton
    Thread 0 name:  Dispatch queue:
    Thread 0 Crashed:
    0   libsystem_kernel.dylib        	0x217bbc5c __pthread_kill + 8
    1   libsystem_pthread.dylib       	0x21861b46 pthread_kill + 62
    2   libsystem_c.dylib             	0x217500c4 abort + 108
    3   libsystem_c.dylib             	0x2172f8ce __assert_rtn + 302
    4   myApp                   	0x00293e30 UnhandledException(RuntimeObject*) (
    5   myApp                   	0x002680cc HTTPSocketData::PageReceived(HTTPSocketImp&, Text const&, int, RuntimeObject*) (XojoExceptions.h:74)
    6   myApp                   	0x00293106 -[XOJConnectionDelegate connectionDidFinishLoading:] (RefCountedObject.h:90)
    7   CFNetwork                     	0x221743a0 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 56
    8   CFNetwork                     	0x22174358 -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 184
    9   CFNetwork                     	0x2217444c -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 36
    10  CFNetwork                     	0x2202ed6e ___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke + 78
    11  CFNetwork                     	0x220eda82 ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 70
    12  libdispatch.dylib             	0x216bfcaa _dispatch_client_callout + 22
    13  libdispatch.dylib             	0x216c7542 _dispatch_block_invoke + 450
    14  CFNetwork                     	0x2201fd22 RunloopBlockContext::_invoke_block(void const*, void*) + 18
    15  CoreFoundation                	0x21a3bc08 CFArrayApplyFunction + 36
    16  CFNetwork                     	0x2201fc0a RunloopBlockContext::perform() + 182
    17  CFNetwork                     	0x2201fad4 MultiplexerSource::perform() + 216
    18  CFNetwork                     	0x2201f968 MultiplexerSource::_perform(void*) + 48
    19  CoreFoundation                	0x21aef9e6 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
    20  CoreFoundation                	0x21aef5d6 __CFRunLoopDoSources0 + 454
    21  CoreFoundation                	0x21aed93e __CFRunLoopRun + 806
    22  CoreFoundation                	0x21a3c1c8 CFRunLoopRunSpecific + 516
    23  CoreFoundation                	0x21a3bfbc CFRunLoopRunInMode + 108
    24  GraphicsServices              	0x23058af8 GSEventRunModal + 160
    25  UIKit                         	0x26176434 UIApplicationMain + 144
    26  myApp                   	0x002949a8 runIOSMainLoop() (
    27  myApp                   	0x000c9e1a xojo._RuntimeRun + 28
    28  myApp                   	0x001ce454 _Main + 354
    29  myApp                   	0x001cdcc0 main + 70
    30  libdyld.dylib                 	0x216e8872 start + 2
  4. Kevin W

    21 Apr 2017 Pre-Release Testers, Xojo Pro

    I'm not sure what that crash log has to do with the font, but it does show that there is an unhandled exception. You could try catching that exception and seeing if you can get some more relevant info based on what the specifics of that exception are.

  5. Antonio R

    22 Apr 2017 Pre-Release Testers, Xojo Pro Europe (Italy)

    What's the code in the page received event?

  6. So it was that I was not copying the tff file after the build. I just had the file drag and drop into the project and it worked for most phones but not for this. Now it works great.

or Sign Up to reply!