freetype
[Top][All Lists]
Advanced

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

[Freetype] Font bounding box?


From: Marcelo E. Magallon
Subject: [Freetype] Font bounding box?
Date: Wed, 24 Oct 2001 14:33:21 +0200
User-agent: Mutt/1.3.23i

Hi,

 I'm implementing a text rasterizer on top of OpenGL and I want to use
 FreeType in order to load fonts (yes, I know about gltt, *that's* why
 I'm doing this).  At the momemt I'm just learning about FreeType and
 trying to figure out an efficient way of supporting what I'd like to
 do.

 Basically my problem now is that I have to render the face to a texture
 which I'll later apply to quads in order to produce the text.  Textures
 have to have a size of the form 2**m x 2**n.  As my first pass, I'm
 playing with monospaced fonts.  I thought I could just use the "face
 bounding box" (FT_Face->bbox) and the number of glyphs in order to
 compute the dimensions of the texture.  According to the docs:

 bbox       The font bounding box. Coordinates are expressed in font
            units (see units_per_EM). The box is large enough to contain
            any glyph from the font. Thus, bbox.yMax can be seen as the
            `maximal ascender', bbox.yMin as the `minimal descender',
            and the maximal glyph width is given by
            `bbox.xMax-bbox.xMin' (not to be confused with the maximal
            _advance_width_). Only relevant for scalable formats.

 Now I need to convert this to pixels.  FT_Face has a size member, and
 from the metrics thereof I get:

    FT_Fixed   x_scale;     /* two scales used to convert font units  */
    FT_Fixed   y_scale;     /* to 26.6 frac. pixel coordinates..      */

 x_scale    A simple 16.16 fixed point format coefficient used to scale
            horizontal distances expressed in font units to fractional
            (26.6) pixel coordinates.

 So, if I'm reading this right, I can do something like:

    FT_MulFix(face->bbox.xMax, face->size->metrics.x_scale) >> 6

 and the result should be pixels, is that right?  (My guess is not,
 because it's not working as I expect).

 The other thing I noticed is that the advance is not constant, which I
 kinda expected for monospaced fonts...  what did I miss?

 TIA,


 Marcelo



reply via email to

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