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.
19 #include "tex2lyx/Font.h"
22 #include "ColorCode.h"
25 #include "support/strfwd.h"
41 explicit Font(FontInfo = sane_font, Language const * l = 0);
44 FontInfo & fontInfo() { return bits_; }
46 FontInfo const & fontInfo() const { return bits_; }
48 Language const * language() const { return lang_; }
50 bool isRightToLeft() const;
52 bool isVisibleRightToLeft() const;
54 void setLanguage(Language const * l);
56 /// Returns misc flag after LyX text format
57 FontState setLyXMisc(std::string const &);
60 /// Returns size of font in LaTeX text notation
61 std::string const latexSize() const;
63 /** Updates font settings according to request.
64 If an attribute is IGNORE, the attribute is left as it is.
65 When toggleall = true, all properties that matches the font in use
66 will have the effect that the properties is reset to the
67 default. If we have a text that is TYPEWRITER_FAMILY, and is
68 update()'ed with TYPEWRITER_FAMILY, the operation will be as if
69 a INHERIT_FAMILY was asked for. This is necessary for the
70 toggle-user-defined-style button on the toolbar.
72 void update(Font const & newfont,
73 Language const * default_lang,
74 bool toggleall = false);
76 /// Writes the changes from this font to orgfont in .lyx format in file
77 void lyxWriteChanges(Font const & orgfont, std::ostream &) const;
79 /** Writes the head of the LaTeX needed to change to this font.
80 Writes to string, the head of the LaTeX needed to change
81 to this font. Returns number of chars written. Base is the
82 font state active now.
84 int latexWriteStartChanges(odocstream &, BufferParams const & bparams,
85 OutputParams const & runparams,
87 Font const & prev) const;
89 /** Writes the tail of the LaTeX needed to change to this font.
90 Returns number of chars written. Base is the font state we want
93 int latexWriteEndChanges(odocstream &, BufferParams const & bparams,
94 OutputParams const & runparams,
97 bool const & closeLanguage = true) const;
100 /// Build GUI description of font state
101 docstring const stateText(BufferParams * params) const;
104 void validate(LaTeXFeatures & features) const;
108 bool operator==(Font const & font1, Font const & font2);
111 std::ostream & operator<<(std::ostream & os, Font const & font);
113 /// Set \param data using \param font and \param toggle.
114 std::string toString(bool toggle) const;
116 /// Set \param font and \param toggle using \param data. Return success.
117 bool fromString(std::string const & data, bool & toggle);
123 Language const * lang_;
125 /// Did latexWriteStartChanges open an encoding environment?
126 mutable bool open_encoding_;
132 bool operator==(Font const & font1, Font const & font2)
134 return font1.bits_ == font2.bits_ && font1.lang_ == font2.lang_;
139 bool operator!=(Font const & font1, Font const & font2)
141 return !(font1 == font2);
144 /** Returns the current freefont, encoded as a std::string to be passed to the
145 * frontends. Implemented in Text3.cpp.
147 std::string const freefont2string();
150 /// Set family after LyX text format
151 void setLyXFamily(std::string const &, FontInfo &);
153 /// Set series after LyX text format
154 void setLyXSeries(std::string const &, FontInfo &);
156 /// Set shape after LyX text format
157 void setLyXShape(std::string const &, FontInfo &);
159 /// Set size after LyX text format
160 void setLyXSize(std::string const &, FontInfo &);
162 /// Sets color after LyX text format
163 void setLyXColor(std::string const &, FontInfo &);
165 /// Read a font specification from Lexer. Used for layout files.
166 FontInfo lyxRead(Lexer &, FontInfo const & fi = sane_font);