Skip to content

Instantly share code, notes, and snippets.

@jtanx
Created November 30, 2013 05:55
Show Gist options
  • Save jtanx/7715851 to your computer and use it in GitHub Desktop.
Save jtanx/7715851 to your computer and use it in GitHub Desktop.
Calculating xAvgCharWidth for the OS/2 font table.

For OS/2 table versions >= 3, take the sum of the advancement widths (from the hmtx table) of each glyph, iff the advancement width is greater than zero. Do integer division of this sum by the number of glyphs that had an advancement width > 0.

For versions < 3, follow a similar procedure, but weight according to: http://www.microsoft.com/typography/otspec/os2ver2.htm#acw, and only consider lowercase latin characters for the average.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment