- added some bug fixes to check if lng files are utf-8 or not and deal with it appropriately

This commit is contained in:
Mark Vejvoda
2011-06-08 07:18:06 +00:00
parent bf9702cdca
commit f65bfe8710
29 changed files with 3072 additions and 83 deletions

View File

@@ -13,11 +13,12 @@
#define _SHARED_GRAPHICS_FONT_H_
#include <string>
#include "font_text.h"
#include "leak_dumper.h"
using std::string;
class Text;
//class Text;
namespace Shared { namespace Graphics {
@@ -26,15 +27,23 @@ namespace Shared { namespace Graphics {
// =====================================================
class FontMetrics {
private:
float *widths;
float height;
float yOffsetFactor;
Text *textHandler;
public:
static float DEFAULT_Y_OFFSET_FACTOR;
FontMetrics(Text *textHandler=NULL);
~FontMetrics();
void setYOffsetFactor(float yOffsetFactor);
float getYOffsetFactor() const;
void setTextHandler(Text *textHandler);
Text * getTextHandler();
@@ -54,6 +63,7 @@ public:
static int charCount;
static std::string fontTypeName;
static bool fontIsMultibyte;
static bool forceLegacyFonts;
public:
enum Width {
@@ -65,13 +75,14 @@ protected:
string type;
int width;
bool inited;
int size;
FontMetrics metrics;
Text *textHandler;
public:
//constructor & destructor
Font();
Font(FontTextHandlerType type);
virtual ~Font();
virtual void init()=0;
virtual void end()=0;
@@ -81,10 +92,16 @@ public:
int getWidth() const;
FontMetrics *getMetrics() {return &metrics;}
Text * getTextHandler() {return textHandler;}
float getYOffsetFactor() const;
string getType() const;
//set
void setYOffsetFactor(float yOffsetFactor);
void setType(string typeX11, string typeGeneric);
void setWidth(int width);
int getSize() const;
void setSize(int size);
};
// =====================================================
@@ -93,14 +110,11 @@ public:
class Font2D: public Font {
protected:
int size;
//int size;
public:
Font2D();
Font2D(FontTextHandlerType type=ftht_2D);
virtual ~Font2D() {};
int getSize() const;
void setSize(int size);
};
// =====================================================
@@ -112,13 +126,15 @@ protected:
float depth;
public:
Font3D();
Font3D(FontTextHandlerType type=ftht_3D);
virtual ~Font3D() {};
float getDepth() const {return depth;}
void setDepth(float depth) {this->depth= depth;}
};
Font3D *ConvertFont2DTo3D(Font2D *font);
}}//end namespace
#endif

View File

@@ -15,17 +15,25 @@
#include <string>
using std::string;
enum FontTextHandlerType {
ftht_2D,
ftht_3D
};
/**
* Base class upon which all text rendering calls are made.
*/
//====================================================================
class Text
{
protected:
FontTextHandlerType type;
public:
static std::string DEFAULT_FONT_PATH;
Text();
Text(FontTextHandlerType type);
virtual ~Text();
virtual void init(string fontName, int fontSize);

View File

@@ -18,7 +18,8 @@
#include "font_text.h"
namespace Shared{ namespace Graphics{ namespace Gl{
namespace Shared { namespace Graphics { namespace Gl {
/**
* Use FTGL for rendering text in OpenGL
*/
@@ -27,7 +28,7 @@ class TextFTGL : public Text
{
public:
TextFTGL();
TextFTGL(FontTextHandlerType type);
virtual ~TextFTGL();
virtual void init(string fontName, int fontSize);

View File

@@ -19,6 +19,7 @@ namespace Shared { namespace Graphics { namespace Gl {
class Font2DGl;
class Font3DGl;
class TextRenderer3DGl;
// =====================================================
// class TextRenderer2DGl
@@ -29,6 +30,9 @@ private:
Font2DGl *font;
bool rendering;
//Font3DGl *font3D;
//TextRenderer3DGl *tester;
public:
TextRenderer2DGl();
virtual ~TextRenderer2DGl();
@@ -42,7 +46,7 @@ public:
// class TextRenderer3DGl
// =====================================================
class TextRenderer3DGl: public TextRenderer3D{
class TextRenderer3DGl: public TextRenderer3D {
private:
Font3DGl *font;
bool rendering;
@@ -52,7 +56,7 @@ public:
virtual ~TextRenderer3DGl();
virtual void begin(Font3D *font);
virtual void render(const string &text, float x, float y, float size, bool centered);
virtual void render(const string &text, float x, float y, bool centered);
virtual void end();
};

View File

@@ -43,7 +43,7 @@ public:
virtual ~TextRenderer3D(){};
virtual void begin(Font3D *font)= 0;
virtual void render(const string &text, float x, float y, float size, bool centered= false)= 0;
virtual void render(const string &text, float x, float y, bool centered= false)= 0;
virtual void end()= 0;
};