[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Devel] Most efficient flags to use with FT_Load_Char to get ONLY me
From: |
Vincent Caron |
Subject: |
Re: [Devel] Most efficient flags to use with FT_Load_Char to get ONLY metrics ? |
Date: |
06 Jun 2002 17:00:53 +0200 |
On Thu, 2002-06-06 at 15:35, Rich Stephens wrote:
> If I am going through the characters in a certain charmap and I really only
> want to glean the information in the face->glyph->metrics structure and not
> the
> bitmap or vector image for rendering, could someone recommend the most
> time-efficient
> flags to use with FT_Load_Char? I'd still like the values to be as they would
> when I use FT_LOAD_DEFAULT, but if there's any I can use that might speed up
> the process, I'd like to hear about them.
I just tackled with this matter recently. Please, Freetype gurus correct
me if I'm wrong !
If you use FT_Load_Char with FT_LOAD_DEFAULT, you load the 'native'
glyph description, that is :
- for bitmap fonts, or embedded bitmap glyphs in scalable fonts, your
FT_Glyph will actually be a FT_BitmapGlyph. The bitmap width & height,
top & left (ie. bearing) and advance are already available in the glyph
struct
- for scalable fonts, the native glyph is a FT_OutlineGlyph. You can
easily and efficiently retrieve its control box, which happens to be its
bbox until you do fancy transformations. It is documented with the
FT_Glyph_Get_CBox function.
It turns out that Ft_Glyph_Get_CBox() actually also retrieves the bbox
for bitmap glyphs. This is pretty handy : you can use this method for
any font (bitmap, scalable) to retrieve glyph metrics efficiently.
Now you should also consider using Freetype cache. For at least two
reasons :
- fetching a glyph from a cache is faster than loading it from the face,
even with the cheap FT_LOAD_RENDER mode (could someone confirm ?)
- for scalable fonts, if you cache rendered bitmaps, you'll be able to
support fancy transformations (rotation, shearing, etc) by using the
real bbox instead of the control box