2
* Copyright 2010 Inalogic Inc.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License version 3, as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the applicable version of the GNU Lesser General Public
12
* License for more details.
14
* You should have received a copy of both the GNU Lesser General Public
15
* License version 3 along with this program. If not, see
16
* <http://www.gnu.org/licenses/>
18
* Authored by: Jay Taoko <jay.taoko_AT_gmail_DOT_com>
27
#include <windows.h> // Header File For Windows
31
// #include <gl\gl.h> // Header File For The OpenGL32 Library
32
// #include <gl\glu.h> // Header File For The GLu32 Library
33
// #include <gl\glaux.h>
39
// #include <GL/glx.h>
40
// #include <GL/glu.h>
45
/*#include "fmt_image.h"
48
#include "dbm_texturemgr.h"*/
51
#include <freetype/fttypes.h>
52
#include <freetype/freetype.h>
53
#include <freetype/ftglyph.h>
54
#include FT_FREETYPE_H
59
typedef enum _TextAlignment
85
int ybearing; // max ybearing of the string
86
int downline; // max downline of the string (max space below the baseline)
109
typedef struct _CharData
122
int xmin, xmax, ymin, ymax;
125
int bitmap_left_bearing;
126
int bitmap_top_bearing;
137
typedef struct _FontStyle
149
typedef struct _FontFamily
154
list <FontStyle*> *style_list;
164
static FontMgr *pinstance;
166
list <FontFamily*> *m_font_list;
168
static FontMgr* Instance();
174
bool load_font(const char* font_name);
175
int get_character_texture_id(const char *font_name, int encoding, CharData *cd);
176
int get_character_texture_id(int encoding, CharData *cd);
177
void get_style_texture_size(const char *font_name, int *width, int *height);
178
void get_style_texture_size(int *width, int *height);
179
void get_style_line_spacing(const char *font_name, int *line_spacing);
180
void get_style_line_spacing(int *line_spacing);
181
unsigned int get_null_character_texture_id(const char *font_name);
182
unsigned int get_null_character_texture_id();
183
bool find_font(const char *font_name, const char *style_name);
185
FontFamily* get_font_family(const char *font_name);
186
FontStyle* get_font_style(char *font_name, char *style_name);
188
void set_current_font(char *font_name, char *style_name);
189
void draw_text(int rect_xmin, int rect_ymin, int rect_xmax, int rect_ymax, const char *text, const char *sh_name);
191
void ComputeGlyphString(int x, int y, const char* text);
192
//unsigned int GetStringWidth(const char* text);
193
//unsigned int GetStringHeight(const char* text);
194
unsigned int GetStringWidth(const std::string& text);
195
unsigned int GetStringHeight(const std::string& text);
196
void ComputeStringBBox(StringBBox &stringBBox, const char* text);
197
void PositionString(const PageBBox&, StringBBox&, TextAlignment align = eAlignTextCenter);
199
//void RenderGlyph(int targer_width, int target_height);
200
void RenderGlyph(const PageBBox& pageSize, const char* text, TextAlignment align = eAlignTextCenter);
201
void RenderString(const PageBBox& pageSize, const std::string& Str, TextAlignment alignment, unsigned int CursorPosition, int offset = 0);
202
void RenderTextLineEdit(const PageBBox& pageSize, const std::string& Str, unsigned int CursorPosition, int offset = 0);
203
void RenderTextLineStatic(const PageBBox& pageSize, const std::string& Str, TextAlignment alignment, char trailingchar = 0);