X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fmodules%2Flyr_freetype%2Flyr_freetype.cpp;h=2ef7eae19c2d3cc40772c738c52a9511454a4203;hb=05325009d7c144099bb06a0bff8e2af04c51690c;hp=4e36591f6baf5281afb0d702d09c753f6c12c642;hpb=37600b4b217caa5e316984ec0b035c5e8f9698af;p=synfig.git diff --git a/synfig-core/trunk/src/modules/lyr_freetype/lyr_freetype.cpp b/synfig-core/trunk/src/modules/lyr_freetype/lyr_freetype.cpp index 4e36591..2ef7eae 100644 --- a/synfig-core/trunk/src/modules/lyr_freetype/lyr_freetype.cpp +++ b/synfig-core/trunk/src/modules/lyr_freetype/lyr_freetype.cpp @@ -381,7 +381,7 @@ Layer_Freetype::new_face(const String &newfont) FcResult result; if( !FcInit() ) { - synfig::warning("Layer_Freetype: fontconfig: %s",_("unable to initialise")); + synfig::warning("Layer_Freetype: fontconfig: %s",_("unable to initialize")); error = 1; } else { FcPattern* pat = FcNameParse((FcChar8 *) newfont.c_str()); @@ -788,6 +788,11 @@ Layer_Freetype::accelerated_render(Context context,Surface *surface,int quality, float line_height; line_height=vcompress*((float)face->height*(((float)face->size->metrics.y_scale/METRICS_SCALE_ONE))); + // This module sees to expect pixel height to be negative, as it + // usually is. But rendering to .bmp format causes ph to be + // positive, which was causing text to be rendered upside down. + if (ph>0) line_height = -line_height; + int string_height; string_height=round_to_int(((lines.size()-1)*line_height+lines.back().actual_height())); //synfig::info("string_height=%d",string_height); @@ -818,7 +823,14 @@ Layer_Freetype::accelerated_render(Context context,Surface *surface,int quality, for(curr_line=0,iter=lines.begin();iter!=lines.end();++iter,curr_line++) { bx=round_to_int((pos[0]-renddesc.get_tl()[0])*pw*CHAR_RESOLUTION-orient[0]*iter->width); - by=round_to_int((pos[1]-renddesc.get_tl()[1])*ph*CHAR_RESOLUTION+(1.0-orient[1])*string_height-line_height*curr_line); + // I've no idea why 1.5, but it kind of works. Otherwise, + // rendering to .bmp (which renders from bottom to top, due to + // the .bmp format describing the image from bottom to top, + // renders text in the wrong place. + by=round_to_int((pos[1]-renddesc.get_tl()[1])*ph*CHAR_RESOLUTION + + (1.0-orient[1])*string_height-line_height*curr_line + + ((ph>0) ? line_height/1.5 : 0)); + //by=round_to_int(vcompress*((pos[1]-renddesc.get_tl()[1])*ph*64+(1.0-orient[1])*string_height-face->size->metrics.height*curr_line)); //synfig::info("curr_line=%d, bx=%d, by=%d",curr_line,bx,by); @@ -832,7 +844,7 @@ Layer_Freetype::accelerated_render(Context context,Surface *surface,int quality, pen.x = bx + iter2->pos.x; pen.y = by + iter2->pos.y; - //synfig::info("GLYPH: pen.x=%d, pen,y=%d",curr_line,(pen.x+32)>>6,(pen.y+32)>>6); + //synfig::info("GLYPH: line %d, pen.x=%d, pen,y=%d",curr_line,(pen.x+32)>>6,(pen.y+32)>>6); error = FT_Glyph_To_Bitmap( &image, ft_render_mode_normal,0/*&pen*/, 1 ); if(error) { FT_Done_Glyph( image ); continue; } @@ -843,7 +855,7 @@ Layer_Freetype::accelerated_render(Context context,Surface *surface,int quality, for(u=0;ubitmap.width;u++) { int x=u+((pen.x+32)>>6)+ bit->left; - int y=v+((pen.y+32)>>6)- bit->top; + int y=((pen.y+32)>>6) + (bit->top - v) * ((ph<0) ? -1 : 1); if( y>=0 && x>=0 && yget_h() &&