分类目录归档:computer

计算机,网络,以及编程。

TrueType Font Tables

https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6.html

Table 1 : The ‘sfnt’ data types

Data type Description
shortFrac 16-bit signed fraction
Fixed 16.16-bit signed fixed-point number
FWord 16-bit signed integer that describes a quantity in FUnits, the smallest measurable distance in em space.
uFWord 16-bit unsigned integer that describes a quantity in FUnits, the smallest measurable distance in em space.
F2Dot14 16-bit signed fixed number with the low 14 bits representing fraction.
longDateTime The long internal format of a date in seconds since 12:00 midnight, January 1, 1904.
It is represented as a signed 64-bit integer.

NOTE:A shortFrac is an int16_t with a bias of 14.
This means it can represent numbers between 1.999 (0x7fff) and -2.0 (0x8000).
1.0 is stored as 16384 (0x4000) and -1.0 is stored as -16384 (0xc000).

Table 2: The required tables

Tag Table
‘cmap’ character to glyph mapping
‘glyf’ glyph data
‘head’ font header
‘hhea’ horizontal header
‘hmtx’ horizontal metrics
‘loca’ index to location
‘maxp’ maximum profile
‘name’ naming
‘post’ PostScript

Table 3: The optional tables

Tag Table
‘cvt ‘ control value
‘fpgm’ font program
‘hdmx’ horizontal device metrics
‘kern’ kerning
‘OS/2’ OS/2
‘prep’ control value program

Table 4 : The offset subtable

Type Name Description
uint32 scaler type A tag to indicate the OFA scaler to be used to rasterize this font;
see the note on the scaler type below for more information.
uint16 numTables number of tables
uint16 searchRange (maximum power of 2 <= numTables)*16
uint16 entrySelector log2(maximum power of 2 <= numTables)
uint16 rangeShift numTables*16-searchRange

Table 5: The table directory

Type Name Description
uint32 tag 4-byte identifier
uint32 checkSum checksum for this table
uint32 offset offset from beginning of sfnt
uint32 length length of this table in byte (actual length not padded length)

The following C function can be used to determine the checksum of a given table: