freetype-devel
[Top][All Lists]
Advanced

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

Re: Calculating the maximum size of a rendered bitmap


From: Sven Neumann
Subject: Re: Calculating the maximum size of a rendered bitmap
Date: Sun, 20 Aug 2000 18:18:36 +0200

Hi,

Kevin Dance wrote some days ago:

> I am using the function calls
> "FT_Load_Glyph(Face,Index,FT_LOAD_DEFAULT)" and
> "FT_Render_Glyph(Face->glyph, ft_render_mode_normal)" to render a given
> glyph into a bitmap of type "FT_Bitmap". However, what I need to do is
> to know the maximum possible size that the bitmap can be before hand.
> Can this be achieved without simply looping throught all of the glyphs
> and rendering them during the initialisation phase of my program, since
> this will obviously take time. Is there a quick was to do this
> calculation?
> 
> Alternatively, if I have to loop through all of the glyphs then I can
> determine the total number of glyphs by using "Face->num_glyphs". 
> However, I have tried to render all glyphs from 0 to "Face->num_glyphs -
> 1" but my program crashes. How can I tell whether I can render a given
> glyph index and has anyone got any code to do this calculation
> successfully?

I have to second that question. I'm in the progress of porting the Gimp
FreeType plug-in to freetype2-beta8 and tried to follow the updated 
tutorials. I really like the idea to only load the glyphs while calculating
the layout, then convert them into a bitmap when rendering. The problem is
that FT_Glyph_Get_CBox (glyph->image, ft_glyph_bbox_pixels, &glyph_bbox)
returns a wrong bounding box since converting to bitmap using 
FT_Glyph_To_Bitmap () introduces slight offsets (bitmap->top and 
bitmap->left) which often cause the rendered string to be drawn beyond
the precalculated bounding box. The code examples from the tutorials might
be accurate enough to render a centered string, but to allocate the 
correctly sized drawable I need the result to always fit into my bounding 
box. The code we use right now is pretty ugly and I'd like to know if 
there's a more elegant way to do it. 


Salut, Sven





reply via email to

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