Hi <@U0CA9CN1M52>, I see you have been working on ...
# translators
k
Hi @Tomasz Staniak, I see you have been working on UTF8 support as well and thought it might be a good idea to work together on this My current take on this is in this branch: github.com/bsek/AROS/tree/utf8-text New public definitions (graphics/text.h) • TA_CharSet (TAG_USER+3): the IANA MIBenum of a font’s strings. 106 means UTF-8. The value still has to be checked against OS4. • TA_GlyphHook (TAG_USER+0x0f00, AROS private) and struct TextGlyph: the hook through which graphics.library asks diskfont for glyphs above 255. • CHARSET_UTF8 (106). graphics.library (no new LVOs) • Text(), TextLength(), TextExtent() and TextFit() decode UTF-8 when the font was opened with TA_CharSet=106. • Counts stay in bytes, and TextFit() never splits a character. • WeighTAMatch() keeps UTF-8 and 8-bit instances of the same font apart, so old programs never get a UTF-8 font. • 8-bit fonts are drawn exactly as before. diskfont.library (no new LVOs) • A font opened with TA_CharSet=106 becomes a separate UTF-8 instance: • Glyphs 0–255 use an identity code page, so they are Latin-1. • The glyph engine stays open, and glyphs above 255 are rendered on demand and cached per font. • The engine and cache are freed together with the font. Expunge is refused while such fonts exist. • Bug fix: for tagged requests, the caller’s tag pointer was stored in the shared font cache. freetype2.library (no new LVOs) • A new .otag tag, OT_Spec10_FontRange, gives a code point range and a .ttf file. It may appear several times, so one .font can use several .ttf files. • The range files are opened on first use and scaled to the main font. • Old .otag files work as before. keymap.library (new LVO 9) • LONG MapRawKeyUTF8(struct InputEvent *, STRPTR buffer, LONG length, struct KeyMap *) works like MapRawKey() but returns UTF-8. • The charset is taken in this order: a. The charset the keymap names itself. b. Otherwise ENV:CHARSET, which is read when a process calls. c. Otherwise Latin-1. If no table is known for the charset, bytes above 0x7F are left out instead of guessed. • Conversion uses the tables in codesets.library and allocates nothing, so it can be called from input handlers. Keymap format, mkamikeymap and kms.library • A keymap descriptor can name its charset with charset: in its config section. mkamikeymap stores it after the keymap name, as “KMCS” followed by the charset name. Old readers ignore it. • kms.library keeps that trailer when it converts a keymap. It also had a bug fixed: the size of high-key strings was counted without padding, which overwrote the keymap name. • 15 keymaps now name their charset. Each one was checked by decoding its bytes: ◦ windows-1251: by, bg, rus, ua ◦ windows-1250: cz, sk ◦ ISO-8859-2: h, hr, pl ◦ ISO-8859-7: gr ◦ windows-1257: lt, lv ◦ ISO-8859-9: tr ◦ ISO-8859-16: ro ◦ windows-1255: il • Keymaps without a charset (western, Estonian) work as before. • Note: the Russian keymap is windows-1251, although russian.c says Amiga-1251. The Czech and Slovak keymaps are windows-1250, although czech.c says ISO-8859-2. muimaster.library / Zune (no new LVOs) • UTF-8 mode is global, switched on with ENV:UTF8. ENV:CHARSET keeps its 8-bit meaning for keymaps and file names. • In UTF-8 mode: ◦ Fonts are opened with TA_CharSet. ◦ String moves the cursor and deletes by whole characters, and gets typed characters from MapRawKeyUTF8(). ◦ Pasted text is taken as is when it is valid UTF-8. ◦ An underlined shortcut (“_Ø”) is a whole character. Status and open points • Bitmap fonts are still 8-bit only. That includes the default Zune font. • One code point = one glyph. There is no shaping (ligatures, combining marks, Arabic or Indic scripts, emoji sequences). PR #2156 does this with HarfBuzz. • Disk I/O in Text(): FreeType reads font files on demand, so a glyph lookup can touch the disk inside Text(). Slack conversation