diff --git a/kandinsky/include/kandinsky/font.h b/kandinsky/include/kandinsky/font.h index a45a1e283..7f716ba70 100644 --- a/kandinsky/include/kandinsky/font.h +++ b/kandinsky/include/kandinsky/font.h @@ -8,6 +8,21 @@ #include #include "palette.h" +/* We use UTF-8 encoding. This means that a character is encoded as a code point + * that uses between 1 and 4 bytes. Code points can be "combining", in which + * case their glyph should be superimposed to the glyph of the previous code + * point in the string. This is for instance used to print accents: the string + * for the glyph 'รจ' is composed of the code point for 'e' followed by the + * combining code point for '`'. + * ASCII characters have the same encoding in ASCII and in UTF-8. + * + * We do not provide a glyph for each of the 1,112,064 valid UTF-8 code points. + * We thus have a table of the glyphs we can draw (uint32_t Codepoints[] in + * kandinsky/fonts/codepoints.h). To easily compute the index of a code point in + * the Codepoints table, we use the m_table matching table: it contains the + * CodepointIndexPairs of the first code point of each series of consecutive + * code points in the Codepoints table. */ + class KDFont { private: static constexpr int k_bitsPerPixel = 4; // TODO: Should be generated by the rasterizer