[Top][All Lists]

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

Re: [ft] FT_Glyph_Get_CBox inaccuracy

From: Róbert Márki
Subject: Re: [ft] FT_Glyph_Get_CBox inaccuracy
Date: Fri, 26 Feb 2010 20:28:17 +0100


I totally agree with you, it should. But FT does already something similar to what you have mentioned. In the background FT probably calls FT_Outline_Get_BBox which expands the outer Bézier arcs in the outline. The difference is only a few pixel from what I get when I render the glyph, and I think some fix can be implemented for this. But I didn't want to reply yet because I'm trying to free up some tome to explore the code of FT more deeply, so I can suggest some fix to Werner.

On Fri, Feb 26, 2010 at 8:17 PM, Michiel Kamermans <address@hidden> wrote:
Apparently I only sent this to Werner, rather than the list. So for his reply to make sense, here's the preceding message:


Hi Werner,

if it's not please give me some advice how can I get accurate
bounding boxes without actually rendering the glyphs.
This is not possible.

But perhaps it should be, since there is nothing preventing FreeType from accurately reporting on the "real" bounding box for a character shape. You don't have to actually render a glyph (in the sense that it is rasterised to a pixel map) to analyse the vector coordinates.

Just run through the 'glyf' table at the correct index, and resolve the coordinate list. For consideration, something like a new function FT_GET_GLYPH_COORDINATES returning a compound struct such as

typedef struct FT_Glyph_Shape {
  FT_Vector* coordinates;
  FT_Vector* controlpoints;
} FT_Glyph_Shape;

could be used to finding the vector coordinates and bezier control points. Determining the bounds could then be done in FT_Get_Glyph_CBox by walking the (compound) glyph's bezier curve(s) and tracking the min/max x/y coordinates as the curve is travelled (without remembering the curve itself).

- Mike "Pomax" Kamermans

Freetype mailing list

reply via email to

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