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.
30 /** The value INHERIT_* means that the font attribute is
31 inherited from the layout. In the case of layout fonts, the
32 attribute is inherited from the default font.
33 The value IGNORE_* is used with LyXFont::update() when the
34 attribute should not be changed.
38 ROMAN_FAMILY
, // fontstruct rely on this to be 0
66 NUM_FAMILIES
= INHERIT_FAMILY
72 MEDIUM_SERIES
, // fontstruct rely on this to be 0
84 UP_SHAPE
, // fontstruct rely on this to be 0
100 SIZE_TINY
, // fontstruct rely on this to be 0
129 /// Used for emph, underbar, noun and latex toggles
130 enum FONT_MISC_STATE
{
143 /// Trick to overload constructor and make it megafast
162 /// Shortcut initialization
164 LyXFont(LyXFont::FONT_INIT1
);
165 /// Shortcut initialization
167 LyXFont(LyXFont::FONT_INIT2
);
168 /// Shortcut initialization
170 LyXFont(LyXFont::FONT_INIT3
);
171 /// Shortcut initialization
172 LyXFont(LyXFont::FONT_INIT1
, Language
const * l
);
173 /// Shortcut initialization
174 LyXFont(LyXFont::FONT_INIT2
, Language
const * l
);
175 /// Shortcut initialization
176 LyXFont(LyXFont::FONT_INIT3
, Language
const * l
);
178 /// Decreases font size by one
181 /// Increases font size by one
185 FONT_FAMILY
family() const;
188 FONT_SERIES
series() const;
191 FONT_SHAPE
shape() const;
194 FONT_SIZE
size() const;
197 FONT_MISC_STATE
emph() const;
200 FONT_MISC_STATE
underbar() const;
203 FONT_MISC_STATE
noun() const;
206 FONT_MISC_STATE
number() const;
209 LColor_color
color() const;
212 Language
const * language() const;
215 bool isRightToLeft() const;
218 bool isVisibleRightToLeft() const;
221 bool isSymbolFont() const;
224 void setFamily(LyXFont::FONT_FAMILY f
);
225 void setSeries(LyXFont::FONT_SERIES s
);
226 void setShape(LyXFont::FONT_SHAPE s
);
227 void setSize(LyXFont::FONT_SIZE s
);
228 void setEmph(LyXFont::FONT_MISC_STATE e
);
229 void setUnderbar(LyXFont::FONT_MISC_STATE u
);
230 void setNoun(LyXFont::FONT_MISC_STATE n
);
231 void setNumber(LyXFont::FONT_MISC_STATE n
);
232 void setColor(LColor_color c
);
233 void setLanguage(Language
const * l
);
235 /// Set family after LyX text format
236 LyXFont
& setLyXFamily(std::string
const &);
238 /// Set series after LyX text format
239 LyXFont
& setLyXSeries(std::string
const &);
241 /// Set shape after LyX text format
242 LyXFont
& setLyXShape(std::string
const &);
244 /// Set size after LyX text format
245 LyXFont
& setLyXSize(std::string
const &);
247 /// Returns misc flag after LyX text format
248 LyXFont::FONT_MISC_STATE
setLyXMisc(std::string
const &);
250 /// Sets color after LyX text format
251 LyXFont
& setLyXColor(std::string
const &);
253 /// Returns size of font in LaTeX text notation
254 std::string
const latexSize() const;
256 /** Updates font settings according to request.
257 If an attribute is IGNORE, the attribute is left as it is.
258 When toggleall = true, all properties that matches the font in use
259 will have the effect that the properties is reset to the
260 default. If we have a text that is TYPEWRITER_FAMILY, and is
261 update()'ed with TYPEWRITER_FAMILY, the operation will be as if
262 a INHERIT_FAMILY was asked for. This is necessary for the
263 toggle-user-defined-style button on the toolbar.
265 void update(LyXFont
const & newfont
,
266 Language
const * default_lang
,
267 bool toggleall
= false);
269 /** Reduce font to fall back to template where possible.
270 Equal fields are reduced to INHERIT */
271 void reduce(LyXFont
const & tmplt
);
273 /// Realize font from a template (INHERIT are realized)
274 LyXFont
& realize(LyXFont
const & tmplt
);
275 /// Is a given font fully resolved?
276 bool resolved() const;
278 /// Read a font specification from LyXLex. Used for layout files.
279 LyXFont
& lyxRead(LyXLex
&);
281 /// Writes the changes from this font to orgfont in .lyx format in file
282 void lyxWriteChanges(LyXFont
const & orgfont
, std::ostream
&) const;
284 /** Writes the head of the LaTeX needed to change to this font.
285 Writes to string, the head of the LaTeX needed to change
286 to this font. Returns number of chars written. Base is the
287 font state active now.
289 int latexWriteStartChanges(std::ostream
&, LyXFont
const & base
,
290 LyXFont
const & prev
) const;
292 /** Writes the tail of the LaTeX needed to change to this font.
293 Returns number of chars written. Base is the font state we want
296 int latexWriteEndChanges(std::ostream
&, LyXFont
const & base
,
297 LyXFont
const & next
) const;
299 /// Build GUI description of font state
300 std::string
const stateText(BufferParams
* params
) const;
303 LColor_color
realColor() const;
307 bool operator==(LyXFont
const & font1
, LyXFont
const & font2
);
310 std::ostream
& operator<<(std::ostream
& os
, LyXFont
const & font
);
312 /// Converts logical attributes to concrete shape attribute
313 LyXFont::FONT_SHAPE
realShape() const;
315 /** Compaq cxx 6.5 requires that the definition be public so that
316 it can compile operator==()
327 /** We store the LColor::color value as an int to get LColor.h out
328 * of the header file.
332 FONT_MISC_STATE emph
;
334 FONT_MISC_STATE underbar
;
336 FONT_MISC_STATE noun
;
338 FONT_MISC_STATE number
;
344 Language
const * lang
;
346 static FontBits sane
;
348 static FontBits inherit
;
350 static FontBits ignore
;
351 /// Updates a misc setting according to request
352 LyXFont::FONT_MISC_STATE
setMisc(LyXFont::FONT_MISC_STATE newfont
,
353 LyXFont::FONT_MISC_STATE org
);
357 /** \c LyXFont_size is a wrapper for LyXFont::FONT_SIZE.
358 * It can be forward-declared and passed as a function argument without
359 * having to expose lyxfont.h.
364 LyXFont_size(LyXFont::FONT_SIZE val
) : val_(val
) {}
366 operator LyXFont::FONT_SIZE() const { return val_
; }
369 LyXFont::FONT_SIZE val_
;
375 LyXFont::FONT_SHAPE
LyXFont::shape() const
382 LyXFont::FONT_FAMILY
LyXFont::family() const
389 LyXFont::FONT_SERIES
LyXFont::series() const
396 LyXFont::FONT_SIZE
LyXFont::size() const
403 LyXFont::FONT_MISC_STATE
LyXFont::emph() const
410 LyXFont::FONT_MISC_STATE
LyXFont::noun() const
417 bool LyXFont::isSymbolFont() const
420 case LyXFont::SYMBOL_FAMILY
:
421 case LyXFont::CMSY_FAMILY
:
422 case LyXFont::CMM_FAMILY
:
423 case LyXFont::CMEX_FAMILY
:
424 case LyXFont::MSA_FAMILY
:
425 case LyXFont::MSB_FAMILY
:
426 case LyXFont::WASY_FAMILY
:
434 std::ostream
& operator<<(std::ostream
&, LyXFont::FONT_MISC_STATE
);
436 bool operator==(LyXFont::FontBits
const & lhs
, LyXFont::FontBits
const & rhs
);
439 bool operator!=(LyXFont::FontBits
const & lhs
, LyXFont::FontBits
const & rhs
)
441 return !(lhs
== rhs
);
446 bool operator==(LyXFont
const & font1
, LyXFont
const & font2
)
448 return font1
.bits
== font2
.bits
&& font1
.lang
== font2
.lang
;
453 bool operator!=(LyXFont
const & font1
, LyXFont
const & font2
)
455 return !(font1
== font2
);