MicroTeX
MicroTeX copied to clipboard
Obtaining baseline
If the library is used to render a single line, say \text{Let } f(x) = \int_0^x g(t) dt
, is there a convenient way to pull out the baseline position of that line, i.e. the vertical position just below the L
?
I thought it might be TeXRender::getBaseline()
, but I find it hard to read what this function actually returns. The code is
((_box->_height * _textSize + 0.99f + _insets.top) /
((_box->_height + _box->_depth) * _textSize + 0.99f + _insets.top + _insets.bottom));
The denominator here is almost the value of getHeight(), except that getHeight() has another + 0.99f
. Does the numerator somehow give the actual baseline?
Or is there some other way to retrieve the baseline?
First I'm sorry to respond to you so late, I'm very busy these days 😅 .
Yes, I got your point. Do you mean to retrieve the ascent
? The getHeight()
and getBaseline()
is confusing 😅 , the getBaseline()
actually is the ratio of the ascent
and the height
, and the 0.99
is almost 1 pixel (for round purpose), this should be removed.
The most convenient way to get the ascent
should be:
const int height = render.getHeight(); // total height of the box = ascent + descent
const int depth = render.getDepth(); // depth = descent
const int ascent = height - depth;
I'm going to remove the round factor 0.99
and make the getBaseline()
deprecated.
No worries about the delay - I always appreciate your comments! What I'm after is the actual baseline on which the glyphs are drawn:
I think this probably works out the same as
height - depth
from what you say.
The baselines were slightly off when calculated by this method; I just discovered that it was because of the rounding (int)
in getHeight()
etc!