2010-05-03 08:16:32 +02:00
|
|
|
// ==============================================================
|
|
|
|
// This file is part of Glest Shared Library (www.glest.org)
|
|
|
|
//
|
2010-09-07 07:25:40 +02:00
|
|
|
// Copyright (C) 2001-2008 Martio Figueroa
|
2010-05-03 08:16:32 +02:00
|
|
|
//
|
|
|
|
// You can redistribute this code and/or modify it under
|
|
|
|
// the terms of the GNU General Public License as published
|
|
|
|
// by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version
|
|
|
|
// ==============================================================
|
|
|
|
|
|
|
|
#ifndef _SHARED_GRAPHICS_FONT_H_
|
|
|
|
#define _SHARED_GRAPHICS_FONT_H_
|
|
|
|
|
|
|
|
#include <string>
|
2011-06-08 09:18:06 +02:00
|
|
|
#include "font_text.h"
|
2010-09-07 07:25:40 +02:00
|
|
|
#include "leak_dumper.h"
|
2010-05-03 08:16:32 +02:00
|
|
|
|
|
|
|
using std::string;
|
|
|
|
|
2011-06-08 09:18:06 +02:00
|
|
|
//class Text;
|
2011-06-06 23:38:25 +02:00
|
|
|
|
|
|
|
namespace Shared { namespace Graphics {
|
2010-05-03 08:16:32 +02:00
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
// class FontMetrics
|
|
|
|
// =====================================================
|
|
|
|
|
2011-06-06 23:38:25 +02:00
|
|
|
class FontMetrics {
|
2011-06-08 09:18:06 +02:00
|
|
|
|
2010-05-03 08:16:32 +02:00
|
|
|
private:
|
|
|
|
float *widths;
|
|
|
|
float height;
|
2011-06-08 09:18:06 +02:00
|
|
|
|
2011-07-02 03:56:06 +02:00
|
|
|
//float yOffsetFactor;
|
2011-06-06 23:38:25 +02:00
|
|
|
Text *textHandler;
|
2010-05-03 08:16:32 +02:00
|
|
|
|
|
|
|
public:
|
2011-07-02 03:56:06 +02:00
|
|
|
//static float DEFAULT_Y_OFFSET_FACTOR;
|
2011-06-08 09:18:06 +02:00
|
|
|
|
2011-06-06 23:38:25 +02:00
|
|
|
FontMetrics(Text *textHandler=NULL);
|
2010-05-03 08:16:32 +02:00
|
|
|
~FontMetrics();
|
|
|
|
|
2011-07-02 03:56:06 +02:00
|
|
|
//void setYOffsetFactor(float yOffsetFactor);
|
|
|
|
//float getYOffsetFactor() const;
|
2011-06-08 09:18:06 +02:00
|
|
|
|
2011-06-06 23:38:25 +02:00
|
|
|
void setTextHandler(Text *textHandler);
|
|
|
|
Text * getTextHandler();
|
|
|
|
|
|
|
|
void setWidth(int i, float width) {this->widths[i] = width;}
|
2010-05-03 08:16:32 +02:00
|
|
|
void setHeight(float height) {this->height= height;}
|
|
|
|
|
2011-06-06 23:38:25 +02:00
|
|
|
float getTextWidth(const string &str);
|
2010-05-03 08:16:32 +02:00
|
|
|
float getHeight() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
// class Font
|
|
|
|
// =====================================================
|
|
|
|
|
2011-06-06 23:38:25 +02:00
|
|
|
class Font {
|
2010-05-03 08:16:32 +02:00
|
|
|
public:
|
|
|
|
static int charCount;
|
|
|
|
static std::string fontTypeName;
|
2011-05-25 23:11:12 +02:00
|
|
|
static bool fontIsMultibyte;
|
2011-06-08 09:18:06 +02:00
|
|
|
static bool forceLegacyFonts;
|
2011-11-18 20:53:56 +01:00
|
|
|
static bool forceFTGLFonts;
|
2011-06-09 07:54:04 +02:00
|
|
|
static bool fontIsRightToLeft;
|
2011-06-28 08:18:24 +02:00
|
|
|
static float scaleFontValue;
|
2011-07-02 03:56:06 +02:00
|
|
|
static float scaleFontValueCenterHFactor;
|
2011-06-30 01:48:48 +02:00
|
|
|
static int baseSize;
|
2011-07-01 03:18:47 +02:00
|
|
|
static int faceResolution;
|
2011-07-02 20:33:59 +02:00
|
|
|
static string langHeightText;
|
2010-05-03 08:16:32 +02:00
|
|
|
|
|
|
|
public:
|
2011-06-06 23:38:25 +02:00
|
|
|
enum Width {
|
2010-05-03 08:16:32 +02:00
|
|
|
wNormal= 400,
|
|
|
|
wBold= 700
|
|
|
|
};
|
|
|
|
|
|
|
|
protected:
|
|
|
|
string type;
|
|
|
|
int width;
|
|
|
|
bool inited;
|
2011-06-08 09:18:06 +02:00
|
|
|
int size;
|
2010-05-03 08:16:32 +02:00
|
|
|
FontMetrics metrics;
|
|
|
|
|
2011-06-06 23:38:25 +02:00
|
|
|
Text *textHandler;
|
|
|
|
|
2010-05-03 08:16:32 +02:00
|
|
|
public:
|
|
|
|
//constructor & destructor
|
2011-06-08 09:18:06 +02:00
|
|
|
Font(FontTextHandlerType type);
|
2011-06-06 23:38:25 +02:00
|
|
|
virtual ~Font();
|
2010-05-03 08:16:32 +02:00
|
|
|
virtual void init()=0;
|
|
|
|
virtual void end()=0;
|
|
|
|
|
|
|
|
//get
|
2011-06-06 23:38:25 +02:00
|
|
|
int getWidth() const;
|
|
|
|
FontMetrics *getMetrics() {return &metrics;}
|
|
|
|
Text * getTextHandler() {return textHandler;}
|
2011-06-08 09:18:06 +02:00
|
|
|
string getType() const;
|
2010-05-03 08:16:32 +02:00
|
|
|
|
|
|
|
//set
|
2011-06-06 23:38:25 +02:00
|
|
|
void setType(string typeX11, string typeGeneric);
|
|
|
|
void setWidth(int width);
|
2011-06-08 09:18:06 +02:00
|
|
|
|
|
|
|
int getSize() const;
|
|
|
|
void setSize(int size);
|
2011-10-25 20:39:11 +02:00
|
|
|
|
|
|
|
static void resetToDefaults();
|
2010-05-03 08:16:32 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
// class Font2D
|
|
|
|
// =====================================================
|
|
|
|
|
2011-06-06 23:38:25 +02:00
|
|
|
class Font2D: public Font {
|
2010-05-03 08:16:32 +02:00
|
|
|
|
|
|
|
public:
|
2011-06-08 09:18:06 +02:00
|
|
|
Font2D(FontTextHandlerType type=ftht_2D);
|
2011-06-06 23:38:25 +02:00
|
|
|
virtual ~Font2D() {};
|
2010-05-03 08:16:32 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
// class Font3D
|
|
|
|
// =====================================================
|
|
|
|
|
2011-06-06 23:38:25 +02:00
|
|
|
class Font3D: public Font {
|
2010-05-03 08:16:32 +02:00
|
|
|
protected:
|
|
|
|
float depth;
|
|
|
|
|
|
|
|
public:
|
2011-06-08 09:18:06 +02:00
|
|
|
Font3D(FontTextHandlerType type=ftht_3D);
|
2011-06-06 23:38:25 +02:00
|
|
|
virtual ~Font3D() {};
|
2010-05-03 08:16:32 +02:00
|
|
|
|
|
|
|
float getDepth() const {return depth;}
|
|
|
|
void setDepth(float depth) {this->depth= depth;}
|
|
|
|
};
|
|
|
|
|
2011-06-08 09:18:06 +02:00
|
|
|
Font3D *ConvertFont2DTo3D(Font2D *font);
|
|
|
|
|
2010-05-03 08:16:32 +02:00
|
|
|
}}//end namespace
|
|
|
|
|
|
|
|
#endif
|