- added packaged game fonts
- updated code to search new default font folder - added chinese language file from the fourm for testing
This commit is contained in:
parent
df178e5eb4
commit
226e8783c0
|
@ -1,7 +1,7 @@
|
|||
// ==============================================================
|
||||
// This file is part of Glest (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Marti�o Figueroa
|
||||
// Copyright (C) 2001-2008 Martiño Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
|
@ -151,11 +151,11 @@ string getAboutString2(int i){
|
|||
|
||||
string getTeammateName(int i) {
|
||||
switch(i) {
|
||||
case 0: return "Martiño Figueroa";
|
||||
case 1: return "José Luis González";
|
||||
case 2: return "Tucho Fernández";
|
||||
case 3: return "José Zanni";
|
||||
case 4: return "Félix Menéndez";
|
||||
case 0: return "Marti<EFBFBD>o Figueroa";
|
||||
case 1: return "Jos<EFBFBD> Luis Gonz<6E>lez";
|
||||
case 2: return "Tucho Fern<EFBFBD>ndez";
|
||||
case 3: return "Jos<EFBFBD> Zanni";
|
||||
case 4: return "F<EFBFBD>lix Men<65>ndez";
|
||||
case 5: return "Marcos Caruncho";
|
||||
case 6: return "Matthias Braun";
|
||||
case 7: return "Titus Tscharntke";
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "cache_manager.h"
|
||||
#include <iterator>
|
||||
#include "core_data.h"
|
||||
#include "font_text.h"
|
||||
//#include "unicode/uclean.h"
|
||||
|
||||
// For gcc backtrace on crash!
|
||||
|
@ -1148,6 +1149,7 @@ int setupGameItemPaths(int argc, char** argv, Config *config) {
|
|||
}
|
||||
}
|
||||
|
||||
Text::DEFAULT_FONT_PATH = pathCache[GameConstants::path_data_CacheLookupKey];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -2448,6 +2450,7 @@ int glestMain(int argc, char** argv) {
|
|||
FontGl::setDefault_fontType(config.getString("DefaultFont",FontGl::getDefault_fontType().c_str()));
|
||||
UPNP_Tools::isUPNP = !config.getBool("DisableUPNP","false");
|
||||
Texture::useTextureCompression = config.getBool("EnableTextureCompression","false");
|
||||
|
||||
// 256 for English
|
||||
// 30000 for Chinese
|
||||
Font::charCount = config.getInt("FONT_CHARCOUNT",intToStr(Font::charCount).c_str());
|
||||
|
|
|
@ -23,6 +23,8 @@ class Text
|
|||
{
|
||||
public:
|
||||
|
||||
static std::string DEFAULT_FONT_PATH;
|
||||
|
||||
Text();
|
||||
virtual ~Text();
|
||||
|
||||
|
|
|
@ -28,20 +28,15 @@ namespace Shared { namespace Graphics { namespace Gl {
|
|||
class FontGl {
|
||||
protected:
|
||||
|
||||
//#ifndef USE_FTGL
|
||||
GLuint handle;
|
||||
//#endif
|
||||
|
||||
static string default_fonttype;
|
||||
|
||||
public:
|
||||
|
||||
//#ifndef USE_FTGL
|
||||
GLuint getHandle() const {return handle;}
|
||||
//#endif
|
||||
GLuint getHandle() const {return handle;}
|
||||
|
||||
static string getDefault_fontType() { return default_fonttype; }
|
||||
static void setDefault_fontType(string value) { default_fonttype = value; }
|
||||
static string getDefault_fontType() {return default_fonttype;}
|
||||
static void setDefault_fontType(string value) {default_fonttype = value;}
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
|
|
|
@ -19,10 +19,6 @@ namespace Shared { namespace Graphics { namespace Gl {
|
|||
|
||||
class Font2DGl;
|
||||
class Font3DGl;
|
||||
//#ifdef USE_FTGL
|
||||
// class TextFTGL;
|
||||
//#endif
|
||||
|
||||
|
||||
// =====================================================
|
||||
// class TextRenderer2DGl
|
||||
|
@ -33,10 +29,6 @@ private:
|
|||
Font2DGl *font;
|
||||
bool rendering;
|
||||
|
||||
//#ifdef USE_FTGL
|
||||
// TextFTGL *fontFTGL;
|
||||
//#endif
|
||||
|
||||
public:
|
||||
TextRenderer2DGl();
|
||||
virtual ~TextRenderer2DGl();
|
||||
|
@ -55,10 +47,6 @@ private:
|
|||
Font3DGl *font;
|
||||
bool rendering;
|
||||
|
||||
//#ifdef USE_FTGL
|
||||
// TextFTGL *fontFTGL;
|
||||
//#endif
|
||||
|
||||
public:
|
||||
TextRenderer3DGl();
|
||||
virtual ~TextRenderer3DGl();
|
||||
|
|
|
@ -28,7 +28,7 @@ using namespace Shared::Graphics::Gl;
|
|||
using namespace std;
|
||||
using namespace Shared::Util;
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
namespace Shared { namespace Graphics {
|
||||
|
||||
// Init statics
|
||||
int Font::charCount = 256;
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
std::string Text::DEFAULT_FONT_PATH = "";
|
||||
|
||||
//====================================================================
|
||||
Text::Text() {}
|
||||
Text::~Text() {}
|
||||
|
|
|
@ -27,7 +27,6 @@ string FontGl::default_fonttype = "fixed";
|
|||
|
||||
void Font2DGl::init() {
|
||||
if(inited == false) {
|
||||
//#ifndef USE_FTGL
|
||||
if(getTextHandler() == NULL) {
|
||||
assertGl();
|
||||
handle= glGenLists(charCount);
|
||||
|
@ -36,21 +35,18 @@ void Font2DGl::init() {
|
|||
createGlFontBitmaps(handle, type, size, width, charCount, metrics);
|
||||
assertGl();
|
||||
}
|
||||
//#endif
|
||||
inited= true;
|
||||
}
|
||||
}
|
||||
|
||||
void Font2DGl::end() {
|
||||
if(inited) {
|
||||
//#ifndef USE_FTGL
|
||||
if(getTextHandler() == NULL) {
|
||||
assertGl();
|
||||
//assert(glIsList(handle));
|
||||
glDeleteLists(handle, 1);
|
||||
assertGl();
|
||||
}
|
||||
//#endif
|
||||
inited = false;
|
||||
}
|
||||
}
|
||||
|
@ -61,28 +57,24 @@ void Font2DGl::end() {
|
|||
|
||||
void Font3DGl::init() {
|
||||
if(inited == false) {
|
||||
//#ifndef USE_FTGL
|
||||
if(getTextHandler() == NULL) {
|
||||
assertGl();
|
||||
handle= glGenLists(charCount);
|
||||
createGlFontOutlines(handle, type, width, depth, charCount, metrics);
|
||||
assertGl();
|
||||
}
|
||||
//#endif
|
||||
inited= true;
|
||||
}
|
||||
}
|
||||
|
||||
void Font3DGl::end() {
|
||||
if(inited) {
|
||||
//#ifndef USE_FTGL
|
||||
if(getTextHandler() == NULL) {
|
||||
assertGl();
|
||||
assert(glIsList(handle));
|
||||
glDeleteLists(handle, 1);
|
||||
assertGl();
|
||||
}
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ TextFTGL::TextFTGL() {
|
|||
//setenv("MEGAGLEST_FONT","/usr/share/fonts/truetype/ttf-sil-doulos/DoulosSILR.ttf",0); // Russian / Cyrillic
|
||||
//setenv("MEGAGLEST_FONT","/usr/share/fonts/truetype/ttf-sil-charis/CharisSILR.ttf",0); // Russian / Cyrillic
|
||||
//setenv("MEGAGLEST_FONT","/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-R.ttf",0); // Russian / Cyrillic
|
||||
//setenv("MEGAGLEST_FONT","/usr/share/fonts/truetype/ttf-japanese-gothic.ttf",0); // Japanese
|
||||
//setenv("MEGAGLEST_FONT","/usr/share/fonts/truetype/takao/TakaoPGothic.ttf",0); // Japanese
|
||||
//setenv("MEGAGLEST_FONT","/usr/share/fonts/truetype/ttf-sil-scheherazade/ScheherazadeRegOT.ttf",0); // Arabic
|
||||
//setenv("MEGAGLEST_FONT","/usr/share/fonts/truetype/linux-libertine/LinLibertine_Re.ttf",0); // Hebrew
|
||||
//setenv("MEGAGLEST_FONT","/usr/share/fonts/truetype/unifont/unifont.ttf",0); // Czech?
|
||||
|
@ -219,6 +219,11 @@ const char* TextFTGL::findFont(const char *firstFontToTry) {
|
|||
}
|
||||
#endif
|
||||
|
||||
string data_path = Text::DEFAULT_FONT_PATH;
|
||||
const string defaultFont = data_path + "data/core/fonts/gothub__.ttf";
|
||||
|
||||
CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothub__.ttf")
|
||||
|
||||
// Check a couple of common paths for Gothic Uralic/bold as a last resort
|
||||
// Debian
|
||||
/*
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Martio Figueroa
|
||||
// Copyright (C) 2001-2008 Martiño Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
|
@ -15,14 +15,8 @@
|
|||
#include "font_gl.h"
|
||||
|
||||
#include "font_text.h"
|
||||
//#ifdef USE_FTGL
|
||||
//#include "font_textFTGL.h"
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
//#include "string_utils.h"
|
||||
//using namespace Shared::Util;
|
||||
//#endif
|
||||
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared { namespace Graphics { namespace Gl {
|
||||
|
@ -34,29 +28,16 @@ namespace Shared { namespace Graphics { namespace Gl {
|
|||
TextRenderer2DGl::TextRenderer2DGl() {
|
||||
rendering= false;
|
||||
this->font = NULL;
|
||||
//#ifdef USE_FTGL
|
||||
// fontFTGL = new TextFTGL();
|
||||
//#endif
|
||||
|
||||
}
|
||||
|
||||
TextRenderer2DGl::~TextRenderer2DGl() {
|
||||
//#ifdef USE_FTGL
|
||||
// delete fontFTGL;
|
||||
// fontFTGL = NULL;
|
||||
//#endif
|
||||
}
|
||||
|
||||
void TextRenderer2DGl::begin(Font2D *font) {
|
||||
assert(!rendering);
|
||||
rendering= true;
|
||||
|
||||
this->font= static_cast<Font2DGl*>(font);
|
||||
|
||||
//#ifdef USE_FTGL
|
||||
// this->font->getMetrics()->setHeight(fontFTGL->LineHeight(" "));
|
||||
// this->font->getMetrics()->setWidth(i,fontFTGL->Advance(" "));
|
||||
//#endif
|
||||
rendering = true;
|
||||
this->font = static_cast<Font2DGl*>(font);
|
||||
}
|
||||
|
||||
// Convert a narrow string to a wide string//
|
||||
|
@ -89,21 +70,20 @@ void TextRenderer2DGl::render(const string &text, int x, int y, bool centered, V
|
|||
const unsigned char *utext = NULL;
|
||||
FontMetrics *metrics = NULL;
|
||||
|
||||
Vec2f rasterPos;
|
||||
//#ifdef USE_FTGL
|
||||
if(font->getTextHandler() != NULL) {
|
||||
//font->getTextHandler()->SetFaceSize(size);
|
||||
//printf("font->getTextHandler() [%p] centered = %d text [%s]\n",font->getTextHandler(),centered,text.c_str());
|
||||
|
||||
Vec2f rasterPos;
|
||||
if(font->getTextHandler() != NULL) {
|
||||
if(centered) {
|
||||
rasterPos.x= x - font->getTextHandler()->Advance(text.c_str()) / 2.f;
|
||||
rasterPos.y= y + font->getTextHandler()->LineHeight(text.c_str()) / 2.f;
|
||||
}
|
||||
else {
|
||||
rasterPos= Vec2f(static_cast<float>(x), static_cast<float>(y));
|
||||
rasterPos.y= y + (font->getTextHandler()->LineHeight(text.c_str()) / 8.f);
|
||||
}
|
||||
}
|
||||
else {
|
||||
//#else
|
||||
utext= reinterpret_cast<const unsigned char*>(text.c_str());
|
||||
metrics= font->getMetrics();
|
||||
if(centered) {
|
||||
|
@ -114,12 +94,9 @@ void TextRenderer2DGl::render(const string &text, int x, int y, bool centered, V
|
|||
rasterPos= Vec2f(static_cast<float>(x), static_cast<float>(y));
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
glRasterPos2f(rasterPos.x, rasterPos.y);
|
||||
|
||||
if(Font::fontIsMultibyte == true) {
|
||||
|
||||
//#ifdef USE_FTGL
|
||||
if(font->getTextHandler() != NULL) {
|
||||
//String str("資料");
|
||||
//WString wstr(str);
|
||||
|
@ -228,8 +205,6 @@ void TextRenderer2DGl::render(const string &text, int x, int y, bool centered, V
|
|||
}
|
||||
}
|
||||
else {
|
||||
//#else
|
||||
|
||||
//setlocale(LC_CTYPE, "en_ca.UTF-8");
|
||||
|
||||
//wstring wText = widen(text);
|
||||
|
@ -252,11 +227,8 @@ void TextRenderer2DGl::render(const string &text, int x, int y, bool centered, V
|
|||
//glListBase(font->getHandle());
|
||||
//glCallLists(utfText.length(), GL_UNSIGNED_SHORT, &utfText[0]);
|
||||
}
|
||||
//#endif
|
||||
}
|
||||
else {
|
||||
|
||||
//#ifdef USE_FTGL
|
||||
if(font->getTextHandler() != NULL) {
|
||||
if(text.find("\n") == text.npos && text.find("\t") == text.npos) {
|
||||
font->getTextHandler()->Render(text.c_str());
|
||||
|
@ -314,7 +286,6 @@ void TextRenderer2DGl::render(const string &text, int x, int y, bool centered, V
|
|||
}
|
||||
}
|
||||
else {
|
||||
//#else
|
||||
for (int i=0; utext[i]!='\0'; ++i) {
|
||||
switch(utext[i]){
|
||||
case '\t':
|
||||
|
@ -331,7 +302,6 @@ void TextRenderer2DGl::render(const string &text, int x, int y, bool centered, V
|
|||
}
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
}
|
||||
|
||||
if(color != NULL) {
|
||||
|
@ -352,16 +322,9 @@ void TextRenderer2DGl::end() {
|
|||
TextRenderer3DGl::TextRenderer3DGl() {
|
||||
rendering= false;
|
||||
this->font = NULL;
|
||||
//#ifdef USE_FTGL
|
||||
// fontFTGL = new TextFTGL();
|
||||
//#endif
|
||||
}
|
||||
|
||||
TextRenderer3DGl::~TextRenderer3DGl() {
|
||||
//#ifdef USE_FTGL
|
||||
// delete fontFTGL;
|
||||
// fontFTGL = NULL;
|
||||
//#endif
|
||||
}
|
||||
|
||||
void TextRenderer3DGl::begin(Font3D *font) {
|
||||
|
@ -390,10 +353,7 @@ void TextRenderer3DGl::render(const string &text, float x, float y, float size,
|
|||
float scale= size / 10.f;
|
||||
Vec3f translatePos;
|
||||
|
||||
//#ifdef USE_FTGL
|
||||
if(font->getTextHandler() != NULL) {
|
||||
//font->getTextHandler()->SetFaceSize(size);
|
||||
|
||||
if(centered) {
|
||||
translatePos.x = x - scale * font->getTextHandler()->Advance(text.c_str()) / 2.f;
|
||||
translatePos.y = y - scale * font->getTextHandler()->LineHeight(text.c_str()) / 2.f;
|
||||
|
@ -406,7 +366,6 @@ void TextRenderer3DGl::render(const string &text, float x, float y, float size,
|
|||
}
|
||||
}
|
||||
else {
|
||||
//#else
|
||||
utext= reinterpret_cast<const unsigned char*>(text.c_str());
|
||||
if(centered) {
|
||||
FontMetrics *metrics= font->getMetrics();
|
||||
|
@ -422,14 +381,11 @@ void TextRenderer3DGl::render(const string &text, float x, float y, float size,
|
|||
translatePos.z = 0;
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
||||
glTranslatef(translatePos.x, translatePos.y, translatePos.z);
|
||||
glScalef(scale, scale, scale);
|
||||
|
||||
if(Font::fontIsMultibyte == true) {
|
||||
|
||||
//#ifdef USE_FTGL
|
||||
if(font->getTextHandler() != NULL) {
|
||||
if(text.find("\n") == text.npos && text.find("\t") == text.npos) {
|
||||
font->getTextHandler()->Render(text.c_str());
|
||||
|
@ -488,7 +444,6 @@ void TextRenderer3DGl::render(const string &text, float x, float y, float size,
|
|||
}
|
||||
}
|
||||
else {
|
||||
//#else
|
||||
//setlocale(LC_CTYPE, "en_ca.UTF-8");
|
||||
|
||||
//wstring wText = widen(text);
|
||||
|
@ -511,12 +466,10 @@ void TextRenderer3DGl::render(const string &text, float x, float y, float size,
|
|||
//glListBase(font->getHandle());
|
||||
//glCallLists(utfText.length(), GL_UNSIGNED_SHORT, &utfText[0]);
|
||||
}
|
||||
//#endif
|
||||
}
|
||||
else {
|
||||
|
||||
if(font->getTextHandler() != NULL) {
|
||||
//#ifdef USE_FTGL
|
||||
if(text.find("\n") == text.npos && text.find("\t") == text.npos) {
|
||||
font->getTextHandler()->Render(text.c_str());
|
||||
}
|
||||
|
@ -574,12 +527,10 @@ void TextRenderer3DGl::render(const string &text, float x, float y, float size,
|
|||
}
|
||||
}
|
||||
else {
|
||||
//#else
|
||||
for (int i=0; utext[i]!='\0'; ++i) {
|
||||
glCallList(font->getHandle()+utext[i]);
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
}
|
||||
glPopMatrix();
|
||||
glPopAttrib();
|
||||
|
|
|
@ -35,7 +35,6 @@ namespace Shared { namespace Platform {
|
|||
void createGlFontBitmaps(uint32 &base, const string &type, int size, int width,
|
||||
int charCount, FontMetrics &metrics) {
|
||||
|
||||
//#ifndef USE_FTGL
|
||||
Display* display = glXGetCurrentDisplay();
|
||||
if(display == 0) {
|
||||
throw std::runtime_error("Couldn't create font: display is 0");
|
||||
|
@ -146,7 +145,6 @@ void createGlFontBitmaps(uint32 &base, const string &type, int size, int width,
|
|||
|
||||
glXUseXFont(fontInfo->fid, 0, charCount, base);
|
||||
XFreeFont(display, fontInfo);
|
||||
//#endif
|
||||
}
|
||||
|
||||
void createGlFontOutlines(uint32 &base, const string &type, int width,
|
||||
|
|
|
@ -27,7 +27,6 @@ using namespace Shared::Util;
|
|||
|
||||
namespace Shared{ namespace Platform{
|
||||
|
||||
//#ifndef USE_FTGL
|
||||
// ======================================
|
||||
// Global Fcs
|
||||
// ======================================
|
||||
|
@ -40,13 +39,11 @@ int CALLBACK EnumFontFamExProc(ENUMLOGFONTEX *lpelfe,
|
|||
systemFontList->push_back((char *)lpelfe->elfFullName);
|
||||
return 1; // I want to get all fonts
|
||||
}
|
||||
//#endif
|
||||
|
||||
void createGlFontBitmaps(uint32 &base, const string &type, int size, int width,
|
||||
int charCount, FontMetrics &metrics) {
|
||||
//return;
|
||||
|
||||
//#ifndef USE_FTGL
|
||||
// -adecw-screen-medium-r-normal--18-180-75-75-m-160-gb2312.1980-1 this is a Chinese font
|
||||
|
||||
std::string useRealFontName = type;
|
||||
|
@ -173,7 +170,6 @@ void createGlFontBitmaps(uint32 &base, const string &type, int size, int width,
|
|||
//}
|
||||
|
||||
assert(err);
|
||||
//#endif
|
||||
}
|
||||
|
||||
void createGlFontOutlines(uint32 &base, const string &type, int width,
|
||||
|
|
Loading…
Reference in New Issue