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
26 #ifdef HAVE_FTGL_UPPERCASE
29 #include <FTGL/ftgl.h>
32 #include <InterfaceGraphic.hxx>
33 #include <TCollection_HAsciiString.hxx>
34 #include <NCollection_List.hxx>
35 #include <NCollection_DataMap.hxx>
36 #include <Graphic3d_NListOfHAsciiString.hxx>
37 #include <OSD_FontMgr.hxx>
44 static OpenGl_FontMgr* instance();
46 int request_font( const Handle(TCollection_HAsciiString)& fontName,
47 const OSD_FontAspect fontAspect,
48 const Standard_Integer fontHeight );
50 void render_text( const Standard_Integer id,
52 const Standard_Boolean is2d = Standard_False );
54 //render text by last requested font
55 void render_text( const wchar_t* text,
56 const Standard_Boolean is2d = Standard_False );
58 //returns direct access to FTGL font
59 //Warning: don't change font pointer.
60 const FTFont* fontById( const Standard_Integer id );
62 //returns width of string
63 Standard_ShortReal computeWidth( const Standard_Integer id, const wchar_t *str );
65 bool requestFontList( Graphic3d_NListOfHAsciiString& );
67 void setCurrentScale( const Standard_ShortReal xScale = 1.f,
68 const Standard_ShortReal yScale = 1.f);
72 OpenGl_FontMgr( const OpenGl_FontMgr& ){};
73 OpenGl_FontMgr& operator = ( const OpenGl_FontMgr&){ return *this;};
76 void _initializeFontDB();
78 typedef NCollection_List<Standard_Integer> IDList;
80 struct OGLFont_SysInfo {
81 Handle(OSD_SystemFont) SysFont;
82 IDList GeneratedFonts;
85 struct OGLFont_Cache {
87 Standard_Integer FontHeight;
91 typedef NCollection_List<OGLFont_SysInfo*> FontDataBase;
92 typedef FontDataBase::Iterator FontDBIt;
93 typedef NCollection_DataMap<Standard_Integer,OGLFont_Cache> FontCache;
94 typedef FontCache::Iterator FCacheIt;
99 Standard_Integer _CurrentFontId;
101 Standard_ShortReal _XCurrentScale,
105 #endif //OPENGL_FONT_MGR_H