Embedded padding/margin in fonts

后端 未结 16 965
执念已碎
执念已碎 2021-01-08 00:56

It seems that all fonts have some sort of embedded padding or margin. By setting:

margin: 0px;
padding: 0px;

You never get what you want. D

16条回答
  •  伪装坚强ぢ
    2021-01-08 01:28

    The "padding" at the top and bottom of fonts is essentially reserved space for diacritics (https://en.wikipedia.org/wiki/Diacritic). Some scripts stack multiple diacritics on some letters, including capitals (for example, Vietnamese https://en.wikipedia.org/wiki/Vietnamese_alphabet) so a font designer that forgets to reserve some place for them won't be able to extend his font later. Also, horizontal scripts require some separation (leading) between lines to be readable.

    Only very specific glyphs like box drawing elements extend to the limits of a glyph box http://www.unicode.org/charts/PDF/U2500.pdf That's also why the "padding" is built-in each glyph. If it was an external property it would not be possible to differentiate between glyphs intended to be jointive and glyphs that need some separation (in other words the amount of padding is a glyph property no a whole-font property).

    The following example requires a good font with decent Unicode coverage (http://dejavu-fonts.org/ works)

    Jointive box drawing elements

    ┃ÇŖŞ
    ┃ẤỄǛȰ┃U ← You really need to include the "padding" to align with box drawings
      ↑
     Latin capitals with multiple diacritics (really crowded)

    Lastly fonts stem from very old technology (movable type), and the conventions used to describe them still refer to fifteenth century habits, which makes them quite un-obvious to laymen.

    (See also http://www.webfonts.info/node/330 for info on complications added by computer font formats)

    fonts opentype text-rendering

提交回复
热议问题