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.
18 #include "ColorCode.h"
21 #include "support/strfwd.h"
37 explicit Font(FontInfo = sane_font, Language const * l = 0);
40 FontInfo & fontInfo() { return bits_; }
42 FontInfo const & fontInfo() const { return bits_; }
44 Language const * language() const { return lang_; }
46 bool isRightToLeft() const;
48 bool isVisibleRightToLeft() const;
50 void setLanguage(Language const * l);
52 /// Returns size of font in LaTeX text notation
53 std::string const latexSize() const;
55 /** Updates font settings according to request.
56 If an attribute is IGNORE, the attribute is left as it is.
57 When toggleall = true, all properties that matches the font in use
58 will have the effect that the properties is reset to the
59 default. If we have a text that is TYPEWRITER_FAMILY, and is
60 update()'ed with TYPEWRITER_FAMILY, the operation will be as if
61 a INHERIT_FAMILY was asked for. This is necessary for the
62 toggle-user-defined-style button on the toolbar.
64 void update(Font const & newfont,
65 Language const * default_lang,
66 bool toggleall = false);
68 /// Writes the changes from this font to orgfont in .lyx format in file
69 void lyxWriteChanges(Font const & orgfont, std::ostream &) const;
71 /** Writes the head of the LaTeX needed to change to this font.
72 Writes to string, the head of the LaTeX needed to change
73 to this font. Returns number of chars written. Base is the
74 font state active now.
76 int latexWriteStartChanges(odocstream &, BufferParams const & bparams,
77 OutputParams const & runparams,
79 Font const & prev) const;
81 /** Writes the tail of the LaTeX needed to change to this font.
82 Returns number of chars written. Base is the font state we want
85 int latexWriteEndChanges(otexstream &, BufferParams const & bparams,
86 OutputParams const & runparams,
89 bool const & closeLanguage = true) const;
92 /// Build GUI description of font state
93 docstring const stateText(BufferParams * params) const;
96 void validate(LaTeXFeatures & features) const;
100 bool operator==(Font const & font1, Font const & font2);
103 std::ostream & operator<<(std::ostream & os, Font const & font);
105 /// Set \param data using \param font and \param toggle.
106 std::string toString(bool toggle) const;
108 /// Set \param font and \param toggle using \param data. Return success.
109 bool fromString(std::string const & data, bool & toggle);
115 Language const * lang_;
116 /// Did latexWriteStartChanges open an encoding environment?
117 mutable bool open_encoding_;
123 bool operator==(Font const & font1, Font const & font2)
125 return font1.bits_ == font2.bits_ && font1.lang_ == font2.lang_;
130 bool operator!=(Font const & font1, Font const & font2)
132 return !(font1 == font2);
135 /** Returns the current freefont, encoded as a std::string to be passed to the
136 * frontends. Implemented in Text3.cpp.
138 std::string const freefont2string();