Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TMathText.cxx
Go to the documentation of this file.
1// @(#)root/graf:$Id: TMathText.cxx $
2// Author: Yue Shi Lai 16/10/12
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include <iostream>
13#include "TROOT.h"
14#include <ft2build.h>
15#include FT_FREETYPE_H
16#include FT_GLYPH_H
17#include "TTF.h"
18#include "TMathText.h"
19#include "TMath.h"
20#include "TVirtualPad.h"
21#include "TVirtualPadPainter.h"
22#include "TVirtualPS.h"
23#include "TText.h"
24
25#include "../../../graf2d/mathtext/inc/mathtext.h"
26#include "../../../graf2d/mathtext/inc/mathrender.h"
27
28/** \class TMathText
29\ingroup BasicGraphics
30
31To draw TeX Mathematical Formula
32
33TMathText's purpose is to write mathematical equations, exactly as TeX would
34do it. The syntax is the same as the TeX's one.
35
36The following example demonstrate how to use TMathText:
37
38Begin_Macro(source)
39../../../tutorials/visualisation/graphics/tmathtext.C
40End_Macro
41
42The list of all available symbols is given in the following example:
43
44Begin_Macro
45../../../tutorials/visualisation/graphics/tmathtext2.C
46End_Macro
47
48#### Limitation:
49TMathText rendering is not implemented for the PDF output.
50PostScript output should be used instead.
51*/
53const Double_t kPI = TMath::Pi();
55class TMathTextRenderer : public TText, public TAttFill,
56 public mathtext::math_text_renderer_t {
57private:
60 float _x0;
61 float _y0;
67 float _current_font_size[mathtext::math_text_renderer_t::NFAMILY];
68 inline size_t root_face_number(
69 const unsigned int family, const bool serif = false) const
70 {
71 static const int precision = 2;
72
73 if (family >= mathtext::math_text_renderer_t::
75 family <= mathtext::math_text_renderer_t::
76 FAMILY_BOLD_ITALIC) {
77 const unsigned int offset = family -
78 mathtext::math_text_renderer_t::FAMILY_REGULAR;
79 return serif ?
80 ((offset == 0 ? 13 : offset) * 10 + precision) :
81 ((offset + 4) * 10 + precision);
82 } else if (family >= mathtext::math_text_renderer_t::
84 const unsigned int offset = family -
85 mathtext::math_text_renderer_t::FAMILY_STIX_REGULAR;
86 return (offset + 16) * 10 + precision;
87 }
88
89 return precision;
90 }
91 inline bool is_cyrillic_or_cjk(const wchar_t c) const
92 {
93 return mathtext::math_text_renderer_t::is_cyrillic(c) ||
94 mathtext::math_text_renderer_t::is_cjk(c);
95 }
96 inline size_t root_cjk_face_number(
97 const bool serif = false) const
98 {
99 return (serif ? 28 : 29) * 10 + 2;
100 }
101protected:
102 inline mathtext::affine_transform_t
103 transform_logical_to_pixel(void) const override
104 {
105 return mathtext::affine_transform_t::identity;
106 }
107 inline mathtext::affine_transform_t
108 transform_pixel_to_logical(void) const override
109 {
110 return mathtext::affine_transform_t::identity;
111 }
112public:
113 inline TMathTextRenderer(TMathText *parent)
114 : TText(), TAttFill(0, 1001),
115 _parent(parent), _font_size(0), _angle_degree(0)
116 {
117 _font_size = 0;
118 _x0 = 0;
119 _y0 = 0;
120 _angle_degree = 0;
121 for (int i = 0; i<6; i++)
123 _pad_scale = 0;
124 _pad_scale_x = 0;
125 _pad_scale_y = 0;
126 for (int i = 0; i < mathtext::math_text_renderer_t::NFAMILY; i++)
127 _current_font_size[i] = 0;
128 }
129 inline float
130 font_size(const unsigned int family = FAMILY_PLAIN) const override
131 {
132 return _current_font_size[family];
133 }
134 inline void
135 point(const float /*x*/, const float /*y*/) override
136 {
137 }
138 inline void
139 set_font_size(const float size, const unsigned int family) override
140 {
141 _current_font_size[family] = size;
142 }
143 inline void
144 set_font_size(const float size) override
145 {
147 std::fill(_current_font_size,
149 }
150 inline void
151 reset_font_size(const unsigned int /*family*/) override
152 {
153 }
154 inline void
155 set_parameter(const float x, const float y, const float size,
156 const float angle_degree)
157 {
158 _x0 = gPad->XtoAbsPixel(x);
159 _y0 = gPad->YtoAbsPixel(y);
160 _pad_scale_x = gPad->GetPadWidth();
161 _pad_scale_y = gPad->GetPadHeight();
163
165
166 const float angle_radiant = _angle_degree * (kPI / 180.0);
167
168 // Initialize the affine transform
175
179 }
180 inline void
181 transform_pad(double &xt, double &yt,
182 const float x, const float y) const
183 {
184 xt = gPad->AbsPixeltoX(Int_t(
187 yt = gPad->AbsPixeltoY(Int_t(
190 }
191 inline void
192 filled_rectangle(const mathtext::bounding_box_t &bounding_box_0) override
193 {
195 SetFillStyle(1001);
197
198 double xt[4];
199 double yt[4];
200
201 transform_pad(xt[0], yt[0],
202 bounding_box_0.left(),
203 bounding_box_0.bottom());
204 transform_pad(xt[1], yt[1],
205 bounding_box_0.right(),
206 bounding_box_0.bottom());
207 transform_pad(xt[2], yt[2],
208 bounding_box_0.right(),
209 bounding_box_0.top());
210 transform_pad(xt[3], yt[3],
211 bounding_box_0.left(),
212 bounding_box_0.top());
213 gPad->PaintFillArea(4, xt, yt);
214 }
215 inline void
216 rectangle(const mathtext::bounding_box_t &/*bounding_box*/) override
217 {
218 }
219 inline mathtext::bounding_box_t
220 bounding_box_char(const wchar_t character, float &current_x, const unsigned int family)
221 {
222 TTFhandle h;
224 h.SetTextSize(_current_font_size[family] * _pad_scale);
225
226 auto font_face = h.GetFontFace();
227 if (!font_face || font_face->units_per_EM == 0)
228 return mathtext::bounding_box_t(0, 0, 0, 0, 0, 0);
229
231 font_face,
234
235 const float scale = _current_font_size[family] / font_face->units_per_EM;
236 const FT_Glyph_Metrics metrics = font_face->glyph->metrics;
237 const float lower_left_x = metrics.horiBearingX;
238 const float lower_left_y =
239 metrics.horiBearingY - metrics.height;
240 const float upper_right_x =
241 metrics.horiBearingX + metrics.width;
242 const float upper_right_y = metrics.horiBearingY;
243 const float advance = metrics.horiAdvance;
244 const float margin = std::max(0.0F, lower_left_x);
245 const float italic_correction =
246 upper_right_x <= advance ? 0.0F :
247 std::max(0.0F, upper_right_x + margin - advance);
248 const mathtext::bounding_box_t ret =
249 mathtext::bounding_box_t(
253
254 current_x += ret.advance();
255
256 return ret;
257 }
258 inline mathtext::bounding_box_t
259 bounding_box(const std::wstring string, const unsigned int family = FAMILY_PLAIN) override
260 {
261 if (string.empty())
262 return mathtext::bounding_box_t(0, 0, 0, 0, 0, 0);
263
264 std::wstring::const_iterator iterator = string.begin();
265 float current_x = 0;
266 mathtext::bounding_box_t ret =
267 bounding_box_char(*iterator, current_x, family);
268
269 ++iterator;
270 for (; iterator != string.end(); ++iterator) {
271 const mathtext::point_t position =
272 mathtext::point_t(current_x, 0);
273 const mathtext::bounding_box_t glyph_bounding_box =
274 bounding_box_char(*iterator, current_x, family);
275 ret = ret.merge(position + glyph_bounding_box);
276 }
277
278 return ret;
280 void text_raw(const float x, const float y,
281 const std::wstring string,
282 const unsigned int family = FAMILY_PLAIN) override
283 {
285
286 wchar_t buf[2];
287 float current_x = 0;
288
289 buf[1] = L'\0';
290 for (auto character : string) {
291 buf[0] = character;
293 if (cyrillic_or_cjk)
295 else
297
298 double xt, yt;
299
301
303 gPad->PaintText(xt, yt, buf);
304
305 // use bounding function to advance current_x
307 }
308 }
309 inline void
310 text_with_bounding_box(const float /*x*/, const float /*y*/,
311 const std::wstring /*string*/,
312 const unsigned int /*family = FAMILY_PLAIN*/) override
313 {
314 }
315 using mathtext::math_text_renderer_t::bounding_box;
316};
317
318
319////////////////////////////////////////////////////////////////////////////////
320/// Default constructor.
323 : TAttFill(0, 1001)
324{
325 fRenderer = new TMathTextRenderer(this);
326}
327
328////////////////////////////////////////////////////////////////////////////////
329/// Normal constructor.
332 : TText(x, y, text), TAttFill(0, 1001)
333{
334 fRenderer = new TMathTextRenderer(this);
335}
336
337////////////////////////////////////////////////////////////////////////////////
338/// Destructor.
341{
342 delete fRenderer;
343}
344
345////////////////////////////////////////////////////////////////////////////////
346/// Copy constructor.
352}
353
354////////////////////////////////////////////////////////////////////////////////
355/// Assignment operator.
358{
359 if (this != &rhs) {
361 TAttFill::operator=(rhs);
362 delete fRenderer;
363 fRenderer = new TMathTextRenderer(this);
364 }
365 return *this;
366}
367
368////////////////////////////////////////////////////////////////////////////////
369/// Copy.
371void TMathText::Copy(TObject &obj) const
372{
373 TMathText &tgt = (TMathText &)obj;
374 delete tgt.fRenderer;
377 tgt.fRenderer = new TMathTextRenderer(&tgt);
378
379}
380
381////////////////////////////////////////////////////////////////////////////////
382/// Render the text.
384void TMathText::Render(const Double_t x, const Double_t y, const Double_t size,
385 const Double_t angle, const Char_t *t, const Int_t /*length*/)
386{
387 const mathtext::math_text_t math_text(t);
388
390 fRenderer->text(0, 0, math_text);
391}
392
393////////////////////////////////////////////////////////////////////////////////
394/// Get the text bounding box.
397 const Double_t size, const Double_t angle, const Char_t *t,
398 const Int_t /*length*/)
399{
400 const mathtext::math_text_t math_text(t);
401
403
404 const mathtext::bounding_box_t bounding_box = fRenderer->bounding_box(math_text);
405 double x[4], y[4];
406
407 fRenderer->transform_pad(x[0], y[0], bounding_box.left(), bounding_box.bottom());
408 fRenderer->transform_pad(x[1], y[1], bounding_box.right(), bounding_box.bottom());
409 fRenderer->transform_pad(x[2], y[2], bounding_box.right(), bounding_box.top());
410 fRenderer->transform_pad(x[3], y[3], bounding_box.left(), bounding_box.top());
411
412 x0 = std::min(std::min(x[0], x[1]), std::min(x[2], x[3]));
413 y0 = std::min(std::min(y[0], y[1]), std::min(y[2], y[3]));
414 x1 = std::max(std::max(x[0], x[1]), std::max(x[2], x[3]));
415 y1 = std::max(std::max(y[0], y[1]), std::max(y[2], y[3]));
416}
417
418////////////////////////////////////////////////////////////////////////////////
419/// Alignment.
422 const Double_t size, const Double_t angle,
423 const Char_t *t, const Int_t /*length*/,
424 const Short_t align)
425{
426 const mathtext::math_text_t math_text(t);
427
429
430 const mathtext::bounding_box_t bounding_box = fRenderer->bounding_box(math_text);
431 float x = 0, y = 0;
432
433 Short_t halign = align / 10;
434 Short_t valign = align - 10 * halign;
435
436 switch(halign) {
437 case 0: x = bounding_box.left(); break;
438 case 1: x = 0; break;
439 case 2: x = bounding_box.horizontal_center(); break;
440 case 3: x = bounding_box.right(); break;
441 }
442 switch(valign) {
443 case 0: y = bounding_box.bottom(); break;
444 case 1: y = 0; break;
445 case 2: y = bounding_box.vertical_center(); break;
446 case 3: y = bounding_box.top(); break;
447 }
448 fRenderer->transform_pad(x0, y0, x, y);
449}
450
451////////////////////////////////////////////////////////////////////////////////
452/// Get the text width and height.
455{
456 if (!gPad) return;
457 const TString newText = GetTitle();
458 const Int_t length = newText.Length();
459 const Char_t *text = newText.Data();
460
461 Double_t x0;
462 Double_t y0;
463 Double_t x1;
464 Double_t y1;
466
467 GetSize(x0, y0, x1, y1, size, 0, text, length);
468 w = (UInt_t)(TMath::Abs(gPad->XtoAbsPixel(x1) - gPad->XtoAbsPixel(x0)));
469 h = (UInt_t)(TMath::Abs(gPad->YtoAbsPixel(y0) - gPad->YtoAbsPixel(y1)));
470}
471
472////////////////////////////////////////////////////////////////////////////////
473/// Get X size.
476{
477 const TString newText = GetTitle();
478 const Int_t length = newText.Length();
479 const Char_t *text = newText.Data();
480 const Double_t size = GetTextSize();
481 const Double_t angle = GetTextAngle();
482
483 Double_t x0;
484 Double_t y0;
485 Double_t x1;
486 Double_t y1;
487
488 GetSize(x0, y0, x1, y1, size, angle, text, length);
489
490 return TMath::Abs(x1 - x0);
491}
492
493////////////////////////////////////////////////////////////////////////////////
494/// Get Y size.
497{
498 const TString newText = GetTitle();
499 const Int_t length = newText.Length();
500 const Char_t *text = newText.Data();
501 const Double_t size = GetTextSize();
502 const Double_t angle = GetTextAngle();
503
504 Double_t x0;
505 Double_t y0;
506 Double_t x1;
507 Double_t y1;
508
509 GetSize(x0, y0, x1, y1, size, angle, text, length);
510
511 return TMath::Abs(y0 - y1);
512}
513
514////////////////////////////////////////////////////////////////////////////////
515/// Make a copy of this object with the new parameters
516/// and copy object attributes.
519{
520 TMathText *newtext = new TMathText(x, y, text);
522
523 newtext->SetBit(kCanDelete);
524 if (TestBit(kTextNDC)) newtext->SetNDC();
525 newtext->AppendPad();
526
527 return newtext;
528}
529
530////////////////////////////////////////////////////////////////////////////////
531/// Paint text.
534{
535 if (!gPad) return;
536 Double_t xsave = fX;
537 Double_t ysave = fY;
538
539 if (TestBit(kTextNDC)) {
540 fX = gPad->GetX1() + xsave * (gPad->GetX2() - gPad->GetX1());
541 fY = gPad->GetY1() + ysave * (gPad->GetY2() - gPad->GetY1());
543 } else {
544 PaintMathText(gPad->XtoPad(fX), gPad->YtoPad(fY),
546 }
547 fX = xsave;
548 fY = ysave;
549}
550
551////////////////////////////////////////////////////////////////////////////////
552/// Paint text (used by Paint()).
555 Double_t size, const Char_t *text1)
556{
557 if (!gPad) return;
561
563 if (auto ps = gPad->GetPainter()->GetPS()) { // Initialise TMathTextRenderer
564 if (ps->InheritsFrom("TImageDump")) gPad->PaintText(0, 0, "");
565 }
566
567 // Do not use Latex if font is low precision.
568 if (fTextFont % 10 < 2) {
569 gPad->GetPainter()->SetTextAngle(angle);
570 gPad->PaintText(x, y, text1);
571 return;
572 }
573
574 if (fTextFont % 10 > 2) {
575 UInt_t w = TMath::Abs(gPad->XtoAbsPixel(gPad->GetX2()) -
576 gPad->XtoAbsPixel(gPad->GetX1()));
577 UInt_t h = TMath::Abs(gPad->YtoAbsPixel(gPad->GetY2()) -
578 gPad->YtoAbsPixel(gPad->GetY1()));
579 size = size / std::min(w, h);
580 SetTextFont(10 * (saveFont / 10) + 2);
581 }
582
584
585 if (newText.Length() == 0) return;
586
587 // Compatibility with TLatex and Latex
588 newText.ReplaceAll("\\omicron","o");
589 newText.ReplaceAll("\\Alpha","A");
590 newText.ReplaceAll("\\Beta","B");
591 newText.ReplaceAll("\\Epsilon","E");
592 newText.ReplaceAll("\\Zeta","Z");
593 newText.ReplaceAll("\\Eta","H");
594 newText.ReplaceAll("\\Iota","I");
595 newText.ReplaceAll("\\Kappa","K");
596 newText.ReplaceAll("\\Mu","M");
597 newText.ReplaceAll("\\Nu","N");
598 newText.ReplaceAll("\\Omicron","O");
599 newText.ReplaceAll("\\Rho","P");
600 newText.ReplaceAll("\\Tau","T");
601 newText.ReplaceAll("\\Chi","X");
602 newText.ReplaceAll("\\varomega","\\varpi");
603 newText.ReplaceAll("\\mbox","\\hbox");
604 newText.ReplaceAll("\\bar","\\wwbar");
605 if (newText.Contains("\\frac")) {
606 Int_t len,i1,i2;
607 TString str;
608 while (newText.Contains("\\frac")) {
609 len = newText.Length();
610 i1 = newText.Index("\\frac");
611 str = newText(i1,len).Data();
612 i2 = str.Index("}{");
613 newText.Replace(i1+i2,2," \\over ");
614 newText.Remove(i1,5);
615 }
616 }
617 if (newText.Contains("\\splitline")) {
618 Int_t len,i1,i2;
619 TString str;
620 while (newText.Contains("\\splitline")) {
621 len = newText.Length();
622 i1 = newText.Index("\\splitline");
623 str = newText(i1,len).Data();
624 i2 = str.Index("}{");
625 newText.Replace(i1+i2,2," \\atop ");
626 newText.Remove(i1,10);
627 }
628 }
629
630 const Int_t length = newText.Length();
631 const Char_t *text = newText.Data();
632 Double_t x0;
633 Double_t y0;
635
636 Render(x - x0, y - y0, size, angle, text, length);
637
641}
642
643////////////////////////////////////////////////////////////////////////////////
644/// Save primitive as a C++ statement(s) on output stream out
646void TMathText::SavePrimitive(std::ostream &out, Option_t *option)
647{
649 out, Class(), "mathtex",
650 TString::Format("%g, %g, \"%s\"", fX, fY, TString(GetTitle()).ReplaceSpecialCppChars().Data()), kFALSE);
651
652 if (TestBit(kTextNDC))
653 out << " mathtex->SetNDC();\n";
654
655 SaveTextAttributes(out, "mathtex", 11, 0, 1, 42, 0.05);
656 SaveFillAttributes(out, "mathtex", 0, 1001);
657
658 SavePrimitiveDraw(out, "mathtex", option);
659}
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
char Char_t
Character 1 byte (char)
Definition RtypesCore.h:51
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:60
short Font_t
Font number (short)
Definition RtypesCore.h:95
short Short_t
Signed Short integer 2 bytes (short)
Definition RtypesCore.h:53
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t option
Option_t Option_t SetFillStyle
Option_t Option_t SetTextSize
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 offset
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 length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t SetTextFont
Option_t Option_t TPoint TPoint angle
Option_t Option_t SetFillColor
Option_t Option_t TPoint TPoint const char text
Option_t Option_t TPoint TPoint const char y1
const Double_t kPI
Definition TMathText.cxx:52
#define gPad
Fill Area Attributes class.
Definition TAttFill.h:21
void Copy(TAttFill &attfill) const
Copy this fill attributes to a new TAttFill.
Definition TAttFill.cxx:203
virtual void Modify()
Change current fill area attributes if necessary.
Definition TAttFill.cxx:212
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
Save fill attributes as C++ statement(s) on output stream out.
Definition TAttFill.cxx:240
virtual void ModifyOn(TVirtualPad &pad)
Change current text attributes if necessary on specified pad.
Definition TAttText.cxx:373
virtual Float_t GetTextSize() const
Return the text size.
Definition TAttText.h:39
virtual void Modify()
Change current text attributes if necessary.
Definition TAttText.cxx:364
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition TAttText.h:48
Color_t fTextColor
Text color.
Definition TAttText.h:27
virtual void SetTextAngle(Float_t tangle=0)
Set the text angle.
Definition TAttText.h:49
virtual Float_t GetTextAngle() const
Return the text angle.
Definition TAttText.h:36
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition TAttText.h:50
Font_t fTextFont
Text font.
Definition TAttText.h:28
virtual void SaveTextAttributes(std::ostream &out, const char *name, Int_t alidef=12, Float_t angdef=0, Int_t coldef=1, Int_t fondef=61, Float_t sizdef=1)
Save text attributes as C++ statement(s) on output stream out.
Definition TAttText.cxx:399
virtual Float_t GetTextSizePercent(Float_t size)
Return the text in percent of the pad size.
Definition TAttText.cxx:316
Short_t fTextAlign
Text alignment.
Definition TAttText.h:26
void Copy(TAttText &atttext) const
Copy this text attributes to a new TAttText.
Definition TAttText.cxx:300
void set_font_size(const float size, const unsigned int family) override
float _current_font_size[mathtext::math_text_renderer_t::NFAMILY]
Definition TMathText.cxx:66
void text_raw(const float x, const float y, const std::wstring string, const unsigned int family=FAMILY_PLAIN) override
void text_with_bounding_box(const float, const float, const std::wstring, const unsigned int) override
float _pad_pixel_transform[6]
Definition TMathText.cxx:62
mathtext::bounding_box_t bounding_box(const std::wstring string, const unsigned int family=FAMILY_PLAIN) override
TMathTextRenderer(TMathText *parent)
float font_size(const unsigned int family=FAMILY_PLAIN) const override
TMathText * _parent
Definition TMathText.cxx:57
mathtext::affine_transform_t transform_pixel_to_logical(void) const override
size_t root_cjk_face_number(const bool serif=false) const
Definition TMathText.cxx:95
bool is_cyrillic_or_cjk(const wchar_t c) const
Definition TMathText.cxx:90
size_t root_face_number(const unsigned int family, const bool serif=false) const
Definition TMathText.cxx:67
mathtext::bounding_box_t bounding_box_char(const wchar_t character, float &current_x, const unsigned int family)
void reset_font_size(const unsigned int) override
void point(const float, const float) override
void rectangle(const mathtext::bounding_box_t &) override
void transform_pad(double &xt, double &yt, const float x, const float y) const
void set_parameter(const float x, const float y, const float size, const float angle_degree)
mathtext::affine_transform_t transform_logical_to_pixel(void) const override
void filled_rectangle(const mathtext::bounding_box_t &bounding_box_0) override
To draw TeX Mathematical Formula.
Definition TMathText.h:19
friend class TMathTextRenderer
Definition TMathText.h:22
void Paint(Option_t *option="") override
Paint text.
Double_t GetYsize()
Get Y size.
TMathText & operator=(const TMathText &)
Assignment operator.
void GetSize(Double_t &x0, Double_t &y0, Double_t &x1, Double_t &y1, const Double_t size, const Double_t angle, const Char_t *t, const Int_t length)
Get the text bounding box.
void GetBoundingBox(UInt_t &w, UInt_t &h, Bool_t angle=kFALSE) override
Get the text width and height.
TMathTextRenderer * fRenderer
!TMathText Painter
Definition TMathText.h:24
static TClass * Class()
Double_t GetXsize()
Get X size.
void GetAlignPoint(Double_t &x0, Double_t &y0, const Double_t size, const Double_t angle, const Char_t *t, const Int_t length, const Short_t align)
Alignment.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
void Render(const Double_t x, const Double_t y, const Double_t size, const Double_t angle, const Char_t *t, const Int_t length)
Render the text.
~TMathText() override
Destructor.
TMathText * DrawMathText(Double_t x, Double_t y, const char *text)
Make a copy of this object with the new parameters and copy object attributes.
TMathText()
Default constructor.
virtual void PaintMathText(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
Paint text (used by Paint()).
void Copy(TObject &text) const override
Copy.
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
Mother of all ROOT objects.
Definition TObject.h:42
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:204
static void SavePrimitiveDraw(std::ostream &out, const char *variable_name, Option_t *option=nullptr)
Save invocation of primitive Draw() method Skipped if option contains "nodraw" string.
Definition TObject.cxx:842
static void SavePrimitiveConstructor(std::ostream &out, TClass *cl, const char *variable_name, const char *constructor_agrs="", Bool_t empty_line=kTRUE)
Save object constructor in the output stream "out".
Definition TObject.cxx:774
@ kCanDelete
if object in a list can be deleted
Definition TObject.h:71
Basic string class.
Definition TString.h:138
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2385
Dynamic handle to work with freetype 2 library.
Definition TTF.h:119
void SetTextFont(Font_t fontnumber)
Set specified font.
Definition TTF.cxx:491
Base class for several text objects.
Definition TText.h:22
Double_t fY
Y position of text (left,center,etc..)
Definition TText.h:26
void Copy(TObject &text) const override
Copy this text to text.
Definition TText.cxx:103
TText & operator=(const TText &src)
Assignment operator.
Definition TText.cxx:94
Double_t fX
X position of text (left,center,etc..)
Definition TText.h:25
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
constexpr Double_t Pi()
Definition TMath.h:40
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:122