blob: e551c7230ff0f9cbccca173e35211f28f81bd604 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#ifndef OPENGL_FONT_MGR_H
#define OPENGL_FONT_MGR_H
#ifdef WNT
# include <windows.h>
# include <stdlib.h>
#endif
#include <oce-config.h>
#ifdef HAVE_FTGL_NEWER212
# include <FTGL/ftgl.h>
#else
# include <FTGL/FTFont.h>
#endif
#include <InterfaceGraphic.hxx>
#include <TCollection_HAsciiString.hxx>
#include <NCollection_List.hxx>
#include <NCollection_DataMap.hxx>
#include <Graphic3d_NListOfHAsciiString.hxx>
#include <OSD_FontMgr.hxx>
void dump_texture();
class OpenGl_FontMgr
{
public:
static OpenGl_FontMgr* instance();
int request_font( const Handle(TCollection_HAsciiString)& fontName,
const OSD_FontAspect fontAspect,
const Standard_Integer fontHeight );
void render_text( const Standard_Integer id,
const wchar_t* text,
const Standard_Boolean is2d = Standard_False );
//render text by last requested font
void render_text( const wchar_t* text,
const Standard_Boolean is2d = Standard_False );
//returns direct access to FTGL font
//Warning: don't change font pointer.
const FTFont* fontById( const Standard_Integer id );
//returns width of string
Standard_ShortReal computeWidth( const Standard_Integer id, const wchar_t *str );
bool requestFontList( Graphic3d_NListOfHAsciiString& );
void setCurrentScale( const Standard_ShortReal xScale = 1.f,
const Standard_ShortReal yScale = 1.f);
private:
OpenGl_FontMgr();
OpenGl_FontMgr( const OpenGl_FontMgr& ){};
OpenGl_FontMgr& operator = ( const OpenGl_FontMgr&){ return *this;};
~OpenGl_FontMgr(){};
void _initializeFontDB();
typedef NCollection_List<Standard_Integer> IDList;
struct OGLFont_SysInfo {
Handle(OSD_SystemFont) SysFont;
IDList GeneratedFonts;
};
struct OGLFont_Cache {
FTFont* Font;
Standard_Integer FontHeight;
GLCONTEXT GlContext;
};
typedef NCollection_List<OGLFont_SysInfo*> FontDataBase;
typedef FontDataBase::Iterator FontDBIt;
typedef NCollection_DataMap<Standard_Integer,OGLFont_Cache> FontCache;
typedef FontCache::Iterator FCacheIt;
FontDataBase _FontDB;
FontCache _FontCache;
Standard_Integer _CurrentFontId;
Standard_ShortReal _XCurrentScale,
_YCurrentScale;
};
#endif //OPENGL_FONT_MGR_H
|