Font handling - ASCII, non-ASCII and CJK #847
Replies: 1 comment 8 replies
-
Hi, One of the main reason I went to the current system was to save flash as having full font tables was getting huge. Would prefer to not go back to burning in an entire ASCII range as a table; especially as for debugging you rarely need text often only need numbers 🤣 My initial plan here was to go to utf style leading bytes (which is why symbols are ranked by use count; to reduce the number of the leaders). But not use actual utf8 due to the overhead. I'm open to any ideas really; but with a preference for ones that reduce flash and ram usage where sane. One thought would be to move to variable width characters with seperate lookup + data arrays. Akin to how adafruit do their fonts iirc (been a long time). No idea what the size difference would be to the current method though 😅 Also have wondered if some simplification can occur with all the settings screens or not as they are all trending towards a similar style 😅 hmmmm |
Beta Was this translation helpful? Give feedback.
-
Just throwing out ideas. After having the initial CJK support and Chinese translation merged, I was thinking how text handling may be improved to allow for more chars in the CJK range and possibly make multi-language firmware releases possible, so I typed out some rough notes. I haven't proofread it so please excuse me if I've wrote something really stupid.
Looking for comments.
Fonts
Latin/Cyrillic
CJK
as Latin/Cyrillic
the Large font for Latin/Cyrillic
Japanese using only half-width Katakana (like JIS X 0201)
Needs comment from native Japanese user. Perhaps not really useful.
Text layout
Full screen static text message
Full screen scrolley text (marquee) message
Menu group
16x16 px graphical icon on the right.
2 px on the right for scroll bar...
Technically printable in the same way as "full screen static text message".
Menu option short description
Option value is printed on the right.
2 px on the right for scroll bar...
Technically printed in the same way as "full screen static text message".
Exact available space depends on the option, but in general it is about the
same as a menu group.
Menu option value
Option values are usually printed programmatically, so the font size is usually
defined statically.
Normal screens / detailed screens / debug menu
Fixed layouts, practically require statically defined font sizes.
Font setup
Issues with the current system
through font table mapping transformation
printed using this size
for CJK
to CJK chars
Proposal 1
For
\x00
to\x7F
, keep the same chars as ASCII for convenient alphanumericdisplay (e.g. debugging info).
For extended Latin/Cyrillic chars outside of ASCII, they should be able to fit
within
\x80
to\xFE
(none of the current non-CJK firmwares uses more than128 chars and that does not exclude ASCII chars). We can use the same dynamic
font table generation method as currently in use for these extended chars.
For CJK versions, we can employ lead bytes, effectly implementing a custom
double-byte charset (DBCS), which theoretically gives us 32768 CJK chars and
should be more than enough. Or alternatively, we can designate
\xF0
to\xFF
as lead bytes and leave the rest to be single-byte chars, so that the more
frequently used CJK chars only takes one byte. The dynamic font table
generation can do the work here again.
Font tables
\x20
(space), as anything <\x20
are control chars\x20
(space), as anything <\x20
are control chars(same as current as in large font table)
but with increased handling complexity
\x80\x00
CJK text printing
Font selection in translation string
null-terminated string
\x01
to indicate usage of large (Latin/Cyrillic)or medium (CJK) font
\x02
to indicate usage of large (Latin/Cyrillic)or mixed (CJK) font
\n
moves to thesecond line
font
Proposal 2
Use UTF-8 encoding for strings.
A font lookup table can be used to map Unicode codepoints to the font table.
ASCII chars from the range of
\x20
(space) to\x7F
may be fixed so as tonot take space in the lookup table.
It is also possible to include different set of available chars for the small
and medium/large fonts to reduce size of font tables.
Downsides:
Font lookup table may be:
Beta Was this translation helpful? Give feedback.
All reactions