iOS Question How can use materialdesignicons-webfont.ttf in B4i ?

dws

Member
Licensed User
Longtime User
Hello, I have already tried using what is mentioned in the article about using custom fonts but unfortunately I don't see any results. A little help please...
I have see font name from materialdesignicons-webfont.ttf and in Main i have

#AppFont: materialdesignicons-webfont.ttf:

I have in Special folder font file
materialdesignicons-webfont.ttf

i try initialize custom font like

1. Dim xFont As Font = Font.CreateNew2("materialdesignicons-webfont", 25)
2. Dim xFont As Font = Font.CreateNew2("materialdesigniconswebfont", 25)
3. Dim xFont As Font = Font.CreateNew2("materialdesignicons", 25)
4. Dim xFont As Font = Font.CreateNew2("MaterialDesignIcons", 25)

but not initialize and i cant use.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Double click on the font file, from your PC, and check its internal name.

 
Upvote 0

dws

Member
Licensed User
Longtime User
Double click on the font file, from your PC, and check its internal name.

 
Upvote 0

dws

Member
Licensed User
Longtime User
Thanks for your response Erel.

1787210864438.png


1787210969610.png

Special Folder
1787211005699.png


I've already done it and that's why I wrote all the examples above. I'm using local if that matters.
I downloaded the file I'm using from your post and work fine in B4a and B4j.

When i use your example with this font file
1787212094465.png

1787212133382.png
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Works fine here...

1787232348967.png


B4X:
    Dim f As Font = Font.CreateNew2("MaterialDesignIcons", 20)
    Label1.Font = xui.CreateFont(f, 20)
    Label1.Text = UnicodeToString(0xF0006) & " " & UnicodeToString(0xF0010)
    Log(Label1.Font)
End Sub

Sub UnicodeToString (codepoint As Int) As String
    Dim bc As ByteConverter
    Dim b() As Byte = bc.IntsToBytes(Array As Int(codepoint))
    Return BytesToString(b, 0, 4, "UTF32")
End Sub

B4X:
#AppFont: materialdesignicons-webfont.ttf
Logs:
<B4IFontWrapper: <UICTFont: 0x10d102d00> font-family: "Material Design Icons"; font-weight: normal; font-style: normal; font-size: 20.00pt>


Downloaded font from: https://app.unpkg.com/@mdi/font@7.0.96/files/fonts/materialdesignicons-webfont.ttf
 
Upvote 0
Top