Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Iss1068 merge #777

Merged
merged 3 commits into from

1 participant

@minggo
Owner

No description provided.

@minggo minggo merged commit ef103d0 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 9, 2012
Commits on Mar 19, 2012
  1. @minggo
  2. @minggo
This page is out of date. Refresh to see the latest.
View
40 cocos2dx/platform/linux/CCImage_linux.cpp
@@ -11,6 +11,9 @@
#include "ft2build.h"
#include "CCStdC.h"
#include FT_FREETYPE_H
+#ifdef USE_FONTCONFIG
+ #include <fontconfig/fontconfig.h>
+#endif
#define szFont_kenning 2
@@ -32,6 +35,10 @@ class BitmapDC
iInterval = szFont_kenning;
m_pData = NULL;
reset();
+
+#ifdef USE_FONTCONFIG
+ libError |= ! FcInit();
+#endif
}
~BitmapDC() {
@@ -40,6 +47,9 @@ class BitmapDC
// if (m_pData) {
// delete m_pData;
// }
+#ifdef USE_FONTCONFIG
+ FcFini();
+#endif
}
@@ -311,6 +321,10 @@ bool CCImage::initWithString(
const char * pFontName/* = nil*/,
int nSize/* = 0*/)
{
+#ifdef USE_FONTCONFIG
+ FcPattern *pat = NULL, *match = NULL;
+#endif
+
bool bRet = false;
do
{
@@ -318,7 +332,28 @@ bool CCImage::initWithString(
BitmapDC &dc = sharedBitmapDC();
+#ifdef USE_FONTCONFIG
+ // convert pFontName into a fontconfig pattern
+ pat = FcNameParse( (FcChar8 *) pFontName );
+ CC_BREAK_IF( ! pat );
+
+ // set pattern substitution
+ FcConfigSubstitute( 0, pat, FcMatchPattern );
+ FcDefaultSubstitute( pat );
+
+ // look for a match
+ FcResult result;
+ match = FcFontMatch( 0, pat, &result );
+ CC_BREAK_IF( ! match );
+
+ // gett result file name
+ FcValue v;
+ FcPatternGet( match, "file", 0, &v );
+ const char* pFullFontName = (const char*) v.u.s;
+ CC_BREAK_IF(! pFullFontName);
+#else
const char* pFullFontName = CCFileUtils::fullPathFromRelativePath(pFontName);
+#endif
CC_BREAK_IF(! dc.getBitmap(pText, nWidth, nHeight, eAlignMask, pFullFontName, nSize));
@@ -337,6 +372,11 @@ bool CCImage::initWithString(
dc.reset();
}while (0);
+#ifdef USE_FONTCONFIG
+ if( pat ) FcPatternDestroy( pat );
+ if( match ) FcPatternDestroy( match );
+#endif
+
//do nothing
return bRet;
}
View
6 cocos2dx/proj.linux/Makefile
@@ -12,8 +12,9 @@ INCLUDES = -I.. \
-I../platform/third_party/linux/libpng \
-I../platform/third_party/linux/libxml2 \
-I../platform/third_party/linux/libjpeg
-
-DEFINES = -DLINUX
+
+# add -DUSE_FONTCONFIG if you want to use libfontconfig
+DEFINES = -DLINUX
OBJECTS = ../actions/CCAction.o \
../actions/CCActionCamera.o \
@@ -119,6 +120,7 @@ STATICLIBS = $(STATICLIBS_DIR)/libfreetype.a \
$(STATICLIBS_DIR)/libpng.a \
$(STATICLIBS_DIR)/libjpeg.a
+# add -lfontconfig if you want to use libfontconfig
SHAREDLIBS = -lglfw -lGL
####### Build rules
Something went wrong with that request. Please try again.