2 #include "FTGL/FTGLBitmapFont.h"
3 #include "FTGL/FTGLExtrdFont.h"
4 #include "FTGL/FTGLOutlineFont.h"
5 #include "FTGL/FTGLPixmapFont.h"
6 #include "FTGL/FTGLPolygonFont.h"
7 #include "FTGL/FTGLTextureFont.h"
8 #include "FTGL/FTLibrary.h"
12 FT_Error
ftgl_initialise();
14 FTGLBitmapFont
* ftgl_new_bitmap_font(const char* filename
);
15 FTGLExtrdFont
* ftgl_new_extrd_font(const char* filename
);
16 FTGLOutlineFont
* ftgl_new_outline_font(const char* filename
);
17 FTGLPixmapFont
* ftgl_new_pixmap_font(const char* filename
);
18 FTGLPolygonFont
* ftgl_new_polygon_font(const char* filename
);
19 FTGLTextureFont
* ftgl_new_texture_font(const char* filename
);
21 FT_Encoding
ftgl_get_encoding(const char* name
);
23 void ftgl_font_delete(FTFont
* font
);
25 FT_Encoding
ftgl_find_encoding(const char* name
);
26 void ftgl_font_set_charmap(FTFont
* font
, FT_Encoding charmap
);
28 void ftgl_font_set_face_size(FTFont
* font
, unsigned int size
, unsigned int res
);
29 unsigned int ftgl_font_get_face_size(FTFont
* font
);
31 void ftgl_font_set_depth(FTFont
* font
, float depth
);
33 float ftgl_font_advance(FTFont
* font
, const char* string
);
34 float ftgl_font_advance_wide(FTFont
* font
, const wchar_t* string
);
35 void ftgl_font_render(FTFont
* font
, const char* string
);
36 void ftgl_font_render_wide(FTFont
* font
, const wchar_t* string
);
38 float ftgl_font_line_height(FTFont
* font
);
39 float ftgl_font_ascender(FTFont
* font
);
40 float ftgl_font_descender(FTFont
* font
);
42 void ftgl_font_use_display_list(FTFont
* font
, char useList
);
44 void ftgl_font_get_bbox(FTFont
* font
, const char* string
, float bbox
[6]);
45 void ftgl_font_get_bbox_wide(FTFont
* font
, const wchar_t* string
, float bbox
[6]);
47 const char* ftgl_font_error(FTFont
* font
);
52 FT_Error
ftgl_initialise() {return FTLibrary::Instance().Error();}
54 FTGLBitmapFont
* ftgl_new_bitmap_font(const char* filename
) {return new FTGLBitmapFont(filename
);}
55 FTGLExtrdFont
* ftgl_new_extrd_font(const char* filename
) {return new FTGLExtrdFont(filename
);}
56 FTGLOutlineFont
* ftgl_new_outline_font(const char* filename
) {return new FTGLOutlineFont(filename
);}
57 FTGLPixmapFont
* ftgl_new_pixmap_font(const char* filename
) {return new FTGLPixmapFont(filename
);}
58 FTGLPolygonFont
* ftgl_new_polygon_font(const char* filename
) {return new FTGLPolygonFont(filename
);}
59 FTGLTextureFont
* ftgl_new_texture_font(const char* filename
) {return new FTGLTextureFont(filename
);}
61 FT_Encoding
ftgl_find_encoding(const char* name
)
63 if (strcmp(name
, "UNICODE")==0) { return FT_ENCODING_UNICODE
; }
64 if (strcmp(name
, "MS-SYMBOL")==0) { return FT_ENCODING_MS_SYMBOL
; }
65 if (strcmp(name
, "SJIS")==0) { return FT_ENCODING_SJIS
; }
66 if (strcmp(name
, "GB2312")==0) { return FT_ENCODING_GB2312
; }
67 if (strcmp(name
, "BIG5")==0) { return FT_ENCODING_BIG5
; }
68 if (strcmp(name
, "WANSUNG")==0) { return FT_ENCODING_WANSUNG
; }
69 if (strcmp(name
, "JOHAB")==0) { return FT_ENCODING_JOHAB
; }
70 if (strcmp(name
, "ADOBE-STANDARD")==0) { return FT_ENCODING_ADOBE_STANDARD
; }
71 if (strcmp(name
, "ADOBE-EXPERT")==0) { return FT_ENCODING_ADOBE_EXPERT
; }
72 if (strcmp(name
, "ADOBE-CUSTOM")==0) { return FT_ENCODING_ADOBE_CUSTOM
; }
73 if (strcmp(name
, "ADOBE-LATIN-1")==0) { return FT_ENCODING_ADOBE_LATIN_1
; }
74 if (strcmp(name
, "OLD-LATIN-2")==0) { return FT_ENCODING_OLD_LATIN_2
; }
75 if (strcmp(name
, "APPLE-ROMAN")==0) { return FT_ENCODING_APPLE_ROMAN
; }
76 return FT_ENCODING_NONE
;
79 void ftgl_font_set_charmap(FTFont
* font
, FT_Encoding charmap
) {font
->CharMap(charmap
);}
81 void ftgl_font_delete(FTFont
* font
) {delete font
;}
83 void ftgl_font_set_face_size(FTFont
* font
, unsigned int size
, unsigned int res
) {font
->FaceSize(size
,res
);}
84 unsigned int ftgl_font_get_face_size(FTFont
* font
) {return font
->FaceSize();}
85 void ftgl_font_set_depth(FTFont
* font
, float depth
){ font
->Depth(depth
);}
87 float ftgl_font_advance(FTFont
* font
, const char* string
) {return font
->Advance(string
);}
88 float ftgl_font_advance_wide(FTFont
* font
, const wchar_t* string
) {return font
->Advance(string
);}
89 void ftgl_font_render(FTFont
* font
, const char* string
) {font
->Render(string
);}
90 void ftgl_font_render_wide(FTFont
* font
, const wchar_t* string
) {font
->Render(string
);}
92 float ftgl_font_line_height(FTFont
* font
) {return font
->LineHeight();}
93 float ftgl_font_ascender(FTFont
* font
) {return font
->Ascender();}
94 float ftgl_font_descender(FTFont
* font
) {return font
->Descender();}
96 void ftgl_font_use_display_list(FTFont
* font
, char useList
) { font
->UseDisplayList(useList
); }
98 void ftgl_font_get_bbox(FTFont
* font
, const char* string
, float bbox
[6])
100 font
->BBox(string
, bbox
[0], bbox
[1], bbox
[2], bbox
[3], bbox
[4], bbox
[5]);
102 void ftgl_font_get_bbox_wide(FTFont
* font
, const wchar_t* string
, float bbox
[6])
104 font
->BBox(string
, bbox
[0], bbox
[1], bbox
[2], bbox
[3], bbox
[4], bbox
[5]);
108 #undef __FTERRORS_H__
109 #define FT_ERRORDEF( e, v, s ) { e, s },
110 #define FT_ERROR_START_LIST {
111 #define FT_ERROR_END_LIST { 0, 0 } };
118 const FreetypeError ft_errors
[] =
122 const char* ftgl_font_error(FTFont
* font
) {
123 int errcode
=font
->Error();
126 for (int i
=0; ft_errors
[i
].err_msg
; i
++)
128 if (errcode
==ft_errors
[i
].err_code
)
130 return ft_errors
[i
].err_msg
;
133 return "Unknown error!";
138 int sizeof_wchar_t() { return sizeof(wchar_t); }