freetype
[Top][All Lists]
Advanced

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

Re: [ft] BBox question


From: Michele Petrazzo
Subject: Re: [ft] BBox question
Date: Fri, 12 Aug 2005 11:28:42 +0200
User-agent: Mozilla Thunderbird 1.0 (X11/20041206)

Chia I Wu wrote:
On Thu, Aug 11, 2005 at 06:07:37PM +0200, Michele Petrazzo wrote:

Another simple question (but I'm crazing... :) )
I load truetype font, a face, and a character. Set size. I want to know
its Bbox, so the width and height in pixel size.
(with another tool I see that Arial font with 50 dimension and 96
resolution, the size is 19 x 75)

For width, is simple: face->glyph->advanced.x / 64  = 19 (right)
And for height? I try to translate to pixel size all the face/glyph
dimension,( face->bbox, face->size->matrix, etc..) but I cannot find the
"75" value.
Can someone point me to the right direction?

After loading the glyph, use
FT_Outline_Get_CBox( &face->glyph->outline, &cbox ) to get the bounding
box of the glyph.

Ok, but in my case ("I" char), I see that glyph's Cbox ( = BBox ) are
not the right value that I'm trying to find, because I'm search the "75"
value, but I found ~100:

FT_MulFix( ( yMax - yMin),  face->size-metric.y_scale ) /64 -> ~100

that is bigger then my value (I don't know why)


face->bbox is a bounding box of all glyphs of a face.

Ok, but if I see this value, I see that it's lesser than that into
glyph! (I think that it's not possible, is it true?)

Is there a possible to know the right value of my "I" character (19x75)
with freetype?

Thanks,
Michele



My code:

error = FT_Set_Char_Size( face, 50 * 64, 0, 96, 96 );
slot = face->glyph;
FT_BBox  acbox;

error = FT_Load_Char( face, "I", FT_LOAD_DEFAULT);

metric_f = face->size->metrics;
metric_g = face->glyph->metrics;

bbox = face->bbox;
printf("W: %d \n", slot->advance.x /64 ); // this is the right 19

FT_Outline_Get_CBox( &face->glyph->outline, &acbox );
printf("Glyph Y: %d, X: %d% \n", FT_MulFix( (acbox.yMax - acbox.yMin), metric_f.y_scale) ,
        FT_MulFix( (acbox.xMax - acbox.xMin), metric_f.x_scale ));

printf("Glyph Metric W: %d -> %d\n", metric_g.width, FT_MulFix( metric_g.width, metric_f.x_scale ) ); printf("Glyph Metric H: %d -> %d\n", metric_g.height, FT_MulFix( metric_g.height, metric_f.y_scale ) );

printf("Face Y: %d, X: %d% \n", FT_MulFix( (bbox.yMax - bbox.yMin), metric_f.y_scale) ,
        FT_MulFix( (bbox.xMax - bbox.xMin), metric_f.x_scale ));
printf("BBox xMi %d,xMa %d,yMi %d,yMa %d, \n", bbox.xMin, bbox.xMax, bbox.yMin, bbox.yMax );





reply via email to

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