david
david

Reputation: 321

how to calculate baseline for freetype font in cairo?

Cairo font extents structure has following information

ascent
descent
height
max_x_advance
max_y_advance

How do i calculate baseline from these metrices?

Upvotes: 1

Views: 415

Answers (1)

Uli Schlachter
Uli Schlachter

Reputation: 9877

See https://www.cairographics.org/tutorial/#L1understandingtext

The reference point is always on the baseline. The descent line is below that, and reflects a rough bounding box for all characters in the font. However it is an artistic choice intended to indicate alignment rather than a true bounding box. The same is true for the ascent line above. Next above that is the height line, the artist-recommended spacing between subsequent baselines. All three of these are reported as distances from the baseline, and expected to be positive despite their differing directions.

What exactly do you mean with "calculate the baseline"? You give cairo a point on the baseline and the ascent and descent are relative to that point.

Upvotes: 1

Related Questions