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"
46 : family_(family), series_(series), shape_(shape), size_(size),
47 color_(color), background_(background), paint_color_(), emph_(emph),
48 underbar_(underbar), noun_(noun), number_(number)
51 /// Decreases font size by one
53 /// Increases font size by one
58 FontFamily family() const { return family_; }
59 void setFamily(FontFamily f) { family_ = f; }
60 FontSeries series() const { return series_; }
61 void setSeries(FontSeries s) { series_ = s; }
62 FontShape shape() const { return shape_; }
63 void setShape(FontShape s) { shape_ = s; }
64 FontSize size() const { return size_; }
65 void setSize(FontSize s) { size_ = s; }
66 FontState emph() const { return emph_; }
67 void setEmph(FontState e) { emph_ = e; }
68 FontState underbar() const { return underbar_; }
69 void setUnderbar(FontState u) { underbar_ = u; }
70 FontState noun() const { return noun_; }
71 void setNoun(FontState n) { noun_ = n; }
72 FontState number() const { return number_; }
73 void setNumber(FontState n) { number_ = n; }
74 ColorCode color() const { return color_; }
75 void setColor(ColorCode c) { color_ = c; }
76 ColorCode background() const { return background_; }
77 void setBackground(ColorCode b) { background_ = b; }
81 void update(FontInfo const & newfont, bool toggleall);
83 /** Reduce font to fall back to template where possible.
84 Equal fields are reduced to INHERIT */
85 void reduce(FontInfo const & tmplt);
87 /// Realize font from a template (INHERIT are realized)
88 FontInfo & realize(FontInfo const & tmplt);
89 /// Is a given font fully resolved?
90 bool resolved() const;
92 /// The real color of the font. This can be the color that is
93 /// set for painting, the color of the font or a default color.
94 Color realColor() const;
95 /// Sets the color which is used during painting
96 void setPaintColor(Color c) { paint_color_ = c; }
98 /// Converts logical attributes to concrete shape attribute
99 /// Try hard to inline this as it shows up with 4.6 % in the profiler.
100 FontShape realShape() const
102 if (noun_ == FONT_ON)
103 return SMALLCAPS_SHAPE;
104 if (emph_ == FONT_ON)
105 return (shape_ == UP_SHAPE) ? ITALIC_SHAPE : UP_SHAPE;
109 bool isSymbolFont() const
127 friend bool operator==(FontInfo const & lhs, FontInfo const & rhs);
140 ColorCode background_;
141 /// The color used for painting
154 inline bool operator==(FontInfo const & lhs, FontInfo const & rhs)
156 return lhs.family_ == rhs.family_
157 && lhs.series_ == rhs.series_
158 && lhs.shape_ == rhs.shape_
159 && lhs.size_ == rhs.size_
160 && lhs.color_ == rhs.color_
161 && lhs.background_ == rhs.background_
162 && lhs.emph_ == rhs.emph_
163 && lhs.underbar_ == rhs.underbar_
164 && lhs.noun_ == rhs.noun_
165 && lhs.number_ == rhs.number_;
169 inline bool operator!=(FontInfo const & lhs, FontInfo const & rhs)
171 return !operator==(lhs, rhs);
175 extern FontInfo const sane_font;
176 /// All inherit font.
177 extern FontInfo const inherit_font;
179 extern FontInfo const ignore_font;
183 #endif // TEX2LYX_FONT_H