> In what situations do you need to do this, but don't need to show any other data (dates and times, localized UI, user timezone, culturally appropriate fonts, RTLness) that involves knowing the user's languages and locale?
For drawing a given glyph, there is normally a lookup into a font table that involves solely the string of Unicode code points coming in.
Except if any characters in the CJK Unified Ideograph range. Then my function call suddenly has to jump out to read environment variables, which are hopefully setup correctly.
My code to do a lookup into a font file should not depend upon the users environment variables due to a space saving optimization made two decades ago.
> For drawing a given glyph, there is normally a lookup into a font table that involves solely the string of Unicode code points coming in.
Why are you implementing OpenType? It's got working libraries already.
But if you are getting into that, glyphs in a font are stored by "glyph name", not necessarily by code point. There's a bunch more steps than that.
- Font substitution: Find fonts that cover every character in the text. The order of your search list depends on the language.
- Text layout and line breaking: for best results, you don't want to line break in the middle of a word, and you need to place punctuation on the correct side of right-to-left sentences. I think both of these need dictionaries.
You have to read the GSUB tables and do a bunch of expected features, like ligatures, automatic fractions, beginning of word special forms (see Zapfino), &c. This includes language specific glyphs, but fonts can also just choose glyphs with a random number generator.
- Drawing the glyph. Remember not to draw each one individually, or a translucent line of overlapping characters (like in Indian languages) will look bad.
For drawing a given glyph, there is normally a lookup into a font table that involves solely the string of Unicode code points coming in.
Except if any characters in the CJK Unified Ideograph range. Then my function call suddenly has to jump out to read environment variables, which are hopefully setup correctly.
My code to do a lookup into a font file should not depend upon the users environment variables due to a space saving optimization made two decades ago.