1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
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.
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.
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.
18 #ifndef OPENGL_FONT_MGR_H
19 #define OPENGL_FONT_MGR_H
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>
40 static OpenGl_FontMgr* instance();
42 int request_font( const Handle(TCollection_HAsciiString)& fontName,
43 const OSD_FontAspect fontAspect,
44 const Standard_Integer fontHeight );
46 void render_text( const Standard_Integer id,
48 const Standard_Boolean is2d = Standard_False );
50 //render text by last requested font
51 void render_text( const wchar_t* text,
52 const Standard_Boolean is2d = Standard_False );
54 //returns direct access to FTGL font
55 //Warning: don't change font pointer.
56 const FTFont* fontById( const Standard_Integer id );
58 //returns width of string
59 Standard_ShortReal computeWidth( const Standard_Integer id, const wchar_t *str );
61 bool requestFontList( Graphic3d_NListOfHAsciiString& );
63 void setCurrentScale( const Standard_ShortReal xScale = 1.f,
64 const Standard_ShortReal yScale = 1.f);
68 OpenGl_FontMgr( const OpenGl_FontMgr& ){};
69 OpenGl_FontMgr& operator = ( const OpenGl_FontMgr&){ return *this;};
72 void _initializeFontDB();
74 typedef NCollection_List<Standard_Integer> IDList;
76 struct OGLFont_SysInfo {
77 Handle(OSD_SystemFont) SysFont;
78 IDList GeneratedFonts;
81 struct OGLFont_Cache {
83 Standard_Integer FontHeight;
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;
95 Standard_Integer _CurrentFontId;
97 Standard_ShortReal _XCurrentScale,
101 #endif //OPENGL_FONT_MGR_H