--- /media/sda/sssa/redhat/BUILD/freetype2-current/acid-main.cpp 2010-12-05 03:20:30.748926821 +0900 +++ acid-main.cpp 2010-12-09 17:21:41.077465614 +0900 @@ -5,6 +5,12 @@ #include FT_SIZES_H #include FT_GLYPH_H + +#define FT_PIX_FLOOR( x ) ( (x) & ~63 ) +#define FT_PIX_ROUND( x ) FT_PIX_FLOOR( (x) + 32 ) +#define FT_PIX_CEIL( x ) FT_PIX_FLOOR( (x) + 63 ) + + static void eerror(const char *msg, FT_Error e) { printf("%s 0x%0x\n", msg, e); @@ -54,6 +59,32 @@ int w = glyphMetrics->width / 64.0; int h = glyphMetrics->height / 64.0; + int x3, y3, w3, h3; + { + FT_BBox cbox; + FT_Outline_Get_CBox(&face->glyph->outline, &cbox); + cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); + cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); + cbox.xMax = FT_PIX_CEIL( cbox.xMax ); + cbox.yMax = FT_PIX_CEIL( cbox.yMax ); + + FT_UInt width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 ); + FT_UInt height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 ); + /* XXX: subpixel rendering requires additional works for width/height */ + + FT_Int x_shift = (FT_Int) cbox.xMin; + FT_Int y_shift = (FT_Int) cbox.yMin; + FT_Int x_left = (FT_Int)( cbox.xMin >> 6 ); + FT_Int y_top = (FT_Int)( cbox.yMax >> 6 ); + + FT_Int bitmap_left = (FT_Int)x_left; + FT_Int bitmap_top = (FT_Int)y_top; + x3 = -bitmap_left; + y3 = bitmap_top; + w3 = width; + h3 = height; + } + if (e = FT_Render_Glyph(slot, ft_render_mode_normal)) eerror("5", e); @@ -62,8 +93,8 @@ int w2 = slot->bitmap.width; int h2 = slot->bitmap.rows; - printf("%d %d\n", x, x2); - printf("%d %d\n", y, y2); - printf("%d %d\n", w, w2); - printf("%d %d\n", h, h2); + printf("%d %d %d\n", x, x2, x3); + printf("%d %d %d\n", y, y2, y3); + printf("%d %d %d\n", w, w2, w3); + printf("%d %d %d\n", h, h2, h3); }