1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
2003-08-23 00:17:00 +00:00
|
|
|
/**
|
2007-04-29 18:17:15 +00:00
|
|
|
* \file src/Font.h
|
2003-08-23 00:17:00 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2003-08-23 00:17:00 +00:00
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
* \author Angus Leeming
|
|
|
|
* \author Dekel Tsur
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
1999-10-02 16:21:10 +00:00
|
|
|
|
2007-04-29 18:17:15 +00:00
|
|
|
#ifndef FONT_H
|
|
|
|
#define FONT_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2007-10-28 18:51:54 +00:00
|
|
|
#include "FontInfo.h"
|
2007-10-25 12:41:02 +00:00
|
|
|
|
2007-11-01 22:17:22 +00:00
|
|
|
#include "support/strfwd.h"
|
2004-11-16 23:18:46 +00:00
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2000-05-22 16:56:05 +00:00
|
|
|
class BufferParams;
|
2001-11-26 18:03:23 +00:00
|
|
|
class Language;
|
2007-10-19 16:22:36 +00:00
|
|
|
class LaTeXFeatures;
|
2007-05-06 20:26:02 +00:00
|
|
|
class OutputParams;
|
Introduce a wrapper class for odocstream to help ensuring that no
blank lines may be inadvertently output. This is achieved by using two
special iomanip-like variables (breakln and safebreakln) in the lyx::
namespace. When they are inserted in the stream, a newline is output
only if not already at the beginning of a line. The difference between
breakln and safebreakln is that, if needed, the former outputs '\n'
and the latter "%\n".
In future, the new class will also be used for counting the number of
newlines issued. Even if the infractrure for doing that is already in
place, the counting is essentially still done the old way.
There are still places in the code where the functionality of the
class could be used, most probably. ATM, it is used for InsetTabular,
InsetListings, InsetFloat, and InsetText.
The Comment and GreyedOut insets required a special treatment and a
new InsetLayout parameter (Display) has been introduced. The default
for Display is "true", meaning that the corresponding latex
environment is of "display" type, i.e., it stands on its own, whereas
"false" means that the contents appear inline with the text. The
latter is the case for both Comment and GreyedOut insets.
Mostly, the only visible effects on latex exports should be the
disappearing of some redundant % chars and the appearing/disappearing
of null {} latex groups after a comment or lyxgreyedout environments
(they are related to the presence or absence of a space immediately
after those environments), as well as the fact that math environments
are now started on their own lines.
As a last thing, only the latex code between \begin{document} and
\end{document} goes through the new class, the preamble being directly
output through odocstream, as usual.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37360 a592a061-630c-0410-9148-cb99ea01b6c8
2011-01-29 02:41:13 +00:00
|
|
|
class otexstream;
|
2001-04-17 15:15:59 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2007-04-29 18:17:15 +00:00
|
|
|
class Font {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2007-10-28 18:51:54 +00:00
|
|
|
public:
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2020-03-16 06:09:39 +00:00
|
|
|
explicit Font(FontInfo = sane_font, Language const * l = nullptr);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
///
|
2007-10-28 18:51:54 +00:00
|
|
|
FontInfo & fontInfo() { return bits_; }
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2007-10-28 18:51:54 +00:00
|
|
|
FontInfo const & fontInfo() const { return bits_; }
|
2000-10-09 12:30:52 +00:00
|
|
|
///
|
2007-10-28 18:51:54 +00:00
|
|
|
Language const * language() const { return lang_; }
|
2000-02-04 09:38:32 +00:00
|
|
|
///
|
2000-03-17 10:14:46 +00:00
|
|
|
bool isRightToLeft() const;
|
|
|
|
///
|
|
|
|
bool isVisibleRightToLeft() const;
|
2001-08-30 22:42:26 +00:00
|
|
|
///
|
2003-09-16 09:01:15 +00:00
|
|
|
void setLanguage(Language const * l);
|
2000-02-03 19:51:27 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Returns size of font in LaTeX text notation
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const latexSize() const;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
/** Updates font settings according to request.
|
|
|
|
If an attribute is IGNORE, the attribute is left as it is.
|
|
|
|
When toggleall = true, all properties that matches the font in use
|
|
|
|
will have the effect that the properties is reset to the
|
|
|
|
default. If we have a text that is TYPEWRITER_FAMILY, and is
|
|
|
|
update()'ed with TYPEWRITER_FAMILY, the operation will be as if
|
|
|
|
a INHERIT_FAMILY was asked for. This is necessary for the
|
|
|
|
toggle-user-defined-style button on the toolbar.
|
|
|
|
*/
|
2007-04-29 18:17:15 +00:00
|
|
|
void update(Font const & newfont,
|
2001-08-11 18:31:14 +00:00
|
|
|
Language const * default_lang,
|
|
|
|
bool toggleall = false);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Writes the changes from this font to orgfont in .lyx format in file
|
2007-04-29 18:17:15 +00:00
|
|
|
void lyxWriteChanges(Font const & orgfont, std::ostream &) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-03-06 02:42:40 +00:00
|
|
|
/** Writes the head of the LaTeX needed to change to this font.
|
|
|
|
Writes to string, the head of the LaTeX needed to change
|
|
|
|
to this font. Returns number of chars written. Base is the
|
|
|
|
font state active now.
|
|
|
|
*/
|
2020-07-29 14:25:19 +00:00
|
|
|
int latexWriteStartChanges(otexstream &, BufferParams const & bparams,
|
2007-05-28 22:27:45 +00:00
|
|
|
OutputParams const & runparams,
|
|
|
|
Font const & base,
|
2020-07-29 14:25:19 +00:00
|
|
|
Font const & prev,
|
2020-10-16 07:19:34 +00:00
|
|
|
bool non_inherit_inset = false,
|
|
|
|
bool needs_cprotection = false) const;
|
2000-03-17 10:14:46 +00:00
|
|
|
|
2003-10-21 16:15:14 +00:00
|
|
|
/** Writes the tail of the LaTeX needed to change to this font.
|
2000-03-06 02:42:40 +00:00
|
|
|
Returns number of chars written. Base is the font state we want
|
|
|
|
to achieve.
|
|
|
|
*/
|
Introduce a wrapper class for odocstream to help ensuring that no
blank lines may be inadvertently output. This is achieved by using two
special iomanip-like variables (breakln and safebreakln) in the lyx::
namespace. When they are inserted in the stream, a newline is output
only if not already at the beginning of a line. The difference between
breakln and safebreakln is that, if needed, the former outputs '\n'
and the latter "%\n".
In future, the new class will also be used for counting the number of
newlines issued. Even if the infractrure for doing that is already in
place, the counting is essentially still done the old way.
There are still places in the code where the functionality of the
class could be used, most probably. ATM, it is used for InsetTabular,
InsetListings, InsetFloat, and InsetText.
The Comment and GreyedOut insets required a special treatment and a
new InsetLayout parameter (Display) has been introduced. The default
for Display is "true", meaning that the corresponding latex
environment is of "display" type, i.e., it stands on its own, whereas
"false" means that the contents appear inline with the text. The
latter is the case for both Comment and GreyedOut insets.
Mostly, the only visible effects on latex exports should be the
disappearing of some redundant % chars and the appearing/disappearing
of null {} latex groups after a comment or lyxgreyedout environments
(they are related to the presence or absence of a space immediately
after those environments), as well as the fact that math environments
are now started on their own lines.
As a last thing, only the latex code between \begin{document} and
\end{document} goes through the new class, the preamble being directly
output through odocstream, as usual.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37360 a592a061-630c-0410-9148-cb99ea01b6c8
2011-01-29 02:41:13 +00:00
|
|
|
int latexWriteEndChanges(otexstream &, BufferParams const & bparams,
|
2007-05-28 22:27:45 +00:00
|
|
|
OutputParams const & runparams,
|
|
|
|
Font const & base,
|
2007-07-20 01:28:20 +00:00
|
|
|
Font const & next,
|
2017-06-03 15:26:05 +00:00
|
|
|
bool & needPar,
|
2020-10-16 07:19:34 +00:00
|
|
|
bool closeLanguage = true) const;
|
2007-01-09 19:25:40 +00:00
|
|
|
|
2000-03-09 23:58:55 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Build GUI description of font state
|
2020-03-16 06:09:39 +00:00
|
|
|
docstring const stateText(BufferParams * params = nullptr, bool const terse = false) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2007-10-19 16:22:36 +00:00
|
|
|
///
|
|
|
|
void validate(LaTeXFeatures & features) const;
|
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
friend
|
2007-04-29 18:17:15 +00:00
|
|
|
bool operator==(Font const & font1, Font const & font2);
|
2003-10-21 16:15:14 +00:00
|
|
|
///
|
|
|
|
friend
|
2007-04-29 18:17:15 +00:00
|
|
|
std::ostream & operator<<(std::ostream & os, Font const & font);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2007-09-29 11:00:18 +00:00
|
|
|
/// Set \param data using \param font and \param toggle.
|
|
|
|
std::string toString(bool toggle) const;
|
|
|
|
|
|
|
|
/// Set \param font and \param toggle using \param data. Return success.
|
|
|
|
bool fromString(std::string const & data, bool & toggle);
|
2002-06-10 07:57:39 +00:00
|
|
|
|
|
|
|
private:
|
2000-04-04 00:19:15 +00:00
|
|
|
///
|
2007-10-28 18:51:54 +00:00
|
|
|
FontInfo bits_;
|
2000-04-04 00:19:15 +00:00
|
|
|
///
|
2007-10-28 18:51:54 +00:00
|
|
|
Language const * lang_;
|
2007-05-06 20:26:02 +00:00
|
|
|
/// Did latexWriteStartChanges open an encoding environment?
|
|
|
|
mutable bool open_encoding_;
|
2000-04-04 00:19:15 +00:00
|
|
|
};
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2020-11-26 10:04:33 +00:00
|
|
|
///
|
|
|
|
std::ostream & operator<<(std::ostream & os, FontInfo const & f);
|
|
|
|
|
2001-04-04 20:20:42 +00:00
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
|
|
|
inline
|
2007-04-29 18:17:15 +00:00
|
|
|
bool operator==(Font const & font1, Font const & font2)
|
2001-03-06 14:07:14 +00:00
|
|
|
{
|
2010-09-14 05:24:04 +00:00
|
|
|
return font1.bits_ == font2.bits_ && font1.lang_ == font2.lang_;
|
2000-08-07 20:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///
|
|
|
|
inline
|
2007-04-29 18:17:15 +00:00
|
|
|
bool operator!=(Font const & font1, Font const & font2)
|
2000-02-10 17:53:36 +00:00
|
|
|
{
|
2001-03-06 14:07:14 +00:00
|
|
|
return !(font1 == font2);
|
2000-10-09 12:30:52 +00:00
|
|
|
}
|
2002-06-10 07:57:39 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#endif
|