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"
25 #include "support/strfwd.h"
50 : family_(family), series_(series), shape_(shape), size_(size),
51 color_(color), background_(background), paint_color_(), emph_(emph),
52 underbar_(underbar), strikeout_(strikeout), uuline_(uuline),
53 uwave_(uwave), noun_(noun), number_(number)
56 /// Decreases font size by one
58 /// Increases font size by one
63 FontFamily family() const { return family_; }
64 void setFamily(FontFamily f) { family_ = f; }
65 FontSeries series() const { return series_; }
66 void setSeries(FontSeries s) { series_ = s; }
67 FontShape shape() const { return shape_; }
68 void setShape(FontShape s) { shape_ = s; }
69 FontSize size() const { return size_; }
70 void setSize(FontSize s) { size_ = s; }
71 FontState emph() const { return emph_; }
72 void setEmph(FontState e) { emph_ = e; }
73 FontState underbar() const { return underbar_; }
74 void setUnderbar(FontState u) { underbar_ = u; }
75 FontState strikeout() const { return strikeout_; }
76 void setStrikeout(FontState s) { strikeout_ = s; }
77 FontState uuline() const { return uuline_; }
78 void setUuline(FontState s) { uuline_ = s; }
79 FontState uwave() const { return uwave_; }
80 void setUwave(FontState s) { uwave_ = s; }
81 FontState noun() const { return noun_; }
82 void setNoun(FontState n) { noun_ = n; }
83 FontState number() const { return number_; }
84 void setNumber(FontState n) { number_ = n; }
85 ColorCode color() const { return color_; }
86 void setColor(ColorCode c) { color_ = c; }
87 ColorCode background() const { return background_; }
88 void setBackground(ColorCode b) { background_ = b; }
92 void update(FontInfo const & newfont, bool toggleall);
94 /** Reduce font to fall back to template where possible.
95 Equal fields are reduced to INHERIT */
96 void reduce(FontInfo const & tmplt);
98 /// Realize font from a template (INHERIT are realized)
99 FontInfo & realize(FontInfo const & tmplt);
100 /// Is a given font fully resolved?
101 bool resolved() const;
103 /// The real color of the font. This can be the color that is
104 /// set for painting, the color of the font or a default color.
105 Color realColor() const;
106 /// Sets the color which is used during painting
107 void setPaintColor(Color c) { paint_color_ = c; }
110 docstring asCSS() const;
112 /// Converts logical attributes to concrete shape attribute
113 /// Try hard to inline this as it shows up with 4.6 % in the profiler.
114 FontShape realShape() const
116 if (noun_ == FONT_ON)
117 return SMALLCAPS_SHAPE;
118 if (emph_ == FONT_ON)
119 return (shape_ == UP_SHAPE) ? ITALIC_SHAPE : UP_SHAPE;
123 bool isSymbolFont() const
141 friend bool operator==(FontInfo const & lhs, FontInfo const & rhs);
154 ColorCode background_;
155 /// The color used for painting
162 FontState strikeout_;
174 inline bool operator==(FontInfo const & lhs, FontInfo const & rhs)
176 return lhs.family_ == rhs.family_
177 && lhs.series_ == rhs.series_
178 && lhs.shape_ == rhs.shape_
179 && lhs.size_ == rhs.size_
180 && lhs.color_ == rhs.color_
181 && lhs.background_ == rhs.background_
182 && lhs.emph_ == rhs.emph_
183 && lhs.underbar_ == rhs.underbar_
184 && lhs.strikeout_ == rhs.strikeout_
185 && lhs.uuline_ == rhs.uuline_
186 && lhs.uwave_ == rhs.uwave_
187 && lhs.noun_ == rhs.noun_
188 && lhs.number_ == rhs.number_;
192 inline bool operator!=(FontInfo const & lhs, FontInfo const & rhs)
194 return !operator==(lhs, rhs);
198 extern FontInfo const sane_font;
199 /// All inherit font.
200 extern FontInfo const inherit_font;
202 extern FontInfo const ignore_font;
206 #endif // TEX2LYX_FONT_H