X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=inline;f=synfig-core%2Ftrunk%2Fsrc%2Fmodules%2Flyr_freetype%2Flyr_freetype.cpp;h=b721476025c3176b68a80bfab48c1201ddbe05c2;hb=5f7270118adc2dfb2ee86d869e2de55d91b557e5;hp=fd54c7a567361cbf616f92e4118dc0397d954d13;hpb=fbf931812d7fc58c6457c898c7758debbf56a3b5;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 fd54c7a..b721476 100644 --- a/synfig-core/trunk/src/modules/lyr_freetype/lyr_freetype.cpp +++ b/synfig-core/trunk/src/modules/lyr_freetype/lyr_freetype.cpp @@ -1,6 +1,6 @@ /* === S Y N F I G ========================================================= */ /*! \file lyr_freetype.cpp -** \brief Template Header +** \brief Implementation of the "Text" layer ** ** $Id$ ** @@ -63,8 +63,8 @@ using namespace synfig; SYNFIG_LAYER_INIT(Layer_Freetype); SYNFIG_LAYER_SET_NAME(Layer_Freetype,"text"); -SYNFIG_LAYER_SET_LOCAL_NAME(Layer_Freetype,_("Text")); -SYNFIG_LAYER_SET_CATEGORY(Layer_Freetype,_("Other")); +SYNFIG_LAYER_SET_LOCAL_NAME(Layer_Freetype,N_("Text")); +SYNFIG_LAYER_SET_CATEGORY(Layer_Freetype,N_("Other")); SYNFIG_LAYER_SET_VERSION(Layer_Freetype,"0.2"); SYNFIG_LAYER_SET_CVS_ID(Layer_Freetype,"$Id$"); @@ -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()); @@ -463,7 +463,9 @@ Layer_Freetype::set_param(const String & param, const ValueBase &value) IMPORT_PLUS(size, if(old_version){size/=2.0;} needs_sync_=true ); IMPORT_PLUS(text,needs_sync_=true); IMPORT_PLUS(pos,needs_sync_=true); - IMPORT(color); + IMPORT_PLUS(color, { if (color.get_a() == 0) if (converted_blend_) { + set_blend_method(Color::BLEND_ALPHA_OVER); + color.set_a(1); } else transparent_color_ = true; }); IMPORT(invert); IMPORT_PLUS(orient,needs_sync_=true); IMPORT_PLUS(compress,needs_sync_=true); @@ -697,6 +699,9 @@ Layer_Freetype::accelerated_render(Context context,Surface *surface,int quality, -- ** -- CREATE GLYPHS ------------------------------------------------------- */ + mbstate_t ps; + memset(&ps, 0, sizeof(ps)); + lines.push_front(TextLine()); string::const_iterator iter; for (iter=text.begin(); iter!=text.end(); ++iter) @@ -716,7 +721,29 @@ Layer_Freetype::accelerated_render(Context context,Surface *surface,int quality, glyph_index = FT_Get_Char_Index( face, ' ' ); } else - glyph_index = FT_Get_Char_Index( face, *iter ); + { + wchar_t wc; + size_t converted = mbrtowc(&wc, &(*iter), text.end() - iter, &ps); + + if(converted == (size_t)(-1)) + { + synfig::warning("Layer_Freetype: multibyte: %s", + _("Invalid multibyte sequence - is the locale set?\n")); + continue; + } + + if(converted == (size_t)(-2)) + { + synfig::warning("Layer_Freetype: multibyte: %s", + _("Can't parse multibyte character.\n")); + continue; + } + + glyph_index = FT_Get_Char_Index( face, wc ); + + if(converted > 1) + iter += converted - 1; + } // retrieve kerning distance and move pen position if ( FT_HAS_KERNING(face) && use_kerning && previous && glyph_index )