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 void setMisspelled(bool misspelled
) { misspelled_
= misspelled
; }
52 bool isMisspelled() const { return misspelled_
; }
54 bool isRightToLeft() const;
56 bool isVisibleRightToLeft() const;
58 void setLanguage(Language
const * l
);
60 /// Returns misc flag after LyX text format
61 FontState
setLyXMisc(std::string
const &);
64 /// Returns size of font in LaTeX text notation
65 std::string
const latexSize() const;
67 /** Updates font settings according to request.
68 If an attribute is IGNORE, the attribute is left as it is.
69 When toggleall = true, all properties that matches the font in use
70 will have the effect that the properties is reset to the
71 default. If we have a text that is TYPEWRITER_FAMILY, and is
72 update()'ed with TYPEWRITER_FAMILY, the operation will be as if
73 a INHERIT_FAMILY was asked for. This is necessary for the
74 toggle-user-defined-style button on the toolbar.
76 void update(Font
const & newfont
,
77 Language
const * default_lang
,
78 bool toggleall
= false);
80 /// Writes the changes from this font to orgfont in .lyx format in file
81 void lyxWriteChanges(Font
const & orgfont
, std::ostream
&) const;
83 /** Writes the head of the LaTeX needed to change to this font.
84 Writes to string, the head of the LaTeX needed to change
85 to this font. Returns number of chars written. Base is the
86 font state active now.
88 int latexWriteStartChanges(odocstream
&, BufferParams
const & bparams
,
89 OutputParams
const & runparams
,
91 Font
const & prev
) const;
93 /** Writes the tail of the LaTeX needed to change to this font.
94 Returns number of chars written. Base is the font state we want
97 int latexWriteEndChanges(odocstream
&, BufferParams
const & bparams
,
98 OutputParams
const & runparams
,
101 bool const & closeLanguage
= true) const;
104 /// Build GUI description of font state
105 docstring
const stateText(BufferParams
* params
) const;
108 void validate(LaTeXFeatures
& features
) const;
112 bool operator==(Font
const & font1
, Font
const & font2
);
115 std::ostream
& operator<<(std::ostream
& os
, Font
const & font
);
117 /// Set \param data using \param font and \param toggle.
118 std::string
toString(bool toggle
) const;
120 /// Set \param font and \param toggle using \param data. Return success.
121 bool fromString(std::string
const & data
, bool & toggle
);
127 Language
const * lang_
;
131 /// Did latexWriteStartChanges open an encoding environment?
132 mutable bool open_encoding_
;
138 bool operator==(Font
const & font1
, Font
const & font2
)
140 return font1
.bits_
== font2
.bits_
&& font1
.lang_
== font2
.lang_
141 && font1
.misspelled_
== font2
.misspelled_
;
146 bool operator!=(Font
const & font1
, Font
const & font2
)
148 return !(font1
== font2
);
151 /** Returns the current freefont, encoded as a std::string to be passed to the
152 * frontends. Implemented in Text3.cpp.
154 std::string
const freefont2string();
157 /// Set family after LyX text format
158 void setLyXFamily(std::string
const &, FontInfo
&);
160 /// Set series after LyX text format
161 void setLyXSeries(std::string
const &, FontInfo
&);
163 /// Set shape after LyX text format
164 void setLyXShape(std::string
const &, FontInfo
&);
166 /// Set size after LyX text format
167 void setLyXSize(std::string
const &, FontInfo
&);
169 /// Sets color after LyX text format
170 void setLyXColor(std::string
const &, FontInfo
&);
172 /// Read a font specification from Lexer. Used for layout files.
173 FontInfo
lyxRead(Lexer
&, FontInfo
const & fi
= sane_font
);