Public Sub CreateB4XFont(FontFileName As String, FontSize As Float) As B4XFont
#IF B4A
Return xui.CreateFont(Typeface.LoadFromAssets(FontFileName), FontSize)
#ELSE IF B4I
FontFileName = FontFileName.Replace(".ttf","").Replace(".otf","")
Dim existFont As Boolean = False
For Each fontename As String In Font.AvailableNames
If fontename = FontFileName Then
existFont = True
Exit
End If
Next
If existFont Then
Return xui.CreateFont(Font.CreateNew2(FontFileName, FontSize), FontSize)
Else
Log($"not found FontFileName: ${FontFileName}"$)
Return xui.CreateDefaultFont(FontSize)
End If
#ELSE ' B4J
Dim FX As JFX
Return xui.CreateFont(FX.LoadFont(File.DirAssets, FontFileName, FontSize), FontSize)
#END IF
End Sub