3
votes

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?

1
I'm not much sure but we can read the font table using fonttools pypi.python.org/pypi/FontTools. I guess you will get each value of the font attributes in the table. you can calculate it from that table. :)Laxmikant Ratnaparkhi
I'm not averse to that, I'm using perl know. I just don't know what table it is in or what it is called.Evan Carroll
@Even Carroll, Thanks, I haven't used perl. Even though in perl it seems to be there is font utils to read font table. Please see the link. scripts.sil.org/cms/scripts/….Laxmikant Ratnaparkhi
I linked to what I was using.Evan Carroll
@EvenCarroll : Can not help, sorry for misguidance!Laxmikant Ratnaparkhi

1 Answers

2
votes

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).