c++ - FreeType2 FT_Outline_Decompose returns huge numbers -
i trying read glyph outline character using freetype lib.i load font standard .ttf file.till using outline tags convert outline path elements segments , bezier curves.then found ft_outline_decompose part of lib.but when using it,the decomposed info values huge.every point on path value of ~ 859722xxx .so down-scaling factor of 64 it's suggested examples doesn't help pixel size values.
my code goes this:
const char* fontfile ="fonts/verdana.ttf"; std::string chars("uta \n"); char charcode = chars[0]; 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; } ft_glyph glyph; // load glyph err = ft_load_char(facehandle, charcode, 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 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; // trace outline of glyph err = ft_outline_decompose(&outline, &funcs, nullptr); if (err) { std::cout <<ft_errors[err].err_msg ; } now, in callbacks moveto() effort resize:
int moveto(ft_vector* to, void* fp) { pathref->moveto(ftvectofloat(to)); /// // ftvectofloat "float(f) / 64.0f" /// homecoming 0; } but initial ft_vector value huge partition 64.0 still doesn't matters.
set funcs.shift = 0; funcs.delta = 0; work
c++ freetype freetype2
No comments:
Post a Comment