Commit | Line | Data |
---|---|---|
b311480e | 1 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
2 | // | |
3 | // The content of this file is subject to the Open CASCADE Technology Public | |
4 | // License Version 6.5 (the "License"). You may not use the content of this file | |
5 | // except in compliance with the License. Please obtain a copy of the License | |
6 | // at http://www.opencascade.org and read it completely before using this file. | |
7 | // | |
8 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its | |
9 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. | |
10 | // | |
11 | // The Original Code and all software distributed under the License is | |
12 | // distributed on an "AS IS" basis, without warranty of any kind, and the | |
13 | // Initial Developer hereby disclaims all such warranties, including without | |
14 | // limitation, any warranties of merchantability, fitness for a particular | |
15 | // purpose or non-infringement. Please see the License for the specific terms | |
16 | // and conditions governing the rights and limitations under the License. | |
17 | ||
7fd59977 | 18 | #ifndef OPENGL_FONT_MGR_H |
19 | #define OPENGL_FONT_MGR_H | |
20 | ||
7fd59977 | 21 | #ifdef WNT |
22 | # include <windows.h> | |
23 | # include <stdlib.h> | |
24 | #endif | |
25 | ||
26 | #include <FTFont.h> | |
27 | ||
28 | #include <InterfaceGraphic.hxx> | |
29 | #include <TCollection_HAsciiString.hxx> | |
30 | #include <NCollection_List.hxx> | |
31 | #include <NCollection_DataMap.hxx> | |
32 | #include <Graphic3d_NListOfHAsciiString.hxx> | |
33 | #include <OSD_FontMgr.hxx> | |
34 | ||
35 | void dump_texture(); | |
36 | ||
37 | class OpenGl_FontMgr | |
38 | { | |
13a22457 | 39 | public: |
7fd59977 | 40 | static OpenGl_FontMgr* instance(); |
41 | ||
42 | int request_font( const Handle(TCollection_HAsciiString)& fontName, | |
13a22457 S |
43 | const OSD_FontAspect fontAspect, |
44 | const Standard_Integer fontHeight ); | |
7fd59977 | 45 | |
46 | void render_text( const Standard_Integer id, | |
13a22457 S |
47 | const wchar_t* text, |
48 | const Standard_Boolean is2d = Standard_False ); | |
7fd59977 | 49 | |
50 | //render text by last requested font | |
13a22457 S |
51 | void render_text( const wchar_t* text, |
52 | const Standard_Boolean is2d = Standard_False ); | |
7fd59977 | 53 | |
54 | //returns direct access to FTGL font | |
55 | //Warning: don't change font pointer. | |
56 | const FTFont* fontById( const Standard_Integer id ); | |
57 | ||
58 | //returns width of string | |
13a22457 | 59 | Standard_ShortReal computeWidth( const Standard_Integer id, const wchar_t *str ); |
7fd59977 | 60 | |
61 | bool requestFontList( Graphic3d_NListOfHAsciiString& ); | |
62 | ||
63 | void setCurrentScale( const Standard_ShortReal xScale = 1.f, | |
64 | const Standard_ShortReal yScale = 1.f); | |
65 | ||
66 | private: | |
67 | OpenGl_FontMgr(); | |
68 | OpenGl_FontMgr( const OpenGl_FontMgr& ){}; | |
69 | OpenGl_FontMgr& operator = ( const OpenGl_FontMgr&){ return *this;}; | |
70 | ~OpenGl_FontMgr(){}; | |
71 | ||
72 | void _initializeFontDB(); | |
73 | ||
74 | typedef NCollection_List<Standard_Integer> IDList; | |
75 | ||
76 | struct OGLFont_SysInfo { | |
77 | Handle(OSD_SystemFont) SysFont; | |
78 | IDList GeneratedFonts; | |
79 | }; | |
80 | ||
81 | struct OGLFont_Cache { | |
82 | FTFont* Font; | |
83 | Standard_Integer FontHeight; | |
84 | GLCONTEXT GlContext; | |
85 | }; | |
86 | ||
87 | typedef NCollection_List<OGLFont_SysInfo*> FontDataBase; | |
88 | typedef FontDataBase::Iterator FontDBIt; | |
89 | typedef NCollection_DataMap<Standard_Integer,OGLFont_Cache> FontCache; | |
90 | typedef FontCache::Iterator FCacheIt; | |
91 | ||
92 | FontDataBase _FontDB; | |
93 | FontCache _FontCache; | |
94 | ||
95 | Standard_Integer _CurrentFontId; | |
96 | ||
97 | Standard_ShortReal _XCurrentScale, | |
98 | _YCurrentScale; | |
99 | }; | |
100 | ||
101 | #endif //OPENGL_FONT_MGR_H |