41

I am wondering, that each char in Unicode has a code point; what's the analogous term for a character in a font?

I never understood the part of the process when a decoded file needs to be mapped to font (or fonts, by some modern font substitution technology).

For example, when a text editor has decoded a file from its character encoding, and suppose there's Greek alpha α (U+03B1). What's the exact process this app chooses a particular glyph in a font? Most app has a preferred font. Let's say it's Courier. (And what happens in the case of a rare Unicode char likethe heart ♥ (U+2665), that's not in the default font? How does the app know the font doesn't contain that char?)

Does a font contain meta info about what symbols it has?

If 2 fonts both have the symbol alpha, do they necessarily share the same “code point”? Or is it dependent on the type of font such as Type1, Type3, TrueType, OpenType? ...

Thanks for any pointers or references.

Andreas Rejbrand
  • 105,602
  • 8
  • 282
  • 384
Xah Lee
  • 16,755
  • 9
  • 37
  • 43

1 Answers1

36

TrueType fonts consist of a number of sections, most importantly for this question a table of "glyphs" and a table ("cmap") for mapping characters to those glyphs.

Long story short, the operating system uses the "cmap" table to convert characters into glyph indexes, substituting a default glyph for any which have no matching entry. Unfortunately there are multiple versions of the font file specification (not to mention different types of fonts) and different character encodings of the same mappings in those tables, so the actual process of doing the mapping, and doing it efficiently so that text drawing is fast, ends up being extremely complex.

A "Code Point" is completely independent of characters, encodings and fonts. A particular code point is universal, but there are many encodings for it (UTF-8, UTF-16, etc.) and it will map to different glyph indexes in different fonts.

Apple's developer documentation has a pretty good section on the details of TrueType fonts:

http://developer.apple.com/fonts/ttrefman/

Specifically:

Glyph table: https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html

Character map: https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6cmap.html

I also recommend an application called BabelMap, which gives you a lot of interesting information about fonts. Specifically look at Tools/Unicode Summary, Fonts/Font Analysis Utility, and Fonts/Font Information, where you can extract the entire glyph mapping table to the clipboard.

Tim Sylvester
  • 22,897
  • 2
  • 80
  • 94
  • are code points standardized for characters in given languages ? like do some committee meetup some day in country X and decide, let's use code point a, b, c, d... for our characters stuff stuff stuff... ? and then its submitted to some ISO ? – v.oddou Apr 27 '16 at 10:14
  • @v.oddou Yes, exactly, http://unicode.org is the committee, and you can see the way the various character sets for different languages are laid out here: https://en.wikipedia.org/wiki/Plane_%28Unicode%29 and the ISO relationship here: https://en.wikipedia.org/wiki/Universal_Coded_Character_Set – Tim Sylvester Apr 30 '16 at 00:45