2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2001 The LyX Team.
10 * ====================================================== */
32 /** The value INHERIT_* means that the font attribute is
33 inherited from the layout. In the case of layout fonts, the
34 attribute is inherited from the default font.
35 The value IGNORE_* is used with LyXFont::update() when the
36 attribute should not be changed.
40 ROMAN_FAMILY, // fontstruct rely on this to be 0
68 NUM_FAMILIES = INHERIT_FAMILY
74 MEDIUM_SERIES, // fontstruct rely on this to be 0
86 UP_SHAPE, // fontstruct rely on this to be 0
102 SIZE_TINY, // fontstruct rely on this to be 0
131 /// Used for emph, underbar, noun and latex toggles
132 enum FONT_MISC_STATE {
145 /// Trick to overload constructor and make it megafast
164 /// Shortcut initialization
166 LyXFont(LyXFont::FONT_INIT1);
167 /// Shortcut initialization
169 LyXFont(LyXFont::FONT_INIT2);
170 /// Shortcut initialization
172 LyXFont(LyXFont::FONT_INIT3);
173 /// Shortcut initialization
174 LyXFont(LyXFont::FONT_INIT1, Language const * l);
175 /// Shortcut initialization
176 LyXFont(LyXFont::FONT_INIT2, Language const * l);
177 /// Shortcut initialization
178 LyXFont(LyXFont::FONT_INIT3, Language const * l);
180 /// Decreases font size by one
183 /// Increases font size by one
187 FONT_FAMILY family() const;
190 FONT_SERIES series() const;
193 FONT_SHAPE shape() const;
196 FONT_SIZE size() const;
199 FONT_MISC_STATE emph() const;
202 FONT_MISC_STATE underbar() const;
205 FONT_MISC_STATE noun() const;
208 FONT_MISC_STATE number() const;
211 LColor::color color() const;
214 Language const * language() const;
217 bool isRightToLeft() const;
220 bool isVisibleRightToLeft() const;
223 bool isSymbolFont() const;
226 LyXFont & setFamily(LyXFont::FONT_FAMILY f);
228 LyXFont & setSeries(LyXFont::FONT_SERIES s);
230 LyXFont & setShape(LyXFont::FONT_SHAPE s);
232 LyXFont & setSize(LyXFont::FONT_SIZE s);
234 LyXFont & setEmph(LyXFont::FONT_MISC_STATE e);
236 LyXFont & setUnderbar(LyXFont::FONT_MISC_STATE u);
238 LyXFont & setNoun(LyXFont::FONT_MISC_STATE n);
240 LyXFont & setNumber(LyXFont::FONT_MISC_STATE n);
242 LyXFont & setColor(LColor::color c);
244 LyXFont & setLanguage(Language const * l);
246 /// Set family after LyX text format
247 LyXFont & setLyXFamily(string const &);
249 /// Set series after LyX text format
250 LyXFont & setLyXSeries(string const &);
252 /// Set shape after LyX text format
253 LyXFont & setLyXShape(string const &);
255 /// Set size after LyX text format
256 LyXFont & setLyXSize(string const &);
258 /// Returns misc flag after LyX text format
259 LyXFont::FONT_MISC_STATE setLyXMisc(string const &);
261 /// Sets color after LyX text format
262 LyXFont & setLyXColor(string const &);
264 /// Returns size of font in LaTeX text notation
265 string const latexSize() const;
267 /** Updates font settings according to request.
268 If an attribute is IGNORE, the attribute is left as it is.
269 When toggleall = true, all properties that matches the font in use
270 will have the effect that the properties is reset to the
271 default. If we have a text that is TYPEWRITER_FAMILY, and is
272 update()'ed with TYPEWRITER_FAMILY, the operation will be as if
273 a INHERIT_FAMILY was asked for. This is necessary for the
274 toggle-user-defined-style button on the toolbar.
276 void update(LyXFont const & newfont,
277 Language const * default_lang,
278 bool toggleall = false);
280 /** Reduce font to fall back to template where possible.
281 Equal fields are reduced to INHERIT */
282 void reduce(LyXFont const & tmplt);
284 /// Realize font from a template (INHERIT are realized)
285 LyXFont & realize(LyXFont const & tmplt);
286 /// Is a given font fully resolved?
287 bool resolved() const;
289 /// Read a font specification from LyXLex. Used for layout files.
290 LyXFont & lyxRead(LyXLex &);
292 /// Writes the changes from this font to orgfont in .lyx format in file
293 void lyxWriteChanges(LyXFont const & orgfont, std::ostream &) const;
295 /** Writes the head of the LaTeX needed to change to this font.
296 Writes to string, the head of the LaTeX needed to change
297 to this font. Returns number of chars written. Base is the
298 font state active now.
300 int latexWriteStartChanges(std::ostream &, LyXFont const & base,
301 LyXFont const & prev) const;
303 /** Writes tha tail of the LaTeX needed to chagne to this font.
304 Returns number of chars written. Base is the font state we want
307 int latexWriteEndChanges(std::ostream &, LyXFont const & base,
308 LyXFont const & next) const;
310 /// Build GUI description of font state
311 string const stateText(BufferParams * params) const;
314 LColor::color realColor() const;
318 bool operator==(LyXFont const & font1, LyXFont const & font2);
320 /// Converts logical attributes to concrete shape attribute
321 LyXFont::FONT_SHAPE realShape() const;
323 /** Compaq cxx 6.5 requires that the definition be public so that
324 it can compile operator==()
338 FONT_MISC_STATE emph;
340 FONT_MISC_STATE underbar;
342 FONT_MISC_STATE noun;
344 FONT_MISC_STATE number;
352 Language const * lang;
355 static FontBits sane;
358 static FontBits inherit;
361 static FontBits ignore;
363 /// Updates a misc setting according to request
364 LyXFont::FONT_MISC_STATE setMisc(LyXFont::FONT_MISC_STATE newfont,
365 LyXFont::FONT_MISC_STATE org);
370 LyXFont::FONT_SHAPE LyXFont::shape() const
377 LyXFont::FONT_FAMILY LyXFont::family() const
384 LyXFont::FONT_SERIES LyXFont::series() const
391 LyXFont::FONT_SIZE LyXFont::size() const
398 LyXFont::FONT_MISC_STATE LyXFont::emph() const
405 LyXFont::FONT_MISC_STATE LyXFont::noun() const
412 bool LyXFont::isSymbolFont() const
415 case LyXFont::SYMBOL_FAMILY:
416 case LyXFont::CMSY_FAMILY:
417 case LyXFont::CMM_FAMILY:
418 case LyXFont::CMEX_FAMILY:
419 case LyXFont::MSA_FAMILY:
420 case LyXFont::MSB_FAMILY:
421 case LyXFont::WASY_FAMILY:
429 std::ostream & operator<<(std::ostream &, LyXFont::FONT_MISC_STATE);
431 bool operator==(LyXFont::FontBits const & lhs, LyXFont::FontBits const & rhs);
434 bool operator!=(LyXFont::FontBits const & lhs, LyXFont::FontBits const & rhs)
436 return !(lhs == rhs);
441 bool operator==(LyXFont const & font1, LyXFont const & font2)
443 return font1.bits == font2.bits &&
444 font1.lang == font2.lang;
449 bool operator!=(LyXFont const & font1, LyXFont const & font2)
451 return !(font1 == font2);