-
• #2
The issue is the
12x20
font is stored inside Espruino as if it was a custom font. When a custom font is loaded, all that's stored in Graphics is the data for the font - so it's pretty much impossible to figure out which function was called to get that data :(Potentially we could also store the font name in Graphics, but that's not trivial due to restrictions on how many arguments built-in functions can have :(
-
• #3
Well, that's bad but not not tragical.
Are there more fonts like
12x20
that will be reported asCustom
? -
• #4
I just wrote a little "program" to find out which fonts on a Bangle.js 2 will be reported properly and which will not:
print('which fonts will not properly be reported?'); print(''); let FontList = g.getFonts(); for (let i = 0, l = FontList.length; i < l; i++) { let Font = FontList[i]; g.setFont(Font); if (g.getFont() === Font) { print('== set: "' + Font + '", got "' + Font + '"'); } else { print('<> set: "' + Font + '", got "' + g.getFont() + '"'); } }
Outcome:
>which fonts will not properly be reported? > >== set: "4x6", got "4x6" == set: "6x8", got "6x8" <> set: "12x20", got "Custom" <> set: "6x15", got "Custom" == set: "Vector", got "Vector" >
-
• #5
Yes, that sounds right - any actual custom fonts added will have the same issue too
-
• #6
Unfortunately no meta data is kept about the custom font (except the fact that it is recognized as a custom font). Therefore, I wrapped in my http://www.espruino.com/ui (doc) / ...UI framework... (forum) the font handling. At the same time I used a palette approach to simplify / application-localize font referencing.
-
• #7
good to know - thank you very much!
can anybody explain the following behaviour (entered into the left-hand side of the Web IDE):
I have a similar problem deep inside a program which crashes with
In
Details.font
I've stored a previously configured font, obtained usingg.getFont()
(which returnedCustom
, although the font was set usingg.setFont12x20()
before)