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.
31 /** The value INHERIT_* means that the font attribute is
32 inherited from the layout. In the case of layout fonts, the
33 attribute is inherited from the default font.
34 The value IGNORE_* is used with LyXFont::update() when the
35 attribute should not be changed.
39 ROMAN_FAMILY, // fontstruct rely on this to be 0
67 NUM_FAMILIES = INHERIT_FAMILY
73 MEDIUM_SERIES, // fontstruct rely on this to be 0
85 UP_SHAPE, // fontstruct rely on this to be 0
101 SIZE_TINY, // fontstruct rely on this to be 0
130 /// Used for emph, underbar, noun and latex toggles
131 enum FONT_MISC_STATE {
144 /// Trick to overload constructor and make it megafast
163 /// Shortcut initialization
165 LyXFont(LyXFont::FONT_INIT1);
166 /// Shortcut initialization
168 LyXFont(LyXFont::FONT_INIT2);
169 /// Shortcut initialization
171 LyXFont(LyXFont::FONT_INIT3);
172 /// Shortcut initialization
173 LyXFont(LyXFont::FONT_INIT1, Language const * l);
174 /// Shortcut initialization
175 LyXFont(LyXFont::FONT_INIT2, Language const * l);
176 /// Shortcut initialization
177 LyXFont(LyXFont::FONT_INIT3, Language const * l);
179 /// Decreases font size by one
182 /// Increases font size by one
186 FONT_FAMILY family() const;
189 FONT_SERIES series() const;
192 FONT_SHAPE shape() const;
195 FONT_SIZE size() const;
198 FONT_MISC_STATE emph() const;
201 FONT_MISC_STATE underbar() const;
204 FONT_MISC_STATE noun() const;
207 FONT_MISC_STATE number() const;
210 LColor_color color() const;
213 Language const * language() const;
216 bool isRightToLeft() const;
219 bool isVisibleRightToLeft() const;
222 bool isSymbolFont() const;
225 void setFamily(LyXFont::FONT_FAMILY f);
226 void setSeries(LyXFont::FONT_SERIES s);
227 void setShape(LyXFont::FONT_SHAPE s);
228 void setSize(LyXFont::FONT_SIZE s);
229 void setEmph(LyXFont::FONT_MISC_STATE e);
230 void setUnderbar(LyXFont::FONT_MISC_STATE u);
231 void setNoun(LyXFont::FONT_MISC_STATE n);
232 void setNumber(LyXFont::FONT_MISC_STATE n);
233 void setColor(LColor_color c);
234 void setLanguage(Language const * l);
236 /// Set family after LyX text format
237 LyXFont & setLyXFamily(std::string const &);
239 /// Set series after LyX text format
240 LyXFont & setLyXSeries(std::string const &);
242 /// Set shape after LyX text format
243 LyXFont & setLyXShape(std::string const &);
245 /// Set size after LyX text format
246 LyXFont & setLyXSize(std::string const &);
248 /// Returns misc flag after LyX text format
249 LyXFont::FONT_MISC_STATE setLyXMisc(std::string const &);
251 /// Sets color after LyX text format
252 LyXFont & setLyXColor(std::string const &);
254 /// Returns size of font in LaTeX text notation
255 std::string const latexSize() const;
257 /** Updates font settings according to request.
258 If an attribute is IGNORE, the attribute is left as it is.
259 When toggleall = true, all properties that matches the font in use
260 will have the effect that the properties is reset to the
261 default. If we have a text that is TYPEWRITER_FAMILY, and is
262 update()'ed with TYPEWRITER_FAMILY, the operation will be as if
263 a INHERIT_FAMILY was asked for. This is necessary for the
264 toggle-user-defined-style button on the toolbar.
266 void update(LyXFont const & newfont,
267 Language const * default_lang,
268 bool toggleall = false);
270 /** Reduce font to fall back to template where possible.
271 Equal fields are reduced to INHERIT */
272 void reduce(LyXFont const & tmplt);
274 /// Realize font from a template (INHERIT are realized)
275 LyXFont & realize(LyXFont const & tmplt);
276 /// Is a given font fully resolved?
277 bool resolved() const;
279 /// Read a font specification from LyXLex. Used for layout files.
280 LyXFont & lyxRead(LyXLex &);
282 /// Writes the changes from this font to orgfont in .lyx format in file
283 void lyxWriteChanges(LyXFont const & orgfont, std::ostream &) const;
285 /** Writes the head of the LaTeX needed to change to this font.
286 Writes to string, the head of the LaTeX needed to change
287 to this font. Returns number of chars written. Base is the
288 font state active now.
290 int latexWriteStartChanges(std::ostream &, LyXFont const & base,
291 LyXFont const & prev) const;
293 /** Writes the tail of the LaTeX needed to change to this font.
294 Returns number of chars written. Base is the font state we want
297 int latexWriteEndChanges(std::ostream &, LyXFont const & base,
298 LyXFont const & next) const;
300 /// Build GUI description of font state
301 std::string const stateText(BufferParams * params) const;
304 LColor_color realColor() const;
308 bool operator==(LyXFont const & font1, LyXFont const & font2);
311 std::ostream & operator<<(std::ostream & os, LyXFont const & font);
313 /// Converts logical attributes to concrete shape attribute
314 LyXFont::FONT_SHAPE realShape() const;
316 /** Compaq cxx 6.5 requires that the definition be public so that
317 it can compile operator==()
328 /** We store the LColor::color value as an int to get LColor.h out
329 * of the header file.
333 FONT_MISC_STATE emph;
335 FONT_MISC_STATE underbar;
337 FONT_MISC_STATE noun;
339 FONT_MISC_STATE number;
345 Language const * lang;
347 static FontBits sane;
349 static FontBits inherit;
351 static FontBits ignore;
352 /// Updates a misc setting according to request
353 LyXFont::FONT_MISC_STATE setMisc(LyXFont::FONT_MISC_STATE newfont,
354 LyXFont::FONT_MISC_STATE org);
358 /** \c LyXFont_size is a wrapper for LyXFont::FONT_SIZE.
359 * It can be forward-declared and passed as a function argument without
360 * having to expose lyxfont.h.
365 LyXFont_size(LyXFont::FONT_SIZE val) : val_(val) {}
367 operator LyXFont::FONT_SIZE() const { return val_; }
370 LyXFont::FONT_SIZE val_;
376 LyXFont::FONT_SHAPE LyXFont::shape() const
383 LyXFont::FONT_FAMILY LyXFont::family() const
390 LyXFont::FONT_SERIES LyXFont::series() const
397 LyXFont::FONT_SIZE LyXFont::size() const
404 LyXFont::FONT_MISC_STATE LyXFont::emph() const
411 LyXFont::FONT_MISC_STATE LyXFont::noun() const
418 bool LyXFont::isSymbolFont() const
421 case LyXFont::SYMBOL_FAMILY:
422 case LyXFont::CMSY_FAMILY:
423 case LyXFont::CMM_FAMILY:
424 case LyXFont::CMEX_FAMILY:
425 case LyXFont::MSA_FAMILY:
426 case LyXFont::MSB_FAMILY:
427 case LyXFont::WASY_FAMILY:
435 std::ostream & operator<<(std::ostream &, LyXFont::FONT_MISC_STATE);
437 bool operator==(LyXFont::FontBits const & lhs, LyXFont::FontBits const & rhs);
440 bool operator!=(LyXFont::FontBits const & lhs, LyXFont::FontBits const & rhs)
442 return !(lhs == rhs);
447 bool operator==(LyXFont const & font1, LyXFont const & font2)
449 return font1.bits == font2.bits && font1.lang == font2.lang;
454 bool operator!=(LyXFont const & font1, LyXFont const & font2)
456 return !(font1 == font2);