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.
20 #include "support/strfwd.h"
36 explicit Font(FontInfo = sane_font, Language const * l = nullptr);
39 FontInfo & fontInfo() { return bits_; }
41 FontInfo const & fontInfo() const { return bits_; }
43 Language const * language() const { return lang_; }
45 bool isRightToLeft() const;
47 bool isVisibleRightToLeft() const;
49 void setLanguage(Language const * l);
51 /// Returns size of font in LaTeX text notation
52 std::string const latexSize() const;
54 /** Updates font settings according to request.
55 If an attribute is IGNORE, the attribute is left as it is.
56 When toggleall = true, all properties that matches the font in use
57 will have the effect that the properties is reset to the
58 default. If we have a text that is TYPEWRITER_FAMILY, and is
59 update()'ed with TYPEWRITER_FAMILY, the operation will be as if
60 a INHERIT_FAMILY was asked for. This is necessary for the
61 toggle-user-defined-style button on the toolbar.
63 void update(Font const & newfont,
64 Language const * default_lang,
65 bool toggleall = false);
67 /// Writes the changes from this font to orgfont in .lyx format in file
68 void lyxWriteChanges(Font const & orgfont, std::ostream &) const;
70 /** Writes the head of the LaTeX needed to change to this font.
71 Writes to string, the head of the LaTeX needed to change
72 to this font. Returns number of chars written. Base is the
73 font state active now.
75 int latexWriteStartChanges(otexstream &, BufferParams const & bparams,
76 OutputParams const & runparams,
79 bool non_inherit_inset = false,
80 bool needs_cprotection = false) const;
82 /** Writes the tail of the LaTeX needed to change to this font.
83 Returns number of chars written. Base is the font state we want
86 int latexWriteEndChanges(otexstream &, BufferParams const & bparams,
87 OutputParams const & runparams,
91 bool closeLanguage = true) const;
94 /// Build GUI description of font state
95 docstring const stateText(BufferParams * params = nullptr, bool const terse = false) const;
98 void validate(LaTeXFeatures & features) const;
102 bool operator==(Font const & font1, Font const & font2);
105 std::ostream & operator<<(std::ostream & os, Font const & font);
107 /// Set \param data using \param font and \param toggle.
108 std::string toString(bool toggle) const;
110 /// Set \param font and \param toggle using \param data. Return success.
111 bool fromString(std::string const & data, bool & toggle);
117 Language const * lang_;
118 /// Did latexWriteStartChanges open an encoding environment?
119 mutable bool open_encoding_;
123 std::ostream & operator<<(std::ostream & os, FontInfo const & f);
128 bool operator==(Font const & font1, Font const & font2)
130 return font1.bits_ == font2.bits_ && font1.lang_ == font2.lang_;
135 bool operator!=(Font const & font1, Font const & font2)
137 return !(font1 == font2);