freetype
[Top][All Lists]
Advanced

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

[ft] How to compute the baseline for for a font face?


From: R0b0t1
Subject: [ft] How to compute the baseline for for a font face?
Date: Tue, 18 Apr 2017 17:22:19 -0500

Despite being able to properly lay out a font given an x, y to draw it
from (i.e. letters will hang below the base line as they should) I am
unable to figure out how to compute the lowest possible position so
that I can offset the font from its bounding box. In other words I
need to find out where the origin point is within the bounding box for
at least one letter.

I am aware of face->bbox and face->height but can't figure out the
computation to figure out how far I should raise all characters so
that the bottom of the lowest character (maybe a "g") will be just
above the horizontal axis.

```C
float x = 0.0f + 1.0f / window_width * (current.bearing_x), // bearing x.
          y = 0.0f - 1.0f / window_height * (current.height -
current.bearing_y); // height - bearing y.
    float w = 1.0f / window_width * (a.advance_x / 64), // this seems
to be too far.
          h = 1.0f / window_height * (a.advance_y / 64);
```

The above will draw everything assuming the vertical origin is zero,
and some letters will end up below it.

Cheers,
   R0b0t1



reply via email to

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