- updated to properly use fontconfig for finding fonts

This commit is contained in:
Mark Vejvoda 2012-01-05 22:35:05 +00:00
parent ced374410c
commit fe72cb629b
12 changed files with 155 additions and 105 deletions

View File

@ -350,7 +350,7 @@ void CoreData::loadFonts() {
if(Renderer::renderText3DEnabled == false) { if(Renderer::renderText3DEnabled == false) {
displayFont= renderer.newFont(rsGlobal); displayFont= renderer.newFont(rsGlobal);
if(displayFont) { if(displayFont) {
displayFont->setType(displayFontName,config.getString("FontDisplay","")); displayFont->setType(displayFontName,config.getString("FontDisplay",""),config.getString("FontDisplayFamily",""));
displayFont->setSize(displayFontSize); displayFont->setSize(displayFontSize);
//displayFont->setYOffsetFactor(config.getFloat("FontDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); //displayFont->setYOffsetFactor(config.getFloat("FontDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
} }
@ -363,7 +363,7 @@ void CoreData::loadFonts() {
if(Renderer::renderText3DEnabled == true) { if(Renderer::renderText3DEnabled == true) {
displayFont3D= renderer.newFont3D(rsGlobal); displayFont3D= renderer.newFont3D(rsGlobal);
if(displayFont3D) { if(displayFont3D) {
displayFont3D->setType(displayFontName,config.getString("FontDisplay","")); displayFont3D->setType(displayFontName,config.getString("FontDisplay",""),config.getString("FontDisplayFamily",""));
displayFont3D->setSize(displayFontSize); displayFont3D->setSize(displayFontSize);
//displayFont3D->setYOffsetFactor(config.getFloat("FontDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); //displayFont3D->setYOffsetFactor(config.getFloat("FontDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
} }
@ -395,7 +395,7 @@ void CoreData::loadFonts() {
if(Renderer::renderText3DEnabled == false) { if(Renderer::renderText3DEnabled == false) {
displayFontSmall= renderer.newFont(rsGlobal); displayFontSmall= renderer.newFont(rsGlobal);
if(displayFontSmall) { if(displayFontSmall) {
displayFontSmall->setType(displayFontNameSmall,config.getString("FontSmallDisplay","")); displayFontSmall->setType(displayFontNameSmall,config.getString("FontSmallDisplay",""),config.getString("FontSmallDisplayFamily",""));
displayFontSmall->setSize(displayFontNameSmallSize); displayFontSmall->setSize(displayFontNameSmallSize);
//displayFontSmall->setYOffsetFactor(config.getFloat("FontSmallDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); //displayFontSmall->setYOffsetFactor(config.getFloat("FontSmallDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
} }
@ -408,7 +408,7 @@ void CoreData::loadFonts() {
if(Renderer::renderText3DEnabled == true) { if(Renderer::renderText3DEnabled == true) {
displayFontSmall3D= renderer.newFont3D(rsGlobal); displayFontSmall3D= renderer.newFont3D(rsGlobal);
if(displayFontSmall3D) { if(displayFontSmall3D) {
displayFontSmall3D->setType(displayFontNameSmall,config.getString("FontSmallDisplay","")); displayFontSmall3D->setType(displayFontNameSmall,config.getString("FontSmallDisplay",""),config.getString("FontSmallDisplayFamily",""));
displayFontSmall3D->setSize(displayFontNameSmallSize); displayFontSmall3D->setSize(displayFontNameSmallSize);
//displayFontSmall3D->setYOffsetFactor(config.getFloat("FontSmallDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); //displayFontSmall3D->setYOffsetFactor(config.getFloat("FontSmallDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
} }
@ -439,7 +439,7 @@ void CoreData::loadFonts() {
if(Renderer::renderText3DEnabled == false) { if(Renderer::renderText3DEnabled == false) {
menuFontNormal= renderer.newFont(rsGlobal); menuFontNormal= renderer.newFont(rsGlobal);
if(menuFontNormal) { if(menuFontNormal) {
menuFontNormal->setType(menuFontNameNormal,config.getString("FontMenuNormal","")); menuFontNormal->setType(menuFontNameNormal,config.getString("FontMenuNormal",""),config.getString("FontMenuNormalFamily",""));
menuFontNormal->setSize(menuFontNameNormalSize); menuFontNormal->setSize(menuFontNameNormalSize);
menuFontNormal->setWidth(Font::wBold); menuFontNormal->setWidth(Font::wBold);
//menuFontNormal->setYOffsetFactor(config.getFloat("FontMenuNormalYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); //menuFontNormal->setYOffsetFactor(config.getFloat("FontMenuNormalYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
@ -453,7 +453,7 @@ void CoreData::loadFonts() {
if(Renderer::renderText3DEnabled == true) { if(Renderer::renderText3DEnabled == true) {
menuFontNormal3D= renderer.newFont3D(rsGlobal); menuFontNormal3D= renderer.newFont3D(rsGlobal);
if(menuFontNormal3D) { if(menuFontNormal3D) {
menuFontNormal3D->setType(menuFontNameNormal,config.getString("FontMenuNormal","")); menuFontNormal3D->setType(menuFontNameNormal,config.getString("FontMenuNormal",""),config.getString("FontMenuNormalFamily",""));
menuFontNormal3D->setSize(menuFontNameNormalSize); menuFontNormal3D->setSize(menuFontNameNormalSize);
menuFontNormal3D->setWidth(Font::wBold); menuFontNormal3D->setWidth(Font::wBold);
//menuFontNormal3D->setYOffsetFactor(config.getFloat("FontMenuNormalYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); //menuFontNormal3D->setYOffsetFactor(config.getFloat("FontMenuNormalYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
@ -485,7 +485,7 @@ void CoreData::loadFonts() {
if(Renderer::renderText3DEnabled == false) { if(Renderer::renderText3DEnabled == false) {
menuFontBig= renderer.newFont(rsGlobal); menuFontBig= renderer.newFont(rsGlobal);
if(menuFontBig) { if(menuFontBig) {
menuFontBig->setType(menuFontNameBig,config.getString("FontMenuBig","")); menuFontBig->setType(menuFontNameBig,config.getString("FontMenuBig",""),config.getString("FontMenuBigFamily",""));
menuFontBig->setSize(menuFontNameBigSize); menuFontBig->setSize(menuFontNameBigSize);
//menuFontBig->setYOffsetFactor(config.getFloat("FontMenuBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); //menuFontBig->setYOffsetFactor(config.getFloat("FontMenuBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
} }
@ -498,7 +498,7 @@ void CoreData::loadFonts() {
if(Renderer::renderText3DEnabled == true) { if(Renderer::renderText3DEnabled == true) {
menuFontBig3D= renderer.newFont3D(rsGlobal); menuFontBig3D= renderer.newFont3D(rsGlobal);
if(menuFontBig3D) { if(menuFontBig3D) {
menuFontBig3D->setType(menuFontNameBig,config.getString("FontMenuBig","")); menuFontBig3D->setType(menuFontNameBig,config.getString("FontMenuBig",""),config.getString("FontMenuBigFamily",""));
menuFontBig3D->setSize(menuFontNameBigSize); menuFontBig3D->setSize(menuFontNameBigSize);
//menuFontBig3D->setYOffsetFactor(config.getFloat("FontMenuBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); //menuFontBig3D->setYOffsetFactor(config.getFloat("FontMenuBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
} }
@ -529,7 +529,7 @@ void CoreData::loadFonts() {
if(Renderer::renderText3DEnabled == false) { if(Renderer::renderText3DEnabled == false) {
menuFontVeryBig= renderer.newFont(rsGlobal); menuFontVeryBig= renderer.newFont(rsGlobal);
if(menuFontVeryBig) { if(menuFontVeryBig) {
menuFontVeryBig->setType(menuFontNameVeryBig,config.getString("FontMenuVeryBig","")); menuFontVeryBig->setType(menuFontNameVeryBig,config.getString("FontMenuVeryBig",""),config.getString("FontMenuVeryBigFamily",""));
menuFontVeryBig->setSize(menuFontNameVeryBigSize); menuFontVeryBig->setSize(menuFontNameVeryBigSize);
//menuFontVeryBig->setYOffsetFactor(config.getFloat("FontMenuVeryBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); //menuFontVeryBig->setYOffsetFactor(config.getFloat("FontMenuVeryBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
} }
@ -542,7 +542,7 @@ void CoreData::loadFonts() {
if(Renderer::renderText3DEnabled == true) { if(Renderer::renderText3DEnabled == true) {
menuFontVeryBig3D= renderer.newFont3D(rsGlobal); menuFontVeryBig3D= renderer.newFont3D(rsGlobal);
if(menuFontVeryBig3D) { if(menuFontVeryBig3D) {
menuFontVeryBig3D->setType(menuFontNameVeryBig,config.getString("FontMenuVeryBig","")); menuFontVeryBig3D->setType(menuFontNameVeryBig,config.getString("FontMenuVeryBig",""),config.getString("FontMenuVeryBigFamily",""));
menuFontVeryBig3D->setSize(menuFontNameVeryBigSize); menuFontVeryBig3D->setSize(menuFontNameVeryBigSize);
//menuFontVeryBig3D->setYOffsetFactor(config.getFloat("FontMenuVeryBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); //menuFontVeryBig3D->setYOffsetFactor(config.getFloat("FontMenuVeryBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
} }
@ -576,7 +576,7 @@ void CoreData::loadFonts() {
if(Renderer::renderText3DEnabled == false) { if(Renderer::renderText3DEnabled == false) {
consoleFont= renderer.newFont(rsGlobal); consoleFont= renderer.newFont(rsGlobal);
if(consoleFont) { if(consoleFont) {
consoleFont->setType(consoleFontName,config.getString("FontConsole","")); consoleFont->setType(consoleFontName,config.getString("FontConsole",""),config.getString("FontConsoleFamily",""));
consoleFont->setSize(consoleFontNameSize); consoleFont->setSize(consoleFontNameSize);
//consoleFont->setYOffsetFactor(config.getFloat("FontConsoleYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); //consoleFont->setYOffsetFactor(config.getFloat("FontConsoleYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
} }
@ -589,7 +589,7 @@ void CoreData::loadFonts() {
if(Renderer::renderText3DEnabled == true) { if(Renderer::renderText3DEnabled == true) {
consoleFont3D= renderer.newFont3D(rsGlobal); consoleFont3D= renderer.newFont3D(rsGlobal);
if(consoleFont3D) { if(consoleFont3D) {
consoleFont3D->setType(consoleFontName,config.getString("FontConsole","")); consoleFont3D->setType(consoleFontName,config.getString("FontConsole",""),config.getString("FontConsoleFamily",""));
consoleFont3D->setSize(consoleFontNameSize); consoleFont3D->setSize(consoleFontNameSize);
//consoleFont3D->setYOffsetFactor(config.getFloat("FontConsoleYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); //consoleFont3D->setYOffsetFactor(config.getFloat("FontConsoleYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
} }

View File

@ -107,6 +107,15 @@ void Lang::loadStrings(string uselanguage, bool loadFonts,
#endif #endif
} }
if( lang.hasString("MEGAGLEST_FONT_FAMILY")) {
#if defined(WIN32)
string newEnvValue = "MEGAGLEST_FONT_FAMILY=" + lang.get("MEGAGLEST_FONT_FAMILY");
_putenv(newEnvValue.c_str());
#else
setenv("MEGAGLEST_FONT_FAMILY",lang.get("MEGAGLEST_FONT_FAMILY").c_str(),0);
#endif
}
// if( lang.hasString("FONT_YOFFSET_FACTOR")) { // if( lang.hasString("FONT_YOFFSET_FACTOR")) {
// FontMetrics::DEFAULT_Y_OFFSET_FACTOR = strToFloat(lang.get("FONT_YOFFSET_FACTOR")); // FontMetrics::DEFAULT_Y_OFFSET_FACTOR = strToFloat(lang.get("FONT_YOFFSET_FACTOR"));
// } // }

View File

@ -138,7 +138,10 @@ IF(BUILD_MEGAGLEST_MODEL_VIEWER OR BUILD_MEGAGLEST_MAP_EDITOR OR BUILD_MEGAGLEST
FIND_PACKAGE(FontConfig) FIND_PACKAGE(FontConfig)
IF(FONTCONFIG_FOUND) IF(FONTCONFIG_FOUND)
MESSAGE(STATUS "**NOTE: FontConfig support was detected and enabled.")
SET(HAVE_FONTCONFIG 1) SET(HAVE_FONTCONFIG 1)
ADD_DEFINITIONS(-DHAVE_FONTCONFIG)
INCLUDE_DIRECTORIES( ${FONTCONFIG_INCLUDE_DIR} ) INCLUDE_DIRECTORIES( ${FONTCONFIG_INCLUDE_DIR} )
SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${FONTCONFIG_LIBRARIES} ) SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${FONTCONFIG_LIBRARIES} )
ENDIF(FONTCONFIG_FOUND) ENDIF(FONTCONFIG_FOUND)

View File

@ -101,7 +101,7 @@ public:
string getType() const; string getType() const;
//set //set
void setType(string typeX11, string typeGeneric); void setType(string typeX11, string typeGeneric, string typeGenericFamily);
void setWidth(int width); void setWidth(int width);
int getSize() const; int getSize() const;
@ -139,7 +139,7 @@ public:
Font3D *ConvertFont2DTo3D(Font2D *font); Font3D *ConvertFont2DTo3D(Font2D *font);
const char* findFont(const char *firstFontToTry=NULL); const char* findFont(const char *firstFontToTry=NULL,const char *firstFontFamilyToTry=NULL);
}}//end namespace }}//end namespace

View File

@ -36,7 +36,7 @@ public:
Text(FontTextHandlerType type); Text(FontTextHandlerType type);
virtual ~Text(); virtual ~Text();
virtual void init(string fontName, int fontSize); virtual void init(string fontName, string fontFamilyName, int fontSize);
virtual void SetFaceSize(int); virtual void SetFaceSize(int);
virtual int GetFaceSize(); virtual int GetFaceSize();

View File

@ -33,7 +33,7 @@ public:
TextFTGL(FontTextHandlerType type); TextFTGL(FontTextHandlerType type);
virtual ~TextFTGL(); virtual ~TextFTGL();
virtual void init(string fontName, int fontSize); virtual void init(string fontName, string fontFamilyName, int fontSize);
virtual void SetFaceSize(int); virtual void SetFaceSize(int);
virtual int GetFaceSize(); virtual int GetFaceSize();

View File

@ -41,7 +41,7 @@ public:
TextFreetypeGL(FontTextHandlerType type); TextFreetypeGL(FontTextHandlerType type);
virtual ~TextFreetypeGL(); virtual ~TextFreetypeGL();
virtual void init(string fontName, int fontSize); virtual void init(string fontName, string fontFamilyName, int fontSize);
virtual void SetFaceSize(int); virtual void SetFaceSize(int);
virtual int GetFaceSize(); virtual int GetFaceSize();
@ -66,6 +66,7 @@ private:
int fontFaceSize; int fontFaceSize;
string fontName; string fontName;
string fontFamilyName;
const char* fontFile; const char* fontFile;
void cleanupFont(); void cleanupFont();

View File

@ -84,8 +84,11 @@ void Font::resetToDefaults() {
#if defined(WIN32) #if defined(WIN32)
string newEnvValue = "MEGAGLEST_FONT="; string newEnvValue = "MEGAGLEST_FONT=";
_putenv(newEnvValue.c_str()); _putenv(newEnvValue.c_str());
newEnvValue = "MEGAGLEST_FONT_FAMILY=";
_putenv(newEnvValue.c_str());
#else #else
unsetenv("MEGAGLEST_FONT"); unsetenv("MEGAGLEST_FONT");
unsetenv("MEGAGLEST_FONT_FAMILY");
#endif #endif
} }
@ -212,11 +215,11 @@ string Font::getType() const {
return this->type; return this->type;
} }
void Font::setType(string typeX11, string typeGeneric) { void Font::setType(string typeX11, string typeGeneric, string typeGenericFamily) {
if(textHandler) { if(textHandler) {
try { try {
this->type= typeGeneric; this->type= typeGeneric;
textHandler->init(typeGeneric,textHandler->GetFaceSize()); textHandler->init(typeGeneric,typeGenericFamily,textHandler->GetFaceSize());
metrics.setTextHandler(this->textHandler); metrics.setTextHandler(this->textHandler);
} }
catch(exception &ex) { catch(exception &ex) {
@ -269,54 +272,11 @@ Font3D::Font3D(FontTextHandlerType type) : Font(type) {
depth= 10.f; depth= 10.f;
} }
const char* findFont(const char *firstFontToTry) { string findFontFamily(const char* font, const char *fontFamily) {
const char* font = NULL; string resultFile = "";
const char* path = NULL;
#define CHECK_FONT_PATH(filename) \
{ \
path = filename; \
if( !font && path && fileExists(path) == true ) \
font = strdup(path); \
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Found font file [%s]\n",font); \
}
string tryFont = "";
if(firstFontToTry) {
tryFont = firstFontToTry;
#ifdef WIN32
replaceAll(tryFont, "/", "\\");
#endif
CHECK_FONT_PATH(tryFont.c_str())
}
// Get user-specified font path
if(getenv("MEGAGLEST_FONT") != NULL) {
tryFont = getenv("MEGAGLEST_FONT");
#ifdef WIN32
replaceAll(tryFont, "/", "\\");
#endif
CHECK_FONT_PATH(tryFont.c_str())
}
string data_path = Text::DEFAULT_FONT_PATH;
string defaultFont = data_path + "data/core/fonts/LinBiolinum_RB.ttf";//LinBiolinum_Re-0.6.4.ttf
tryFont = defaultFont;
#ifdef WIN32
replaceAll(tryFont, "/", "\\");
#endif
CHECK_FONT_PATH(tryFont.c_str())
#ifdef FONT_PATH
// Get distro-specified font path
CHECK_FONT_PATH(FONT_PATH)
#endif
#ifdef HAVE_FONTCONFIG #ifdef HAVE_FONTCONFIG
// Get default font via fontconfig // Get default font via fontconfig
if( !font && FcInit() ) { if( !font && FcInit() && fontFamily) {
FcResult result; FcResult result;
FcFontSet *fs; FcFontSet *fs;
FcPattern* pat; FcPattern* pat;
@ -327,30 +287,107 @@ const char* findFont(const char *firstFontToTry) {
name of a font that contains all the Unicode characters in use in name of a font that contains all the Unicode characters in use in
your translation. your translation.
*/ */
pat = FcNameParse((FcChar8 *)"Gothic Uralic"); //pat = FcNameParse((FcChar8 *)"Gothic Uralic");
pat = FcNameParse((FcChar8 *)fontFamily);
FcConfigSubstitute(0, pat, FcMatchPattern); FcConfigSubstitute(0, pat, FcMatchPattern);
FcPatternDel(pat, FC_WEIGHT); //FcPatternDel(pat, FC_WEIGHT);
FcPatternAddInteger(pat, FC_WEIGHT, FC_WEIGHT_BOLD); //FcPatternAddInteger(pat, FC_WEIGHT, FC_WEIGHT_BOLD);
FcDefaultSubstitute(pat); FcDefaultSubstitute(pat);
fs = FcFontSetCreate(); fs = FcFontSetCreate();
match = FcFontMatch(0, pat, &result); match = FcFontMatch(0, pat, &result);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Trying fontconfig for fontfamily [%s]\n",fontFamily);
if (match) FcFontSetAdd(fs, match); if (match) FcFontSetAdd(fs, match);
if (pat) FcPatternDestroy(pat); if (pat) FcPatternDestroy(pat);
if(fs) { if(fs) {
FcChar8* file; FcChar8* file;
if( FcPatternGetString (fs->fonts[0], FC_FILE, 0, &file) == FcResultMatch ) { if( FcPatternGetString (fs->fonts[0], FC_FILE, 0, &file) == FcResultMatch ) {
CHECK_FONT_PATH((const char*)file) //CHECK_FONT_PATH((const char*)file,NULL)
resultFile = (const char*)file;
} }
FcFontSetDestroy(fs); FcFontSetDestroy(fs);
} }
FcFini(); FcFini();
} }
#else
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("******************* NO FONT CONFIG ENABLED!\n");
#endif #endif
CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothub__.ttf") return resultFile;
}
const char* findFont(const char *firstFontToTry,const char *firstFontFamilyToTry) {
const char* font = NULL;
const char* path = NULL;
#define CHECK_FONT_PATH(filename,fontFamily) \
{ \
path = filename; \
if( !font && path && strlen(path) > 0 && fileExists(path) == true ) { \
font = strdup(path); \
} \
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#1 Searching for font file [%s] result [%s]\n",path,font); \
if( !font && fontFamily && strlen(fontFamily) > 0) { \
string fileFound = findFontFamily(font, fontFamily); \
if(fileFound != "") { \
path = fileFound.c_str(); \
if( !font && path && strlen(path) > 0 && fileExists(path) == true ) { \
font = strdup(path); \
} \
} \
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#2 Searching for font family [%s] result [%s]\n",fontFamily,font); \
} \
}
string tryFont = "";
if(firstFontToTry || firstFontFamilyToTry) {
if(firstFontToTry && strlen(firstFontToTry) > 0) {
tryFont = firstFontToTry;
#ifdef WIN32
replaceAll(tryFont, "/", "\\");
#endif
CHECK_FONT_PATH(tryFont.c_str(),firstFontFamilyToTry)
}
else {
CHECK_FONT_PATH(NULL,firstFontFamilyToTry)
}
}
// Get user-specified font path
if(getenv("MEGAGLEST_FONT") != NULL || getenv("MEGAGLEST_FONT_FAMILY") != NULL) {
if(getenv("MEGAGLEST_FONT") != NULL) {
tryFont = getenv("MEGAGLEST_FONT");
#ifdef WIN32
replaceAll(tryFont, "/", "\\");
#endif
CHECK_FONT_PATH(tryFont.c_str(),getenv("MEGAGLEST_FONT_FAMILY"))
}
else {
CHECK_FONT_PATH(NULL,getenv("MEGAGLEST_FONT_FAMILY"))
}
}
string data_path = Text::DEFAULT_FONT_PATH;
string defaultFont = data_path + "data/core/fonts/LinBiolinum_RB.ttf";//LinBiolinum_Re-0.6.4.ttf
tryFont = defaultFont;
#ifdef WIN32
replaceAll(tryFont, "/", "\\");
#endif
CHECK_FONT_PATH(tryFont.c_str(),"Linux Biolinum O:style=Bold")
#ifdef FONT_PATH
// Get distro-specified font path
CHECK_FONT_PATH(FONT_PATH)
#endif
CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothub__.ttf","Gothic Uralic:style=Regular")
// Check a couple of common paths for Gothic Uralic/bold as a last resort // Check a couple of common paths for Gothic Uralic/bold as a last resort
// Debian // Debian
@ -359,44 +396,44 @@ const char* findFont(const char *firstFontToTry) {
font that contains all the Unicode characters in use in your translation. font that contains all the Unicode characters in use in your translation.
If the font is available in Debian it should be the Debian path. If the font is available in Debian it should be the Debian path.
*/ */
CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothub__.ttf") CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothub__.ttf","Gothic Uralic:style=Regular")
/* /*
TRANSLATORS: If using the FTGL backend, this should be the path of a TRANSLATORS: If using the FTGL backend, this should be the path of a
font that contains all the Unicode characters in use in your translation. font that contains all the Unicode characters in use in your translation.
If the font is available in Debian it should be the Debian path. If the font is available in Debian it should be the Debian path.
*/ */
CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothu___.ttf") CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothu___.ttf","Gothic Uralic:style=Regular")
// Mandrake // Mandrake
/* /*
TRANSLATORS: If using the FTGL backend, this should be the path of a bold TRANSLATORS: If using the FTGL backend, this should be the path of a bold
font that contains all the Unicode characters in use in your translation. font that contains all the Unicode characters in use in your translation.
If the font is available in Mandrake it should be the Mandrake path. If the font is available in Mandrake it should be the Mandrake path.
*/ */
CHECK_FONT_PATH("/usr/share/fonts/TTF/uralic/GOTHUB__.TTF") CHECK_FONT_PATH("/usr/share/fonts/TTF/uralic/GOTHUB__.TTF","Gothic Uralic:style=Bold")
/* /*
TRANSLATORS: If using the FTGL backend, this should be the path of a TRANSLATORS: If using the FTGL backend, this should be the path of a
font that contains all the Unicode characters in use in your translation. font that contains all the Unicode characters in use in your translation.
If the font is available in Mandrake it should be the Mandrake path. If the font is available in Mandrake it should be the Mandrake path.
*/ */
CHECK_FONT_PATH("/usr/share/fonts/TTF/uralic/GOTHU___.TTF") CHECK_FONT_PATH("/usr/share/fonts/TTF/uralic/GOTHU___.TTF","Gothic Uralic:style=Regular")
// Check the non-translated versions of the above // Check the non-translated versions of the above
CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothub__.ttf") CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothub__.ttf","Gothic Uralic:style=Regular")
CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothu___.ttf") CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothu___.ttf","Gothic Uralic:style=Regular")
CHECK_FONT_PATH("/usr/share/fonts/TTF/uralic/GOTHUB__.TTF") CHECK_FONT_PATH("/usr/share/fonts/TTF/uralic/GOTHUB__.TTF","Gothic Uralic:style=Regular")
CHECK_FONT_PATH("/usr/share/fonts/TTF/uralic/GOTHU___.TTF") CHECK_FONT_PATH("/usr/share/fonts/TTF/uralic/GOTHU___.TTF","Gothic Uralic:style=Regular")
CHECK_FONT_PATH("/usr/share/fonts/truetype/linux-libertine/LinLibertine_Re.ttf") CHECK_FONT_PATH("/usr/share/fonts/truetype/linux-libertine/LinLibertine_Re.ttf","Linux Libertine O:style=Regular")
CHECK_FONT_PATH("/usr/share/fonts/truetype/freefont/FreeSerif.ttf") CHECK_FONT_PATH("/usr/share/fonts/truetype/freefont/FreeSerif.ttf","FreeSerif")
CHECK_FONT_PATH("/usr/share/fonts/truetype/freefont/FreeSans.ttf") CHECK_FONT_PATH("/usr/share/fonts/truetype/freefont/FreeSans.ttf","FreeSans")
CHECK_FONT_PATH("/usr/share/fonts/truetype/freefont/FreeMono.ttf") CHECK_FONT_PATH("/usr/share/fonts/truetype/freefont/FreeMono.ttf","FreeMono")
#ifdef _WIN32 #ifdef _WIN32
CHECK_FONT_PATH("c:\\windows\\fonts\\verdana.ttf") CHECK_FONT_PATH("c:\\windows\\fonts\\verdana.ttf",NULL)
CHECK_FONT_PATH("c:\\windows\\fonts\\tahoma.ttf") CHECK_FONT_PATH("c:\\windows\\fonts\\tahoma.ttf",NULL)
CHECK_FONT_PATH("c:\\windows\\fonts\\arial.ttf") CHECK_FONT_PATH("c:\\windows\\fonts\\arial.ttf",NULL)
CHECK_FONT_PATH("\\windows\\fonts\\arial.ttf") CHECK_FONT_PATH("\\windows\\fonts\\arial.ttf",NULL)
#endif #endif
return font; return font;

View File

@ -19,7 +19,7 @@ Text::Text(FontTextHandlerType type) {
this->type = type; this->type = type;
} }
Text::~Text() {} Text::~Text() {}
void Text::init(string fontName, int fontSize) {} void Text::init(string fontName, string fontFamilyName, int fontSize) {}
void Text::Render(const char*, const int) {} void Text::Render(const char*, const int) {}
float Text::Advance(const char*, const int) {return 0;} float Text::Advance(const char*, const int) {return 0;}
float Text::LineHeight(const char*, const int) {return 0;} float Text::LineHeight(const char*, const int) {return 0;}

View File

@ -84,17 +84,16 @@ void Font3DGl::end() {
}}}//end namespace }}}//end namespace
namespace Shared { namespace Graphics { //namespace Shared { namespace Graphics {
//
using namespace Gl; // using namespace Gl;
Font3D * ConvertFont2DTo3D(Font2D *font) { //Font3D * ConvertFont2DTo3D(Font2D *font) {
//
Font3D *result = new Font3DGl(); // Font3D *result = new Font3DGl();
result->setSize(font->getSize()); // result->setSize(font->getSize());
result->setType("",font->getType()); // result->setType("",font->getType());
result->setWidth(font->getWidth()); // result->setWidth(font->getWidth());
result->init(); // result->init();
return result; // return result;
} //}
//}}
}}

View File

@ -123,9 +123,9 @@ void TextFTGL::cleanupFont() {
fontFile = NULL; fontFile = NULL;
} }
void TextFTGL::init(string fontName, int fontSize) { void TextFTGL::init(string fontName, string fontFamilyName, int fontSize) {
cleanupFont(); cleanupFont();
fontFile = findFont(fontName.c_str()); fontFile = findFont(fontName.c_str(),fontFamilyName.c_str());
//ftFont = new FTBufferFont(fontFile); //ftFont = new FTBufferFont(fontFile);
//ftFont = new FTGLPixmapFont(fontFile); //ftFont = new FTGLPixmapFont(fontFile);

View File

@ -52,10 +52,11 @@ void TextFreetypeGL::cleanupFont() {
} }
} }
void TextFreetypeGL::init(string fontName, int fontSize) { void TextFreetypeGL::init(string fontName, string fontFamilyName, int fontSize) {
cleanupFont(); cleanupFont();
this->fontName = fontName; this->fontName = fontName;
this->fontFile = findFont(this->fontName.c_str()); this->fontFamilyName = fontFamilyName;
this->fontFile = findFont(this->fontName.c_str(),this->fontFamilyName.c_str());
this->fontFaceSize = fontSize; this->fontFaceSize = fontSize;
const wchar_t *cache = L" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; const wchar_t *cache = L" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";