BCTextEngine measures each character separately. So even if the font is monospace, as the character glyphs include spaces on the sides, the drawn text will not appear "monospaced".
Sorry I didn't make this clear but because of Justified alignment means that I can use any font that I want. So the monospace font is replaced with serif. My original problem is that I cannot get a custom font to be used. A font that I downloaded from the web.
Dim MyFont As B4XFont
#If B4A
MyFont = xui.CreateFont(Typeface.LoadFromAssets("audiowide.regular.ttf"),62)
#Else If B4J
Dim fx As JFX
MyFont = xui.CreateFont(fx.LoadFont(File.DirAssets,"audiowide.regular.ttf",62),62)
#Else
MyFont = xui.CreateFont(Font.CreateNew2("audiowide.regular.ttf",62),62)
#End If
TextEngine.CustomFonts.Put("MyFont", MyFont)
BBCodeView1.TextEngine = TextEngine
BBCodeView1.Text = $"[Alignment=Center][TextSize=30][b][Font=MyFont] My Header [/Font][/b][/TextSize][/Alignment]"$
Demo:
Example:
B4X:
BBCodeView1.Text = _
$"[Alignment=Center][TextSize=30][b][u][Font=MyFont Size=50]This is the title [/Font][FontAwesome=0xF034/] [FontAwesome=0xF035/][/u][/b][/TextSize][/Alignment]
Emoji made of multiple "characters": ?? and a flag: [TextSize=30][e=??/][/TextSize]
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc fermentum elit vitae nisi faucibus, vitae lacinia turpis mattis.
....
....
Thank you Omar my good man. That worked but I also needed to delete the bold statements around my text. I'll need to look into that as I use this font in other places in my app and am able to use bold.
Thank you Omar my good man. That worked but I also needed to delete the bold statements around my text. I'll need to look into that as I use this font in other places in my app and am able to use bold.