freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft] Vert advance on line break


From: Mickey Gabel
Subject: Re: [ft] Vert advance on line break
Date: Tue, 27 Jan 2009 15:23:21 +0200
User-agent: Thunderbird 2.0.0.19 (Windows/20081209)

Putting it all together (and looking at ftdiff):

* Distance (scaled distance) between two successive baselines should be face->size->metrics->height. This is the nominal height of the line, in 26.6 format, and _is scaled_ to the current size of the face.
The unscaled (font units) value is in face->size->height.

* line gap = height - (ascender - descender)

* The line gap is the space between the lines, where "nothing" is written (except with strange fonts, etc).

* The "physical" height of the line (the area where most letters would be expected) is (ascent - descent).

Conclusion:
If I want an "exact" space of, say, 1.5 lines between each two lines (no matter what the font design says) then I should ignore the FT2 height and use the following:

  my line gap               = (ascender - descender) * 1.5
  my height (baseline diff) = (ascender - descender) + my line gap

Mickey


Werner LEMBERG wrote:
  height        
    The height is the vertical distance between two consecutive
    baselines, expressed in font units.  It is always positive.
    Only relevant for scalable formats.

This is the unscaled value, of course.  BTW, I've just fixed a few
typos in the tutorial's step2.html file; some of the FT_FaceRec
members were incorrectly named.

I tried using [i]face->size->metrics.height[/i], but this seemed
far too steep for some fonts (almost like the font was
double-spaced), and simply doesn't exist at all (is zero) for
many, many fonts such as Courier, which makes it completely
useless for me.

This is not correct.  If you try the ftdiff demo program you can see
that you get good vertical distances using `metrics.height' for both
the TTF and PFB variants of Courier.  It works for bitmap fonts also
(however, ftdiff is slightly buggy since it shows incorrect results if
you don't select the right ppem value).

Yeah, it notices the height of glyph, not the space between the
lines.  Usually, the calculation of the space between the lines is
not recognized as the role of the fonts.

In principle, this is correct.  TeX, for example, doesn't use a
font-based `linegap' or `text height' value at all; instead, the
standard LaTeX document classes use a factor 1.2 to scale from the
font's designsize to the baseline-to-baseline distance.

This is a seemingly simple question, yet the tutorials fail to
mention anything about it,

Do they?  The `height' member is described in section 3b of the
tutorial as `the vertical distance from one baseline to the next'.  A
similar definition is given in the `FreeType Glyph Conventions'.  What
are you missing?

Maybe you want to pass "single space" or "double space" to some FT2
API and receive the appropriate shift from the previous line to
current line, but such 2D layout work is for more intelligent
layout systems.

Yep.

In fact, the LineGaps in hhea & OS/2 are no more than the minimum
space.

Well, rather a kind of default value.

Some font file formats does not provide such informations at all.
It would be the reason why FT2 tutorials don't describe
line-to-line process.

As mentioned above, the `height' value is questionable for real
typographic purposes.

1) What about "line gap" (aka "external leading") mentioned in
docs/glyphs/glyphs-3.html (Glyph Convension)? How does FT2 get this
line gap if it's not specified in the font?

It is algorithmically computed to a (hopefully) meaningful value.

2) If FT2 does get it, how do I get this line gap / external leading
from FT2?  I thought face->size->metrics.height IS the way to get
it!

Be careful: `linegap' is not the same as `baseline-to-baseline
distance', a.k.a. (text) `height'.  In most cases you are not
interested in the linegap value.  If you really need it, you can
compute it with

  linegap = height - (ascender - descender)

as documented in section III.2 of the `FreeType Glyph Conventions'.

3) It seems mpsuzuki and Werner have two contradicting answers :(

No, we haven't.  I hope that the above clarifications help.

4) Does FT2 use the hhea table in anyway by itself? (for example to
initialize the FaceRec "height" member?

Yes.

5) We sometimes use (2 + ascender - descender) as a the line
height. This seems to work, and may be useful workaround so I
mentioned it here.

Then you use a fixed line gap value of `2'.  If the font has correct
ascender and descender values, this will never fail.  However, the
font designer might have other values in mind: For example, the
`Zapfino' font should be set vertically tighter IMHO since it doesn't
matter if the ascenders and descenders of the glyphs (slightly)
overlap.


    Werner






reply via email to

[Prev in Thread] Current Thread [Next in Thread]