Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> 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.

- Choosing individual glyphs: it's complicated! http://ilovetypography.com/OpenType/opentype-features.html

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.

Each glyph actually comes with a custom program to do the hinting! It's even more complicated: https://developer.apple.com/fonts/TrueType-Reference-Manual/...

Luckily I don't think it depends on much external state.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: