I am having trouble with a custom font:
- I have edited the info.plist file and included it and the font itself in project. (They build correctly into the project).
- I have these lines in the App.Open event:
Dim classPtr as Ptr = NSClassFromString (“UIFont”)
Dim fontsize as Double
Declare function fontWithName lib “Foundation” selector “fontWithName:size:” (id as ptr, Fontname as CFStringRef, Size as double) as Ptr
Dim fontsize as single
Declare function fontWithName lib “Foundation” selector “fontWithName:size:” (id as ptr, Fontname as CFStringRef, Size as single) as Ptr
Dim fontfile as xojo.IO.FolderItem = SpecialFolder.GetResource(“HamburgSymbols.ttf”)
Dim myfontname as ptr
fontsize = 20
If fontfile <> Nil And fontfile.Exists Then
myfontname = fontWithName(classPtr, “HamburgSymbols”, fontsize)
if myfontname = nil then
MsgBox(“Cannot find ‘HamburgSymbols’.”)
MsgBox(“Cannot find font with that name.”)
every time, the font file is found (fontfile is not Nil and fontfile Exists) but then assigning myfontname fails and returns nil. I have also tried hardcoding fontsize rather than using a variable, but no difference.
Finally, assuming someone can see what I am doing wrong and myfontname can become a valid ptr to a font, how do I assign that font to an IOSCanvas as a TextFont?
PS Simply doing Dim myfontname as New IOSfont(“HamburgSymbols”,20) after loading the font via the info.plist did not work (generates an invalid font name error) although I have seen a post where someone apparently just did that - cant imagine how.
Hope someone can help!