[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freetype-devel
Subject:    [Devel] Bug in ah_hinter_load_glyph
From:       "Maarten Breddels" <dmon () xs4all ! nl>
Date:       2004-03-27 15:04:17
Message-ID: 000901c4140c$c6d6de70$0100a8c0 () ishi
[Download RAW message or body]

Hi, I believe I've found a bug in freetype (in 2.1.7 and current cvs
version).
It happens when loading some characters, with a transform matrix
(1,0,0,-1).
I don't know the exact reason, but it's around line 1813 in ahhint.c, 
	FT_Pos  fitted = FT_PIX_ROUND( scaled );
Sometimes, fitted becomes 0, making y_scale, on line 1820
	y_scale = FT_MulDiv( y_scale, fitted, scaled );
Also 0.
Which means the character metrics, outlines etc are all height 0.
The code below demonstrates the bug. Also, when loading the glyph again,
with another matrix, the bug is still there, I guess it's caused by
caching.


----begin------
#include <ft2build.h>
#include FT_FREETYPE_H

int main()
{
    FT_Library ft_library;
    FT_Face face;
    FT_Matrix mat;

    FT_Init_FreeType (&ft_library);
    FT_New_Face (ft_library, "e:\\windows\\fonts\\arial.ttf", 0, &face);
    if(face == NULL)
    {
        printf("font file not found\n");
    }
    mat.xx = 1<<16;
    mat.xy = 0;
    mat.yx = 0;
    mat.yy = (FT_Fixed)(-1.0 * 65536.0);  
    FT_Set_Char_Size(face, 40<<6, 40<<6, 0, 0);
    FT_Set_Transform(face, &mat, NULL);
    FT_Load_Glyph (face, FT_Get_Char_Index (face, 'C'),
FT_LOAD_DEFAULT);
    printf("height = %i units\n", face->glyph->metrics.height);

    mat.xx = 1<<16;
    mat.xy = 0;
    mat.yx = 0;
    mat.yy = (FT_Fixed)(1.0 * 65536.0);  
    FT_Set_Char_Size(face, 40<<6, 40<<6, 0, 0);
    FT_Set_Transform(face, &mat, NULL);
    FT_Load_Glyph (face, FT_Get_Char_Index (face, 'C'),
FT_LOAD_DEFAULT);
    printf("height = %i units\n", face->glyph->metrics.height);
    return 0;
}
-----end-------
Output:
height = 0 units
height = 0 units


_______________________________________________
Devel mailing list
Devel@freetype.org
http://www.freetype.org/mailman/listinfo/devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic