iOS Tutorial Custom Fonts

Discussion in 'iOS Tutorials' started by Erel, Nov 4, 2014.

  1. Erel

    Erel Administrator Staff Member Licensed User

    In order to add custom font files to your application you need to follow these instructions:
    1. Add the font file to the "special" folder: <project>\Files\Special
    2. Add the #AppFont attribute for each font file (including the extension):
    Code:
    #AppFont: papercuts-2.ttf
    #AppFont: vermidirouge 1.0.ttf
    3. Find the font name. You can double click on the font file:

    [​IMG]

    4. Create a new font with this font name. The name should not include spaces:
    Code:
    Label1.Font = Font.CreateNew2("VermidiRouge"30)
    Label2.Font = 
    Font.CreateNew2("PaperCuts2"20)
    [​IMG]


    Note that #AppFont and the special folder features are not available in the current beta.
     

    Attached Files:

    Mashiane and netkomm like this.
  2. GiulioVale

    GiulioVale Active Member Licensed User

    HI Erel,
    with this example I have
    Error occurred on line: 30 (main)
    Object was not initialized (UIFont)

    Any help?

    edit:
    ooooppss my fault I not read the message for the current beta. Sorry
     
    Last edited: Nov 4, 2014
    Erel likes this.
  3. GiulioVale

    GiulioVale Active Member Licensed User

    HI Erel,
    with btnSeguente.CustomLabel.Font = Font.CreateNew2("FontAwesome", 20) i want assign a font to a text button.
    My text is UnescapeUnicode("\uf061")
    How i can assign at runtime this char to button label?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Code:
    btn.Text = chr(0xf061)
     
    Mashiane and GiulioVale like this.
  5. susu

    susu Well-Known Member Licensed User

    Your app runs on iPhone 5S (iOS 7.1.2) but there's no change of font? Is it a bug?
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    I've just tested it on an iOS 7 device and I do see the fonts. Are you running the example as is?
     
  7. susu

    susu Well-Known Member Licensed User

    Yes, I just download your code and run as "Debug".
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    Which version of B4i are you using?
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    This is B4i forum.
     
  10. susu

    susu Well-Known Member Licensed User

    B4i 1.21
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    Not sure why it doesn't appear on your device. I tested it on iPad running iOS 7.

    Have you tried to run it in Release mode?
     
  12. tufanv

    tufanv Expert Licensed User

    Hello
    How can we use this with a button ?
     
  13. Erel

    Erel Administrator Staff Member Licensed User

    Yes:
    Code:
    Button1.CustomLabel.Font = Font.CreateNew2("PaperCuts2"20)
     
  14. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    Hi.
    I use custom font and it's work good but still cannot change fontsize.
    of course sometime i get error "The file 'J:\Basic4x\Basic4iOS\Chapter 18\Attachment\Project\Objects\src\tahoma' already exists." what it is?
    How change font size? (I use label1.Font = Font.CreateNew(30))
     
  15. Erel

    Erel Administrator Staff Member Licensed User

    The size is set when you call Font.Create2. See the example in the first post.
     
  16. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    I use Font.Create2 but not work even i set size in 40 but not change.
     
  17. Erel

    Erel Administrator Staff Member Licensed User

    It is probably the designer that changes your font size. Set the font size in the designer.
     
  18. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    I try change font size from settings.I dont want to change font size in designer.Is there a way?
     
  19. stari

    stari Active Member Licensed User

    see Replay #15
     
  20. Erel

    Erel Administrator Staff Member Licensed User

    Yes. You can either change the font size in Page_Resize event or set the "Handle Resize Event" property to false.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice