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
67 ~TXftFontData() override
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
150
151////////////////////////////////////////////////////////////////////////////////
152/// Create copy of TGX11 but now use TrueType fonts.
153
155{
156 SetName("X11TTF");
157 SetTitle("ROOT interface to X11 with TrueType fonts");
158
159 if (!TTF::fgInit) TTF::Init();
160
162 fHasXft = kFALSE;
163 fAlign.x = 0;
164 fAlign.y = 0;
165
166#ifdef R__HAS_XFT
167 fXftFontHash = nullptr;
168#endif
169}
170
171////////////////////////////////////////////////////////////////////////////////
172/// Static method setting TGX11TTF as the acting gVirtualX.
173
175{
176 if (auto oldg = dynamic_cast<TGX11*>(gVirtualX)) {
177 gVirtualX = new TGX11TTF(std::move(*oldg));
178 delete oldg;
179 }
180}
181
182////////////////////////////////////////////////////////////////////////////////
183/// Initialize X11 system. Returns kFALSE in case of failure.
184
185Bool_t TGX11TTF::Init(void *display)
186{
187#ifdef R__HAS_XFT
188 fXftFontHash = nullptr;
189 XFontStruct *fs = nullptr;
190 if (display) fs = XLoadQueryFont((Display *)display, "-*-helvetica-*-r-*-*-14-*-*-*-*-*-*-*");
191 if (!fs) gEnv->SetValue("X11.UseXft", 1);
192 if (display && fs) XFreeFont((Display *)display, fs);
193 if (gEnv->GetValue("X11.UseXft", 0)) {
194 fHasXft = kTRUE;
196 }
197#endif
198 Bool_t r = TGX11::Init(display);
199
200 if (fDepth > 8) {
202 } else {
204 }
205
206 return r;
207}
208
209////////////////////////////////////////////////////////////////////////////////
210/// Compute alignment variables. The alignment is done on the horizontal string
211/// then the rotation is applied on the alignment variables.
212/// SetRotation and LayoutGlyphs should have been called before.
213
215{
216 auto align = GetTextAlignW(wctxt);
217
218 // vertical alignment
219 if (align == kTLeft || align == kTCenter || align == kTRight) {
221 } else if (align == kMLeft || align == kMCenter || align == kMRight) {
222 fAlign.y = TTF::fgAscent/2;
223 } else {
224 fAlign.y = 0;
225 }
226
227 // horizontal alignment
228 if (align == kTRight || align == kMRight || align == kBRight) {
230 } else if (align == kTCenter || align == kMCenter || align == kBCenter) {
231 fAlign.x = TTF::fgWidth/2;
232 } else {
233 fAlign.x = 0;
234 }
235
237 fAlign.x = fAlign.x >> 6;
238 fAlign.y = fAlign.y >> 6;
239}
240
241////////////////////////////////////////////////////////////////////////////////
242/// Draw FT_Bitmap bitmap to xim image at position bx,by using specified
243/// foreground color.
244
247{
248 UChar_t d = 0, *s = source->buffer;
249
250 if (TTF::fgSmoothing) {
251
252 static RXColor col[5];
253 RXColor *bcol = nullptr;
254 XColor *bc;
255 Int_t x, y;
256
257 // background kClear, i.e. transparent, we take as background color
258 // the average of the rgb values of all pixels covered by this character
259 if (back == (ULong_t) -1 && (UInt_t)source->width) {
260 ULong_t r, g, b;
262 const Int_t maxdots = 50000;
263
264 dots = Int_t(source->width * source->rows);
265 dots = dots > maxdots ? maxdots : dots;
266 bcol = new RXColor[dots];
267 if (!bcol) return;
268 bc = bcol;
269 dotcnt = 0;
270 for (y = 0; y < (int) source->rows; y++) {
271 for (x = 0; x < (int) source->width; x++, bc++) {
272/// bc->pixel = XGetPixel(xim, bx + x, by - c->TTF::fgAscent + y);
273 bc->pixel = XGetPixel(xim, bx + x, by + y);
274 bc->flags = DoRed | DoGreen | DoBlue;
275 if (++dotcnt >= maxdots) break;
276 }
277 }
279 r = g = b = 0;
280 bc = bcol;
281 dotcnt = 0;
282 for (y = 0; y < (int) source->rows; y++) {
283 for (x = 0; x < (int) source->width; x++, bc++) {
284 r += bc->red;
285 g += bc->green;
286 b += bc->blue;
287 if (++dotcnt >= maxdots) break;
288 }
289 }
290 if (dots != 0) {
291 r /= dots;
292 g /= dots;
293 b /= dots;
294 }
295 bc = &col[0];
296 if (bc->red == r && bc->green == g && bc->blue == b)
297 bc->pixel = back;
298 else {
299 bc->pixel = ~back;
300 bc->red = (UShort_t) r;
301 bc->green = (UShort_t) g;
302 bc->blue = (UShort_t) b;
303 }
304 }
305 delete [] bcol;
306
307 // if fore or background have changed from previous character
308 // recalculate the 3 smoothing colors (interpolation between fore-
309 // and background colors)
310 if (fore != col[4].pixel || back != col[0].pixel) {
311 col[4].pixel = fore;
312 col[4].flags = DoRed|DoGreen|DoBlue;
313 if (back != (ULong_t) -1) {
314 col[3].pixel = back;
315 col[3].flags = DoRed | DoGreen | DoBlue;
316 QueryColors(fColormap, &col[3], 2);
317 col[0] = col[3];
318 } else {
319 QueryColors(fColormap, &col[4], 1);
320 }
321
322 // interpolate between fore and background colors
323 for (x = 3; x > 0; x--) {
324 col[x].red = (col[4].red *x + col[0].red *(4-x)) /4;
325 col[x].green = (col[4].green*x + col[0].green*(4-x)) /4;
326 col[x].blue = (col[4].blue *x + col[0].blue *(4-x)) /4;
327 if (!AllocColor(fColormap, &col[x])) {
328 Warning("DrawImage", "cannot allocate smoothing color");
329 col[x].pixel = col[x+1].pixel;
330 }
331 }
332 }
333
334 // put smoothed character, character pixmap values are an index
335 // into the 5 colors used for aliasing (4 = foreground, 0 = background)
336 for (y = 0; y < (int) source->rows; y++) {
337 for (x = 0; x < (int) source->width; x++) {
338 d = *s++ & 0xff;
339 d = ((d + 10) * 5) / 256;
340 if (d > 4) d = 4;
341 if (d && x < (int) source->width) {
342 ULong_t p = col[d].pixel;
343 XPutPixel(xim, bx + x, by + y, p);
344 }
345 }
346 }
347 } else {
348 // no smoothing, just put character using foreground color
349 UChar_t* row=s;
350 for (int y = 0; y < (int) source->rows; y++) {
351 int n = 0;
352 s = row;
353 for (int x = 0; x < (int) source->width; x++) {
354 if (n == 0) d = *s++;
355 if (TESTBIT(d,7-n))
356 XPutPixel(xim, bx + x, by + y, fore);
357 if (++n == (int) kBitsPerByte) n = 0;
358 }
359 row += source->pitch;
360 }
361 }
362}
363
364////////////////////////////////////////////////////////////////////////////////
365/// Draw text using TrueType fonts. If TrueType fonts are not available the
366/// text is drawn with TGX11::DrawTextW.
367
382
383////////////////////////////////////////////////////////////////////////////////
384/// Draw text using TrueType fonts. If TrueType fonts are not available the
385/// text is drawn with TGX11::DrawTextW.
386
401
402////////////////////////////////////////////////////////////////////////////////
403/// Get the background of the current window in an XImage.
404
406{
410 Int_t xy;
412
413 if (x < 0) {
414 w += x;
415 x = 0;
416 }
417 if (y < 0) {
418 h += y;
419 y = 0;
420 }
421
422 if (x+w > width) w = width - x;
423 if (y+h > height) h = height - y;
424
425 return (RXImage *)XGetImage((Display*)fDisplay, cws, x, y, w, h, AllPlanes, ZPixmap);
426}
427
428////////////////////////////////////////////////////////////////////////////////
429/// Test if there is really something to render.
430
432{
436 Int_t xy;
438
439 // If w or h is 0, very likely the string is only blank characters
440 if ((int)w == 0 || (int)h == 0)
441 return kFALSE;
442
443 // If string falls outside window, there is probably no need to draw it.
444 if (x + (int)w <= 0 || x >= (int)width)
445 return kFALSE;
446 if (y + (int)h <= 0 || y >= (int)height)
447 return kFALSE;
448
449 // If w or h are much larger than the window size, there is probably no need
450 // to draw it. Moreover a to large text size may produce a Seg Fault in
451 // malloc in RenderString.
452 if (w > 10*width)
453 return kFALSE;
454 if (h > 10*height)
455 return kFALSE;
456
457 return kTRUE;
458}
459
460////////////////////////////////////////////////////////////////////////////////
461/// Perform the string rendering in the pad.
462/// LayoutGlyphs should have been called before.
463
465{
467
468 // compute the size and position of the XImage that will contain the text
469 Int_t Xoff = 0; if (TTF::GetBox().xMin < 0) Xoff = -TTF::GetBox().xMin;
470 Int_t Yoff = 0; if (TTF::GetBox().yMin < 0) Yoff = -TTF::GetBox().yMin;
471 Int_t w = TTF::GetBox().xMax + Xoff;
472 Int_t h = TTF::GetBox().yMax + Yoff;
473 Int_t x1 = x-Xoff-fAlign.x;
474 Int_t y1 = y+Yoff+fAlign.y-h;
475
476 if (!IsVisible(wctxt, x1, y1, w, h))
477 return;
478
479 // create the XImage that will contain the text
481 XImage *xim = XCreateImage((Display*)fDisplay, fVisual,
482 depth, ZPixmap, 0, nullptr, w, h,
483 depth <= 8 ? 8 : (depth <= 16 ? 16 : 32), 0);
484 //bitmap_pad should be 8, 16 or 32 https://www.x.org/releases/X11R7.5/doc/man/man3/XPutPixel.3.html
485 if (!xim) return;
486
487 // use malloc since Xlib will use free() in XDestroyImage
488 xim->data = (char *) malloc(xim->bytes_per_line * h);
489 memset(xim->data, 0, xim->bytes_per_line * h);
490
491 ULong_t bg;
492 XGCValues values;
493 auto gc = (GC *) GetGCW(wctxt, 3);
494 if (!gc) {
495 Error("RenderString", "error getting Graphics Context");
496 return;
497 }
498 XGetGCValues((Display*)fDisplay, *gc, GCForeground | GCBackground, &values);
499
500 // get the background
501 if (mode == kClear) {
502 // if mode == kClear we need to get an image of the background
504 if (!bim) {
505 Error("DrawText", "error getting background image");
506 return;
507 }
508
509 // and copy it into the text image
510 Int_t xo = 0, yo = 0;
511 if (x1 < 0) xo = -x1;
512 if (y1 < 0) yo = -y1;
513
514 for (int yp = 0; yp < (int) bim->height; yp++) {
515 for (int xp = 0; xp < (int) bim->width; xp++) {
518 }
519 }
521 bg = (ULong_t) -1;
522 } else {
523 // if mode == kOpaque its simple, we just draw the background
524 XAddPixel(xim, values.background);
525 bg = values.background;
526 }
527
528 // paint the glyphs in the XImage
530 for (int n = 0; n < TTF::fgNumGlyphs; n++, glyph++) {
531 if (FT_Glyph_To_Bitmap(&glyph->fImage,
534 nullptr, 1 )) continue;
536 FT_Bitmap* source = &bitmap->bitmap;
537 Int_t bx, by;
538
539 bx = bitmap->left+Xoff;
540 by = h - bitmap->top-Yoff;
541 DrawImage(source, values.foreground, bg, (RXImage*)xim, bx, by);
542 }
543
544 // put the Ximage on the screen
546 gc = (GC *) GetGCW(wctxt, 6);
547 if (gc)
548 XPutImage((Display*)fDisplay, cws, *gc, xim, 0, 0, x1, y1, w, h);
550}
551
552////////////////////////////////////////////////////////////////////////////////
553/// Set specified font.
554
556{
557 // TODO: add to window context custom part for TTF,
558 // it can be allocated and provided via private interface
560
561 if (fHasTTFonts) {
562 TTF::SetTextFont(att.GetTextFont());
563 TTF::SetTextSize(att.GetTextSize());
564 }
565}
566
567////////////////////////////////////////////////////////////////////////////////
568/// Set text font to specified name.
569/// mode : loading flag
570/// mode=0 : search if the font exist (kCheck)
571/// mode=1 : search the font and load it if it exists (kLoad)
572/// font : font name
573///
574/// Set text font to specified name. This function returns 0 if
575/// the specified font is found, 1 if not.
576
578{
579 if (!fHasTTFonts) {
581 } else {
583 }
584}
585
586#ifdef R__HAS_XFT
587
588///////////////////////////// Xft font methods /////////////////////////////////
589////////////////////////////////////////////////////////////////////////////////
590/// Parses an XLFD name and opens a font.
591
592FontStruct_t TGX11TTF::LoadQueryFont(const char *font_name)
593{
594 if (!fXftFontHash) {
595 return TGX11::LoadQueryFont(font_name);
596 }
597
598 TXftFontData *data = fXftFontHash->FindByName(font_name);
599
600 // already loaded
601 if (data) {
602 return (FontStruct_t)data->fXftFont;
603 }
604
605 if (!gXftInit) {
606 XftInit(nullptr);
607 gXftInit = kTRUE;
608 }
609
610 XftFont *xftfont = XftFontOpenXlfd((Display*)fDisplay, fScreenNumber, font_name);
611
612 data = new TXftFontData(0, xftfont, font_name);
613 fXftFontHash->AddFont(data);
614
615 return (FontStruct_t)xftfont;
616}
617
618////////////////////////////////////////////////////////////////////////////////
619/// Explicitly delete font structure obtained with LoadQueryFont().
620
622{
623 if (!fXftFontHash) {
625 return;
626 }
627
628 TXftFontData *data = fXftFontHash->FindByFont(fs);
629
630 if (data)
631 fXftFontHash->FreeFont(data);
632}
633
634////////////////////////////////////////////////////////////////////////////////
635/// Explicitly delete a graphics context.
636
638{
639 if (!fXftFontHash) {
641 return;
642 }
643
644 TXftFontData *gcdata = fXftFontHash->FindByGC(gc);
645 if (gcdata) fXftFontHash->FreeFont(gcdata);
647}
648
649////////////////////////////////////////////////////////////////////////////////
650/// Return handle to font described by font structure.
651
653{
654 if (!fXftFontHash) {
655 return TGX11::GetFontHandle(fs);
656 }
657
658 return (FontH_t)fs;
659}
660
661////////////////////////////////////////////////////////////////////////////////
662/// Return the font associated with the graphics context gc
663
665{
666 if (!fXftFontHash) {
667 return 0;
668 }
669
670 TXftFontData *data = fXftFontHash->FindByGC(gc);
671
672 // no XftFont data
673 if (!data) return 0;
674
675 return (FontStruct_t)data->fXftFont;
676}
677
678////////////////////////////////////////////////////////////////////////////////
679/// Map the XftFont with the Graphics Context using it.
680
682{
683 if (!fXftFontHash)
684 return;
685
686 TXftFontData *gcdata = fXftFontHash->FindByGC(gc);
687 TXftFontData *fontdata = fXftFontHash->FindByFont(font);
688
689 if (gcdata) { // && (gcdata->fXftFont == 0)) {
690 gcdata->fXftFont = (XftFont *)font;
691 }
692 else if (fontdata) {
693 TXftFontData *data = new TXftFontData(gc, (XftFont *)font, fontdata->GetName());
694 fXftFontHash->AddFont(data);
695 }
696}
697
698////////////////////////////////////////////////////////////////////////////////
699/// Return length of string in pixels. Size depends on font
700
701Int_t TGX11TTF::TextWidth(FontStruct_t font, const char *s, Int_t len)
702{
703 if (!fXftFontHash) {
704 return TGX11::TextWidth(font, s, len);
705 }
706
707 TXftFontData *data = fXftFontHash->FindByFont(font);
708
709 if (!data) return 0;
710
711 XftFont *xftfont = data->fXftFont;
712
713 if (xftfont) {
716 return glyph_info.xOff;
717 }
718 return 0;
719}
720
721////////////////////////////////////////////////////////////////////////////////
722/// Return some font properties
723
725{
726 if (!fXftFontHash) {
728 return;
729 }
730
731 TXftFontData *data = fXftFontHash->FindByFont(font);
732
733 if (!data) {
735 return;
736 }
737
738 XftFont *xftfont = data->fXftFont;
739
740 if (!xftfont) {
742 return;
743 }
744
745 max_ascent = xftfont->ascent;
746 max_descent = xftfont->descent;
747}
748
749////////////////////////////////////////////////////////////////////////////////
750/// Draw text string
751
753 const char *text, Int_t len)
754{
759
760 if (!xwindow) {
761 return;
762 }
763
764 if (!gc) {
765 return;
766 }
767
768 if (!text || (len < 1) || !text[0]) {
769 return;
770 }
771
772 if (!fXftFontHash) {
774 return;
775 }
776
778 gval.fMask = kGCForeground | kGCBackground; // retrieve GC values
780
781 TXftFontData *data = fXftFontHash->FindByGC(gc);
782
783 // no XftFont data
784 if (!data) {
786 return;
787 }
788
789 xftfont = data->fXftFont;
790
791 // no Xft font
792 if (!xftfont) {
794 return;
795 }
796
797 // dummies
799 Int_t dx,dy;
801
802 // check if drawable is bitmap
803 XGetGeometry((Display*)fDisplay, (Drawable)xwindow, &droot, &dx, &dy,
804 &width, &height, &bwidth, &depth);
805
806 if (depth <= 1) {
808 return;
809 }
810
811 memset(&xcolor, 0, sizeof(xcolor));
812 xcolor.pixel = gval.fForeground;
813
814 XQueryColor((Display*)fDisplay, fColormap, &xcolor);
815
816 // create XftDraw
818
819 if (!xftdraw) {
820 //Warning("could not create an XftDraw");
822 return;
823 }
824
825 xftcolor.color.red = xcolor.red;
826 xftcolor.color.green = xcolor.green;
827 xftcolor.color.blue = xcolor.blue;
828 xftcolor.color.alpha = 0xffff;
829 xftcolor.pixel = gval.fForeground;
830
832
833 // cleanup
835}
836
837#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
winID h TVirtualViewer3D TVirtualGLPainter p
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 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:148
XID Window
Definition TGX11.h:38
XID Drawable
Definition TGX11.h:35
#define gVirtualX
Definition TVirtualX.h:368
#define malloc
Definition civetweb.c:1575
Text Attributes class.
Definition TAttText.h:21
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:174
void Align(WinContext_t wctxt)
Compute alignment variables.
Definition TGX11TTF.cxx:214
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:368
Bool_t Init(void *display) override
Initialize X11 system. Returns kFALSE in case of failure.
Definition TGX11TTF.cxx:185
void RenderString(WinContext_t wctxt, Int_t x, Int_t y, ETextMode mode)
Perform the string rendering in the pad.
Definition TGX11TTF.cxx:464
Int_t SetTextFont(char *fontname, ETextSetMode mode) override
Set text font to specified name.
Definition TGX11TTF.cxx:577
void SetAttText(WinContext_t wctxt, const TAttText &att) override
Set specified font.
Definition TGX11TTF.cxx:555
TGX11TTF(TGX11 &&org)
Create copy of TGX11 but now use TrueType fonts.
Definition TGX11TTF.cxx:154
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:245
FT_Vector fAlign
alignment vector
Definition TGX11TTF.h:30
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:405
Bool_t IsVisible(WinContext_t wctxt, Int_t x, Int_t y, UInt_t w, UInt_t h)
Test if there is really something to render.
Definition TGX11TTF.cxx:431
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
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 SetAttText(WinContext_t wctxt, const TAttText &att) override
Set text attributes for specified window.
Definition TGX11.cxx:3799
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
Int_t SetTextFont(char *fontname, ETextSetMode mode) override
Set text font to specified name.
Definition TGX11.cxx:2543
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: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:271
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:64
static void LayoutGlyphs()
Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
Definition TTF.cxx:202
static void SetSmoothing(Bool_t state)
Set smoothing (anti-aliasing) flag.
Definition TTF.cxx:370
static void SetRotationMatrix(Float_t angle)
Set the rotation matrix used to rotate the font outlines.
Definition TTF.cxx:347
static void SetTextFont(Font_t fontnumber)
Set specified font.
Definition TTF.cxx:495
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:656
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:566
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:225