Hello FreeType Team,
I am Ivailo Stoianov, and I am trying to use The FreeType Library (ver.
2.4.2) to use TrueType fonts.
I have some issues about that, so I would like to ask you for help!
My first question is about glyph size. When I specify exact pixel size
for the glyph, the generated bitmap has smaller dimensions. For example:
if I execute the folowing code (I am using standart Windows Arial font
in all examples):
FT_Library library;
FT_Error result;
FT_Face face;
FT_Matrix matrix;
FT_Vector delta;
result = FT_Init_FreeType(&library);
result = FT_New_Face(library, "arial.ttf", 0, &face);
result = FT_Set_Pixel_Sizes(face, 250, 250);
delta.x = 0 * 64;
delta.y = 0 * 64;
matrix.xx = 0x10000L;
matrix.xy = 0x0000L;
matrix.yx = 0x0000L;
matrix.yy = 0x10000L;
FT_Set_Transform(face, &matrix, &delta);
result = FT_Load_Char(face, 'D' , FT_LOAD_RENDER | FT_LOAD_MONOCHROME);
the 'face' object has the following fields:
FACE:
NUM. FACES(face->num_faces): '1'
FACE INDEX(face->face_index): '0'
FACE FLAGS(face->face_flags): '00000A59'
STYLE FLAGS(face->style_flags): '00000000'
NUM. GLYPHS(face->num_glyphs): '3415'
FAMILY NAME(face->family_name): 'Arial'
STYLE NAME(face->style_name): 'Regular'
NUM. CHARMAPS(face->num_charmaps): '3'
BBOX:
X MIN(face->bbox.xMin): '-1361'
X MAX(face->bbox.xMax): '4096'
Y MIN(face->bbox.yMin): '-665'
Y MAX(face->bbox.yMax): '2060'
UNITS PER EM(face->units_per_EM): '2048'
HEIGHT(face->height): '2355'
MAX ADVANCE WIDTH(face->max_advance_width): '4096'
MAX ADVANCE HEIGHT(face->max_advance_height): '2355'
UNDERLINE POSITION(face->underline_position): '-292'
UNDERLINE THICKNESS(face->underline_thickness): '150'
METRICS:
HEIGHT(face->glyph->metrics.height): '11456'
WIDTH(face->glyph->metrics.width): '9536'
HORIZONTAL ADVANCE(face->glyph->metrics.horiAdvance): '11584'
HORIZONTAL BEARING X(face->glyph->metrics.horiBearingX): '1280'
HORIZONTAL BEARING Y(face->glyph->metrics.horiBearingY): '11456'
LINEAR HORIZONTAL ADVANCE(face->glyph->linearHoriAdvance): '11832000'
LINEAR VERTICAL ADVANCE(face->glyph->linearVertAdvance): '15376000'
ADVANCE X(face->glyph->advance.x): '11584'
ADVANCE Y(face->glyph->advance.y): '0'
FORMAT(face->glyph->format): '62697473'
BITMAP:
ROWS(face->glyph->bitmap.rows): '179'
WIDTH(face->glyph->bitmap.width): '149'
PITCH(face->glyph->bitmap.pitch): '20'
BITMAP LEFT(face->glyph->bitmap_left): '20'
BITMAP TOP(face->glyph->bitmap_top): '179'
The output bitmap has smaller dimensions than these specified in the '
FT_Set_Pixel_Sizes' function. Specified size is 250x250, but the
generated bitmap has this size - 149x179.
Even if I use 'FT_Set_Char_Size' instead of ' FT_Set_Pixel_Sizes' the
output size is not the expected by me. In the code above if I replace
the row "result = FT_Set_Pixel_Sizes(face, 250, 250);" with "result =
FT_Set_Char_Size(face, 50*64, 0, 96, 0);" (96 is the dpi of my monitor),
the 'face' object has the following fields:
FACE:
NUM. FACES(face->num_faces): '1'
FACE INDEX(face->face_index): '0'
FACE FLAGS(face->face_flags): '00000A59'
STYLE FLAGS(face->style_flags): '00000000'
NUM. GLYPHS(face->num_glyphs): '3415'
FAMILY NAME(face->family_name): 'Arial'
STYLE NAME(face->style_name): 'Regular'
NUM. CHARMAPS(face->num_charmaps): '3'
BBOX:
X MIN(face->bbox.xMin): '-1361'
X MAX(face->bbox.xMax): '4096'
Y MIN(face->bbox.yMin): '-665'
Y MAX(face->bbox.yMax): '2060'
UNITS PER EM(face->units_per_EM): '2048'
HEIGHT(face->height): '2355'
MAX ADVANCE WIDTH(face->max_advance_width): '4096'
MAX ADVANCE HEIGHT(face->max_advance_height): '2355'
UNDERLINE POSITION(face->underline_position): '-292'
UNDERLINE THICKNESS(face->underline_thickness): '150'
METRICS:
HEIGHT(face->glyph->metrics.height): '3072'
WIDTH(face->glyph->metrics.width): '2560'
HORIZONTAL ADVANCE(face->glyph->metrics.horiAdvance): '3072'
HORIZONTAL BEARING X(face->glyph->metrics.horiBearingX): '320'
HORIZONTAL BEARING Y(face->glyph->metrics.horiBearingY): '3072'
LINEAR HORIZONTAL ADVANCE(face->glyph->linearHoriAdvance): '3155447'
LINEAR VERTICAL ADVANCE(face->glyph->linearVertAdvance): '4100587'
ADVANCE X(face->glyph->advance.x): '3072'
ADVANCE Y(face->glyph->advance.y): '0'
FORMAT(face->glyph->format): '62697473'
BITMAP:
ROWS(face->glyph->bitmap.rows): '48'
WIDTH(face->glyph->bitmap.width): '40'
PITCH(face->glyph->bitmap.pitch): '6'
BITMAP LEFT(face->glyph->bitmap_left): '5'
BITMAP TOP(face->glyph->bitmap_top): '48'
If I use the formula "pixel_size = point_size * resolution / 72" from
The FreeType Conventions
<http://freetype.sourceforge.net/freetype2/docs/glyphs/glyphs-2.html>
the calculated size is 67 pixels, but the output size of the bitmap is
smaller - 40x48 pixels. When I use 203 dpi in the function above (203 is
the dpi of my target device), the 'face' object has the following fields:
FACE:
NUM. FACES(face->num_faces): '1'
FACE INDEX(face->face_index): '0'
FACE FLAGS(face->face_flags): '00000A59'
STYLE FLAGS(face->style_flags): '00000000'
NUM. GLYPHS(face->num_glyphs): '3415'
FAMILY NAME(face->family_name): 'Arial'
STYLE NAME(face->style_name): 'Regular'
NUM. CHARMAPS(face->num_charmaps): '3'
BBOX:
X MIN(face->bbox.xMin): '-1361'
X MAX(face->bbox.xMax): '4096'
Y MIN(face->bbox.yMin): '-665'
Y MAX(face->bbox.yMax): '2060'
UNITS PER EM(face->units_per_EM): '2048'
HEIGHT(face->height): '2355'
MAX ADVANCE WIDTH(face->max_advance_width): '4096'
MAX ADVANCE HEIGHT(face->max_advance_height): '2355'
UNDERLINE POSITION(face->underline_position): '-292'
UNDERLINE THICKNESS(face->underline_thickness): '150'
METRICS:
HEIGHT(face->glyph->metrics.height): '6464'
WIDTH(face->glyph->metrics.width): '5376'
HORIZONTAL ADVANCE(face->glyph->metrics.horiAdvance): '6528'
HORIZONTAL BEARING X(face->glyph->metrics.horiBearingX): '704'
HORIZONTAL BEARING Y(face->glyph->metrics.horiBearingY): '6464'
LINEAR HORIZONTAL ADVANCE(face->glyph->linearHoriAdvance): '6671769'
LINEAR VERTICAL ADVANCE(face->glyph->linearVertAdvance): '8670142'
ADVANCE X(face->glyph->advance.x): '6528'
ADVANCE Y(face->glyph->advance.y): '0'
FORMAT(face->glyph->format): '62697473'
BITMAP:
ROWS(face->glyph->bitmap.rows): '101'
WIDTH(face->glyph->bitmap.width): '84'
PITCH(face->glyph->bitmap.pitch): '12'
BITMAP LEFT(face->glyph->bitmap_left): '11'
BITMAP TOP(face->glyph->bitmap_top): '101'
When I make the calculations again - the size expected by me is 141
pixels, but the generated image is smaller - 84x101 pixels.
So, as a conclusion, my question is - Is it possible to generate birmap
image with the size, desired by me? - for example if I want letter with
size 200x200 pixels, the output bitmap image to be with this size or
with size near to the desired one.
My second qustion is - Is it possible to generate "outline letters" -
letter only with outlines, without fill? - like this one Outline letter
<http://www.surfnetkids.com/images//tn-big-outline-letter-a.gif>.
If you need any additional information about my code(field data of other
objects, return values of functions or something else), please, send me
an e-mail and I will answer it as soon as possible.
Thank you for the time spent on reading my mail! I look forward to your
reply. Thanks in advance!
Best regards!
--
Ivailo Stoianov - Firmware Engineer, DATECS LTD. Firmware Deparment
_______________________________________________
Freetype mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/freetype