4

This is a graph with definition of a few terms for the horizontal glyph metrics for fonts.

Glyph metrics

Let's say I have a sentence,

Foo bar baz.

How do I get the spacing size, in pixels, between the words "Foo" and "bar"? I suppose I sum,

  • The whitespace right-padding in the grapheme for 'o' in "Foo": subtract from the advance the bearingX + width
  • The advance of the space character.
  • The whitespace left-padding of the letter 'b' in "bar": simply bearingX.

Is this correct? What table has the bearingX?

Bob Gilmore
  • 12,608
  • 13
  • 46
  • 53
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468

1 Answers1

4

How do I get the spacing size, in pixels, between the words "Foo" and "bar"?

You need to know the horizontal advance of the space character and kerning between "o" and " ", and between " " and b". I don't think you need bearingX to get the spacing. The result will be in font "units", defined by unitsPerEm of HEAD tag. So convert this result * font size / unitsPerEm, and you will get the spacing in "points". Then you will need to known, how many pixels there are in one point: depends on the application, could be your monitor DPI or Postscript's 72 dpi.

What table has the bearingX?

bearingX is in also in HMTX, under "lsb" (left-side bearing) of longHorMetric (and also leftSideBearing, obviously).

user22698
  • 195
  • 10