Evan Carroll
Evan Carroll

Reputation: 1

How do I calculate the space in between two glyphs in a TTF font?

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,

Is this correct? What table has the bearingX?

Upvotes: 4

Views: 2931

Answers (1)

user22698
user22698

Reputation: 195

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

Upvotes: 4

Related Questions