mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-27 22:41:09 +00:00
1ef605f625
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
143 lines
3.6 KiB
C++
143 lines
3.6 KiB
C++
// -*- C++ -*-
|
|
/**
|
|
* \file src/Font.h
|
|
* This file is part of LyX, the document processor.
|
|
* Licence details can be found in the file COPYING.
|
|
*
|
|
* \author Lars Gullik Bjønnes
|
|
* \author Jean-Marc Lasgouttes
|
|
* \author Angus Leeming
|
|
* \author Dekel Tsur
|
|
*
|
|
* Full author contact details are available in file CREDITS.
|
|
*/
|
|
|
|
#ifndef FONT_H
|
|
#define FONT_H
|
|
|
|
#include "ColorCode.h"
|
|
#include "FontInfo.h"
|
|
|
|
#include "support/strfwd.h"
|
|
|
|
|
|
namespace lyx {
|
|
|
|
class BufferParams;
|
|
class Language;
|
|
class LaTeXFeatures;
|
|
class OutputParams;
|
|
class otexstream;
|
|
|
|
///
|
|
class Font {
|
|
|
|
public:
|
|
///
|
|
explicit Font(FontInfo = sane_font, Language const * l = 0);
|
|
|
|
///
|
|
FontInfo & fontInfo() { return bits_; }
|
|
///
|
|
FontInfo const & fontInfo() const { return bits_; }
|
|
///
|
|
Language const * language() const { return lang_; }
|
|
///
|
|
bool isRightToLeft() const;
|
|
///
|
|
bool isVisibleRightToLeft() const;
|
|
///
|
|
void setLanguage(Language const * l);
|
|
|
|
/// Returns size of font in LaTeX text notation
|
|
std::string const latexSize() const;
|
|
|
|
/** 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.
|
|
*/
|
|
void update(Font const & newfont,
|
|
Language const * default_lang,
|
|
bool toggleall = false);
|
|
|
|
/// Writes the changes from this font to orgfont in .lyx format in file
|
|
void lyxWriteChanges(Font const & orgfont, std::ostream &) const;
|
|
|
|
/** 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.
|
|
*/
|
|
int latexWriteStartChanges(odocstream &, BufferParams const & bparams,
|
|
OutputParams const & runparams,
|
|
Font const & base,
|
|
Font const & prev) const;
|
|
|
|
/** Writes the tail of the LaTeX needed to change to this font.
|
|
Returns number of chars written. Base is the font state we want
|
|
to achieve.
|
|
*/
|
|
int latexWriteEndChanges(otexstream &, BufferParams const & bparams,
|
|
OutputParams const & runparams,
|
|
Font const & base,
|
|
Font const & next,
|
|
bool const & closeLanguage = true) const;
|
|
|
|
|
|
/// Build GUI description of font state
|
|
docstring const stateText(BufferParams * params) const;
|
|
|
|
///
|
|
void validate(LaTeXFeatures & features) const;
|
|
|
|
///
|
|
friend
|
|
bool operator==(Font const & font1, Font const & font2);
|
|
///
|
|
friend
|
|
std::ostream & operator<<(std::ostream & os, Font const & font);
|
|
|
|
/// 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);
|
|
|
|
private:
|
|
///
|
|
FontInfo bits_;
|
|
///
|
|
Language const * lang_;
|
|
/// Did latexWriteStartChanges open an encoding environment?
|
|
mutable bool open_encoding_;
|
|
};
|
|
|
|
|
|
///
|
|
inline
|
|
bool operator==(Font const & font1, Font const & font2)
|
|
{
|
|
return font1.bits_ == font2.bits_ && font1.lang_ == font2.lang_;
|
|
}
|
|
|
|
///
|
|
inline
|
|
bool operator!=(Font const & font1, Font const & font2)
|
|
{
|
|
return !(font1 == font2);
|
|
}
|
|
|
|
/** Returns the current freefont, encoded as a std::string to be passed to the
|
|
* frontends. Implemented in Text3.cpp.
|
|
*/
|
|
std::string const freefont2string();
|
|
|
|
} // namespace lyx
|
|
|
|
#endif
|