Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RAttrFont.hxx
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. *
3 * All rights reserved. *
4 * *
5 * For the licensing terms see $ROOTSYS/LICENSE. *
6 * For the list of contributors see $ROOTSYS/README/CREDITS. *
7 *************************************************************************/
8
9#ifndef ROOT7_RAttrFont
10#define ROOT7_RAttrFont
11
13#include <ROOT/RAttrValue.hxx>
14
15namespace ROOT {
16namespace Experimental {
17
18/** \class RAttrFont
19\ingroup GpadROOT7
20\brief A font attributes, used together with text attributes
21\author Sergey Linev <s.linev@gsi.de>
22\date 2021-06-28
23\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
24*/
25
27
29
30public:
31
32 RAttrValue<std::string> family{this, "family"}; ///<! font family, corresponds to css font-familty attribute
33 RAttrValue<std::string> style{this, "style"}; ///<! font style, corresponds to css font-style attribute
34 RAttrValue<std::string> weight{this, "weight"}; ///<! font weight, corresponds to css font-weight attribute
35
36 enum EFont {
40 kArial = 4,
48 // kSymbol = 12, // not supported by web browsers
49 kTimes = 13,
50 // kWingdings = 14,
51 // kSymbolItalic = 15, // not supported by web browsers
56 };
57
58 ///Set text font by id as usually handled in the ROOT (without precision), number should be between 1 and 15
60 {
61 switch(font) {
62 case kTimesItalic: family = "Times New Roman"; style = "italic"; break;
63 case kTimesBold: family = "Times New Roman"; weight = "bold"; break;
64 case kTimesBoldItalic: family = "Times New Roman"; style = "italic"; weight = "bold"; break;
65 case kArial: family = "Arial"; break;
66 case kArialOblique: family = "Arial"; style = "oblique"; break;
67 case kArialBold: family = "Arial"; weight = "bold"; break;
68 case kArialBoldOblique: family = "Arial"; style = "oblique"; weight = "bold"; break;
69 case kCourier: family = "Courier New"; break;
70 case kCourierOblique: family = "Courier New"; style = "oblique"; break;
71 case kCourierBold: family = "Courier New"; weight = "bold"; break;
72 case kCourierBoldOblique: family = "Courier New"; style = "oblique"; weight = "bold"; break;
73 // case kSymbol: family = "Symbol"; break;
74 case kTimes: family = "Times New Roman"; break;
75 // case kWingdings: family = "Wingdings"; break;
76 // case kSymbolItalic: family = "Symbol"; style = "italic"; break;
77 case kVerdana: family = "Verdana"; break;
78 case kVerdanaItalic: family = "Verdana"; style = "italic"; break;
79 case kVerdanaBold: family = "Verdana"; weight = "bold"; break;
80 case kVerdanaBoldItalic: family = "Verdana"; weight = "bold"; style = "italic"; break;
81 }
82 return *this;
83 }
84
85 /// assign font id, setting all necessary properties
86 RAttrFont &operator=(EFont id) { SetFont(id); return *this; }
87
88 friend bool operator==(const RAttrFont &font, EFont id) { RAttrFont font2; font2.SetFont(id); return font == font2; }
89
90 /// Returns full font name including weight and style
91 std::string GetFullName() const
92 {
93 std::string name = family, s = style, w = weight;
94 if (!w.empty()) {
95 name += " ";
96 name += w;
97 }
98 if (!s.empty()) {
99 name += " ";
100 name += s;
101 }
102 return name;
103 }
104
105};
106
107} // namespace Experimental
108} // namespace ROOT
109
110#endif
#define R__ATTR_CLASS(ClassName, dflt_prefix)
char name[80]
Definition TGX11.cxx:110
Base class for attributes aggregations like lines or fill attributes.
A font attributes, used together with text attributes.
Definition RAttrFont.hxx:26
RAttrFont & operator=(EFont id)
assign font id, setting all necessary properties
Definition RAttrFont.hxx:86
RAttrFont & SetFont(EFont font)
Set text font by id as usually handled in the ROOT (without precision), number should be between 1 an...
Definition RAttrFont.hxx:59
std::string GetFullName() const
Returns full font name including weight and style.
Definition RAttrFont.hxx:91
friend bool operator==(const RAttrFont &font, EFont id)
Definition RAttrFont.hxx:88
RAttrValue< std::string > family
! font family, corresponds to css font-familty attribute
Definition RAttrFont.hxx:32
RAttrValue< std::string > weight
! font weight, corresponds to css font-weight attribute
Definition RAttrFont.hxx:34
RAttrValue< std::string > style
! font style, corresponds to css font-style attribute
Definition RAttrFont.hxx:33
Template class to access single value from drawable or other attributes.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.