Newer
Older
Import / research / ui / toolkit / fonts.txt

Font terms

- baseline - line at bottom that letters 'sit' on
- xMin,yMin,xMax,yMax - the tight bounds around the glyph
- left side bearing - (lsb) space to left of xMin (when drawing this after another glyph)
                    - think letters like D,E,F,K,L,M,N,P,R with a flat left side to them
                    - then think of letters like C,G,O,Q with a curved left side
                    - they have different amounts of space to the left of them
- right side bearing - (rsb) space to right of xMax (space to leave on right side of glyph)
                    - H,N,M with flat right sides, and D,P,B etc with rounded right sides, they have different
                      amounts of space to the right of them
- advance width - (rsb - lsb) how much the cursor position moves forward from this glyph to the next
- tracking - a uniform amount of space to add between letters of a word (in addition to the advance width)
- kerning - adjustment of spacing between particular letter pairs
                    - Think of A followed by V or T. AV or AT or VA or 74. These letter pairs can be pushed
                      closer together. The lsb,rsb alone is not enough, this is specific for particular
                      combinations of letters.
                    - some font design software allows class based kerning
                         - classes like left-side-curve and left-side-flat letters
- italics - leaning text - italic versions of glyphs will need its own different set of metrics and kerning

- hinting - hints to the rasterizer so that at small point sizes, important details aren't ignored and
            proportions of the font are maintained. This involves a type of VM and instructions. There
            were patents that have expired, but an alternative approach is to use anti-aliasing instead
            and there are other patents related to clear-type / lcd sub-pixel aware rasterization which
            may not have expired yet. This can give sub-pixel positioning of glyphs on the screen, but that
            has an effect on cachability of glyphs.

- musings - I wonder if it is possible to find for latin-1 text, some cross-font common kerning strategies
            and letter classes that hold true, and also to be able to tween between the non-italic to italic
            metrics and kerning to be able to skew the glyphs by arbitary angles without needing different
            fonts. - it seems unfortunate that a whole new font is needed for an italic version when the
            original is in vector form and easy to skew, all but for the metric and kerning tables. I wonder
            if the same can be applied to bold fonts, with tweening between weights. Another type of font
            called a stroke based font may solve some of these. I'm aware of Arphic that provides a stroke
            based font for CJK fonts. Another technology is SDF - signed distance fields, which are bitmaps
            of distances so that smooth outline can be made from a texture mapped description. A SDF might
            be more GPU friendly as the rendering can be done by a shader, it doesn't address the issue of
            changing italic angle - although that might be achieved by angling the quads, but it might
            be able to change weights by adjusting a threshold distance to draw a point at.
            
            I wonder then if an idea might be to rasterize a TTF font in to a SDF rather than directly
            to a regular bitmap/texture?