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