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 "TTFhandle.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 "mathtext/mathtext.h"
26#include "mathtext/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 = (FT_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(lower_left_x * scale, lower_left_y * scale, upper_right_x * scale,
251
252 current_x += ret.advance();
253
254 return ret;
255 }
256 inline mathtext::bounding_box_t
257 bounding_box(const std::wstring string, const unsigned int family = FAMILY_PLAIN) override
258 {
259 if (string.empty())
260 return mathtext::bounding_box_t(0, 0, 0, 0, 0, 0);
261
262 std::wstring::const_iterator iterator = string.begin();
263 float current_x = 0;
264 mathtext::bounding_box_t ret =
265 bounding_box_char(*iterator, current_x, family);
266
267 ++iterator;
268 for (; iterator != string.end(); ++iterator) {
269 const mathtext::point_t position =
270 mathtext::point_t(current_x, 0);
271 const mathtext::bounding_box_t glyph_bounding_box =
272 bounding_box_char(*iterator, current_x, family);
273 ret = ret.merge(position + glyph_bounding_box);
274 }
275
276 return ret;
278 void text_raw(const float x, const float y,
279 const std::wstring string,
280 const unsigned int family = FAMILY_PLAIN) override
281 {
283
284 wchar_t buf[2];
285 float current_x = 0;
286
287 buf[1] = L'\0';
288 for (auto character : string) {
289 buf[0] = character;
291 if (cyrillic_or_cjk)
293 else
295
296 double xt, yt;
297
299
301 gPad->PaintText(xt, yt, buf);
302
303 // use bounding function to advance current_x
305 }
306 }
307 inline void
308 text_with_bounding_box(const float /*x*/, const float /*y*/,
309 const std::wstring /*string*/,
310 const unsigned int /*family = FAMILY_PLAIN*/) override
311 {
312 }
313 using mathtext::math_text_renderer_t::bounding_box;
314};
315
316
317////////////////////////////////////////////////////////////////////////////////
318/// Default constructor.
321 : TAttFill(0, 1001)
322{
323 fRenderer = new TMathTextRenderer(this);
324}
325
326////////////////////////////////////////////////////////////////////////////////
327/// Normal constructor.
330 : TText(x, y, text), TAttFill(0, 1001)
331{
332 fRenderer = new TMathTextRenderer(this);
333}
334
335////////////////////////////////////////////////////////////////////////////////
336/// Destructor.
339{
340 delete fRenderer;
341}
342
343////////////////////////////////////////////////////////////////////////////////
344/// Copy constructor.
350}
351
352////////////////////////////////////////////////////////////////////////////////
353/// Assignment operator.
356{
357 if (this != &rhs) {
359 TAttFill::operator=(rhs);
360 delete fRenderer;
361 fRenderer = new TMathTextRenderer(this);
362 }
363 return *this;
364}
365
366////////////////////////////////////////////////////////////////////////////////
367/// Copy.
369void TMathText::Copy(TObject &obj) const
370{
371 TMathText &tgt = (TMathText &)obj;
372 delete tgt.fRenderer;
375 tgt.fRenderer = new TMathTextRenderer(&tgt);
376
377}
378
379////////////////////////////////////////////////////////////////////////////////
380/// Render the text.
382void TMathText::Render(const Double_t x, const Double_t y, const Double_t size,
383 const Double_t angle, const Char_t *t, const Int_t /*length*/)
384{
385 const mathtext::math_text_t math_text(t);
386
388 fRenderer->text(0, 0, math_text);
389}
390
391////////////////////////////////////////////////////////////////////////////////
392/// Get the text bounding box.
395 const Double_t size, const Double_t angle, const Char_t *t,
396 const Int_t /*length*/)
397{
398 const mathtext::math_text_t math_text(t);
399
401
402 const mathtext::bounding_box_t bounding_box = fRenderer->bounding_box(math_text);
403 double x[4], y[4];
404
405 fRenderer->transform_pad(x[0], y[0], bounding_box.left(), bounding_box.bottom());
406 fRenderer->transform_pad(x[1], y[1], bounding_box.right(), bounding_box.bottom());
407 fRenderer->transform_pad(x[2], y[2], bounding_box.right(), bounding_box.top());
408 fRenderer->transform_pad(x[3], y[3], bounding_box.left(), bounding_box.top());
409
410 x0 = std::min(std::min(x[0], x[1]), std::min(x[2], x[3]));
411 y0 = std::min(std::min(y[0], y[1]), std::min(y[2], y[3]));
412 x1 = std::max(std::max(x[0], x[1]), std::max(x[2], x[3]));
413 y1 = std::max(std::max(y[0], y[1]), std::max(y[2], y[3]));
414}
415
416////////////////////////////////////////////////////////////////////////////////
417/// Alignment.
420 const Double_t size, const Double_t angle,
421 const Char_t *t, const Int_t /*length*/,
422 const Short_t align)
423{
424 const mathtext::math_text_t math_text(t);
425
427
428 const mathtext::bounding_box_t bounding_box = fRenderer->bounding_box(math_text);
429 float x = 0, y = 0;
430
431 Short_t halign = align / 10;
432 Short_t valign = align - 10 * halign;
433
434 switch(halign) {
435 case 0: x = bounding_box.left(); break;
436 case 1: x = 0; break;
437 case 2: x = bounding_box.horizontal_center(); break;
438 case 3: x = bounding_box.right(); break;
439 }
440 switch(valign) {
441 case 0: y = bounding_box.bottom(); break;
442 case 1: y = 0; break;
443 case 2: y = bounding_box.vertical_center(); break;
444 case 3: y = bounding_box.top(); break;
445 }
446 fRenderer->transform_pad(x0, y0, x, y);
447}
448
449////////////////////////////////////////////////////////////////////////////////
450/// Get the text width and height.
453{
454 if (!gPad) return;
455 const TString newText = GetTitle();
456 const Int_t length = newText.Length();
457 const Char_t *text = newText.Data();
458
459 Double_t x0;
460 Double_t y0;
461 Double_t x1;
462 Double_t y1;
464
465 GetSize(x0, y0, x1, y1, size, 0, text, length);
466 w = (UInt_t)(TMath::Abs(gPad->XtoAbsPixel(x1) - gPad->XtoAbsPixel(x0)));
467 h = (UInt_t)(TMath::Abs(gPad->YtoAbsPixel(y0) - gPad->YtoAbsPixel(y1)));
468}
469
470////////////////////////////////////////////////////////////////////////////////
471/// Get X size.
474{
475 const TString newText = GetTitle();
476 const Int_t length = newText.Length();
477 const Char_t *text = newText.Data();
478 const Double_t size = GetTextSize();
479 const Double_t angle = GetTextAngle();
480
481 Double_t x0;
482 Double_t y0;
483 Double_t x1;
484 Double_t y1;
485
486 GetSize(x0, y0, x1, y1, size, angle, text, length);
487
488 return TMath::Abs(x1 - x0);
489}
490
491////////////////////////////////////////////////////////////////////////////////
492/// Get Y size.
495{
496 const TString newText = GetTitle();
497 const Int_t length = newText.Length();
498 const Char_t *text = newText.Data();
499 const Double_t size = GetTextSize();
500 const Double_t angle = GetTextAngle();
501
502 Double_t x0;
503 Double_t y0;
504 Double_t x1;
505 Double_t y1;
506
507 GetSize(x0, y0, x1, y1, size, angle, text, length);
508
509 return TMath::Abs(y0 - y1);
510}
511
512////////////////////////////////////////////////////////////////////////////////
513/// Make a copy of this object with the new parameters
514/// and copy object attributes.
517{
518 TMathText *newtext = new TMathText(x, y, text);
520
521 newtext->SetBit(kCanDelete);
522 if (TestBit(kTextNDC)) newtext->SetNDC();
523 newtext->AppendPad();
524
525 return newtext;
526}
527
528////////////////////////////////////////////////////////////////////////////////
529/// Paint text.
532{
533 if (!gPad) return;
534 Double_t xsave = fX;
535 Double_t ysave = fY;
536
537 if (TestBit(kTextNDC)) {
538 fX = gPad->GetX1() + xsave * (gPad->GetX2() - gPad->GetX1());
539 fY = gPad->GetY1() + ysave * (gPad->GetY2() - gPad->GetY1());
541 } else {
542 PaintMathText(gPad->XtoPad(fX), gPad->YtoPad(fY),
544 }
545 fX = xsave;
546 fY = ysave;
547}
548
549////////////////////////////////////////////////////////////////////////////////
550/// Paint text (used by Paint()).
553 Double_t size, const Char_t *text1)
554{
555 if (!gPad) return;
559
561 if (auto ps = gPad->GetPainter()->GetPS()) { // Initialise TMathTextRenderer
562 if (ps->InheritsFrom("TImageDump")) gPad->PaintText(0, 0, "");
563 }
564
565 // Do not use Latex if font is low precision.
566 if (fTextFont % 10 < 2) {
567 gPad->GetPainter()->SetTextAngle(angle);
568 gPad->PaintText(x, y, text1);
569 return;
570 }
571
572 if (fTextFont % 10 > 2) {
573 UInt_t w = TMath::Abs(gPad->XtoAbsPixel(gPad->GetX2()) -
574 gPad->XtoAbsPixel(gPad->GetX1()));
575 UInt_t h = TMath::Abs(gPad->YtoAbsPixel(gPad->GetY2()) -
576 gPad->YtoAbsPixel(gPad->GetY1()));
577 size = size / std::min(w, h);
578 SetTextFont(10 * (saveFont / 10) + 2);
579 }
580
582
583 if (newText.Length() == 0) return;
584
585 // Compatibility with TLatex and Latex
586 newText.ReplaceAll("\\omicron","o");
587 newText.ReplaceAll("\\Alpha","A");
588 newText.ReplaceAll("\\Beta","B");
589 newText.ReplaceAll("\\Epsilon","E");
590 newText.ReplaceAll("\\Zeta","Z");
591 newText.ReplaceAll("\\Eta","H");
592 newText.ReplaceAll("\\Iota","I");
593 newText.ReplaceAll("\\Kappa","K");
594 newText.ReplaceAll("\\Mu","M");
595 newText.ReplaceAll("\\Nu","N");
596 newText.ReplaceAll("\\Omicron","O");
597 newText.ReplaceAll("\\Rho","P");
598 newText.ReplaceAll("\\Tau","T");
599 newText.ReplaceAll("\\Chi","X");
600 newText.ReplaceAll("\\varomega","\\varpi");
601 newText.ReplaceAll("\\mbox","\\hbox");
602 newText.ReplaceAll("\\bar","\\wwbar");
603 if (newText.Contains("\\frac")) {
604 Int_t len,i1,i2;
605 TString str;
606 while (newText.Contains("\\frac")) {
607 len = newText.Length();
608 i1 = newText.Index("\\frac");
609 str = newText(i1,len).Data();
610 i2 = str.Index("}{");
611 newText.Replace(i1+i2,2," \\over ");
612 newText.Remove(i1,5);
613 }
614 }
615 if (newText.Contains("\\splitline")) {
616 Int_t len,i1,i2;
617 TString str;
618 while (newText.Contains("\\splitline")) {
619 len = newText.Length();
620 i1 = newText.Index("\\splitline");
621 str = newText(i1,len).Data();
622 i2 = str.Index("}{");
623 newText.Replace(i1+i2,2," \\atop ");
624 newText.Remove(i1,10);
625 }
626 }
627
628 const Int_t length = newText.Length();
629 const Char_t *text = newText.Data();
630 Double_t x0;
631 Double_t y0;
633
634 Render(x - x0, y - y0, size, angle, text, length);
635
639}
640
641////////////////////////////////////////////////////////////////////////////////
642/// Save primitive as a C++ statement(s) on output stream out
644void TMathText::SavePrimitive(std::ostream &out, Option_t *option)
645{
647 out, Class(), "mathtex",
648 TString::Format("%g, %g, \"%s\"", fX, fY, TString(GetTitle()).ReplaceSpecialCppChars().Data()), kFALSE);
649
650 if (TestBit(kTextNDC))
651 out << " mathtex->SetNDC();\n";
652
653 SaveTextAttributes(out, "mathtex", 11, 0, 1, 42, 0.05);
654 SaveFillAttributes(out, "mathtex", 0, 1001);
655
656 SavePrimitiveDraw(out, "mathtex", option);
657}
#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:60
char Char_t
Character 1 byte (char)
Definition RtypesCore.h:52
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:61
short Font_t
Font number (short)
Definition RtypesCore.h:96
short Short_t
Signed Short integer 2 bytes (short)
Definition RtypesCore.h:54
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
double Double_t
Double 8 bytes.
Definition RtypesCore.h:74
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
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:844
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:776
@ 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:2459
Dynamic handle to work with freetype 2 library.
Definition TTFhandle.h:21
void SetTextFont(Font_t fontnumber)
Set specified font.
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:104
TText & operator=(const TText &src)
Assignment operator.
Definition TText.cxx:95
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