ubit
uhardfont.hpp
1 /* ***********************************************************************
2  *
3  * uhardfont.hpp
4  * Ubit GUI Toolkit - Version 6.0
5  * (C) 1999-2008 Eric Lecolinet | ENST Paris | www.enst.fr/~elc/ubit
6  *
7  * ***********************************************************************
8  * COPYRIGHT NOTICE :
9  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE
10  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
11  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU
12  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
13  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
14  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
15  * ***********************************************************************/
16 
17 #ifndef _uhardfont_hpp_
18 #define _uhardfont_hpp_ 1
19 #include <ubit/ubit_features.h>
20 
21 #if WITH_2D_GRAPHICS
22 #if UBIT_WITH_X11
23 # include <X11/Xlib.h>
24 #elif UBIT_WITH_GDK
25 # include <gdk/gdk.h>
26 #endif
27 #endif
28 
29 class FTFont;
30 
31 namespace ubit {
32 
35 class UHardFont {
36 public:
37  enum {NO_FONT=0, SYS_FONT, GLX_FONT, FTGL_FONT};
38 
39  UHardFont(UDisp*, const UFontDesc&);
40  ~UHardFont();
41 
42  void drawString(const char* str, int str_len, float x, float y) const;
43 
44  bool isReady() {return status > NO_FONT;}
45  int getStatus() {return status;}
46  float getAscent() const;
47  float getDescent() const;
48  float getHeight() const;
49  float getWidth(char) const;
50  float getWidth(const char* str, int len = -1) const;
51 
52 private:
53  friend class UDisp;
54  friend class UGraph;
55  short status, count;
56 
57 #if UBIT_WITH_GL
58  union {
59  unsigned int glf; //GLuint glf;
60  FTFont* ftf;
61  };
62  FTFont* loadFTGLFont(UDisp*, const UFontDesc&);
64 #endif
65 
66 #if WITH_2D_GRAPHICS
67 # if UBIT_WITH_X11
68  friend class UX11context;
69  XFontStruct* sysf;
70  XFontStruct* loadSysFont(UDisp*, const UFontDesc&);
71 # elif UBIT_WITH_GDK
72  friend class UGDKContext;
73  GdkFont* sysf;
74  GdkFont* loadSysFont(UDisp*, const UFontDesc&);
75 # endif
76 #endif
77 };
78 
79 }
80 #endif
81 
[Impl] Native Font.
Definition: uhardfont.hpp:35
class for drawing on widgets.
Definition: ugraph.hpp:44
Display Context.
Definition: udisp.hpp:44
[impl] Internal representation for fonts.
Definition: ufontImpl.hpp:24
Definition: uhardfont.hpp:31