4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
9 * \author Angus Leeming
12 * Full author contact details are available in file CREDITS.
15 #ifndef FONT_PROPERTIES_H
16 #define FONT_PROPERTIES_H
19 #include "tex2lyx/Font.h"
23 #include "ColorCode.h"
24 #include "FontEnums.h"
47 : family_(family), series_(series), shape_(shape), size_(size),
48 color_(color), background_(background), paint_color_(), emph_(emph),
49 underbar_(underbar), strikeout_(strikeout), noun_(noun), number_(number)
52 /// Decreases font size by one
54 /// Increases font size by one
59 FontFamily family() const { return family_; }
60 void setFamily(FontFamily f) { family_ = f; }
61 FontSeries series() const { return series_; }
62 void setSeries(FontSeries s) { series_ = s; }
63 FontShape shape() const { return shape_; }
64 void setShape(FontShape s) { shape_ = s; }
65 FontSize size() const { return size_; }
66 void setSize(FontSize s) { size_ = s; }
67 FontState emph() const { return emph_; }
68 void setEmph(FontState e) { emph_ = e; }
69 FontState underbar() const { return underbar_; }
70 void setUnderbar(FontState u) { underbar_ = u; }
71 FontState strikeout() const { return strikeout_; }
72 void setStrikeout(FontState s) { strikeout_ = s; }
73 FontState noun() const { return noun_; }
74 void setNoun(FontState n) { noun_ = n; }
75 FontState number() const { return number_; }
76 void setNumber(FontState n) { number_ = n; }
77 ColorCode color() const { return color_; }
78 void setColor(ColorCode c) { color_ = c; }
79 ColorCode background() const { return background_; }
80 void setBackground(ColorCode b) { background_ = b; }
84 void update(FontInfo const & newfont, bool toggleall);
86 /** Reduce font to fall back to template where possible.
87 Equal fields are reduced to INHERIT */
88 void reduce(FontInfo const & tmplt);
90 /// Realize font from a template (INHERIT are realized)
91 FontInfo & realize(FontInfo const & tmplt);
92 /// Is a given font fully resolved?
93 bool resolved() const;
95 /// The real color of the font. This can be the color that is
96 /// set for painting, the color of the font or a default color.
97 Color realColor() const;
98 /// Sets the color which is used during painting
99 void setPaintColor(Color c) { paint_color_ = c; }
101 /// Converts logical attributes to concrete shape attribute
102 /// Try hard to inline this as it shows up with 4.6 % in the profiler.
103 FontShape realShape() const
105 if (noun_ == FONT_ON)
106 return SMALLCAPS_SHAPE;
107 if (emph_ == FONT_ON)
108 return (shape_ == UP_SHAPE) ? ITALIC_SHAPE : UP_SHAPE;
112 bool isSymbolFont() const
130 friend bool operator==(FontInfo const & lhs, FontInfo const & rhs);
143 ColorCode background_;
144 /// The color used for painting
151 FontState strikeout_;
159 inline bool operator==(FontInfo const & lhs, FontInfo const & rhs)
161 return lhs.family_ == rhs.family_
162 && lhs.series_ == rhs.series_
163 && lhs.shape_ == rhs.shape_
164 && lhs.size_ == rhs.size_
165 && lhs.color_ == rhs.color_
166 && lhs.background_ == rhs.background_
167 && lhs.emph_ == rhs.emph_
168 && lhs.underbar_ == rhs.underbar_
169 && lhs.strikeout_ == rhs.strikeout_
170 && lhs.noun_ == rhs.noun_
171 && lhs.number_ == rhs.number_;
175 inline bool operator!=(FontInfo const & lhs, FontInfo const & rhs)
177 return !operator==(lhs, rhs);
181 extern FontInfo const sane_font;
182 /// All inherit font.
183 extern FontInfo const inherit_font;
185 extern FontInfo const ignore_font;
189 #endif // TEX2LYX_FONT_H