iOS Question B4X UI Gauges Class

walterf25

Expert
Licensed User
Longtime User
Hi all, i am trying to use this class in a B4i project, i just downloaded the class and the B4A Example, everything works as expected in the B4A example, but i get an error when trying to compile, and it has to do with the Font file being used, Erel is using a font file named Crystal.ttf which he mentions needs to be copied to the /Special folder inside the Files folder.

I have copied that file and I have also added the following to the main Module
Font file:
#AppFont: Crysta.ttf

But the project is still not compiling and telling me the error is at this line in the Gauge.bas class.
Error:
#else if B4i
    NativeFont = Font.CreateNew2("Crysta", 20)
#End If

Any ideas why this fails, the Crysta.ttf file has been copied to the Special folder and the #AppFont attribute has been added to the Main Module.

Walter
 

sorex

Expert
Licensed User
Longtime User
I'm doing it like this

Main .B4i module
B4X:
#AppFont: gamefont.ttf

The rest is main or class
B4X:
    Dim gameFont As B4XFont

B4X:
#If B4A
    gameFont=xui.CreateFont(Typeface.LoadFromAssets("gamefont.ttf"), 16)
#else
    gameFont=xui.CreateFont(Font.CreateNew2("gamefont", 30), 16)
#end if

if it still doesn't work (no error but not visible on label) then the problem might be the naming inside the font file.

when you open the file in windows it will tell you what name it uses. It could be "Crysta normal" or something.
the app will load the font without problems but you reference to it with the wrong font name.
 
Last edited:
Upvote 0
Top