X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fmodules%2Flyr_freetype%2Flyr_freetype.cpp;h=73d30a0da54b4ebec11e0564e13e97f12359e7ef;hb=6a93b37505b3fa92df8b9efd5a525e49c37d8710;hp=07d25332a764bdb1b3bcd38a0dda01f58dc37953;hpb=21bfc670b83d4c45da9ed1b95063b7e6a007168c;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 07d2533..73d30a0 100644 --- a/synfig-core/trunk/src/modules/lyr_freetype/lyr_freetype.cpp +++ b/synfig-core/trunk/src/modules/lyr_freetype/lyr_freetype.cpp @@ -4,6 +4,7 @@ ** $Id: lyr_freetype.cpp,v 1.5 2005/01/24 05:00:18 darco Exp $ ** ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2006 Paul Wise ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -29,6 +30,9 @@ #ifdef HAVE_CONFIG_H # include #endif +#ifdef WITH_FONTCONFIG +#include +#endif #include "lyr_freetype.h" @@ -366,6 +370,37 @@ lyr_freetype::new_face(const String &newfont) } #endif +#ifdef WITH_FONTCONFIG + if(error) + { + FcFontSet *fs; + FcResult result; + if( !FcInit() ) + { + synfig::warning("lyr_freetype: fontconfig: %s",_("unable to initialise")); + error = 1; + } else { + FcPattern* pat = FcNameParse((FcChar8 *) newfont.c_str()); + FcConfigSubstitute(0, pat, FcMatchPattern); + FcDefaultSubstitute(pat); + FcPattern *match; + fs = FcFontSetCreate(); + match = FcFontMatch(0, pat, &result); + if (match) + FcFontSetAdd(fs, match); + if (pat) + FcPatternDestroy(pat); + if(fs){ + FcChar8* file; + if( FcPatternGetString (fs->fonts[0], FC_FILE, 0, &file) == FcResultMatch ) + error=FT_New_Face(ft_library,(const char*)file,face_index,&face); + FcFontSetDestroy(fs); + } else + synfig::warning("lyr_freetype: fontconfig: %s",_("empty font set")); + } + } +#endif + #ifdef WIN32 if(error)error=FT_New_Face(ft_library,("C:\\WINDOWS\\FONTS\\"+newfont).c_str(),face_index,&face); if(error)error=FT_New_Face(ft_library,("C:\\WINDOWS\\FONTS\\"+newfont+".ttf").c_str(),face_index,&face);