freetype
[Top][All Lists]
Advanced

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

Re: [ft] FT_Glyph_Get_CBox inaccuracy


From: Michiel Kamermans
Subject: Re: [ft] FT_Glyph_Get_CBox inaccuracy
Date: Fri, 26 Feb 2010 11:17:41 -0800
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0

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
nihongoresources.com

reply via email to

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