From eb9fc9c8065742402bc8946b5c8624b892cc0bfc Mon Sep 17 00:00:00 2001 From: pabs Date: Wed, 12 Jul 2006 16:47:01 +0000 Subject: [PATCH] Fix Debian #368733: implement fontconfig support git-svn-id: http://svn.voria.com/code@183 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-core/trunk/config/configure.ac | 35 ++++++++++++++-------- .../trunk/src/modules/lyr_freetype/Makefile.am | 5 ++++ .../src/modules/lyr_freetype/lyr_freetype.cpp | 35 ++++++++++++++++++++++ 3 files changed, 63 insertions(+), 12 deletions(-) diff --git a/synfig-core/trunk/config/configure.ac b/synfig-core/trunk/config/configure.ac index 9345e77..faef858 100644 --- a/synfig-core/trunk/config/configure.ac +++ b/synfig-core/trunk/config/configure.ac @@ -225,22 +225,12 @@ AC_ARG_WITH(freetype,[ with_freetype="yes" ]) - if test $with_freetype != "no" ; then { - PKG_CHECK_MODULES(FREETYPE, xft freetype2 fontconfig,[ + PKG_CHECK_MODULES(FREETYPE, freetype2,[ with_freetype="yes" ],[ - PKG_CHECK_MODULES(FREETYPE, freetype2 fontconfig,[ - with_freetype="yes" - ],[ - with_freetype="no" - ]) + with_freetype="no" ]) -# AC_CHECK_FT2(,[ -# with_freetype="yes" -# ],[ -# with_freetype="no" -# ]) } ; fi if test $with_freetype = "no" ; then { @@ -250,8 +240,28 @@ if test $with_freetype = "no" ; then { } ; fi +# FONTCONFIG CHECK-------------------- +AC_ARG_WITH(fontconfig,[ + --without-fontconfig disable support for fontconfig (Default=auto)],[ +],[ + with_fontconfig="yes" +]) +if test $with_fontconfig != "no" ; then { + PKG_CHECK_MODULES(FONTCONFIG, fontconfig,[ + with_fontconfig="yes" + ],[ + with_fontconfig="no" + ]) +} ; fi + +if test $with_fontconfig = "yes" ; then { + AC_DEFINE(WITH_FONTCONFIG,[],[enable fontconfig support]) + AM_CONDITIONAL(WITH_FONTCONFIG,true) +} else { + AM_CONDITIONAL(WITH_FONTCONFIG,false) +} ; fi # OPENEXR CHECK------------------------ @@ -556,6 +566,7 @@ TIFF output target support -------> $TARGET_TIF JPEG output target support -------> $TARGET_JPEG ETL_CFLAGS -----------------------> $ETL_CFLAGS FreeType2 ------------------------> $with_freetype +fontconfig ------------------------> $with_fontconfig libavcodec -----------------------> $with_libavcodec vImage ---------------------------> $with_vimage GLib -----------------------------> $GLIB diff --git a/synfig-core/trunk/src/modules/lyr_freetype/Makefile.am b/synfig-core/trunk/src/modules/lyr_freetype/Makefile.am index c48daff..418dfc6 100644 --- a/synfig-core/trunk/src/modules/lyr_freetype/Makefile.am +++ b/synfig-core/trunk/src/modules/lyr_freetype/Makefile.am @@ -12,6 +12,11 @@ liblyr_freetype_la_SOURCES = main.cpp lyr_freetype.cpp lyr_freetype.h liblyr_freetype_la_LIBADD = -L../../synfig -lsynfig @FREETYPE_LIBS@ @SYNFIG_LIBS@ liblyr_freetype_la_LDFLAGS = -module -no-undefined liblyr_freetype_la_CXXFLAGS = @SYNFIG_CFLAGS@ @FREETYPE_CFLAGS@ +if WITH_FONTCONFIG +liblyr_freetype_la_LIBADD += @FONTCONFIG_LIBS@ +liblyr_freetype_la_CXXFLAGS += @FONTCONFIG_CFLAGS@ +else +endif else endif 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..bd98e85 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); -- 2.7.4