1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
Description: use fontconfig if available, instead of a hardcoded font
file. Paves way for splitting the font file into a separate package.
Forwarded: no
Author: Leo 'costela' Antunes <costela@debian.org>
Index: numptyphysics-0.2+svn156/Font.cpp
===================================================================
--- numptyphysics-0.2+svn156.orig/Font.cpp 2010-02-22 22:51:55.000000000 +0100
+++ numptyphysics-0.2+svn156/Font.cpp 2010-06-20 15:10:31.000000000 +0200
@@ -18,6 +18,10 @@
#include "Config.h"
#include <SDL/SDL_ttf.h>
+#ifdef HAVE_FONTCONFIG
+#include <fontconfig/fontconfig.h>
+#endif
+
#define FONT(fONTpTR) ((TTF_Font*)((fONTpTR)->m_state))
struct FontCanvas : public Canvas
@@ -31,7 +35,33 @@
Font::Font( const std::string& file, int ptsize )
{
TTF_Init();
- std::string fname = Config::findFile(file);
+#ifdef HAVE_FONTCONFIG
+ std::string fname;
+ if( FcInit() )
+ {
+ FcResult result;
+ FcChar8 *fontfile;
+
+ FcPattern *pat = FcNameParse( (FcChar8 *) file.c_str() );
+ FcConfigSubstitute (0, pat, FcMatchPattern);
+ FcDefaultSubstitute (pat);
+
+ FcPattern *match = FcFontMatch (0, pat, &result);
+
+ FcPatternDestroy (pat);
+
+ FcPatternGetString(match, FC_FILE, 0, &fontfile);
+
+ fname = std::string((const char*)fontfile);
+ }
+ else
+ {
+ // no fontconfig, fallback to builtin font
+ fname = Config::findFile(file+".ttf");
+ }
+#else
+ std::string fname = Config::findFile(file+".ttf");
+#endif
m_state = TTF_OpenFont( fname.c_str(), ptsize );
m_height = metrics("M").y;
}
@@ -93,19 +123,18 @@
const Font* Font::titleFont()
{
- static Font* f = new Font("femkeklaver.ttf",48);
+ static Font* f = new Font("femkeklaver",48);
return f;
}
const Font* Font::headingFont()
{
- static Font* f = new Font("femkeklaver.ttf",32);
+ static Font* f = new Font("femkeklaver",32);
return f;
}
const Font* Font::blurbFont()
{
- static Font* f = new Font("femkeklaver.ttf",24);
+ static Font* f = new Font("femkeklaver",24);
return f;
}
-
Index: numptyphysics-0.2+svn156/configure.in
===================================================================
--- numptyphysics-0.2+svn156.orig/configure.in 2010-06-20 15:04:59.000000000 +0200
+++ numptyphysics-0.2+svn156/configure.in 2010-06-20 15:10:31.000000000 +0200
@@ -76,6 +76,13 @@
AC_SUBST(icon_scalabledir)
PKG_CHECK_MODULES(BOX2D, box2d >= 2.0.0)
+PKG_CHECK_MODULES(FONTCONFIG, fontconfig,
+ [
+ AC_DEFINE([HAVE_FONTCONFIG], 1)
+ ],
+ [
+ AC_MSG_WARN([no fontconfig, using builtin font])
+ ])
AC_CHECK_LIB(stdc++, main)
AC_CHECK_LIB(X11, main)
Index: numptyphysics-0.2+svn156/Makefile.am
===================================================================
--- numptyphysics-0.2+svn156.orig/Makefile.am 2010-06-20 15:04:59.000000000 +0200
+++ numptyphysics-0.2+svn156/Makefile.am 2010-06-20 15:10:31.000000000 +0200
@@ -30,8 +30,10 @@
OsFreeDesktop.cpp \
OsWin32.cpp
-numptyphysics_CPPFLAGS = -IXX $(SDL_CFLAGS) $(HILDON_CFLAGS) $(BOX2D_CFLAGS)
-numptyphysics_LDADD = $(SDL_LIBS) $(HILDON_LIBS) $(BOX2D_LIBS)
+numptyphysics_CPPFLAGS = -IXX $(SDL_CFLAGS) $(HILDON_CFLAGS) $(BOX2D_CFLAGS) \
+ $(FONTCONFIG_CFLAGS)
+numptyphysics_LDADD = $(SDL_LIBS) $(HILDON_LIBS) $(BOX2D_LIBS) \
+ $(FONTCONFIG_LIBS)
numptyphysics_DATA = \
data/C00_Title.npz \
@@ -56,6 +58,6 @@
data/close.png \
data/record.png \
data/theend.png \
- data/femkeklaver.ttf
+ #data/femkeklaver.ttf
|