freetype
[Top][All Lists]
Advanced

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

[ft] How to generate a glyph bitmap of a specific pixel size using FT_Se


From: Z C
Subject: [ft] How to generate a glyph bitmap of a specific pixel size using FT_Set_Pixel_Sizes
Date: Mon, 9 Jun 2014 12:37:14 +0800

I called FT_Set_Pixel_Sizes(face, 40, 20); hoping to get a glyph of 20x40 dimension in pixels, but when I used face->glyph->bitmap to access the bitmap, its dimension is 26*14

Below is my code:

FT_Library library;
if (FT_Init_FreeType(&library) != FT_Err_Ok) throw runtime_error("Failed to load freetype library");
FT_Face face;
if (FT_New_Memory_Face(library, fontData, fontDataSize, faceIndex, &face) != FT_Err_Ok) throw runtime_error("Failed to load face from font file");
FT_Set_Pixel_Sizes(face, 40, 20);
int glyphIndex = FT_Get_Char_Index(face, 65); // 65 is 'A'
if (glyphIndex == 0) throw runtime_error("Character doesn't exist in font");
FT_Load_Glyph(face, glyphIndex, FT_LOAD_DEFAULT);
if (face->glyph->format != FT_GLYPH_FORMAT_BITMAP)
FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL);
FT_Bitmap bitmap = face->glyph->bitmap;
cout<<bitmap.rows<<' '<<bitmap.width<<endl;

reply via email to

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