From 34f6fabfcefdc878ba3c08b82358ae4aef439e99 Mon Sep 17 00:00:00 2001 From: darco Date: Fri, 8 Jul 2005 09:22:21 +0000 Subject: [PATCH] meh git-svn-id: http://svn.voria.com/code@25 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-core/trunk/config/configure.ac | 8 +- synfig-core/trunk/macosxbuild.sh | 6 +- .../trunk/src/modules/lyr_freetype/Makefile.am | 4 +- .../src/modules/lyr_freetype/lyr_freetype.cpp | 134 +++++++++++++++------ .../trunk/src/modules/lyr_freetype/lyr_freetype.h | 24 +++- 5 files changed, 129 insertions(+), 47 deletions(-) diff --git a/synfig-core/trunk/config/configure.ac b/synfig-core/trunk/config/configure.ac index 34760e1..0fb932f 100644 --- a/synfig-core/trunk/config/configure.ac +++ b/synfig-core/trunk/config/configure.ac @@ -224,10 +224,14 @@ AC_ARG_WITH(freetype,[ if test $with_freetype != "no" ; then { - PKG_CHECK_MODULES(FREETYPE, freetype2,[ + PKG_CHECK_MODULES(FREETYPE, xft fontconfig,[ with_freetype="yes" ],[ - with_freetype="no" + PKG_CHECK_MODULES(FREETYPE, freetype2 fontconfig,[ + with_freetype="yes" + ],[ + with_freetype="no" + ]) ]) # AC_CHECK_FT2(,[ # with_freetype="yes" diff --git a/synfig-core/trunk/macosxbuild.sh b/synfig-core/trunk/macosxbuild.sh index 56b3f13..e112a69 100755 --- a/synfig-core/trunk/macosxbuild.sh +++ b/synfig-core/trunk/macosxbuild.sh @@ -4,11 +4,11 @@ OPTIONS="" #OPTIONS="$OPTIONS --enable-timelimit=120" -OPTIONS="$OPTIONS --enable-optimization=2" -#OPTIONS="$OPTIONS --enable-optimization=3 --enable-g5opt" +#OPTIONS="$OPTIONS --enable-optimization=2" +OPTIONS="$OPTIONS --enable-optimization=3 --enable-g5opt" #OPTIONS="$OPTIONS --disable-optimization" OPTIONS="$OPTIONS --disable-debug" -OPTIONS="$OPTIONS --with-vimage" +#OPTIONS="$OPTIONS --with-vimage" CC=gcc CXX=g++ diff --git a/synfig-core/trunk/src/modules/lyr_freetype/Makefile.am b/synfig-core/trunk/src/modules/lyr_freetype/Makefile.am index 531acce..82a04bf 100644 --- a/synfig-core/trunk/src/modules/lyr_freetype/Makefile.am +++ b/synfig-core/trunk/src/modules/lyr_freetype/Makefile.am @@ -9,8 +9,8 @@ moduledir=@MODULE_DIR@ if WITH_FREETYPE module_LTLIBRARIES = liblyr_freetype.la liblyr_freetype_la_SOURCES = main.cpp lyr_freetype.cpp lyr_freetype.h -liblyr_freetype_la_LIBADD = -L../../synfig -lsynfig @SYNFIG_LIBS@ -liblyr_freetype_la_LDFLAGS = -module @FREETYPE_LIBS@ -no-undefined +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@ 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 3dc5397..d4c244d 100644 --- a/synfig-core/trunk/src/modules/lyr_freetype/lyr_freetype.cpp +++ b/synfig-core/trunk/src/modules/lyr_freetype/lyr_freetype.cpp @@ -31,17 +31,6 @@ #include "lyr_freetype.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include #endif @@ -138,23 +127,26 @@ lyr_freetype::new_font(const synfig::String &family, int style, int weight) } bool -lyr_freetype::new_font_(const synfig::String &family_, int style, int weight) +lyr_freetype::new_font_(const synfig::String &font_fam_, int style, int weight) { - synfig::String family(family_); + synfig::String font_fam(font_fam_); + + if(new_face(font_fam_)) + return true; //start evil hack - for(int i=0;iWEIGHT_NORMAL) @@ -166,9 +158,13 @@ lyr_freetype::new_font_(const synfig::String &family_, int style, int weight) if(new_face(arial)) return true; +#ifdef __APPLE__ + if(new_face("Helvetica RO")) + return true; +#endif } - if(family=="comic" || family=="comic sans") + if(font_fam=="comic" || font_fam=="comic sans") { String filename("comic"); if(weight>WEIGHT_NORMAL) @@ -181,7 +177,7 @@ lyr_freetype::new_font_(const synfig::String &family_, int style, int weight) return true; } - if(family=="courier" || family=="courier new") + if(font_fam=="courier" || font_fam=="courier new") { String filename("cour"); if(weight>WEIGHT_NORMAL) @@ -194,7 +190,7 @@ lyr_freetype::new_font_(const synfig::String &family_, int style, int weight) return true; } - if(family=="serif" || family=="times" || family=="times new roman") + if(font_fam=="serif" || font_fam=="times" || font_fam=="times new roman") { String filename("times"); if(weight>WEIGHT_NORMAL) @@ -207,7 +203,7 @@ lyr_freetype::new_font_(const synfig::String &family_, int style, int weight) return true; } - if(family=="trebuchet") + if(font_fam=="trebuchet") { String filename("trebuc"); if(weight>WEIGHT_NORMAL) @@ -224,7 +220,7 @@ lyr_freetype::new_font_(const synfig::String &family_, int style, int weight) } - if(family=="sans serif" || family=="luxi sans") + if(font_fam=="sans serif" || font_fam=="luxi sans") { { String luxi("luxis"); @@ -244,7 +240,7 @@ lyr_freetype::new_font_(const synfig::String &family_, int style, int weight) if(new_face("Arial")) return true; } - if(family=="serif" || family=="times" || family=="times new roman" || family=="luxi serif") + if(font_fam=="serif" || font_fam=="times" || font_fam=="times new roman" || font_fam=="luxi serif") { { String luxi("luxir"); @@ -263,7 +259,7 @@ lyr_freetype::new_font_(const synfig::String &family_, int style, int weight) if(new_face("Times")) return true; } - if(family=="luxi") + if(font_fam=="luxi") { { String luxi("luxim"); @@ -284,16 +280,47 @@ lyr_freetype::new_font_(const synfig::String &family_, int style, int weight) return true; } - return new_face(family_) || new_face(family); + return new_face(font_fam_) || new_face(font_fam); return false; } +#ifdef USE_MAC_FT_FUNCS +void fss2path(char *path, FSSpec *fss) +{ + int l; //fss->name contains name of last item in path + for(l=0; l<(fss->name[0]); l++) path[l] = fss->name[l + 1]; + path[l] = 0; + + if(fss->parID != fsRtParID) //path is more than just a volume name + { + int i, len; + CInfoPBRec pb; + + pb.dirInfo.ioNamePtr = fss->name; + pb.dirInfo.ioVRefNum = fss->vRefNum; + pb.dirInfo.ioDrParID = fss->parID; + do + { + pb.dirInfo.ioFDirIndex = -1; //get parent directory name + pb.dirInfo.ioDrDirID = pb.dirInfo.ioDrParID; + if(PBGetCatInfoSync(&pb) != noErr) break; + + len = fss->name[0] + 1; + for(i=l; i>=0; i--) path[i + len] = path[i]; + for(i=1; iname[i]; //add to start of path + path[i - 1] = ':'; + l += len; +} while(pb.dirInfo.ioDrDirID != fsRtDirID); //while more directory levels + } +} +#endif + bool lyr_freetype::new_face(const String &newfont) { int error; - int face_index=0; + FT_Long face_index=0; // If we are already loaded, don't bother reloading. if(face && font==newfont) @@ -314,30 +341,57 @@ lyr_freetype::new_face(const String &newfont) if(error)error=FT_New_Face(ft_library,(get_canvas()->get_file_path()+ETL_DIRECTORY_SEPERATOR+newfont+".ttf").c_str(),face_index,&face); } +#ifdef USE_MAC_FT_FUNCS + if(error) + { + FSSpec fs_spec; + error=FT_GetFile_From_Mac_Name(newfont.c_str(),&fs_spec,&face_index); + if(!error) + { + char filename[512]; + fss2path(filename,&fs_spec); + //FSSpecToNativePathName(fs_spec,filename,sizeof(filename)-1, 0); + + error=FT_New_Face(ft_library, filename, face_index,&face); + //error=FT_New_Face_From_FSSpec(ft_library, &fs_spec, face_index,&face); + synfig::info(__FILE__":%d: \"%s\" (%s) -- ft_error=%d",__LINE__,newfont.c_str(),filename,error); + } + else + { + synfig::info(__FILE__":%d: \"%s\" -- ft_error=%d",__LINE__,newfont.c_str(),error); + // Unable to generate fs_spec + } + + } +#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); #else - if(error)error=FT_New_Face(ft_library,("/usr/share/fonts/truetype/"+newfont).c_str(),face_index,&face); - if(error)error=FT_New_Face(ft_library,("/usr/share/fonts/truetype/"+newfont+".ttf").c_str(),face_index,&face); - - if(error)error=FT_New_Face(ft_library,("/usr/X11R6/lib/X11/fonts/TTF/"+newfont).c_str(),face_index,&face); - if(error)error=FT_New_Face(ft_library,("/usr/X11R6/lib/X11/fonts/TTF/"+newfont+".ttf").c_str(),face_index,&face); - - if(error)error=FT_New_Face(ft_library,("/usr/X11R6/lib/X11/fonts/truetype/"+newfont).c_str(),face_index,&face); - if(error)error=FT_New_Face(ft_library,("/usr/X11R6/lib/X11/fonts/truetype/"+newfont+".ttf").c_str(),face_index,&face); - - if(error)error=FT_New_Face(ft_library,("/usr/X11R6/lib/X11/fonts/type1/"+newfont).c_str(),face_index,&face); - if(error)error=FT_New_Face(ft_library,("/usr/X11R6/lib/X11/fonts/type1/"+newfont+".ttf").c_str(),face_index,&face); #ifdef __APPLE__ if(error)error=FT_New_Face(ft_library,("~/Library/Fonts/"+newfont).c_str(),face_index,&face); if(error)error=FT_New_Face(ft_library,("~/Library/Fonts/"+newfont+".ttf").c_str(),face_index,&face); + if(error)error=FT_New_Face(ft_library,("~/Library/Fonts/"+newfont+".dfont").c_str(),face_index,&face); if(error)error=FT_New_Face(ft_library,("/Library/Fonts/"+newfont).c_str(),face_index,&face); if(error)error=FT_New_Face(ft_library,("/Library/Fonts/"+newfont+".ttf").c_str(),face_index,&face); + if(error)error=FT_New_Face(ft_library,("/Library/Fonts/"+newfont+".dfont").c_str(),face_index,&face); #endif + if(error)error=FT_New_Face(ft_library,("/usr/X11R6/lib/X11/fonts/type1/"+newfont).c_str(),face_index,&face); + if(error)error=FT_New_Face(ft_library,("/usr/X11R6/lib/X11/fonts/type1/"+newfont+".ttf").c_str(),face_index,&face); + + if(error)error=FT_New_Face(ft_library,("/usr/share/fonts/truetype/"+newfont).c_str(),face_index,&face); + if(error)error=FT_New_Face(ft_library,("/usr/share/fonts/truetype/"+newfont+".ttf").c_str(),face_index,&face); + + if(error)error=FT_New_Face(ft_library,("/usr/X11R6/lib/X11/fonts/TTF/"+newfont).c_str(),face_index,&face); + if(error)error=FT_New_Face(ft_library,("/usr/X11R6/lib/X11/fonts/TTF/"+newfont+".ttf").c_str(),face_index,&face); + + if(error)error=FT_New_Face(ft_library,("/usr/X11R6/lib/X11/fonts/truetype/"+newfont).c_str(),face_index,&face); + if(error)error=FT_New_Face(ft_library,("/usr/X11R6/lib/X11/fonts/truetype/"+newfont+".ttf").c_str(),face_index,&face); + #endif if(error) { @@ -355,12 +409,14 @@ bool lyr_freetype::set_param(const String & param, const ValueBase &value) { Mutex::Lock lock(mutex); +/* if(param=="font" && value.same_as(font)) { new_font(etl::basename(value.get(font)),style,weight); family=etl::basename(value.get(font)); return true; } +*/ IMPORT_PLUS(family,new_font(family,style,weight)); IMPORT_PLUS(weight,new_font(family,style,weight)); IMPORT_PLUS(style,new_font(family,style,weight)); @@ -504,7 +560,7 @@ lyr_freetype::sync() } Color -lyr_freetype::get_color(Context context, const Point &pos)const +lyr_freetype::get_color(Context context, const synfig::Point &pos)const { if(needs_sync_) const_cast(this)->sync(); @@ -777,5 +833,5 @@ lyr_freetype::get_bounding_rect()const if(needs_sync_) const_cast(this)->sync(); // if(!is_disabled()) - return Rect::full_plane(); + return synfig::Rect::full_plane(); } diff --git a/synfig-core/trunk/src/modules/lyr_freetype/lyr_freetype.h b/synfig-core/trunk/src/modules/lyr_freetype/lyr_freetype.h index 4de4b19..09b684c 100644 --- a/synfig-core/trunk/src/modules/lyr_freetype/lyr_freetype.h +++ b/synfig-core/trunk/src/modules/lyr_freetype/lyr_freetype.h @@ -25,6 +25,10 @@ /* === H E A D E R S ======================================================= */ +//#ifdef __APPLE__ +//#define USE_MAC_FT_FUNCS (1) +//#endif + #include #include #include @@ -35,6 +39,24 @@ #include FT_GLYPH_H #include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include + +#ifdef USE_MAC_FT_FUNCS + #include + #include FT_MAC_H +#endif + /* === M A C R O S ========================================================= */ /* === T Y P E D E F S ===================================================== */ @@ -115,7 +137,7 @@ public: virtual bool set_param(const String & param, const synfig::ValueBase &value); virtual ValueBase get_param(const String & param)const; - virtual Color get_color(Context context, const Point &pos)const; + virtual Color get_color(Context context, const synfig::Point &pos)const; virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const; virtual Vocab get_param_vocab()const; -- 2.7.4