Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGX11TTF.cxx
Go to the documentation of this file.
1// @(#)root/x11ttf:$Id: 80028b538e60290371c1c5d73728f78b1c32f09a $
2// Author: Valeriy Onuchin (Xft support) 02/10/07
3// Author: Olivier Couet 01/10/02
4// Author: Fons Rademakers 21/11/98
5
6/*************************************************************************
7 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
8 * All rights reserved. *
9 * *
10 * For the licensing terms see $ROOTSYS/LICENSE. *
11 * For the list of contributors see $ROOTSYS/README/CREDITS. *
12 *************************************************************************/
13
14/** \class TGX11TTF
15\ingroup x11
16
17Interface to low level X11 (Xlib). This class gives access to basic
18X11 graphics via the parent class TGX11. However, all text and font
19handling is done via the Freetype TrueType library. When the
20shared library containing this class is loaded the global gVirtualX
21is redirected to point to this class.
22*/
23
24
25#include "TGX11TTF.h"
26
27#ifdef R__HAS_XFT
28#include "THashTable.h"
29#include "TRefCnt.h"
30#include <X11/Xft/Xft.h>
31#endif
32
33#include <X11/Xlib.h>
34#include <X11/Xutil.h>
35#include <X11/Xatom.h>
36#include <X11/cursorfont.h>
37#include <X11/keysym.h>
38#include <X11/xpm.h>
39
40
41#include <cstdlib>
42
43#include "TEnv.h"
44#include "TTFhandle.h"
45#include "TMathBase.h"
46
47
48struct RXColor:XColor{};
49struct RVisual:Visual{};
50struct RXImage:XImage{};
51
52#ifdef R__HAS_XFT
53
54///////////////////////// xft font data //////////////////////////////////////
55class TXftFontData : public TNamed, public TRefCnt {
56public:
57 GContext_t fGC; // graphics context
58 XftFont *fXftFont; // xft font
59
62 {
63 SetRefCount(1);
64 fGC = gc;
65 }
66
67 void MapGCFont(GContext_t gc, FontStruct_t font)
68 {
69 fGC = gc; fXftFont = (XftFont *)font;
70 }
71
72 ~TXftFontData() override
73 {
74 if (References() == 1) {
75 if (fXftFont) XftFontClose((Display*)gVirtualX->GetDisplay(), fXftFont);
76 }
77 }
78};
79
80/////////////////// hash table //////////////////////////////////////////////
81class TXftFontHash {
82public:
83 THashTable *fList; // hash table
84
85 TXftFontHash() { fList = new THashTable(50); }
86
87 TXftFontData *FindByName(const char *name)
88 {
89 return (TXftFontData*)fList->FindObject(name);
90 }
91
93 {
94 TIter next(fList);
95
96 while (auto d = (TXftFontData*) next()) {
97 if (d->fXftFont == (XftFont *)font)
98 return d;
99 }
100 return nullptr;
101 }
102
104 {
105 TIter next(fList);
106
107 while (auto d = (TXftFontData*) next()) {
108 if (d->fGC == gc)
109 return d;
110 }
111 return nullptr;
112 }
113
114 void AddFont(TXftFontData *data)
115 {
116 // Loop over all existing TXftFontData, if we already have one with the same
117 // font data, set the reference counter of this one beyond 1 so it does
118 // delete the font pointer
119 TIter next(fList);
120
121 while (auto d = (TXftFontData*) next()) {
122 if (d->fXftFont == data->fXftFont)
123 data->AddReference();
124 }
125
126 fList->Add(data);
127 }
128
129 void FreeFont(TXftFontData *data)
130 {
131 fList->Remove(data);
132 delete data;
133 }
134};
135
136Bool_t TGX11TTF::gXftInit = kFALSE;
137
138#endif // R__HAS_XFT
139
140/** \class TTFX11Init
141\ingroup GraphicsBackends
142
143Small utility class that takes care of switching the current
144gVirtualX to the new TGX11TTF class as soon as the shared library
145containing this class is loaded.
146*/
147
149public:
151};
153
154
155
156////////////////////////////////////////////////////////////////////////////////
157/// Create copy of TGX11 but now use TrueType fonts.
158
160{
161 SetName("X11TTF");
162 SetTitle("ROOT interface to X11 with TrueType fonts");
163
165 fHasXft = kFALSE;
166
167#ifdef R__HAS_XFT
168 fXftFontHash = nullptr;
169#endif
170}
171
172////////////////////////////////////////////////////////////////////////////////
173/// Static method setting TGX11TTF as the acting gVirtualX.
174
176{
177 if (auto oldg = dynamic_cast<TGX11*>(gVirtualX)) {
178 gVirtualX = new TGX11TTF(std::move(*oldg));
179 delete oldg;
180 }
181}
182
183////////////////////////////////////////////////////////////////////////////////
184/// Initialize X11 system. Returns kFALSE in case of failure.
185
187{
188#ifdef R__HAS_XFT
189 fXftFontHash = nullptr;
190 XFontStruct *fs = nullptr;
191 if (display) fs = XLoadQueryFont((Display *)display, "-*-helvetica-*-r-*-*-14-*-*-*-*-*-*-*");
192 if (!fs) gEnv->SetValue("X11.UseXft", 1);
193 if (display && fs) XFreeFont((Display *)display, fs);
194 if (gEnv->GetValue("X11.UseXft", 0)) {
195 fHasXft = kTRUE;
197 }
198#endif
200
201 return r;
202}
203
204
205template<typename CharType>
207 const CharType *text, ETextMode mode)
208{
209 if (!fHasTTFonts) {
211 return;
212 }
213
214 if (!wctxt)
215 return;
216
219 Int_t xy;
221
222 auto &att = GetTextAttW(wctxt);
223
225 ttf.SetSmoothing(fDepth > 8);
226 ttf.SetTextFont(att.GetTextFont());
227 ttf.SetTextSize(att.GetTextSize());
228 ttf.SetRotationMatrix(angle);
229 ttf.PrepareString(text);
230 ttf.LayoutGlyphs();
231 if (ttf.ApplyAlignRotate(x, y, att.GetTextAlign(), width, height))
233}
234
235////////////////////////////////////////////////////////////////////////////////
236/// Draw TTF glyphs on the specified window context
237
239{
240 Int_t w = ttf.GetGlyphsWidth();
241 Int_t h = ttf.GetGlyphsHeight();
242
244
246 XImage *xim = XCreateImage((Display*)fDisplay, fVisual,
247 depth, ZPixmap, 0, nullptr, w, h,
248 depth <= 8 ? 8 : (depth <= 16 ? 16 : 32), 0);
249 //bitmap_pad should be 8, 16 or 32 https://www.x.org/releases/X11R7.5/doc/man/man3/XPutPixel.3.html
250 if (!xim)
251 return;
252
253 // use malloc since Xlib will use free() in XDestroyImage
254 xim->data = (char *) malloc(xim->bytes_per_line * h);
255 memset(xim->data, 0, xim->bytes_per_line * h);
256
257 XGCValues values;
258 auto gc = (GC *) GetGCW(wctxt, 3);
259 if (!gc) {
260 Error("DrawTTFglyphsW", "error getting Graphics Context");
261 return;
262 }
263 XGetGCValues((Display*)fDisplay, *gc, GCForeground | GCBackground, &values);
264
265 // get the background
266 if (mode == kClear) {
267 // if mode == kClear we need to get an image of the background
269 if (!bim) {
270 Error("DrawTTFglyphsW", "error getting background image");
271 return;
272 }
273
274 // and copy it into the text image
275 Int_t xo = x1 < 0 ? -x1 : 0;
276 Int_t yo = y1 < 0 ? -y1 : 0;
277
278 for (int yp = 0; yp < (int) bim->height; yp++) {
279 for (int xp = 0; xp < (int) bim->width; xp++) {
281 XPutPixel(xim, xo + xp, yo + yp, pixel);
282 }
283 }
285 } else {
286 // if mode == kOpaque its simple, we just draw the background
287 XAddPixel(xim, values.background);
288 }
289
290 // paint the glyphs in the XImage
291 for (UInt_t nglyph = 0; nglyph < ttf.GetNumGlyphs(); nglyph++) {
292 Int_t bx = 0, by = 0;
293 UChar_t *buffer = nullptr;
294 UInt_t width = 0, rows = 0, pitch = 0;
295 if (!ttf.GetGlyphData(nglyph, bx, by, buffer, width, rows, pitch))
296 continue;
297
298 if (ttf.GetSmoothing()) {
299 RXColor col[5];
300
301 // background kClear, i.e. transparent, we take as background color
302 // the average of the rgb values of all pixels covered by this character
303 if (mode == kClear) {
304 const UInt_t ndots = TMath::Min((UInt_t) 50000, width * rows);
305
306 std::vector<RXColor> bcol(ndots);
307 if (!bcol.size()) {
308 Error("DrawTTFglyphsW", "Allocation failure with bcol vector");
309 return;
310 }
311 for (unsigned y = 0, dotcnt = 0; y < rows; y++) {
312 for (unsigned x = 0; (x < width) && (dotcnt < bcol.size()); x++) {
313 bcol[dotcnt].pixel = XGetPixel(xim, bx + x, by + y);
314 bcol[dotcnt].flags = DoRed | DoGreen | DoBlue;
315 dotcnt++;
316 }
317 }
318 QueryColors(fColormap, bcol.data(), bcol.size());
319 ULong_t r = 0, g = 0, b = 0;
320 for (auto &entry : bcol) {
321 r += entry.red;
322 g += entry.green;
323 b += entry.blue;
324 }
325 col[0].red = (UShort_t) (r / bcol.size());
326 col[0].green = (UShort_t) (g / bcol.size());
327 col[0].blue = (UShort_t) (b / bcol.size());
328 } else {
329 // just request rgb value for background color
330 col[0].pixel = values.background;
331 col[0].flags = DoRed | DoGreen | DoBlue;
332 QueryColors(fColormap, &col[0], 1);
333 }
334
335 // request rgb value for foreground color
336 col[4].pixel = values.foreground;
337 col[4].flags = DoRed | DoGreen | DoBlue;
338 QueryColors(fColormap, &col[4], 1);
339
340 // recalculate the 3 smoothing colors
341 // (interpolation between fore- and background colors)
342 for (int x = 3; x > 0; x--) {
343 col[x].red = (col[4].red *x + col[0].red *(4-x)) /4;
344 col[x].green = (col[4].green*x + col[0].green*(4-x)) /4;
345 col[x].blue = (col[4].blue *x + col[0].blue *(4-x)) /4;
346 if (!AllocColor(fColormap, &col[x])) {
347 Warning("DrawTTFglyphsW", "cannot allocate smoothing color");
348 col[x].pixel = col[x+1].pixel;
349 }
350 }
351
352 UChar_t *s = buffer;
353 // put smoothed character, character pixmap values are an index
354 // into the 5 colors used for aliasing (4 = foreground, 0 = background)
355 for (unsigned y = 0; y < rows; y++) {
356 for (unsigned x = 0; x < width; x++) {
357 UChar_t d = TMath::Min((UChar_t) 4, (UChar_t)((((*s++ & 0xff) + 10) * 5) / 256));
358 if (d > 0)
359 XPutPixel(xim, bx + x, by + y, col[d].pixel);
360 }
361 }
362 } else {
363 // no smoothing, just put character using foreground color
364 UChar_t *row = buffer;
365 for (unsigned y = 0; y < rows; y++) {
366 unsigned n = 0;
367 UChar_t d = 0;
368 UChar_t *s = row;
369 for (unsigned x = 0; x < width; x++) {
370 if (n == 0) d = *s++;
371 if (TESTBIT(d,7-n))
372 XPutPixel(xim, bx + x, by + y, values.foreground);
373 if (++n == kBitsPerByte) n = 0;
374 }
375 row += pitch;
376 }
377 }
378 }
379
380 // put the Ximage on the screen
381 gc = (GC *) GetGCW(wctxt, 6);
382 if (gc)
383 XPutImage((Display*)fDisplay, cws, *gc, xim, 0, 0, x1, y1, w, h);
385}
386
387////////////////////////////////////////////////////////////////////////////////
388/// Draw text using TrueType fonts. If TrueType fonts are not available the
389/// text is drawn with TGX11::DrawTextW.
390
396
397////////////////////////////////////////////////////////////////////////////////
398/// Draw text using TrueType fonts. If TrueType fonts are not available the
399/// text is drawn with TGX11::DrawTextW.
400
406
407////////////////////////////////////////////////////////////////////////////////
408/// Get the background of the current window in an XImage.
409
411{
415 Int_t xy;
417
418 if (x < 0) {
419 w += x;
420 x = 0;
421 }
422 if (y < 0) {
423 h += y;
424 y = 0;
425 }
426
427 if (x+w > width) w = width - x;
428 if (y+h > height) h = height - y;
429
430 return (RXImage *)XGetImage((Display*)fDisplay, cws, x, y, w, h, AllPlanes, ZPixmap);
431}
432
433
434#ifdef R__HAS_XFT
435
436///////////////////////////// Xft font methods /////////////////////////////////
437////////////////////////////////////////////////////////////////////////////////
438/// Parses an XLFD name and opens a font.
439
441{
442 if (!fXftFontHash) {
444 }
445
446 TXftFontData *data = fXftFontHash->FindByName(font_name);
447
448 // already loaded
449 if (data) {
450 return (FontStruct_t)data->fXftFont;
451 }
452
453 if (!gXftInit) {
454 XftInit(nullptr);
455 gXftInit = kTRUE;
456 }
457
459
461 fXftFontHash->AddFont(data);
462
463 return (FontStruct_t)xftfont;
464}
465
466////////////////////////////////////////////////////////////////////////////////
467/// Explicitly delete font structure obtained with LoadQueryFont().
468
470{
471 if (!fXftFontHash) {
473 return;
474 }
475
476 TXftFontData *data = fXftFontHash->FindByFont(fs);
477
478 if (data)
479 fXftFontHash->FreeFont(data);
480}
481
482////////////////////////////////////////////////////////////////////////////////
483/// Explicitly delete a graphics context.
484
486{
487 if (!fXftFontHash) {
489 return;
490 }
491
492 TXftFontData *gcdata = fXftFontHash->FindByGC(gc);
493 if (gcdata) fXftFontHash->FreeFont(gcdata);
495}
496
497////////////////////////////////////////////////////////////////////////////////
498/// Return handle to font described by font structure.
499
501{
502 if (!fXftFontHash) {
503 return TGX11::GetFontHandle(fs);
504 }
505
506 return (FontH_t)fs;
507}
508
509////////////////////////////////////////////////////////////////////////////////
510/// Return the font associated with the graphics context gc
511
513{
514 if (!fXftFontHash) {
515 return 0;
516 }
517
518 TXftFontData *data = fXftFontHash->FindByGC(gc);
519
520 // no XftFont data
521 if (!data) return 0;
522
523 return (FontStruct_t)data->fXftFont;
524}
525
526////////////////////////////////////////////////////////////////////////////////
527/// Map the XftFont with the Graphics Context using it.
528
530{
531 if (!fXftFontHash)
532 return;
533
534 TXftFontData *gcdata = fXftFontHash->FindByGC(gc);
535 TXftFontData *fontdata = fXftFontHash->FindByFont(font);
536
537 if (gcdata) { // && (gcdata->fXftFont == 0)) {
538 gcdata->fXftFont = (XftFont *)font;
539 }
540 else if (fontdata) {
541 TXftFontData *data = new TXftFontData(gc, (XftFont *)font, fontdata->GetName());
542 fXftFontHash->AddFont(data);
543 }
544}
545
546////////////////////////////////////////////////////////////////////////////////
547/// Return length of string in pixels. Size depends on font
548
549Int_t TGX11TTF::TextWidth(FontStruct_t font, const char *s, Int_t len)
550{
551 if (!fXftFontHash) {
552 return TGX11::TextWidth(font, s, len);
553 }
554
555 TXftFontData *data = fXftFontHash->FindByFont(font);
556
557 if (!data) return 0;
558
559 XftFont *xftfont = data->fXftFont;
560
561 if (xftfont) {
564 return glyph_info.xOff;
565 }
566 return 0;
567}
568
569////////////////////////////////////////////////////////////////////////////////
570/// Return some font properties
571
573{
574 if (!fXftFontHash) {
576 return;
577 }
578
579 TXftFontData *data = fXftFontHash->FindByFont(font);
580
581 if (!data) {
583 return;
584 }
585
586 XftFont *xftfont = data->fXftFont;
587
588 if (!xftfont) {
590 return;
591 }
592
593 max_ascent = xftfont->ascent;
594 max_descent = xftfont->descent;
595}
596
597////////////////////////////////////////////////////////////////////////////////
598/// Draw text string
599
601 const char *text, Int_t len)
602{
607
608 if (!xwindow) {
609 return;
610 }
611
612 if (!gc) {
613 return;
614 }
615
616 if (!text || (len < 1) || !text[0]) {
617 return;
618 }
619
620 if (!fXftFontHash) {
622 return;
623 }
624
626 gval.fMask = kGCForeground | kGCBackground; // retrieve GC values
628
629 TXftFontData *data = fXftFontHash->FindByGC(gc);
630
631 // no XftFont data
632 if (!data) {
634 return;
635 }
636
637 xftfont = data->fXftFont;
638
639 // no Xft font
640 if (!xftfont) {
642 return;
643 }
644
645 // dummies
647 Int_t dx,dy;
649
650 // check if drawable is bitmap
651 XGetGeometry((Display*)fDisplay, (Drawable)xwindow, &droot, &dx, &dy,
652 &width, &height, &bwidth, &depth);
653
654 if (depth <= 1) {
656 return;
657 }
658
659 memset(&xcolor, 0, sizeof(xcolor));
660 xcolor.pixel = gval.fForeground;
661
662 XQueryColor((Display*)fDisplay, fColormap, &xcolor);
663
664 // create XftDraw
666
667 if (!xftdraw) {
668 //Warning("could not create an XftDraw");
670 return;
671 }
672
673 xftcolor.color.red = xcolor.red;
674 xftcolor.color.green = xcolor.green;
675 xftcolor.color.blue = xcolor.blue;
676 xftcolor.color.alpha = 0xffff;
677 xftcolor.pixel = gval.fForeground;
678
680
681 // cleanup
683}
684
685#endif // R__HAS_XFT
Handle_t WinContext_t
Window drawing context.
Definition GuiTypes.h:30
const Mask_t kGCBackground
Definition GuiTypes.h:290
const Mask_t kGCForeground
Definition GuiTypes.h:289
Handle_t FontH_t
Font handle (as opposed to Font_t which is an index)
Definition GuiTypes.h:36
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:39
Handle_t Drawable_t
Drawable handle.
Definition GuiTypes.h:32
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:40
#define d(i)
Definition RSha256.hxx:102
#define b(i)
Definition RSha256.hxx:100
#define g(i)
Definition RSha256.hxx:105
#define h(i)
Definition RSha256.hxx:106
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:78
unsigned short UShort_t
Unsigned Short integer 2 bytes (unsigned short)
Definition RtypesCore.h:55
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
constexpr ULong_t kBitsPerByte
Definition RtypesCore.h:131
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:70
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:61
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
#define TESTBIT(n, i)
Definition Rtypes.h:94
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEnv * gEnv
Definition TEnv.h:126
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t GetWindowSize
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GetGCValues
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void pixel
Option_t Option_t mgn
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint angle
Option_t Option_t TPoint xy
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t org
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize fs
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t gval
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void gc
Option_t Option_t TPoint TPoint const char text
Option_t Option_t TPoint TPoint const char y1
static TTFX11Init gTTFX11Init
Definition TGX11TTF.cxx:152
char name[80]
Definition TGX11.cxx:142
XID Window
Definition TGX11.h:38
XID Drawable
Definition TGX11.h:35
#define gVirtualX
Definition TVirtualX.h:379
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:511
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=nullptr)
Set the value of a resource or create a new resource.
Definition TEnv.cxx:752
static void Activate()
Static method setting TGX11TTF as the acting gVirtualX.
Definition TGX11TTF.cxx:175
void DrawTextW(WinContext_t wctxt, Int_t x, Int_t y, Float_t angle, Float_t mgn, const char *text, ETextMode mode) override
Draw text using TrueType fonts.
Definition TGX11TTF.cxx:391
Bool_t Init(void *display) override
Initialize X11 system. Returns kFALSE in case of failure.
Definition TGX11TTF.cxx:186
TGX11TTF(TGX11 &&org)
Create copy of TGX11 but now use TrueType fonts.
Definition TGX11TTF.cxx:159
void DrawTextHelper(WinContext_t wctxt, Int_t x, Int_t y, Float_t angle, Float_t mgn, const CharType *text, ETextMode mode)
Definition TGX11TTF.cxx:206
RXImage * GetBackground(WinContext_t wctxt, 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:410
void DrawTTFglyphsW(WinContext_t wctxt, Int_t x, Int_t y, TTFhandle &ttf, ETextMode mode) override
Draw TTF glyphs on the specified window context.
Definition TGX11TTF.cxx:238
This class is the basic interface to the X11 (Xlib) graphics system.
Definition TGX11.h:64
void * fDisplay
Pointer to display.
Definition TGX11.h:100
const TAttText & GetTextAttW(WinContext_t wctxt) const
Return text attributes for specified window context.
Definition TGX11.cxx:1073
Colormap fColormap
Default colormap, 0 if b/w.
Definition TGX11.h:104
FontStruct_t LoadQueryFont(const char *font_name) override
Load font and query font.
Definition GX11Gui.cxx:941
Int_t fScreenNumber
Screen number.
Definition TGX11.h:107
Bool_t AllocColor(Colormap cmap, RXColor *color)
Allocate color in colormap.
Definition TGX11.cxx:338
void QueryColors(Colormap cmap, RXColor *colors, Int_t ncolors)
Returns the current RGB value for the pixel in the XColor structure.
Definition TGX11.cxx:355
void DrawTextW(WinContext_t wctxt, Int_t x, Int_t y, Float_t angle, Float_t mgn, const char *text, ETextMode mode) override
Draw a text string using current font on specified window.
Definition TGX11.cxx:844
Bool_t fHasXft
True when XftFonts are used.
Definition TGX11.h:119
void * GetGCW(WinContext_t wctxt, Int_t which) const
Return X11 Graphics Context for specified window context.
Definition TGX11.cxx:1054
Int_t fDepth
Number of color planes.
Definition TGX11.h:111
Bool_t Init(void *display) override
Initialize X11 system. Returns kFALSE in case of failure.
Definition TGX11.cxx:313
Window_t GetWindow(WinContext_t wctxt) const
Return X11 window for specified window context.
Definition TGX11.cxx:1044
void DeleteGC(GContext_t gc) override
Explicitly delete a graphics context.
Definition GX11Gui.cxx:1032
void DeleteFont(FontStruct_t fs) override
Explicitly delete font structure obtained with LoadQueryFont().
Definition GX11Gui.cxx:962
Int_t TextWidth(FontStruct_t font, const char *s, Int_t len) override
Return length of string in pixels. Size depends on font.
Definition GX11Gui.cxx:2090
FontH_t GetFontHandle(FontStruct_t fs) override
Return handle to font described by font structure.
Definition GX11Gui.cxx:950
void DrawString(Drawable_t id, GContext_t gc, Int_t x, Int_t y, const char *s, Int_t len) override
Draw a string using a specific graphics context in position (x,y).
Definition GX11Gui.cxx:2079
RVisual * fVisual
Pointer to visual used by all windows.
Definition TGX11.h:101
void GetFontProperties(FontStruct_t font, Int_t &max_ascent, Int_t &max_descent) override
Return some font properties.
Definition GX11Gui.cxx:2098
Bool_t fHasTTFonts
True when TrueType fonts are used.
Definition TGX11.h:118
THashTable implements a hash table to store TObject's.
Definition THashTable.h:35
void Add(TObject *obj) override
Add object to the hash table.
TObject * Remove(TObject *obj) override
Remove object from the hashtable.
TObject * FindObject(const char *name) const override
Find object using its name.
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:173
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:149
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1082
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1096
Definitions for TRefCnt, base class for reference counted objects.
Definition TRefCnt.h:27
Small utility class that takes care of switching the current gVirtualX to the new TGX11TTF class as s...
Definition TGX11TTF.cxx:148
Dynamic handle to work with freetype 2 library.
Definition TTFhandle.h:21
static Bool_t Init()
virtual void DeleteFont(FontStruct_t fs)
Explicitly deletes the font structure "fs" obtained via LoadQueryFont().
virtual FontStruct_t GetGCFont(GContext_t gc)
Return the font associated with the graphics context gc.
virtual FontStruct_t LoadQueryFont(const char *font_name)
Provides the most common way for accessing a font: opens (loads) the specified font and returns a poi...
virtual FontH_t GetFontHandle(FontStruct_t fs)
Returns the font handle of the specified font structure "fs".
virtual void GetFontProperties(FontStruct_t font, Int_t &max_ascent, Int_t &max_descent)
Returns the font properties.
virtual void DeleteGC(GContext_t gc)
Deletes the specified GC "gc".
virtual void DrawString(Drawable_t id, GContext_t gc, Int_t x, Int_t y, const char *s, Int_t len)
Each character image, as defined by the font in the GC, is treated as an additional mask for a fill o...
virtual void MapGCFont(GContext_t, FontStruct_t)
Map the XftFont with the Graphics Context using it.
virtual Int_t TextWidth(FontStruct_t font, const char *s, Int_t len)
Return length of the string "s" in pixels. Size depends on font.
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:197
Graphics context structure.
Definition GuiTypes.h:225