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);
On Thu, Jun 19, 2014 at 7:55 AM, Werner LEMBERG <[email protected]> wrote:
>
> > Yeah!I finally figured it out. shift and delta were not set. But now
> > I don't understand why in the examples number 64 is used to
> > downscale the coordinates?
>
> FreeType normally returns coordinates to be multiples if 1/64th
> pixels, called `26.6 fractional points'.
>
> > I mean how do I set my text to be of size 20px when using the
> > outlines? Given that the resolution is 72 dpi. Should I divide 72
> > by 2048 and use that product to scale down the path points?
>
> For `FT_Set_Char_Size', the horizontal and vertical resolution
> parameters are integers (72 for your example), and the width and
> height parameters must be given in 1/64th pixels (20*64).
>
> If you really need integer coordinates, you have to divide all
> coordinate values by 64 in the returned `FT_Outline' structure.
>
> Maybe you can point out where the documentation fails to explain
> this...
>
>
> Werner
>
--
Michael Ivanov
Graphics Software
onlygraphix.com
Tel:+972 54 4962254
_______________________________________________
Freetype mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/freetype