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
32#include <X11/Xlib.h>
33#include <X11/Xutil.h>
34#include <X11/Xatom.h>
35#include <X11/cursorfont.h>
36#include <X11/keysym.h>
37#include <X11/xpm.h>
38
39struct RXColor:XColor{};
40struct RVisual:Visual{};
41struct RXImage:XImage{};
42
43#ifdef R__HAS_XFT
44
45#include "THashTable.h"
46#include "TRefCnt.h"
47#include <X11/Xft/Xft.h>
48
49///////////////////////// xft font data //////////////////////////////////////
50class TXftFontData : public TNamed, public TRefCnt {
51public:
52 GContext_t fGC; // graphics context
53 XftFont *fXftFont; // xft font
54
57 {
58 SetRefCount(1);
59 fGC = gc;
60 }
61
62 void MapGCFont(GContext_t gc, FontStruct_t font)
63 {
64 fGC = gc; fXftFont = (XftFont *)font;
65 }
66
68 {
69 if (References() == 1) {
70 if (fXftFont) XftFontClose((Display*)gVirtualX->GetDisplay(), fXftFont);
71 }
72 }
73};
74
75/////////////////// hash table //////////////////////////////////////////////
76class TXftFontHash {
77public:
78 THashTable *fList; // hash table
79
80 TXftFontHash() { fList = new THashTable(50); }
81
82 TXftFontData *FindByName(const char *name)
83 {
84 return (TXftFontData*)fList->FindObject(name);
85 }
86
88 {
89 TIter next(fList);
90
91 while (auto d = (TXftFontData*) next()) {
92 if (d->fXftFont == (XftFont *)font)
93 return d;
94 }
95 return nullptr;
96 }
97
99 {
100 TIter next(fList);
101
102 while (auto d = (TXftFontData*) next()) {
103 if (d->fGC == gc)
104 return d;
105 }
106 return nullptr;
107 }
108
109 void AddFont(TXftFontData *data)
110 {
111 // Loop over all existing TXftFontData, if we already have one with the same
112 // font data, set the reference counter of this one beyond 1 so it does
113 // delete the font pointer
114 TIter next(fList);
115
116 while (auto d = (TXftFontData*) next()) {
117 if (d->fXftFont == data->fXftFont)
118 data->AddReference();
119 }
120
121 fList->Add(data);
122 }
123
124 void FreeFont(TXftFontData *data)
125 {
126 fList->Remove(data);
127 delete data;
128 }
129};
130
131Bool_t TGX11TTF::gXftInit = kFALSE;
132
133#endif // R__HAS_XFT
134
135/** \class TTFX11Init
136\ingroup GraphicsBackends
137
138Small utility class that takes care of switching the current
139gVirtualX to the new TGX11TTF class as soon as the shared library
140containing this class is loaded.
141*/
142
144public:
146};
148
149
151
152////////////////////////////////////////////////////////////////////////////////
153/// Create copy of TGX11 but now use TrueType fonts.
154
156{
157 SetName("X11TTF");
158 SetTitle("ROOT interface to X11 with TrueType fonts");
159
160 if (!TTF::fgInit) TTF::Init();
161
163 fHasXft = kFALSE;
164 fAlign.x = 0;
165 fAlign.y = 0;
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 (gVirtualX && dynamic_cast<TGX11*>(gVirtualX)) {
178 TGX11 *oldg = (TGX11 *) gVirtualX;
179 gVirtualX = new TGX11TTF(*oldg);
180 delete oldg;
181 }
182}
183
184////////////////////////////////////////////////////////////////////////////////
185/// Initialize X11 system. Returns kFALSE in case of failure.
186
187Bool_t TGX11TTF::Init(void *display)
188{
189#ifdef R__HAS_XFT
190 fXftFontHash = nullptr;
191 XFontStruct *fs = nullptr;
192 if (display) fs = XLoadQueryFont((Display *)display, "-*-helvetica-*-r-*-*-14-*-*-*-*-*-*-*");
193 if (!fs) gEnv->SetValue("X11.UseXft", 1);
194 if (display && fs) XFreeFont((Display *)display, fs);
195 if (gEnv->GetValue("X11.UseXft", 0)) {
196 fHasXft = kTRUE;
198 }
199#endif
200 Bool_t r = TGX11::Init(display);
201
202 if (fDepth > 8) {
204 } else {
206 }
207
208 return r;
209}
210
211////////////////////////////////////////////////////////////////////////////////
212/// Compute alignment variables. The alignment is done on the horizontal string
213/// then the rotation is applied on the alignment variables.
214/// SetRotation and LayoutGlyphs should have been called before.
215
217{
218 EAlign align = (EAlign) fTextAlign;
219
220 // vertical alignment
221 if (align == kTLeft || align == kTCenter || align == kTRight) {
223 } else if (align == kMLeft || align == kMCenter || align == kMRight) {
224 fAlign.y = TTF::fgAscent/2;
225 } else {
226 fAlign.y = 0;
227 }
228
229 // horizontal alignment
230 if (align == kTRight || align == kMRight || align == kBRight) {
232 } else if (align == kTCenter || align == kMCenter || align == kBCenter) {
233 fAlign.x = TTF::fgWidth/2;
234 } else {
235 fAlign.x = 0;
236 }
237
239 fAlign.x = fAlign.x >> 6;
240 fAlign.y = fAlign.y >> 6;
241}
242
243////////////////////////////////////////////////////////////////////////////////
244/// Draw FT_Bitmap bitmap to xim image at position bx,by using specified
245/// foreground color.
246
249{
250 UChar_t d = 0, *s = source->buffer;
251
252 if (TTF::fgSmoothing) {
253
254 static RXColor col[5];
255 RXColor *bcol = nullptr;
256 XColor *bc;
257 Int_t x, y;
258
259 // background kClear, i.e. transparent, we take as background color
260 // the average of the rgb values of all pixels covered by this character
261 if (back == (ULong_t) -1 && (UInt_t)source->width) {
262 ULong_t r, g, b;
264 const Int_t maxdots = 50000;
265
266 dots = Int_t(source->width * source->rows);
267 dots = dots > maxdots ? maxdots : dots;
268 bcol = new RXColor[dots];
269 if (!bcol) return;
270 bc = bcol;
271 dotcnt = 0;
272 for (y = 0; y < (int) source->rows; y++) {
273 for (x = 0; x < (int) source->width; x++, bc++) {
274/// bc->pixel = XGetPixel(xim, bx + x, by - c->TTF::fgAscent + y);
275 bc->pixel = XGetPixel(xim, bx + x, by + y);
276 bc->flags = DoRed | DoGreen | DoBlue;
277 if (++dotcnt >= maxdots) break;
278 }
279 }
281 r = g = b = 0;
282 bc = bcol;
283 dotcnt = 0;
284 for (y = 0; y < (int) source->rows; y++) {
285 for (x = 0; x < (int) source->width; x++, bc++) {
286 r += bc->red;
287 g += bc->green;
288 b += bc->blue;
289 if (++dotcnt >= maxdots) break;
290 }
291 }
292 if (dots != 0) {
293 r /= dots;
294 g /= dots;
295 b /= dots;
296 }
297 bc = &col[0];
298 if (bc->red == r && bc->green == g && bc->blue == b)
299 bc->pixel = back;
300 else {
301 bc->pixel = ~back;
302 bc->red = (UShort_t) r;
303 bc->green = (UShort_t) g;
304 bc->blue = (UShort_t) b;
305 }
306 }
307 delete [] bcol;
308
309 // if fore or background have changed from previous character
310 // recalculate the 3 smoothing colors (interpolation between fore-
311 // and background colors)
312 if (fore != col[4].pixel || back != col[0].pixel) {
313 col[4].pixel = fore;
314 col[4].flags = DoRed|DoGreen|DoBlue;
315 if (back != (ULong_t) -1) {
316 col[3].pixel = back;
317 col[3].flags = DoRed | DoGreen | DoBlue;
318 QueryColors(fColormap, &col[3], 2);
319 col[0] = col[3];
320 } else {
321 QueryColors(fColormap, &col[4], 1);
322 }
323
324 // interpolate between fore and background colors
325 for (x = 3; x > 0; x--) {
326 col[x].red = (col[4].red *x + col[0].red *(4-x)) /4;
327 col[x].green = (col[4].green*x + col[0].green*(4-x)) /4;
328 col[x].blue = (col[4].blue *x + col[0].blue *(4-x)) /4;
329 if (!AllocColor(fColormap, &col[x])) {
330 Warning("DrawImage", "cannot allocate smoothing color");
331 col[x].pixel = col[x+1].pixel;
332 }
333 }
334 }
335
336 // put smoothed character, character pixmap values are an index
337 // into the 5 colors used for aliasing (4 = foreground, 0 = background)
338 for (y = 0; y < (int) source->rows; y++) {
339 for (x = 0; x < (int) source->width; x++) {
340 d = *s++ & 0xff;
341 d = ((d + 10) * 5) / 256;
342 if (d > 4) d = 4;
343 if (d && x < (int) source->width) {
344 ULong_t p = col[d].pixel;
345 XPutPixel(xim, bx + x, by + y, p);
346 }
347 }
348 }
349 } else {
350 // no smoothing, just put character using foreground color
351 UChar_t* row=s;
352 for (int y = 0; y < (int) source->rows; y++) {
353 int n = 0;
354 s = row;
355 for (int x = 0; x < (int) source->width; x++) {
356 if (n == 0) d = *s++;
357 if (TESTBIT(d,7-n))
358 XPutPixel(xim, bx + x, by + y, fore);
359 if (++n == (int) kBitsPerByte) n = 0;
360 }
361 row += source->pitch;
362 }
363 }
364}
365
366////////////////////////////////////////////////////////////////////////////////
367/// Draw text using TrueType fonts. If TrueType fonts are not available the
368/// text is drawn with TGX11::DrawText.
369
371 const char *text, ETextMode mode)
372{
373 if (!fHasTTFonts) {
375 } else {
376 if (!TTF::fgInit) TTF::Init();
380 Align();
381 RenderString(x, y, mode);
382 }
383}
384
385////////////////////////////////////////////////////////////////////////////////
386/// Draw text using TrueType fonts. If TrueType fonts are not available the
387/// text is drawn with TGX11::DrawText.
388
390 const wchar_t *text, ETextMode mode)
391{
392 if (!fHasTTFonts) {
394 } else {
395 if (!TTF::fgInit) TTF::Init();
399 Align();
400 RenderString(x, y, mode);
401 }
402}
403
404////////////////////////////////////////////////////////////////////////////////
405/// Get the background of the current window in an XImage.
406
408{
412 Int_t xy;
413 gVirtualX->GetWindowSize(cws, xy, xy, width, height);
414
415 if (x < 0) {
416 w += x;
417 x = 0;
418 }
419 if (y < 0) {
420 h += y;
421 y = 0;
422 }
423
424 if (x+w > width) w = width - x;
425 if (y+h > height) h = height - y;
426
427 return (RXImage*)XGetImage((Display*)fDisplay, cws, x, y, w, h, AllPlanes, ZPixmap);
428}
429
430////////////////////////////////////////////////////////////////////////////////
431/// Test if there is really something to render.
432
434{
438 Int_t xy;
439 gVirtualX->GetWindowSize(cws, xy, xy, width, height);
440
441 // If w or h is 0, very likely the string is only blank characters
442 if ((int)w == 0 || (int)h == 0) return kFALSE;
443
444 // If string falls outside window, there is probably no need to draw it.
445 if (x + (int)w <= 0 || x >= (int)width) return kFALSE;
446 if (y + (int)h <= 0 || y >= (int)height) return kFALSE;
447
448 // If w or h are much larger than the window size, there is probably no need
449 // to draw it. Moreover a to large text size may produce a Seg Fault in
450 // malloc in RenderString.
451 if (w > 10*width) return kFALSE;
452 if (h > 10*height) return kFALSE;
453
454 return kTRUE;
455}
456
457////////////////////////////////////////////////////////////////////////////////
458/// Perform the string rendering in the pad.
459/// LayoutGlyphs should have been called before.
460
462{
464
465 // compute the size and position of the XImage that will contain the text
466 Int_t Xoff = 0; if (TTF::GetBox().xMin < 0) Xoff = -TTF::GetBox().xMin;
467 Int_t Yoff = 0; if (TTF::GetBox().yMin < 0) Yoff = -TTF::GetBox().yMin;
468 Int_t w = TTF::GetBox().xMax + Xoff;
469 Int_t h = TTF::GetBox().yMax + Yoff;
470 Int_t x1 = x-Xoff-fAlign.x;
471 Int_t y1 = y+Yoff+fAlign.y-h;
472
473 if (!IsVisible(x1, y1, w, h)) return;
474
475 // create the XImage that will contain the text
477 XImage *xim = XCreateImage((Display*)fDisplay, fVisual,
478 depth, ZPixmap, 0, nullptr, w, h,
479 depth <= 8 ? 8 : (depth <= 16 ? 16 : 32), 0);
480 //bitmap_pad should be 8, 16 or 32 https://www.x.org/releases/X11R7.5/doc/man/man3/XPutPixel.3.html
481 if (!xim) return;
482
483 // use malloc since Xlib will use free() in XDestroyImage
484 xim->data = (char *) malloc(xim->bytes_per_line * h);
485 memset(xim->data, 0, xim->bytes_per_line * h);
486
487 ULong_t bg;
488 XGCValues values;
489 GC *gc = (GC*)GetGC(3);
490 if (!gc) {
491 Error("DrawText", "error getting Graphics Context");
492 return;
493 }
494 XGetGCValues((Display*)fDisplay, *gc, GCForeground | GCBackground, &values);
495
496 // get the background
497 if (mode == kClear) {
498 // if mode == kClear we need to get an image of the background
499 XImage *bim = GetBackground(x1, y1, w, h);
500 if (!bim) {
501 Error("DrawText", "error getting background image");
502 return;
503 }
504
505 // and copy it into the text image
506 Int_t xo = 0, yo = 0;
507 if (x1 < 0) xo = -x1;
508 if (y1 < 0) yo = -y1;
509
510 for (int yp = 0; yp < (int) bim->height; yp++) {
511 for (int xp = 0; xp < (int) bim->width; xp++) {
514 }
515 }
517 bg = (ULong_t) -1;
518 } else {
519 // if mode == kOpaque its simple, we just draw the background
520 XAddPixel(xim, values.background);
521 bg = values.background;
522 }
523
524 // paint the glyphs in the XImage
526 for (int n = 0; n < TTF::fgNumGlyphs; n++, glyph++) {
527 if (FT_Glyph_To_Bitmap(&glyph->fImage,
530 nullptr, 1 )) continue;
532 FT_Bitmap* source = &bitmap->bitmap;
533 Int_t bx, by;
534
535 bx = bitmap->left+Xoff;
536 by = h - bitmap->top-Yoff;
537 DrawImage(source, values.foreground, bg, (RXImage*)xim, bx, by);
538 }
539
540 // put the Ximage on the screen
542 gc = (GC*)GetGC(6);
543 if (gc) XPutImage((Display*)fDisplay, cws, *gc, xim, 0, 0, x1, y1, w, h);
545}
546
547////////////////////////////////////////////////////////////////////////////////
548/// Set specified font.
549
559
560////////////////////////////////////////////////////////////////////////////////
561/// Set text font to specified name.
562/// mode : loading flag
563/// mode=0 : search if the font exist (kCheck)
564/// mode=1 : search the font and load it if it exists (kLoad)
565/// font : font name
566///
567/// Set text font to specified name. This function returns 0 if
568/// the specified font is found, 1 if not.
569
571{
572 if (!fHasTTFonts) {
574 } else {
576 }
577}
578
579////////////////////////////////////////////////////////////////////////////////
580/// Set current text size.
581
591
592#ifdef R__HAS_XFT
593
594///////////////////////////// Xft font methods /////////////////////////////////
595////////////////////////////////////////////////////////////////////////////////
596/// Parses an XLFD name and opens a font.
597
598FontStruct_t TGX11TTF::LoadQueryFont(const char *font_name)
599{
600 if (!fXftFontHash) {
601 return TGX11::LoadQueryFont(font_name);
602 }
603
604 TXftFontData *data = fXftFontHash->FindByName(font_name);
605
606 // already loaded
607 if (data) {
608 return (FontStruct_t)data->fXftFont;
609 }
610
611 if (!gXftInit) {
612 XftInit(nullptr);
613 gXftInit = kTRUE;
614 }
615
616 XftFont *xftfont = XftFontOpenXlfd((Display*)fDisplay, fScreenNumber, font_name);
617
618 data = new TXftFontData(0, xftfont, font_name);
619 fXftFontHash->AddFont(data);
620
621 return (FontStruct_t)xftfont;
622}
623
624////////////////////////////////////////////////////////////////////////////////
625/// Explicitly delete font structure obtained with LoadQueryFont().
626
628{
629 if (!fXftFontHash) {
631 return;
632 }
633
634 TXftFontData *data = fXftFontHash->FindByFont(fs);
635
636 if (data)
637 fXftFontHash->FreeFont(data);
638}
639
640////////////////////////////////////////////////////////////////////////////////
641/// Explicitly delete a graphics context.
642
644{
645 if (!fXftFontHash) {
647 return;
648 }
649
650 TXftFontData *gcdata = fXftFontHash->FindByGC(gc);
651 if (gcdata) fXftFontHash->FreeFont(gcdata);
653}
654
655////////////////////////////////////////////////////////////////////////////////
656/// Return handle to font described by font structure.
657
659{
660 if (!fXftFontHash) {
661 return TGX11::GetFontHandle(fs);
662 }
663
664 return (FontH_t)fs;
665}
666
667////////////////////////////////////////////////////////////////////////////////
668/// Return the font associated with the graphics context gc
669
671{
672 if (!fXftFontHash) {
673 return 0;
674 }
675
676 TXftFontData *data = fXftFontHash->FindByGC(gc);
677
678 // no XftFont data
679 if (!data) return 0;
680
681 return (FontStruct_t)data->fXftFont;
682}
683
684////////////////////////////////////////////////////////////////////////////////
685/// Map the XftFont with the Graphics Context using it.
686
688{
689 if (!fXftFontHash)
690 return;
691
692 TXftFontData *gcdata = fXftFontHash->FindByGC(gc);
693 TXftFontData *fontdata = fXftFontHash->FindByFont(font);
694
695 if (gcdata) { // && (gcdata->fXftFont == 0)) {
696 gcdata->fXftFont = (XftFont *)font;
697 }
698 else if (fontdata) {
699 TXftFontData *data = new TXftFontData(gc, (XftFont *)font, fontdata->GetName());
700 fXftFontHash->AddFont(data);
701 }
702}
703
704////////////////////////////////////////////////////////////////////////////////
705/// Return length of string in pixels. Size depends on font
706
707Int_t TGX11TTF::TextWidth(FontStruct_t font, const char *s, Int_t len)
708{
709 if (!fXftFontHash) {
710 return TGX11::TextWidth(font, s, len);
711 }
712
713 TXftFontData *data = fXftFontHash->FindByFont(font);
714
715 if (!data) return 0;
716
717 XftFont *xftfont = data->fXftFont;
718
719 if (xftfont) {
722 return glyph_info.xOff;
723 }
724 return 0;
725}
726
727////////////////////////////////////////////////////////////////////////////////
728/// Return some font properties
729
731{
732 if (!fXftFontHash) {
734 return;
735 }
736
737 TXftFontData *data = fXftFontHash->FindByFont(font);
738
739 if (!data) {
741 return;
742 }
743
744 XftFont *xftfont = data->fXftFont;
745
746 if (!xftfont) {
748 return;
749 }
750
751 max_ascent = xftfont->ascent;
752 max_descent = xftfont->descent;
753}
754
755////////////////////////////////////////////////////////////////////////////////
756/// Draw text string
757
759 const char *text, Int_t len)
760{
765
766 if (!xwindow) {
767 return;
768 }
769
770 if (!gc) {
771 return;
772 }
773
774 if (!text || (len < 1) || !text[0]) {
775 return;
776 }
777
778 if (!fXftFontHash) {
780 return;
781 }
782
784 gval.fMask = kGCForeground | kGCBackground; // retrieve GC values
786
787 TXftFontData *data = fXftFontHash->FindByGC(gc);
788
789 // no XftFont data
790 if (!data) {
792 return;
793 }
794
795 xftfont = data->fXftFont;
796
797 // no Xft font
798 if (!xftfont) {
800 return;
801 }
802
803 // dummies
805 Int_t dx,dy;
807
808 // check if drawable is bitmap
809 XGetGeometry((Display*)fDisplay, (Drawable)xwindow, &droot, &dx, &dy,
810 &width, &height, &bwidth, &depth);
811
812 if (depth <= 1) {
814 return;
815 }
816
817 memset(&xcolor, 0, sizeof(xcolor));
818 xcolor.pixel = gval.fForeground;
819
820 XQueryColor((Display*)fDisplay, fColormap, &xcolor);
821
822 // create XftDraw
824
825 if (!xftdraw) {
826 //Warning("could not create an XftDraw");
828 return;
829 }
830
831 xftcolor.color.red = xcolor.red;
832 xftcolor.color.green = xcolor.green;
833 xftcolor.color.blue = xcolor.blue;
834 xftcolor.color.alpha = 0xffff;
835 xftcolor.pixel = gval.fForeground;
836
838
839 // cleanup
841}
842
843#endif // R__HAS_XFT
const Mask_t kGCBackground
Definition GuiTypes.h:289
const Mask_t kGCForeground
Definition GuiTypes.h:288
Handle_t FontH_t
Font handle (as opposed to Font_t which is an index)
Definition GuiTypes.h:35
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:38
Handle_t Drawable_t
Drawable handle.
Definition GuiTypes.h:31
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:39
#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
Definition RtypesCore.h:63
unsigned short UShort_t
Definition RtypesCore.h:40
int Int_t
Definition RtypesCore.h:45
constexpr ULong_t kBitsPerByte
Definition RtypesCore.h:123
unsigned long ULong_t
Definition RtypesCore.h:55
unsigned int UInt_t
Definition RtypesCore.h:46
float Float_t
Definition RtypesCore.h:57
short Font_t
Definition RtypesCore.h:88
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:377
#define TESTBIT(n, i)
Definition Rtypes.h:88
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
winID h TVirtualViewer3D TVirtualGLPainter p
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 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 r
Option_t Option_t fontnumber
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 textsize
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 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 fontname
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:147
char name[80]
Definition TGX11.cxx:110
XID Window
Definition TGX11.h:36
XID Drawable
Definition TGX11.h:33
#define gVirtualX
Definition TVirtualX.h:337
#define malloc
Definition civetweb.c:1536
Font_t fTextFont
Text font.
Definition TAttText.h:25
Float_t fTextSize
Text size.
Definition TAttText.h:22
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:491
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:736
Interface to low level X11 (Xlib).
Definition TGX11TTF.h:27
void RenderString(Int_t x, Int_t y, ETextMode mode)
Perform the string rendering in the pad.
Definition TGX11TTF.cxx:461
static void Activate()
Static method setting TGX11TTF as the acting gVirtualX.
Definition TGX11TTF.cxx:175
void Align(void)
Compute alignment variables.
Definition TGX11TTF.cxx:216
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:407
Bool_t Init(void *display) override
Initialize X11 system. Returns kFALSE in case of failure.
Definition TGX11TTF.cxx:187
void SetTextSize(Float_t textsize) override
Set current text size.
Definition TGX11TTF.cxx:582
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:247
FT_Vector fAlign
alignment vector
Definition TGX11TTF.h:33
void SetTextFont(Font_t fontnumber) override
Set specified font.
Definition TGX11TTF.cxx:550
TGX11TTF(const TGX11 &org)
Create copy of TGX11 but now use TrueType fonts.
Definition TGX11TTF.cxx:155
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:433
@ kTCenter
Definition TGX11TTF.h:30
@ kBRight
Definition TGX11TTF.h:31
@ kBCenter
Definition TGX11TTF.h:31
@ kMCenter
Definition TGX11TTF.h:30
@ kMRight
Definition TGX11TTF.h:30
@ kTRight
Definition TGX11TTF.h:30
void DrawText(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:370
This class is the basic interface to the X11 (Xlib) graphics system.
Definition TGX11.h:80
void * fDisplay
Pointer to display.
Definition TGX11.h:125
Colormap fColormap
Default colormap, 0 if b/w.
Definition TGX11.h:129
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:132
Bool_t AllocColor(Colormap cmap, RXColor *color)
Allocate color in colormap.
Definition TGX11.cxx:366
void DrawText(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.
Definition TGX11.cxx:751
void QueryColors(Colormap cmap, RXColor *colors, Int_t ncolors)
Returns the current RGB value for the pixel in the XColor structure.
Definition TGX11.cxx:383
void * GetGC(Int_t which) const
Return desired Graphics Context ("which" maps directly on gGCList[]).
Definition TGX11.cxx:931
Bool_t fHasXft
True when XftFonts are used.
Definition TGX11.h:147
Int_t SetTextFont(char *fontname, ETextSetMode mode) override
Set text font to specified name.
Definition TGX11.cxx:3154
Int_t fTextAlign
Text alignment (set in SetTextAlign)
Definition TGX11.h:135
Int_t fDepth
Number of color planes.
Definition TGX11.h:139
Bool_t Init(void *display) override
Initialize X11 system. Returns kFALSE in case of failure.
Definition TGX11.cxx:342
void DeleteGC(GContext_t gc) override
Explicitly delete a graphics context.
Definition GX11Gui.cxx:1032
void SetTextSize(Float_t textsize) override
Set current text size.
Definition TGX11.cxx:3203
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
RVisual * fVisual
Pointer to visual used by all windows.
Definition TGX11.h:126
Window_t GetCurrentWindow() const override
Return current window pointer. Protected method used by TGX11TTF.
Definition TGX11.cxx:922
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:146
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:164
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:140
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:973
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:987
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:143
TTF helper class containing glyphs description.
Definition TTF.h:65
static void PrepareString(const char *string)
Put the characters in "string" in the "glyphs" array.
Definition TTF.cxx:250
static TTF::TTGlyph fgGlyphs[kMaxGlyphs]
glyphs
Definition TTF.h:83
static Bool_t fgSmoothing
use anti-aliasing (true when >8 planes, false otherwise)
Definition TTF.h:90
static void Init()
Initialise the TrueType fonts interface.
Definition TTF.cxx:65
static void LayoutGlyphs()
Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
Definition TTF.cxx:181
static void SetSmoothing(Bool_t state)
Set smoothing (anti-aliasing) flag.
Definition TTF.cxx:365
static void SetRotationMatrix(Float_t angle)
Set the rotation matrix used to rotate the font outlines.
Definition TTF.cxx:342
static void SetTextFont(Font_t fontnumber)
Set specified font.
Definition TTF.cxx:490
static Int_t fgAscent
string ascent, used to compute Y alignment
Definition TTF.h:75
static Int_t fgWidth
string width, used to compute X alignment
Definition TTF.h:92
static Bool_t fgInit
true if the Init has been called
Definition TTF.h:85
static const FT_BBox & GetBox()
Definition TTF.cxx:644
static Int_t fgNumGlyphs
number of glyphs in the string
Definition TTF.h:88
static FT_Matrix * fgRotMatrix
rotation matrix
Definition TTF.h:89
static void SetTextSize(Float_t textsize)
Set current text size.
Definition TTF.cxx:561
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
Graphics context structure.
Definition GuiTypes.h:224