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 LyXFont & setFamily(LyXFont::FONT_FAMILY f);
227 LyXFont & setSeries(LyXFont::FONT_SERIES s);
229 LyXFont & setShape(LyXFont::FONT_SHAPE s);
231 LyXFont & setSize(LyXFont::FONT_SIZE s);
233 LyXFont & setEmph(LyXFont::FONT_MISC_STATE e);
235 LyXFont & setUnderbar(LyXFont::FONT_MISC_STATE u);
237 LyXFont & setNoun(LyXFont::FONT_MISC_STATE n);
239 LyXFont & setNumber(LyXFont::FONT_MISC_STATE n);
241 LyXFont & setColor(LColor::color c);
243 LyXFont & setLanguage(Language const * l);
245 /// Set family after LyX text format
246 LyXFont & setLyXFamily(string const &);
248 /// Set series after LyX text format
249 LyXFont & setLyXSeries(string const &);
251 /// Set shape after LyX text format
252 LyXFont & setLyXShape(string const &);
254 /// Set size after LyX text format
255 LyXFont & setLyXSize(string const &);
257 /// Returns misc flag after LyX text format
258 LyXFont::FONT_MISC_STATE setLyXMisc(string const &);
260 /// Sets color after LyX text format
261 LyXFont & setLyXColor(string const &);
263 /// Returns size of font in LaTeX text notation
264 string const latexSize() const;
266 /** Updates font settings according to request.
267 If an attribute is IGNORE, the attribute is left as it is.
268 When toggleall = true, all properties that matches the font in use
269 will have the effect that the properties is reset to the
270 default. If we have a text that is TYPEWRITER_FAMILY, and is
271 update()'ed with TYPEWRITER_FAMILY, the operation will be as if
272 a INHERIT_FAMILY was asked for. This is necessary for the
273 toggle-user-defined-style button on the toolbar.
275 void update(LyXFont const & newfont,
276 Language const * default_lang,
277 bool toggleall = false);
279 /** Reduce font to fall back to template where possible.
280 Equal fields are reduced to INHERIT */
281 void reduce(LyXFont const & tmplt);
283 /// Realize font from a template (INHERIT are realized)
284 LyXFont & realize(LyXFont const & tmplt);
285 /// Is a given font fully resolved?
286 bool resolved() const;
288 /// Read a font specification from LyXLex. Used for layout files.
289 LyXFont & lyxRead(LyXLex &);
291 /// Writes the changes from this font to orgfont in .lyx format in file
292 void lyxWriteChanges(LyXFont const & orgfont, std::ostream &) const;
294 /** Writes the head of the LaTeX needed to change to this font.
295 Writes to string, the head of the LaTeX needed to change
296 to this font. Returns number of chars written. Base is the
297 font state active now.
299 int latexWriteStartChanges(std::ostream &, LyXFont const & base,
300 LyXFont const & prev) const;
302 /** Writes tha tail of the LaTeX needed to chagne to this font.
303 Returns number of chars written. Base is the font state we want
306 int latexWriteEndChanges(std::ostream &, LyXFont const & base,
307 LyXFont const & next) const;
309 /// Build GUI description of font state
310 string const stateText(BufferParams * params) const;
313 LColor::color realColor() const;
317 bool operator==(LyXFont const & font1, LyXFont const & font2);
319 /// Converts logical attributes to concrete shape attribute
320 LyXFont::FONT_SHAPE realShape() const;
322 /** Compaq cxx 6.5 requires that the definition be public so that
323 it can compile operator==()
337 FONT_MISC_STATE emph;
339 FONT_MISC_STATE underbar;
341 FONT_MISC_STATE noun;
343 FONT_MISC_STATE number;
351 Language const * lang;
354 static FontBits sane;
357 static FontBits inherit;
360 static FontBits ignore;
362 /// Updates a misc setting according to request
363 LyXFont::FONT_MISC_STATE setMisc(LyXFont::FONT_MISC_STATE newfont,
364 LyXFont::FONT_MISC_STATE org);
369 LyXFont::FONT_SHAPE LyXFont::shape() const
376 LyXFont::FONT_FAMILY LyXFont::family() const
383 LyXFont::FONT_SERIES LyXFont::series() const
390 LyXFont::FONT_SIZE LyXFont::size() const
397 LyXFont::FONT_MISC_STATE LyXFont::emph() const
404 LyXFont::FONT_MISC_STATE LyXFont::noun() const
411 bool LyXFont::isSymbolFont() const
414 case LyXFont::SYMBOL_FAMILY:
415 case LyXFont::CMSY_FAMILY:
416 case LyXFont::CMM_FAMILY:
417 case LyXFont::CMEX_FAMILY:
418 case LyXFont::MSA_FAMILY:
419 case LyXFont::MSB_FAMILY:
420 case LyXFont::WASY_FAMILY:
428 std::ostream & operator<<(std::ostream &, LyXFont::FONT_MISC_STATE);
430 bool operator==(LyXFont::FontBits const & lhs, LyXFont::FontBits const & rhs);
433 bool operator!=(LyXFont::FontBits const & lhs, LyXFont::FontBits const & rhs)
435 return !(lhs == rhs);
440 bool operator==(LyXFont const & font1, LyXFont const & font2)
442 return font1.bits == font2.bits &&
443 font1.lang == font2.lang;
448 bool operator!=(LyXFont const & font1, LyXFont const & font2)
450 return !(font1 == font2);