ROOT  6.06/09
Reference Guide
TGX11TTF.h
Go to the documentation of this file.
1 // @(#)root/x11ttf:$Id$
2 // Author: Olivier Couet 01/10/02
3 // Author: Fons Rademakers 21/11/98
4 
5 /*************************************************************************
6  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
7  * All rights reserved. *
8  * *
9  * For the licensing terms see $ROOTSYS/LICENSE. *
10  * For the list of contributors see $ROOTSYS/README/CREDITS. *
11  *************************************************************************/
12 
13 #ifndef ROOT_TGX11TTF
14 #define ROOT_TGX11TTF
15 
16 
17 //////////////////////////////////////////////////////////////////////////
18 // //
19 // TGX11TTF //
20 // //
21 // Interface to low level X11 (Xlib). This class gives access to basic //
22 // X11 graphics via the parent class TGX11. However, all text and font //
23 // handling is done via the Freetype TrueType library. When the //
24 // shared library containing this class is loaded the global gVirtualX //
25 // is redirected to point to this class. //
26 // //
27 //////////////////////////////////////////////////////////////////////////
28 
29 #ifndef ROOT_TGX11
30 #include "TGX11.h"
31 #endif
32 
33 #ifndef ROOT_TTF
34 #include "TTF.h"
35 #endif
36 
37 #ifndef ROOT_RConfigure
38 #include "RConfigure.h"
39 #endif
40 
41 #ifdef R__HAS_XFT
42 class TXftFontHash;
43 #endif
44 
45 class TGX11TTF : public TGX11 {
46 
47 private:
50 
51  FT_Vector fAlign; // alignment vector
52 #ifdef R__HAS_XFT
53  TXftFontHash *fXftFontHash; // hash table for Xft fonts
54 #endif
55 
56  void Align(void);
57  void DrawImage(FT_Bitmap *source, ULong_t fore, ULong_t back, RXImage *xim,
58  Int_t bx, Int_t by);
60  RXImage *GetBackground(Int_t x, Int_t y, UInt_t w, UInt_t h);
61  void RenderString(Int_t x, Int_t y, ETextMode mode);
62 
63 public:
64  TGX11TTF(const TGX11 &org);
65  virtual ~TGX11TTF() { }
66 
67  Bool_t Init(void *display);
68  void DrawText(Int_t x, Int_t y, Float_t angle, Float_t mgn,
69  const char *text, ETextMode mode);
70  void DrawText(Int_t x, Int_t y, Float_t angle, Float_t mgn,
71  const wchar_t *text, ETextMode mode);
72  void SetTextFont(Font_t fontnumber);
73  Int_t SetTextFont(char *fontname, ETextSetMode mode);
74  void SetTextSize(Float_t textsize);
75 
76 #ifdef R__HAS_XFT
77  //---- Methods used text/fonts handling via Xft -----
78  //void SetClipRectangles(GContext_t gc, Int_t x, Int_t y, Rectangle_t *recs, Int_t n);
79  FontStruct_t LoadQueryFont(const char *font_name);
80  void DeleteFont(FontStruct_t fs);
81  void DeleteGC(GContext_t gc);
82  void DrawString(Drawable_t id, GContext_t gc, Int_t x, Int_t y, const char *s, Int_t len);
83  Int_t TextWidth(FontStruct_t font, const char *s, Int_t len);
84  void GetFontProperties(FontStruct_t font, Int_t &max_ascent, Int_t &max_descent);
87  void MapGCFont(GContext_t gc, FontStruct_t font);
88 #endif
89 
90  static void Activate();
91 
92  ClassDef(TGX11TTF,0) //Interface to X11 + TTF font handling
93 };
94 
95 #endif
static void Activate()
Static method setting TGX11TTF as the acting gVirtualX.
Definition: TGX11TTF.cxx:166
Handle_t FontStruct_t
Definition: GuiTypes.h:40
void DeleteFont(FontStruct_t fs)
Explicitly delete font structure obtained with LoadQueryFont().
Definition: GX11Gui.cxx:976
float Float_t
Definition: RtypesCore.h:53
TH1 * h
Definition: legend2.C:5
Handle_t GContext_t
Definition: GuiTypes.h:39
void DrawImage(FT_Bitmap *source, ULong_t fore, ULong_t back, RXImage *xim, Int_t bx, Int_t by)
Draw FT_Bitmap bitmap to xim image at position bx,by using specified foreground color.
Definition: TGX11TTF.cxx:238
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Handle_t Drawable_t
Definition: GuiTypes.h:32
short Font_t
Definition: RtypesCore.h:75
Interface to low level X11 (Xlib).
Definition: TGX11TTF.h:45
FT_Vector fAlign
Definition: TGX11TTF.h:51
Handle_t FontH_t
Definition: GuiTypes.h:36
Double_t x[n]
Definition: legend1.C:17
ClassDef(TAttLine, 2)
void GetFontProperties(FontStruct_t font, Int_t &max_ascent, Int_t &max_descent)
Return some font properties.
Definition: GX11Gui.cxx:2088
void SetTextSize(Float_t textsize)
Set current text size.
Definition: TGX11TTF.cxx:574
FontH_t GetFontHandle(FontStruct_t fs)
Return handle to font described by font structure.
Definition: GX11Gui.cxx:964
void DrawString(Drawable_t id, GContext_t gc, Int_t x, Int_t y, const char *s, Int_t len)
Draw a string using a specific graphics context in position (x,y).
Definition: GX11Gui.cxx:2069
void DrawText(Int_t x, Int_t y, Float_t angle, Float_t mgn, const char *text, ETextMode mode)
Draw text using TrueType fonts.
Definition: TGX11TTF.cxx:361
FontStruct_t LoadQueryFont(const char *font_name)
Load font and query font.
Definition: GX11Gui.cxx:955
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual ~TGX11TTF()
Definition: TGX11TTF.h:65
virtual FontStruct_t GetGCFont(GContext_t gc)
Return the font associated with the graphics context gc.
Definition: TVirtualX.cxx:1843
TGX11TTF(const TGX11 &org)
void SetTextFont(Font_t fontnumber)
Set specified font.
Definition: TGX11TTF.cxx:542
This class is the basic interface to the X11 (Xlib) graphics system.
Definition: TGX11.h:85
void RenderString(Int_t x, Int_t y, ETextMode mode)
Perform the string rendering in the pad.
Definition: TGX11TTF.cxx:452
TText * text
unsigned long ULong_t
Definition: RtypesCore.h:51
Double_t y[n]
Definition: legend1.C:17
void Align(void)
Compute alignment variables.
Definition: TGX11TTF.cxx:207
void DeleteGC(GContext_t gc)
Explicitly delete a graphics context.
Definition: GX11Gui.cxx:1046
#define org(otri, vertexptr)
Definition: triangle.c:1037
virtual void MapGCFont(GContext_t, FontStruct_t)
Map the XftFont with the Graphics Context using it.
Definition: TVirtualX.cxx:2503
Bool_t Init(void *display)
Initialize X11 system. Returns kFALSE in case of failure.
Definition: TGX11TTF.cxx:178
Bool_t IsVisible(Int_t x, Int_t y, UInt_t w, UInt_t h)
Test if there is really something to render.
Definition: TGX11TTF.cxx:424
RXImage * GetBackground(Int_t x, Int_t y, UInt_t w, UInt_t h)
Get the background of the current window in an XImage.
Definition: TGX11TTF.cxx:398
Int_t TextWidth(FontStruct_t font, const char *s, Int_t len)
Return length of string in pixels. Size depends on font.
Definition: GX11Gui.cxx:2080