I do completely understand what you are saying but it just doesn't work.
So you say to get an outline by font size of 20px for DPI = 72 I have to do this:
err = FT_Set_Char_Size( faceHandle,64 * 20, 64 * 20, 72, 72 );
But it changes nothing.The text remains the same size no matter what I put for width/height.
The only way I found to resize the outline points to real-world font size is to calc scale factor by this formula : pixelFontSize = fontSize / EMunit and then multiply the outline points with it.
Here is my full code :
const char* fontFile ="fonts/Verdana.ttf";
std::string chars("& \n");
char charcode = chars[0];
//ParseGlyphsToPath(testPath , fontFile ,chars);
FT_Library defLibHandle;
FT_Error err = FT_Init_FreeType(&defLibHandle);
if(err){
printf(ft_errors[err].err_msg);
throw;
}
FT_Face faceHandle;
err = FT_New_Face(defLibHandle,fontFile,0,&faceHandle);
if(err){
printf(ft_errors[err].err_msg);
throw;
}
float fontSize = 10.0f;
FT_F26Dot6 sz = ftFloatTo266( fontSize );
// FT_Set_Pixel_Sizes(faceHandle, 0, 16);
err = FT_Set_Char_Size( faceHandle,64 * 100, 64 * 100, 72, 72 );
FT_Glyph glyph;
// load glyph
FT_UInt glyphIndex = FT_Get_Char_Index(faceHandle, (FT_ULong)charcode);
err = FT_Load_Glyph(faceHandle,
glyphIndex,
FT_LOAD_NO_BITMAP | FT_LOAD_NO_SCALE);
if (err) {
std::cout << "FT_Load_Glyph: error\n";
}
//FT_Get_Glyph(faceHandle->glyph, &glyph);
FT_Outline outline = faceHandle->glyph->outline;
if (faceHandle->glyph->format != ft_glyph_format_outline) {
std::cout << "not an outline font\n";
}
FT_Outline_Funcs funcs;
funcs.move_to = (FT_Outline_MoveTo_Func)&moveTo;
funcs.line_to = (FT_Outline_LineTo_Func)&lineTo;
funcs.conic_to = (FT_Outline_ConicTo_Func)&conicTo;
funcs.cubic_to = (FT_Outline_CubicTo_Func)&cubicTo;
funcs.shift = 0;
funcs.delta = 0;
// trace outline of the glyph
err = FT_Outline_Decompose(&outline,
&funcs, nullptr);