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#include <cstdlib>
25
26#include <ft2build.h>
27#include FT_FREETYPE_H
28#include FT_GLYPH_H
29#include "TGX11TTF.h"
30#include "TEnv.h"
31#include "TTF.h"
32#include "TMathBase.h"
33
34
35#include <X11/Xlib.h>
36#include <X11/Xutil.h>
37#include <X11/Xatom.h>
38#include <X11/cursorfont.h>
39#include <X11/keysym.h>
40#include <X11/xpm.h>
41
42struct RXColor:XColor{};
43struct RVisual:Visual{};
44struct RXImage:XImage{};
45
46#ifdef R__HAS_XFT
47
48#include "THashTable.h"
49#include "TRefCnt.h"
50#include <X11/Xft/Xft.h>
51
52///////////////////////// xft font data //////////////////////////////////////
53class TXftFontData : public TNamed, public TRefCnt {
54public:
55 GContext_t fGC; // graphics context
56 XftFont *fXftFont; // xft font
57
60 {
61 SetRefCount(1);
62 fGC = gc;
63 }
64
65 void MapGCFont(GContext_t gc, FontStruct_t font)
66 {
67 fGC = gc; fXftFont = (XftFont *)font;
68 }
69
70 ~TXftFontData() override
71 {
72 if (References() == 1) {
73 if (fXftFont) XftFontClose((Display*)gVirtualX->GetDisplay(), fXftFont);
74 }
75 }
76};
77
78/////////////////// hash table //////////////////////////////////////////////
79class TXftFontHash {
80public:
81 THashTable *fList; // hash table
82
83 TXftFontHash() { fList = new THashTable(50); }
84
85 TXftFontData *FindByName(const char *name)
86 {
87 return (TXftFontData*)fList->FindObject(name);
88 }
89
91 {
92 TIter next(fList);
93
94 while (auto d = (TXftFontData*) next()) {
95 if (d->fXftFont == (XftFont *)font)
96 return d;
97 }
98 return nullptr;
99 }
100
102 {
103 TIter next(fList);
104
105 while (auto d = (TXftFontData*) next()) {
106 if (d->fGC == gc)
107 return d;
108 }
109 return nullptr;
110 }
111
112 void AddFont(TXftFontData *data)
113 {
114 // Loop over all existing TXftFontData, if we already have one with the same
115 // font data, set the reference counter of this one beyond 1 so it does
116 // delete the font pointer
117 TIter next(fList);
118
119 while (auto d = (TXftFontData*) next()) {
120 if (d->fXftFont == data->fXftFont)
121 data->AddReference();
122 }
123
124 fList->Add(data);
125 }
126
127 void FreeFont(TXftFontData *data)
128 {
129 fList->Remove(data);
130 delete data;
131 }
132};
133
134Bool_t TGX11TTF::gXftInit = kFALSE;
135
136#endif // R__HAS_XFT
137
138/** \class TTFX11Init
139\ingroup GraphicsBackends
140
141Small utility class that takes care of switching the current
142gVirtualX to the new TGX11TTF class as soon as the shared library
143containing this class is loaded.
144*/
145
147public:
149};
151
152
153
154////////////////////////////////////////////////////////////////////////////////
155/// Create copy of TGX11 but now use TrueType fonts.
156
158{
159 SetName("X11TTF");
160 SetTitle("ROOT interface to X11 with TrueType fonts");
161
163 fHasXft = kFALSE;
164
165#ifdef R__HAS_XFT
166 fXftFontHash = nullptr;
167#endif
168}
169
170////////////////////////////////////////////////////////////////////////////////
171/// Static method setting TGX11TTF as the acting gVirtualX.
172
174{
175 if (auto oldg = dynamic_cast<TGX11*>(gVirtualX)) {
176 gVirtualX = new TGX11TTF(std::move(*oldg));
177 delete oldg;
178 }
179}
180
181////////////////////////////////////////////////////////////////////////////////
182/// Initialize X11 system. Returns kFALSE in case of failure.
183
184Bool_t TGX11TTF::Init(void *display)
185{
186#ifdef R__HAS_XFT
187 fXftFontHash = nullptr;
188 XFontStruct *fs = nullptr;
189 if (display) fs = XLoadQueryFont((Display *)display, "-*-helvetica-*-r-*-*-14-*-*-*-*-*-*-*");
190 if (!fs) gEnv->SetValue("X11.UseXft", 1);
191 if (display && fs) XFreeFont((Display *)display, fs);
192 if (gEnv->GetValue("X11.UseXft", 0)) {
193 fHasXft = kTRUE;
195 }
196#endif
197 Bool_t r = TGX11::Init(display);
198
200
201 return r;
202}
203
204////////////////////////////////////////////////////////////////////////////////
205/// Draw FT_Bitmap bitmap to xim image at position bx,by using specified
206/// foreground color.
207
210{
211 auto source = (FT_Bitmap *) _source;
212 if (!source->width)
213 return;
214
215 UChar_t *s = source->buffer;
216
218 RXColor col[5];
219
220 // background kClear, i.e. transparent, we take as background color
221 // the average of the rgb values of all pixels covered by this character
222 if (back == (ULong_t) -1) {
223 const UInt_t ndots = TMath::Min((UInt_t) 50000, source->width * source->rows);
224
225 std::vector<RXColor> bcol(ndots);
226 if (!bcol.size())
227 return;
228 UInt_t dotcnt = 0;
229 for (unsigned y = 0; y < source->rows; y++) {
230 for (unsigned x = 0; x < source->width; x++) {
231/// bc->pixel = XGetPixel(xim, bx + x, by - c->TTF::GetAscent() + y);
232 auto &bc = bcol[dotcnt];
233 bc.pixel = XGetPixel(xim, bx + x, by + y);
234 bc.flags = DoRed | DoGreen | DoBlue;
235 if (++dotcnt >= bcol.size()) break;
236 }
237 }
238 QueryColors(fColormap, bcol.data(), bcol.size());
239 ULong_t r = 0, g = 0, b = 0;
240 for (auto &entry : bcol) {
241 r += entry.red;
242 g += entry.green;
243 b += entry.blue;
244 }
245 col[0].red = (UShort_t) (r / bcol.size());
246 col[0].green = (UShort_t) (g / bcol.size());
247 col[0].blue = (UShort_t) (b / bcol.size());
248 } else {
249 // just request rgb value for background color
250 col[0].pixel = back;
251 col[0].flags = DoRed | DoGreen | DoBlue;
252 QueryColors(fColormap, &col[0], 1);
253 }
254
255 // request rgb value for foreground color
256 col[4].pixel = fore;
257 col[4].flags = DoRed | DoGreen | DoBlue;
258 QueryColors(fColormap, &col[4], 1);
259
260 // recalculate the 3 smoothing colors
261 // (interpolation between fore- and background colors)
262 for (int x = 3; x > 0; x--) {
263 col[x].red = (col[4].red *x + col[0].red *(4-x)) /4;
264 col[x].green = (col[4].green*x + col[0].green*(4-x)) /4;
265 col[x].blue = (col[4].blue *x + col[0].blue *(4-x)) /4;
266 if (!AllocColor(fColormap, &col[x])) {
267 Warning("DrawFTGlyph", "cannot allocate smoothing color");
268 col[x].pixel = col[x+1].pixel;
269 }
270 }
271
272 // put smoothed character, character pixmap values are an index
273 // into the 5 colors used for aliasing (4 = foreground, 0 = background)
274 for (unsigned y = 0; y < source->rows; y++) {
275 for (unsigned x = 0; x < source->width; x++) {
276 UChar_t d = TMath::Min((UChar_t) 4, (UChar_t)((((*s++ & 0xff) + 10) * 5) / 256));
277 if (d > 0)
278 XPutPixel(xim, bx + x, by + y, col[d].pixel);
279 }
280 }
281 } else {
282 // no smoothing, just put character using foreground color
283 UChar_t *row = s;
284 for (unsigned y = 0; y < source->rows; y++) {
285 unsigned n = 0;
286 UChar_t d = 0;
287 s = row;
288 for (unsigned x = 0; x < source->width; x++) {
289 if (n == 0) d = *s++;
290 if (TESTBIT(d,7-n))
291 XPutPixel(xim, bx + x, by + y, fore);
292 if (++n == kBitsPerByte) n = 0;
293 }
294 row += source->pitch;
295 }
296 }
297}
298
299template<class CharType>
301 const CharType *text, ETextMode mode)
302{
303 if (!fHasTTFonts) {
305 return;
306 }
307
308 if (!wctxt)
309 return;
310
311 auto &att = GetTextAttW(wctxt);
312 auto align = GetTextAlignW(wctxt);
313
315 ttf.SetTextFont(att.GetTextFont());
316 ttf.SetTextSize(att.GetTextSize());
317 ttf.SetRotationMatrix(angle);
318 ttf.PrepareString(text);
319 ttf.LayoutGlyphs();
320
321 FT_Vector align_vect; ///< alignment vector
322 // vertical alignment
323 if (align == kTLeft || align == kTCenter || align == kTRight) {
324 align_vect.y = ttf.GetAscent();
325 } else if (align == kMLeft || align == kMCenter || align == kMRight) {
326 align_vect.y = ttf.GetAscent() / 2;
327 } else {
328 align_vect.y = 0;
329 }
330
331 // horizontal alignment
332 if (align == kTRight || align == kMRight || align == kBRight) {
333 align_vect.x = ttf.GetWidth();
334 } else if (align == kTCenter || align == kMCenter || align == kBCenter) {
335 align_vect.x = ttf.GetWidth() / 2;
336 } else {
337 align_vect.x = 0;
338 }
339
340 FT_Vector_Transform(&align_vect, ttf.GetRotMatrix());
341 align_vect.x = align_vect.x >> 6;
342 align_vect.y = align_vect.y >> 6;
343
344 Int_t Xoff = TMath::Max(0, (Int_t) -ttf.GetBox().xMin);
345 Int_t Yoff = TMath::Max(0, (Int_t) -ttf.GetBox().yMin);
346 Int_t w = ttf.GetBox().xMax + Xoff;
347 Int_t h = ttf.GetBox().yMax + Yoff;
348 // If w or h is 0, very likely the string is only blank characters
349 if (w <= 0 || h <= 0)
350 return;
351
352 Int_t x1 = x - Xoff - align_vect.x;
353 Int_t y1 = y + Yoff + align_vect.y - h;
354
357 Int_t xy;
359
360 // If string falls outside window, there is probably no need to draw it.
362 return;
363
364 // If w or h are much larger than the window size, there is probably no need
365 // to draw it. Moreover a to large text size may produce a Seg Fault in
366 // malloc in DrawTextW.
367 if (((UInt_t) w > 10 * width) || ((UInt_t) h > 10 * height))
368 return;
369
370 // create the XImage that will contain the text
372 XImage *xim = XCreateImage((Display*)fDisplay, fVisual,
373 depth, ZPixmap, 0, nullptr, w, h,
374 depth <= 8 ? 8 : (depth <= 16 ? 16 : 32), 0);
375 //bitmap_pad should be 8, 16 or 32 https://www.x.org/releases/X11R7.5/doc/man/man3/XPutPixel.3.html
376 if (!xim)
377 return;
378
379 // use malloc since Xlib will use free() in XDestroyImage
380 xim->data = (char *) malloc(xim->bytes_per_line * h);
381 memset(xim->data, 0, xim->bytes_per_line * h);
382
383 ULong_t bg;
384 XGCValues values;
385 auto gc = (GC *) GetGCW(wctxt, 3);
386 if (!gc) {
387 Error("DrawTextW", "error getting Graphics Context");
388 return;
389 }
390 XGetGCValues((Display*)fDisplay, *gc, GCForeground | GCBackground, &values);
391
392 // get the background
393 if (mode == kClear) {
394 // if mode == kClear we need to get an image of the background
396 if (!bim) {
397 Error("DrawTextW", "error getting background image");
398 return;
399 }
400
401 // and copy it into the text image
402 Int_t xo = 0, yo = 0;
403 if (x1 < 0) xo = -x1;
404 if (y1 < 0) yo = -y1;
405
406 for (int yp = 0; yp < (int) bim->height; yp++) {
407 for (int xp = 0; xp < (int) bim->width; xp++) {
410 }
411 }
413 bg = (ULong_t) -1;
414 } else {
415 // if mode == kOpaque its simple, we just draw the background
416 XAddPixel(xim, values.background);
417 bg = values.background;
418 }
419
420 // paint the glyphs in the XImage
421 for (UInt_t n = 0; n < ttf.GetNumGlyphs(); n++) {
422 if (auto bitmap = ttf.GetGlyphBitmap(n)) {
423 Int_t bx = bitmap->left + Xoff;
424 Int_t by = h - bitmap->top - Yoff;
425 DrawFTGlyph(&bitmap->bitmap, values.foreground, bg, (RXImage *)xim, bx, by);
426 }
427 }
428
429 // put the Ximage on the screen
430 gc = (GC *) GetGCW(wctxt, 6);
431 if (gc)
432 XPutImage((Display*)fDisplay, cws, *gc, xim, 0, 0, x1, y1, w, h);
434}
435
436////////////////////////////////////////////////////////////////////////////////
437/// Draw text using TrueType fonts. If TrueType fonts are not available the
438/// text is drawn with TGX11::DrawTextW.
439
445
446////////////////////////////////////////////////////////////////////////////////
447/// Draw text using TrueType fonts. If TrueType fonts are not available the
448/// text is drawn with TGX11::DrawTextW.
449
455
456////////////////////////////////////////////////////////////////////////////////
457/// Get the background of the current window in an XImage.
458
460{
464 Int_t xy;
466
467 if (x < 0) {
468 w += x;
469 x = 0;
470 }
471 if (y < 0) {
472 h += y;
473 y = 0;
474 }
475
476 if (x+w > width) w = width - x;
477 if (y+h > height) h = height - y;
478
479 return (RXImage *)XGetImage((Display*)fDisplay, cws, x, y, w, h, AllPlanes, ZPixmap);
480}
481
482
483#ifdef R__HAS_XFT
484
485///////////////////////////// Xft font methods /////////////////////////////////
486////////////////////////////////////////////////////////////////////////////////
487/// Parses an XLFD name and opens a font.
488
489FontStruct_t TGX11TTF::LoadQueryFont(const char *font_name)
490{
491 if (!fXftFontHash) {
492 return TGX11::LoadQueryFont(font_name);
493 }
494
495 TXftFontData *data = fXftFontHash->FindByName(font_name);
496
497 // already loaded
498 if (data) {
499 return (FontStruct_t)data->fXftFont;
500 }
501
502 if (!gXftInit) {
503 XftInit(nullptr);
504 gXftInit = kTRUE;
505 }
506
507 XftFont *xftfont = XftFontOpenXlfd((Display*)fDisplay, fScreenNumber, font_name);
508
509 data = new TXftFontData(0, xftfont, font_name);
510 fXftFontHash->AddFont(data);
511
512 return (FontStruct_t)xftfont;
513}
514
515////////////////////////////////////////////////////////////////////////////////
516/// Explicitly delete font structure obtained with LoadQueryFont().
517
519{
520 if (!fXftFontHash) {
522 return;
523 }
524
525 TXftFontData *data = fXftFontHash->FindByFont(fs);
526
527 if (data)
528 fXftFontHash->FreeFont(data);
529}
530
531////////////////////////////////////////////////////////////////////////////////
532/// Explicitly delete a graphics context.
533
535{
536 if (!fXftFontHash) {
538 return;
539 }
540
541 TXftFontData *gcdata = fXftFontHash->FindByGC(gc);
542 if (gcdata) fXftFontHash->FreeFont(gcdata);
544}
545
546////////////////////////////////////////////////////////////////////////////////
547/// Return handle to font described by font structure.
548
550{
551 if (!fXftFontHash) {
552 return TGX11::GetFontHandle(fs);
553 }
554
555 return (FontH_t)fs;
556}
557
558////////////////////////////////////////////////////////////////////////////////
559/// Return the font associated with the graphics context gc
560
562{
563 if (!fXftFontHash) {
564 return 0;
565 }
566
567 TXftFontData *data = fXftFontHash->FindByGC(gc);
568
569 // no XftFont data
570 if (!data) return 0;
571
572 return (FontStruct_t)data->fXftFont;
573}
574
575////////////////////////////////////////////////////////////////////////////////
576/// Map the XftFont with the Graphics Context using it.
577
579{
580 if (!fXftFontHash)
581 return;
582
583 TXftFontData *gcdata = fXftFontHash->FindByGC(gc);
584 TXftFontData *fontdata = fXftFontHash->FindByFont(font);
585
586 if (gcdata) { // && (gcdata->fXftFont == 0)) {
587 gcdata->fXftFont = (XftFont *)font;
588 }
589 else if (fontdata) {
590 TXftFontData *data = new TXftFontData(gc, (XftFont *)font, fontdata->GetName());
591 fXftFontHash->AddFont(data);
592 }
593}
594
595////////////////////////////////////////////////////////////////////////////////
596/// Return length of string in pixels. Size depends on font
597
598Int_t TGX11TTF::TextWidth(FontStruct_t font, const char *s, Int_t len)
599{
600 if (!fXftFontHash) {
601 return TGX11::TextWidth(font, s, len);
602 }
603
604 TXftFontData *data = fXftFontHash->FindByFont(font);
605
606 if (!data) return 0;
607
608 XftFont *xftfont = data->fXftFont;
609
610 if (xftfont) {
613 return glyph_info.xOff;
614 }
615 return 0;
616}
617
618////////////////////////////////////////////////////////////////////////////////
619/// Return some font properties
620
622{
623 if (!fXftFontHash) {
625 return;
626 }
627
628 TXftFontData *data = fXftFontHash->FindByFont(font);
629
630 if (!data) {
632 return;
633 }
634
635 XftFont *xftfont = data->fXftFont;
636
637 if (!xftfont) {
639 return;
640 }
641
642 max_ascent = xftfont->ascent;
643 max_descent = xftfont->descent;
644}
645
646////////////////////////////////////////////////////////////////////////////////
647/// Draw text string
648
650 const char *text, Int_t len)
651{
656
657 if (!xwindow) {
658 return;
659 }
660
661 if (!gc) {
662 return;
663 }
664
665 if (!text || (len < 1) || !text[0]) {
666 return;
667 }
668
669 if (!fXftFontHash) {
671 return;
672 }
673
675 gval.fMask = kGCForeground | kGCBackground; // retrieve GC values
677
678 TXftFontData *data = fXftFontHash->FindByGC(gc);
679
680 // no XftFont data
681 if (!data) {
683 return;
684 }
685
686 xftfont = data->fXftFont;
687
688 // no Xft font
689 if (!xftfont) {
691 return;
692 }
693
694 // dummies
696 Int_t dx,dy;
698
699 // check if drawable is bitmap
700 XGetGeometry((Display*)fDisplay, (Drawable)xwindow, &droot, &dx, &dy,
701 &width, &height, &bwidth, &depth);
702
703 if (depth <= 1) {
705 return;
706 }
707
708 memset(&xcolor, 0, sizeof(xcolor));
709 xcolor.pixel = gval.fForeground;
710
711 XQueryColor((Display*)fDisplay, fColormap, &xcolor);
712
713 // create XftDraw
715
716 if (!xftdraw) {
717 //Warning("could not create an XftDraw");
719 return;
720 }
721
722 xftcolor.color.red = xcolor.red;
723 xftcolor.color.green = xcolor.green;
724 xftcolor.color.blue = xcolor.blue;
725 xftcolor.color.alpha = 0xffff;
726 xftcolor.pixel = gval.fForeground;
727
729
730 // cleanup
732}
733
734#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:77
unsigned short UShort_t
Unsigned Short integer 2 bytes (unsigned short)
Definition RtypesCore.h:54
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
constexpr ULong_t kBitsPerByte
Definition RtypesCore.h:130
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:69
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:60
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
#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:170
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 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 bitmap
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:150
char name[80]
Definition TGX11.cxx:148
XID Window
Definition TGX11.h:38
XID Drawable
Definition TGX11.h:35
#define gVirtualX
Definition TVirtualX.h:375
#define malloc
Definition civetweb.c:1575
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:503
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:744
static void Activate()
Static method setting TGX11TTF as the acting gVirtualX.
Definition TGX11TTF.cxx:173
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:440
Bool_t Init(void *display) override
Initialize X11 system. Returns kFALSE in case of failure.
Definition TGX11TTF.cxx:184
void DrawFTGlyph(void *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:208
TGX11TTF(TGX11 &&org)
Create copy of TGX11 but now use TrueType fonts.
Definition TGX11TTF.cxx:157
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:300
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:459
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:1078
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:344
void QueryColors(Colormap cmap, RXColor *colors, Int_t ncolors)
Returns the current RGB value for the pixel in the XColor structure.
Definition TGX11.cxx:361
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:839
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:1049
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:319
Window_t GetWindow(WinContext_t wctxt) const
Return X11 window for specified window context.
Definition TGX11.cxx:1039
void DeleteGC(GContext_t gc) override
Explicitly delete a graphics context.
Definition GX11Gui.cxx:1032
@ kTLeft
Definition TGX11.h:124
@ kMRight
Definition TGX11.h:124
@ kMLeft
Definition TGX11.h:124
@ kTCenter
Definition TGX11.h:124
@ kBCenter
Definition TGX11.h:125
@ kBRight
Definition TGX11.h:125
@ kMCenter
Definition TGX11.h:124
@ kTRight
Definition TGX11.h:124
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:2069
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:2058
EAlign GetTextAlignW(WinContext_t wctxt) const
Return text align value for specified window context.
Definition TGX11.cxx:1068
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:2077
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:1081
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1095
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:146
Dynamic handle to work with freetype 2 library.
Definition TTF.h:119
static Bool_t Init()
Definition TTF.cxx:587
static Bool_t GetSmoothing()
Definition TTF.cxx:602
static void SetSmoothing(Bool_t state)
Definition TTF.cxx:616
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 Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:249
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