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-25 12:41:02 +00:00
|
|
|
#include "ColorCode.h"
|
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;
|
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
|
|
|
///
|
2007-10-28 23:32:18 +00:00
|
|
|
explicit Font(FontInfo = sane_font, Language const * l = 0);
|
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.
|
|
|
|
*/
|
2007-05-06 20:26:02 +00:00
|
|
|
int latexWriteStartChanges(odocstream &, BufferParams const & bparams,
|
2007-05-28 22:27:45 +00:00
|
|
|
OutputParams const & runparams,
|
|
|
|
Font const & base,
|
|
|
|
Font const & prev) 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.
|
|
|
|
*/
|
2007-05-06 20:26:02 +00:00
|
|
|
int latexWriteEndChanges(odocstream &, 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,
|
|
|
|
bool const & 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
|
2006-12-21 14:31:19 +00:00
|
|
|
docstring const stateText(BufferParams * params) 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
|
|
|
|
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
|
|
|
|
2007-09-29 11:00:18 +00:00
|
|
|
/** Returns the current freefont, encoded as a std::string to be passed to the
|
2007-10-28 18:51:54 +00:00
|
|
|
* frontends. Implemented in Text3.cpp.
|
2007-09-29 11:00:18 +00:00
|
|
|
*/
|
|
|
|
std::string const freefont2string();
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#endif
|