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 | ||
c5fc362f | 26 | #ifdef HAVE_FTGL_UPPERCASE |
b10d190c | 27 | #include <FTGLTextureFont.h> |
c5fc362f | 28 | #else |
567148d8 | 29 | #include <FTGL/ftgl.h> |
c5fc362f | 30 | #endif |
7fd59977 | 31 | |
32 | #include <InterfaceGraphic.hxx> | |
33 | #include <TCollection_HAsciiString.hxx> | |
34 | #include <NCollection_List.hxx> | |
35 | #include <NCollection_DataMap.hxx> | |
36 | #include <Graphic3d_NListOfHAsciiString.hxx> | |
eeaaaefb | 37 | #include <Font_FontMgr.hxx> |
7fd59977 | 38 | |
39 | void dump_texture(); | |
40 | ||
41 | class OpenGl_FontMgr | |
42 | { | |
13a22457 | 43 | public: |
7fd59977 | 44 | static OpenGl_FontMgr* instance(); |
45 | ||
aff395a3 | 46 | int request_font (const Handle(TCollection_HAsciiString)& theFontName, |
47 | const Font_FontAspect theFontAspect, | |
48 | const Standard_Integer& theFontHeight); | |
7fd59977 | 49 | |
50 | void render_text( const Standard_Integer id, | |
13a22457 S |
51 | const wchar_t* text, |
52 | const Standard_Boolean is2d = Standard_False ); | |
7fd59977 | 53 | |
54 | //render text by last requested font | |
13a22457 S |
55 | void render_text( const wchar_t* text, |
56 | const Standard_Boolean is2d = Standard_False ); | |
7fd59977 | 57 | |
58 | //returns direct access to FTGL font | |
59 | //Warning: don't change font pointer. | |
60 | const FTFont* fontById( const Standard_Integer id ); | |
61 | ||
62 | //returns width of string | |
13a22457 | 63 | Standard_ShortReal computeWidth( const Standard_Integer id, const wchar_t *str ); |
7fd59977 | 64 | |
7fd59977 | 65 | void setCurrentScale( const Standard_ShortReal xScale = 1.f, |
66 | const Standard_ShortReal yScale = 1.f); | |
67 | ||
68 | private: | |
69 | OpenGl_FontMgr(); | |
70 | OpenGl_FontMgr( const OpenGl_FontMgr& ){}; | |
71 | OpenGl_FontMgr& operator = ( const OpenGl_FontMgr&){ return *this;}; | |
72 | ~OpenGl_FontMgr(){}; | |
73 | ||
74 | void _initializeFontDB(); | |
75 | ||
76 | typedef NCollection_List<Standard_Integer> IDList; | |
77 | ||
7fd59977 | 78 | struct OGLFont_Cache { |
79 | FTFont* Font; | |
80 | Standard_Integer FontHeight; | |
81 | GLCONTEXT GlContext; | |
82 | }; | |
83 | ||
aff395a3 | 84 | typedef NCollection_DataMap<Handle(Font_SystemFont), IDList> FontDataBase; |
85 | typedef FontDataBase::Iterator FontDBIterator; | |
86 | typedef NCollection_DataMap<Standard_Integer, OGLFont_Cache> FontCache; | |
87 | typedef FontCache::Iterator FontCacheIterator; | |
7fd59977 | 88 | |
aff395a3 | 89 | FontDataBase myGeneratedFontDB; |
90 | FontCache myGeneratedFontCache; | |
7fd59977 | 91 | |
aff395a3 | 92 | Standard_Integer myCurrentFontId; |
7fd59977 | 93 | |
aff395a3 | 94 | Standard_ShortReal myXCurrentScale, |
95 | myYCurrentScale; | |
7fd59977 | 96 | }; |
97 | ||
98 | #endif //OPENGL_FONT_MGR_H |