Search code examples
windowsfontsogrefreetypebaseline

how to compute vertical line shift for font drawing?


Do you know how to compute the vertical shift for font drawing ?

Explaination: I am drawing 2D letters in a 3D world and I would like to return to a newline. So I need to compute the vector between the origin point of the 1rst baseline and the new origin point of the 2nd newline.

I think this operation should keep in mind the YBearing, the height of the letter and real size of the plan which will draw the font texture.


Solution

  • It appears it would be computed as :

    baseline-to-baseline-shift = ascent - descent + linegap (descent is a negative value)

    These parameters should be globals, so now the problem is just to find accessor to it.