freetype
[Top][All Lists]
Advanced

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

Re: [ft] putting text in a box


From: dave
Subject: Re: [ft] putting text in a box
Date: Thu, 21 Jan 2010 00:22:57 -0000 (GMT)
User-agent: SquirrelMail/1.4.13

>> I guess this is what's confusing me.  I looked at the tutorial code
>> for getting the cbox, for example, and the result of the call is
>> just that, a box.  So that would be a box which completely enclosed
>> the glyph right?
>
> Yes.

>> How does that yield the information I need, namely the distance
>> below the baseline which the glyph extends?
>
> As I told you earlier: A negative bbox value descends below the
> baseline (which has y=0).

How could a bounding box represent both the overall size of the glyph and
the descent at the same time?  For example, consider a lower case "y".  A
single value wouldn't be able to communicate both the overall height of
that glyph and the descent distance below the baseline would it?  In that
case let's say its height overall is 10 pixels (which completely encloses
top-to-bottom the glyph) and the decent is 3 pixels.  How can both pieces
of information be communicated through a box height?

> I have no idea what's going on with GL.
> There might be even a bug in FreeType, thus my request to test it with
> native FreeType API calls.
>
> A possible reason for GL to disallow negative bbox values is the
> PostScript rendering model which by default cuts off all coordinates
> with non-positive values (since they are drawn outside of the `drawing
> paper' with its physical origin (0,0) at the lower left corner).
>

Even ignoring the rendering piece of it for now, I'm just confused with
the metrics I guess.  If I have a glyph, lowercase "y" for example which
descends below the baseline, I know I can determine the bounding box for
it, but I also need another piece of information.  I need the distance
from the baseline to the bottom of the glyph, which I think will be less
than the bounding box size.

As far as GL, when you render it with GL at a given X,Y coordinate, for
example, the baseline of the text goes at that X,Y coordinate.  So if you
want the text string to be flush with a horizontal line, you have to know
how far each glyph in the string goes below the baseline so you can shift
it up by that amount.  Shifting it up by the largest descent in the string
would then have the string just touching the horizontal line.

I've been able to reliably (so far) get the bounding box, which tells me
the overall size of the text, but I can't seem to figure out how to get
those descent values for individual glyphs.  They would be smaller than
the heights of the bounding boxes so I'm thinking there must be another
value somewhere.





reply via email to

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