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.
29 /** The value INHERIT_* means that the font attribute is
30 inherited from the layout. In the case of layout fonts, the
31 attribute is inherited from the default font.
32 The value IGNORE_* is used with LyXFont::update() when the
33 attribute should not be changed.
37 ROMAN_FAMILY, // fontstruct rely on this to be 0
65 NUM_FAMILIES = INHERIT_FAMILY
71 MEDIUM_SERIES, // fontstruct rely on this to be 0
83 UP_SHAPE, // fontstruct rely on this to be 0
99 SIZE_TINY, // fontstruct rely on this to be 0
128 /// Used for emph, underbar, noun and latex toggles
129 enum FONT_MISC_STATE {
142 /// Trick to overload constructor and make it megafast
161 /// Shortcut initialization
163 LyXFont(LyXFont::FONT_INIT1);
164 /// Shortcut initialization
166 LyXFont(LyXFont::FONT_INIT2);
167 /// Shortcut initialization
169 LyXFont(LyXFont::FONT_INIT3);
170 /// Shortcut initialization
171 LyXFont(LyXFont::FONT_INIT1, Language const * l);
172 /// Shortcut initialization
173 LyXFont(LyXFont::FONT_INIT2, Language const * l);
174 /// Shortcut initialization
175 LyXFont(LyXFont::FONT_INIT3, Language const * l);
177 /// Decreases font size by one
180 /// Increases font size by one
184 FONT_FAMILY family() const;
187 FONT_SERIES series() const;
190 FONT_SHAPE shape() const;
193 FONT_SIZE size() const;
196 FONT_MISC_STATE emph() const;
199 FONT_MISC_STATE underbar() const;
202 FONT_MISC_STATE noun() const;
205 FONT_MISC_STATE number() const;
208 LColor_color color() const;
211 Language const * language() const;
214 bool isRightToLeft() const;
217 bool isVisibleRightToLeft() const;
220 bool isSymbolFont() const;
223 void setFamily(LyXFont::FONT_FAMILY f);
224 void setSeries(LyXFont::FONT_SERIES s);
225 void setShape(LyXFont::FONT_SHAPE s);
226 void setSize(LyXFont::FONT_SIZE s);
227 void setEmph(LyXFont::FONT_MISC_STATE e);
228 void setUnderbar(LyXFont::FONT_MISC_STATE u);
229 void setNoun(LyXFont::FONT_MISC_STATE n);
230 void setNumber(LyXFont::FONT_MISC_STATE n);
231 void setColor(LColor_color c);
232 void setLanguage(Language const * l);
234 /// Set family after LyX text format
235 LyXFont & setLyXFamily(std::string const &);
237 /// Set series after LyX text format
238 LyXFont & setLyXSeries(std::string const &);
240 /// Set shape after LyX text format
241 LyXFont & setLyXShape(std::string const &);
243 /// Set size after LyX text format
244 LyXFont & setLyXSize(std::string const &);
246 /// Returns misc flag after LyX text format
247 LyXFont::FONT_MISC_STATE setLyXMisc(std::string const &);
249 /// Sets color after LyX text format
250 LyXFont & setLyXColor(std::string const &);
252 /// Returns size of font in LaTeX text notation
253 std::string const latexSize() const;
255 /** Updates font settings according to request.
256 If an attribute is IGNORE, the attribute is left as it is.
257 When toggleall = true, all properties that matches the font in use
258 will have the effect that the properties is reset to the
259 default. If we have a text that is TYPEWRITER_FAMILY, and is
260 update()'ed with TYPEWRITER_FAMILY, the operation will be as if
261 a INHERIT_FAMILY was asked for. This is necessary for the
262 toggle-user-defined-style button on the toolbar.
264 void update(LyXFont const & newfont,
265 Language const * default_lang,
266 bool toggleall = false);
268 /** Reduce font to fall back to template where possible.
269 Equal fields are reduced to INHERIT */
270 void reduce(LyXFont const & tmplt);
272 /// Realize font from a template (INHERIT are realized)
273 LyXFont & realize(LyXFont const & tmplt);
274 /// Is a given font fully resolved?
275 bool resolved() const;
277 /// Read a font specification from LyXLex. Used for layout files.
278 LyXFont & lyxRead(LyXLex &);
280 /// Writes the changes from this font to orgfont in .lyx format in file
281 void lyxWriteChanges(LyXFont const & orgfont, std::ostream &) const;
283 /** Writes the head of the LaTeX needed to change to this font.
284 Writes to string, the head of the LaTeX needed to change
285 to this font. Returns number of chars written. Base is the
286 font state active now.
288 int latexWriteStartChanges(std::ostream &, LyXFont const & base,
289 LyXFont const & prev) const;
291 /** Writes tha tail of the LaTeX needed to chagne to this font.
292 Returns number of chars written. Base is the font state we want
295 int latexWriteEndChanges(std::ostream &, LyXFont const & base,
296 LyXFont const & next) const;
298 /// Build GUI description of font state
299 std::string const stateText(BufferParams * params) const;
302 LColor_color realColor() const;
306 bool operator==(LyXFont const & font1, LyXFont const & font2);
308 /// Converts logical attributes to concrete shape attribute
309 LyXFont::FONT_SHAPE realShape() const;
311 /** Compaq cxx 6.5 requires that the definition be public so that
312 it can compile operator==()
323 /** We store the LColor::color value as an int to get LColor.h out
324 * of the header file.
328 FONT_MISC_STATE emph;
330 FONT_MISC_STATE underbar;
332 FONT_MISC_STATE noun;
334 FONT_MISC_STATE number;
342 Language const * lang;
345 static FontBits sane;
348 static FontBits inherit;
351 static FontBits ignore;
353 /// Updates a misc setting according to request
354 LyXFont::FONT_MISC_STATE setMisc(LyXFont::FONT_MISC_STATE newfont,
355 LyXFont::FONT_MISC_STATE org);
359 /** \c LyXFont_size is a wrapper for LyXFont::FONT_SIZE.
360 * It can be forward-declared and passed as a function argument without
361 * having to expose lyxfont.h.
364 LyXFont::FONT_SIZE val_;
366 LyXFont_size(LyXFont::FONT_SIZE val) : val_(val) {}
367 operator LyXFont::FONT_SIZE() const{ return val_; }
373 LyXFont::FONT_SHAPE LyXFont::shape() const
380 LyXFont::FONT_FAMILY LyXFont::family() const
387 LyXFont::FONT_SERIES LyXFont::series() const
394 LyXFont::FONT_SIZE LyXFont::size() const
401 LyXFont::FONT_MISC_STATE LyXFont::emph() const
408 LyXFont::FONT_MISC_STATE LyXFont::noun() const
415 bool LyXFont::isSymbolFont() const
418 case LyXFont::SYMBOL_FAMILY:
419 case LyXFont::CMSY_FAMILY:
420 case LyXFont::CMM_FAMILY:
421 case LyXFont::CMEX_FAMILY:
422 case LyXFont::MSA_FAMILY:
423 case LyXFont::MSB_FAMILY:
424 case LyXFont::WASY_FAMILY:
432 std::ostream & operator<<(std::ostream &, LyXFont::FONT_MISC_STATE);
434 bool operator==(LyXFont::FontBits const & lhs, LyXFont::FontBits const & rhs);
437 bool operator!=(LyXFont::FontBits const & lhs, LyXFont::FontBits const & rhs)
439 return !(lhs == rhs);
444 bool operator==(LyXFont const & font1, LyXFont const & font2)
446 return font1.bits == font2.bits &&
447 font1.lang == font2.lang;
452 bool operator!=(LyXFont const & font1, LyXFont const & font2)
454 return !(font1 == font2);