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 "ColorCode.h"
20 #include "FontEnums.h"
21 #include "support/strfwd.h"
48 : family_(family), series_(series), shape_(shape), size_(size),
49 color_(color), background_(background), paint_color_(), emph_(emph),
50 underbar_(underbar), strikeout_(strikeout), uuline_(uuline),
51 uwave_(uwave), noun_(noun), number_(number)
54 /// Decreases font size by one
56 /// Increases font size by one
59 /// \name Accessor methods
61 FontFamily family() const { return family_; }
62 void setFamily(FontFamily f) { family_ = f; }
63 FontSeries series() const { return series_; }
64 void setSeries(FontSeries s) { series_ = s; }
65 FontShape shape() const { return shape_; }
66 void setShape(FontShape s) { shape_ = s; }
67 FontSize size() const { return size_; }
68 void setSize(FontSize s) { size_ = s; }
69 FontState emph() const { return emph_; }
70 void setEmph(FontState e) { emph_ = e; }
71 FontState underbar() const { return underbar_; }
72 void setUnderbar(FontState u) { underbar_ = u; }
73 FontState strikeout() const { return strikeout_; }
74 void setStrikeout(FontState s) { strikeout_ = s; }
75 FontState uuline() const { return uuline_; }
76 void setUuline(FontState s) { uuline_ = s; }
77 FontState uwave() const { return uwave_; }
78 void setUwave(FontState s) { uwave_ = s; }
79 FontState noun() const { return noun_; }
80 void setNoun(FontState n) { noun_ = n; }
81 FontState number() const { return number_; }
82 void setNumber(FontState n) { number_ = n; }
83 ColorCode color() const { return color_; }
84 void setColor(ColorCode c) { color_ = c; }
85 ColorCode background() const { return background_; }
86 void setBackground(ColorCode b) { background_ = b; }
90 void update(FontInfo const & newfont, bool toggleall);
92 /** Reduce font to fall back to template where possible.
93 Equal fields are reduced to INHERIT */
94 void reduce(FontInfo const & tmplt);
96 /// Realize font from a template (INHERIT are realized)
97 FontInfo & realize(FontInfo const & tmplt);
98 /// Is a given font fully resolved?
99 bool resolved() const;
101 /// The real color of the font. This can be the color that is
102 /// set for painting, the color of the font or a default color.
103 Color realColor() const;
104 /// Sets the color which is used during painting
105 void setPaintColor(Color c) { paint_color_ = c; }
108 docstring asCSS() const;
110 /// Converts logical attributes to concrete shape attribute
111 /// Try hard to inline this as it shows up with 4.6 % in the profiler.
112 FontShape realShape() const
114 if (noun_ == FONT_ON)
115 return SMALLCAPS_SHAPE;
116 if (emph_ == FONT_ON)
117 return (shape_ == UP_SHAPE) ? ITALIC_SHAPE : UP_SHAPE;
121 bool isSymbolFont() const
140 friend bool operator==(FontInfo const & lhs, FontInfo const & rhs);
153 ColorCode background_;
154 /// The color used for painting
161 FontState strikeout_;
173 inline bool operator==(FontInfo const & lhs, FontInfo const & rhs)
175 return lhs.family_ == rhs.family_
176 && lhs.series_ == rhs.series_
177 && lhs.shape_ == rhs.shape_
178 && lhs.size_ == rhs.size_
179 && lhs.color_ == rhs.color_
180 && lhs.background_ == rhs.background_
181 && lhs.emph_ == rhs.emph_
182 && lhs.underbar_ == rhs.underbar_
183 && lhs.strikeout_ == rhs.strikeout_
184 && lhs.uuline_ == rhs.uuline_
185 && lhs.uwave_ == rhs.uwave_
186 && lhs.noun_ == rhs.noun_
187 && lhs.number_ == rhs.number_;
191 inline bool operator!=(FontInfo const & lhs, FontInfo const & rhs)
193 return !operator==(lhs, rhs);
197 extern FontInfo const sane_font;
198 /// All inherit font.
199 extern FontInfo const inherit_font;
201 extern FontInfo const ignore_font;
203 /// Set family after LyX text format
204 void setLyXFamily(std::string const &, FontInfo &);
206 /// Set series after LyX text format
207 void setLyXSeries(std::string const &, FontInfo &);
209 /// Set shape after LyX text format
210 void setLyXShape(std::string const &, FontInfo &);
212 /// Set size after LyX text format
213 void setLyXSize(std::string const &, FontInfo &);
215 /// Sets color after LyX text format
216 void setLyXColor(std::string const &, FontInfo &);
218 /// Returns misc flag after LyX text format
219 FontState setLyXMisc(std::string const &);
221 /// Read a font specification from Lexer. Used for layout files.
222 FontInfo lyxRead(Lexer &, FontInfo const & fi = sane_font);