mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Splitup Font in saner bits:
* Font::FontBits -> FontInfo * Font::FONT_XXX -> all enums transfered to FontEnums.h and renamed to FontXxx I've replaced Font uses with FontInfo were the language() member was not needed, basically all draw() and metrics methods. There's one problematic cases with InsetQuotes which I solved by taking the Buffer main language. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21240 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
053e705779
commit
5ddc612b73
@ -62,6 +62,8 @@ src_header_files = Split('''
|
||||
FloatList.h
|
||||
Floating.h
|
||||
Font.h
|
||||
FontEnums.h
|
||||
FontInfo.h
|
||||
FontIterator.h
|
||||
FontList.h
|
||||
Format.h
|
||||
@ -171,6 +173,8 @@ src_pre_files = Split('''
|
||||
FloatList.cpp
|
||||
Floating.cpp
|
||||
Font.cpp
|
||||
FontEnums.cpp
|
||||
FontInfo.cpp
|
||||
FontIterator.cpp
|
||||
FontList.cpp
|
||||
Format.cpp
|
||||
|
@ -110,9 +110,9 @@ void Bidi::computeTables(Paragraph const & par,
|
||||
? lpos + 1 : lpos;
|
||||
Font font = par.getFontSettings(bufparams, pos);
|
||||
if (pos != lpos && 0 < lpos && rtl0 && font.isRightToLeft() &&
|
||||
font.number() == Font::ON &&
|
||||
par.getFontSettings(bufparams, lpos - 1).number()
|
||||
== Font::ON) {
|
||||
font.fontInfo().number() == FONT_ON &&
|
||||
par.getFontSettings(bufparams, lpos - 1).fontInfo().number()
|
||||
== FONT_ON) {
|
||||
font = par.getFontSettings(bufparams, lpos);
|
||||
is_space = false;
|
||||
}
|
||||
|
@ -1392,15 +1392,14 @@ void BufferParams::clearLayoutModules() {
|
||||
|
||||
Font const BufferParams::getFont() const
|
||||
{
|
||||
Font f = getTextClass().defaultfont();
|
||||
f.setLanguage(language);
|
||||
FontInfo f = getTextClass().defaultfont();
|
||||
if (fontsDefaultFamily == "rmdefault")
|
||||
f.setFamily(Font::ROMAN_FAMILY);
|
||||
f.setFamily(ROMAN_FAMILY);
|
||||
else if (fontsDefaultFamily == "sfdefault")
|
||||
f.setFamily(Font::SANS_FAMILY);
|
||||
f.setFamily(SANS_FAMILY);
|
||||
else if (fontsDefaultFamily == "ttdefault")
|
||||
f.setFamily(Font::TYPEWRITER_FAMILY);
|
||||
return f;
|
||||
f.setFamily(TYPEWRITER_FAMILY);
|
||||
return Font(f, language);
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,9 +15,10 @@
|
||||
#ifndef BUFFERPARAMS_H
|
||||
#define BUFFERPARAMS_H
|
||||
|
||||
#include "Font.h"
|
||||
#include "BiblioInfo.h"
|
||||
#include "TextClass.h"
|
||||
#include "paper.h"
|
||||
#include "TextClass.h"
|
||||
|
||||
#include "insets/InsetQuotes.h"
|
||||
|
||||
|
@ -468,7 +468,7 @@ bool BufferView::fitCursor()
|
||||
{
|
||||
if (cursorStatus(d->cursor_) == CUR_INSIDE) {
|
||||
frontend::FontMetrics const & fm =
|
||||
theFontMetrics(d->cursor_.getFont());
|
||||
theFontMetrics(d->cursor_.getFont().fontInfo());
|
||||
int const asc = fm.maxAscent();
|
||||
int const des = fm.maxDescent();
|
||||
Point const p = getPos(d->cursor_, d->cursor_.boundary());
|
||||
|
@ -266,7 +266,8 @@ namespace {
|
||||
// bv functions are not yet available!
|
||||
Cursor::Cursor(BufferView & bv)
|
||||
: DocIterator(), bv_(&bv), anchor_(), x_target_(-1), textTargetOffset_(0),
|
||||
selection_(false), mark_(false), logicalpos_(false), current_font(Font::ALL_INHERIT)
|
||||
selection_(false), mark_(false), logicalpos_(false),
|
||||
current_font(inherit_font)
|
||||
{}
|
||||
|
||||
|
||||
@ -1544,9 +1545,9 @@ void Cursor::setCurrentFont()
|
||||
&& !boundary()) {
|
||||
Language const * lang = par.getParLanguage(bufparams);
|
||||
current_font.setLanguage(lang);
|
||||
current_font.setNumber(Font::OFF);
|
||||
current_font.fontInfo().setNumber(FONT_OFF);
|
||||
real_current_font.setLanguage(lang);
|
||||
real_current_font.setNumber(Font::OFF);
|
||||
real_current_font.fontInfo().setNumber(FONT_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
664
src/Font.cpp
664
src/Font.cpp
@ -56,7 +56,7 @@ using support::subst;
|
||||
|
||||
namespace {
|
||||
|
||||
char const * GUIFamilyNames[Font::NUM_FAMILIES + 2 /* default & error */] =
|
||||
char const * GUIFamilyNames[NUM_FAMILIES + 2 /* default & error */] =
|
||||
{ N_("Roman"), N_("Sans Serif"), N_("Typewriter"), N_("Symbol"),
|
||||
"cmr", "cmsy", "cmm", "cmex", "msa", "msb", "eufrak", "wasy", "esint",
|
||||
N_("Inherit"), N_("Ignore") };
|
||||
@ -80,7 +80,7 @@ char const * GUIMiscNames[5] =
|
||||
//
|
||||
// Strings used to read and write .lyx format files
|
||||
//
|
||||
char const * LyXFamilyNames[Font::NUM_FAMILIES + 2 /* default & error */] =
|
||||
char const * LyXFamilyNames[NUM_FAMILIES + 2 /* default & error */] =
|
||||
{ "roman", "sans", "typewriter", "symbol",
|
||||
"cmr", "cmsy", "cmm", "cmex", "msa", "msb", "eufrak", "wasy", "esint",
|
||||
"default", "error" };
|
||||
@ -118,253 +118,30 @@ char const * LaTeXSizeNames[14] =
|
||||
} // namespace anon
|
||||
|
||||
|
||||
// Initialize static member
|
||||
Font::FontBits Font::sane = {
|
||||
ROMAN_FAMILY,
|
||||
MEDIUM_SERIES,
|
||||
UP_SHAPE,
|
||||
SIZE_NORMAL,
|
||||
Color_none,
|
||||
OFF,
|
||||
OFF,
|
||||
OFF,
|
||||
OFF };
|
||||
|
||||
// Initialize static member
|
||||
Font::FontBits Font::inherit = {
|
||||
INHERIT_FAMILY,
|
||||
INHERIT_SERIES,
|
||||
INHERIT_SHAPE,
|
||||
INHERIT_SIZE,
|
||||
Color_inherit,
|
||||
INHERIT,
|
||||
INHERIT,
|
||||
INHERIT,
|
||||
OFF };
|
||||
|
||||
// Initialize static member
|
||||
Font::FontBits Font::ignore = {
|
||||
IGNORE_FAMILY,
|
||||
IGNORE_SERIES,
|
||||
IGNORE_SHAPE,
|
||||
IGNORE_SIZE,
|
||||
Color_ignore,
|
||||
IGNORE,
|
||||
IGNORE,
|
||||
IGNORE,
|
||||
IGNORE };
|
||||
|
||||
|
||||
bool operator==(Font::FontBits const & lhs,
|
||||
Font::FontBits const & rhs)
|
||||
Font::Font(FontInfo bits, Language const * l)
|
||||
: bits_(bits), lang_(l), open_encoding_(false)
|
||||
{
|
||||
return lhs.family == rhs.family &&
|
||||
lhs.series == rhs.series &&
|
||||
lhs.shape == rhs.shape &&
|
||||
lhs.size == rhs.size &&
|
||||
lhs.color == rhs.color &&
|
||||
lhs.emph == rhs.emph &&
|
||||
lhs.underbar == rhs.underbar &&
|
||||
lhs.noun == rhs.noun &&
|
||||
lhs.number == rhs.number;
|
||||
}
|
||||
|
||||
|
||||
Font::Font()
|
||||
: bits(sane), lang(default_language), open_encoding_(false)
|
||||
{}
|
||||
|
||||
|
||||
Font::Font(Font::FONT_INIT1)
|
||||
: bits(inherit), lang(default_language), open_encoding_(false)
|
||||
{}
|
||||
|
||||
|
||||
Font::Font(Font::FONT_INIT2)
|
||||
: bits(ignore), lang(ignore_language), open_encoding_(false)
|
||||
{}
|
||||
|
||||
|
||||
Font::Font(Font::FONT_INIT3)
|
||||
: bits(sane), lang(default_language), open_encoding_(false)
|
||||
{}
|
||||
|
||||
|
||||
Font::Font(Font::FONT_INIT1, Language const * l)
|
||||
: bits(inherit), lang(l), open_encoding_(false)
|
||||
{}
|
||||
|
||||
|
||||
Font::Font(Font::FONT_INIT2, Language const * l)
|
||||
: bits(ignore), lang(l), open_encoding_(false)
|
||||
{}
|
||||
|
||||
|
||||
Font::Font(Font::FONT_INIT3, Language const * l)
|
||||
: bits(sane), lang(l), open_encoding_(false)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
ColorCode Font::color() const
|
||||
{
|
||||
return ColorCode(bits.color);
|
||||
if (!lang_)
|
||||
lang_ = default_language;
|
||||
}
|
||||
|
||||
|
||||
bool Font::isRightToLeft() const
|
||||
{
|
||||
return lang->rightToLeft();
|
||||
return lang_->rightToLeft();
|
||||
}
|
||||
|
||||
|
||||
bool Font::isVisibleRightToLeft() const
|
||||
{
|
||||
return (lang->rightToLeft() &&
|
||||
number() != ON);
|
||||
}
|
||||
|
||||
|
||||
void Font::setFamily(Font::FONT_FAMILY f)
|
||||
{
|
||||
bits.family = f;
|
||||
}
|
||||
|
||||
|
||||
void Font::setSeries(Font::FONT_SERIES s)
|
||||
{
|
||||
bits.series = s;
|
||||
}
|
||||
|
||||
|
||||
void Font::setShape(Font::FONT_SHAPE s)
|
||||
{
|
||||
bits.shape = s;
|
||||
}
|
||||
|
||||
|
||||
void Font::setSize(Font::FONT_SIZE s)
|
||||
{
|
||||
bits.size = s;
|
||||
}
|
||||
|
||||
|
||||
void Font::setEmph(Font::FONT_MISC_STATE e)
|
||||
{
|
||||
bits.emph = e;
|
||||
}
|
||||
|
||||
|
||||
void Font::setUnderbar(Font::FONT_MISC_STATE u)
|
||||
{
|
||||
bits.underbar = u;
|
||||
}
|
||||
|
||||
|
||||
void Font::setNoun(Font::FONT_MISC_STATE n)
|
||||
{
|
||||
bits.noun = n;
|
||||
}
|
||||
|
||||
|
||||
void Font::setColor(ColorCode c)
|
||||
{
|
||||
bits.color = c;
|
||||
return (lang_->rightToLeft() &&
|
||||
bits_.number() != FONT_ON);
|
||||
}
|
||||
|
||||
|
||||
void Font::setLanguage(Language const * l)
|
||||
{
|
||||
lang = l;
|
||||
}
|
||||
|
||||
|
||||
void Font::setNumber(Font::FONT_MISC_STATE n)
|
||||
{
|
||||
bits.number = n;
|
||||
}
|
||||
|
||||
|
||||
/// Decreases font size by one
|
||||
Font & Font::decSize()
|
||||
{
|
||||
switch (size()) {
|
||||
case SIZE_HUGER: setSize(SIZE_HUGE); break;
|
||||
case SIZE_HUGE: setSize(SIZE_LARGEST); break;
|
||||
case SIZE_LARGEST: setSize(SIZE_LARGER); break;
|
||||
case SIZE_LARGER: setSize(SIZE_LARGE); break;
|
||||
case SIZE_LARGE: setSize(SIZE_NORMAL); break;
|
||||
case SIZE_NORMAL: setSize(SIZE_SMALL); break;
|
||||
case SIZE_SMALL: setSize(SIZE_FOOTNOTE); break;
|
||||
case SIZE_FOOTNOTE: setSize(SIZE_SCRIPT); break;
|
||||
case SIZE_SCRIPT: setSize(SIZE_TINY); break;
|
||||
case SIZE_TINY: break;
|
||||
case INCREASE_SIZE:
|
||||
lyxerr << "Can't Font::decSize on INCREASE_SIZE" << endl;
|
||||
break;
|
||||
case DECREASE_SIZE:
|
||||
lyxerr <<"Can't Font::decSize on DECREASE_SIZE" << endl;
|
||||
break;
|
||||
case INHERIT_SIZE:
|
||||
lyxerr <<"Can't Font::decSize on INHERIT_SIZE" << endl;
|
||||
break;
|
||||
case IGNORE_SIZE:
|
||||
lyxerr <<"Can't Font::decSize on IGNORE_SIZE" << endl;
|
||||
break;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/// Increases font size by one
|
||||
Font & Font::incSize()
|
||||
{
|
||||
switch (size()) {
|
||||
case SIZE_HUGER: break;
|
||||
case SIZE_HUGE: setSize(SIZE_HUGER); break;
|
||||
case SIZE_LARGEST: setSize(SIZE_HUGE); break;
|
||||
case SIZE_LARGER: setSize(SIZE_LARGEST); break;
|
||||
case SIZE_LARGE: setSize(SIZE_LARGER); break;
|
||||
case SIZE_NORMAL: setSize(SIZE_LARGE); break;
|
||||
case SIZE_SMALL: setSize(SIZE_NORMAL); break;
|
||||
case SIZE_FOOTNOTE: setSize(SIZE_SMALL); break;
|
||||
case SIZE_SCRIPT: setSize(SIZE_FOOTNOTE); break;
|
||||
case SIZE_TINY: setSize(SIZE_SCRIPT); break;
|
||||
case INCREASE_SIZE:
|
||||
lyxerr <<"Can't Font::incSize on INCREASE_SIZE" << endl;
|
||||
break;
|
||||
case DECREASE_SIZE:
|
||||
lyxerr <<"Can't Font::incSize on DECREASE_SIZE" << endl;
|
||||
break;
|
||||
case INHERIT_SIZE:
|
||||
lyxerr <<"Can't Font::incSize on INHERIT_SIZE" << endl;
|
||||
break;
|
||||
case IGNORE_SIZE:
|
||||
lyxerr <<"Can't Font::incSize on IGNORE_SIZE" << endl;
|
||||
break;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/// Updates a misc setting according to request
|
||||
Font::FONT_MISC_STATE Font::setMisc(FONT_MISC_STATE newfont,
|
||||
FONT_MISC_STATE org)
|
||||
{
|
||||
if (newfont == TOGGLE) {
|
||||
if (org == ON)
|
||||
return OFF;
|
||||
else if (org == OFF)
|
||||
return ON;
|
||||
else {
|
||||
lyxerr <<"Font::setMisc: Need state"
|
||||
" ON or OFF to toggle. Setting to ON" << endl;
|
||||
return ON;
|
||||
}
|
||||
} else if (newfont == IGNORE)
|
||||
return org;
|
||||
else
|
||||
return newfont;
|
||||
lang_ = l;
|
||||
}
|
||||
|
||||
|
||||
@ -373,49 +150,8 @@ void Font::update(Font const & newfont,
|
||||
Language const * document_language,
|
||||
bool toggleall)
|
||||
{
|
||||
if (newfont.family() == family() && toggleall)
|
||||
setFamily(INHERIT_FAMILY); // toggle 'back'
|
||||
else if (newfont.family() != IGNORE_FAMILY)
|
||||
setFamily(newfont.family());
|
||||
// else it's IGNORE_SHAPE
|
||||
bits_.update(newfont.fontInfo(), toggleall);
|
||||
|
||||
// "Old" behaviour: "Setting" bold will toggle bold on/off.
|
||||
switch (newfont.series()) {
|
||||
case BOLD_SERIES:
|
||||
// We toggle...
|
||||
if (series() == BOLD_SERIES && toggleall)
|
||||
setSeries(MEDIUM_SERIES);
|
||||
else
|
||||
setSeries(BOLD_SERIES);
|
||||
break;
|
||||
case MEDIUM_SERIES:
|
||||
case INHERIT_SERIES:
|
||||
setSeries(newfont.series());
|
||||
break;
|
||||
case IGNORE_SERIES:
|
||||
break;
|
||||
}
|
||||
|
||||
if (newfont.shape() == shape() && toggleall)
|
||||
setShape(INHERIT_SHAPE); // toggle 'back'
|
||||
else if (newfont.shape() != IGNORE_SHAPE)
|
||||
setShape(newfont.shape());
|
||||
// else it's IGNORE_SHAPE
|
||||
|
||||
if (newfont.size() != IGNORE_SIZE) {
|
||||
if (newfont.size() == INCREASE_SIZE)
|
||||
incSize();
|
||||
else if (newfont.size() == DECREASE_SIZE)
|
||||
decSize();
|
||||
else
|
||||
setSize(newfont.size());
|
||||
}
|
||||
|
||||
setEmph(setMisc(newfont.emph(), emph()));
|
||||
setUnderbar(setMisc(newfont.underbar(), underbar()));
|
||||
setNoun(setMisc(newfont.noun(), noun()));
|
||||
|
||||
setNumber(setMisc(newfont.number(), number()));
|
||||
if (newfont.language() == language() && toggleall)
|
||||
if (language() == document_language)
|
||||
setLanguage(default_language);
|
||||
@ -423,119 +159,57 @@ void Font::update(Font const & newfont,
|
||||
setLanguage(document_language);
|
||||
else if (newfont.language() != ignore_language)
|
||||
setLanguage(newfont.language());
|
||||
|
||||
if (newfont.color() == color() && toggleall)
|
||||
setColor(Color_inherit); // toggle 'back'
|
||||
else if (newfont.color() != Color_ignore)
|
||||
setColor(newfont.color());
|
||||
}
|
||||
|
||||
|
||||
/// Reduce font to fall back to template where possible
|
||||
void Font::reduce(Font const & tmplt)
|
||||
docstring const stateText(FontInfo const & f)
|
||||
{
|
||||
if (family() == tmplt.family())
|
||||
setFamily(INHERIT_FAMILY);
|
||||
if (series() == tmplt.series())
|
||||
setSeries(INHERIT_SERIES);
|
||||
if (shape() == tmplt.shape())
|
||||
setShape(INHERIT_SHAPE);
|
||||
if (size() == tmplt.size())
|
||||
setSize(INHERIT_SIZE);
|
||||
if (emph() == tmplt.emph())
|
||||
setEmph(INHERIT);
|
||||
if (underbar() == tmplt.underbar())
|
||||
setUnderbar(INHERIT);
|
||||
if (noun() == tmplt.noun())
|
||||
setNoun(INHERIT);
|
||||
if (color() == tmplt.color())
|
||||
setColor(Color_inherit);
|
||||
}
|
||||
odocstringstream os;
|
||||
if (f.family() != INHERIT_FAMILY)
|
||||
os << _(GUIFamilyNames[f.family()]) << ", ";
|
||||
if (f.series() != INHERIT_SERIES)
|
||||
os << _(GUISeriesNames[f.series()]) << ", ";
|
||||
if (f.shape() != INHERIT_SHAPE)
|
||||
os << _(GUIShapeNames[f.shape()]) << ", ";
|
||||
if (f.size() != FONT_SIZE_INHERIT)
|
||||
os << _(GUISizeNames[f.size()]) << ", ";
|
||||
if (f.color() != Color_inherit)
|
||||
os << lcolor.getGUIName(f.color()) << ", ";
|
||||
// FIXME: uncomment this when we support background.
|
||||
//if (f.background() != Color_inherit)
|
||||
// os << lcolor.getGUIName(f.background()) << ", ";
|
||||
if (f.emph() != FONT_INHERIT)
|
||||
os << bformat(_("Emphasis %1$s, "),
|
||||
_(GUIMiscNames[f.emph()]));
|
||||
if (f.underbar() != FONT_INHERIT)
|
||||
os << bformat(_("Underline %1$s, "),
|
||||
_(GUIMiscNames[f.underbar()]));
|
||||
if (f.noun() != FONT_INHERIT)
|
||||
os << bformat(_("Noun %1$s, "),
|
||||
_(GUIMiscNames[f.noun()]));
|
||||
if (f == inherit_font)
|
||||
os << _("Default") << ", ";
|
||||
|
||||
|
||||
/// Realize font from a template
|
||||
Font & Font::realize(Font const & tmplt)
|
||||
{
|
||||
if (bits == inherit) {
|
||||
bits = tmplt.bits;
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (bits.family == INHERIT_FAMILY)
|
||||
bits.family = tmplt.bits.family;
|
||||
|
||||
if (bits.series == INHERIT_SERIES)
|
||||
bits.series = tmplt.bits.series;
|
||||
|
||||
if (bits.shape == INHERIT_SHAPE)
|
||||
bits.shape = tmplt.bits.shape;
|
||||
|
||||
if (bits.size == INHERIT_SIZE)
|
||||
bits.size = tmplt.bits.size;
|
||||
|
||||
if (bits.emph == INHERIT)
|
||||
bits.emph = tmplt.bits.emph;
|
||||
|
||||
if (bits.underbar == INHERIT)
|
||||
bits.underbar = tmplt.bits.underbar;
|
||||
|
||||
if (bits.noun == INHERIT)
|
||||
bits.noun = tmplt.bits.noun;
|
||||
|
||||
if (bits.color == Color_inherit)
|
||||
bits.color = tmplt.bits.color;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/// Is font resolved?
|
||||
bool Font::resolved() const
|
||||
{
|
||||
return (family() != INHERIT_FAMILY && series() != INHERIT_SERIES &&
|
||||
shape() != INHERIT_SHAPE && size() != INHERIT_SIZE &&
|
||||
emph() != INHERIT && underbar() != INHERIT &&
|
||||
noun() != INHERIT &&
|
||||
color() != Color_inherit);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
docstring const Font::stateText(BufferParams * params) const
|
||||
{
|
||||
odocstringstream os;
|
||||
if (family() != INHERIT_FAMILY)
|
||||
os << _(GUIFamilyNames[family()]) << ", ";
|
||||
if (series() != INHERIT_SERIES)
|
||||
os << _(GUISeriesNames[series()]) << ", ";
|
||||
if (shape() != INHERIT_SHAPE)
|
||||
os << _(GUIShapeNames[shape()]) << ", ";
|
||||
if (size() != INHERIT_SIZE)
|
||||
os << _(GUISizeNames[size()]) << ", ";
|
||||
if (color() != Color_inherit)
|
||||
os << lcolor.getGUIName(color()) << ", ";
|
||||
if (emph() != INHERIT)
|
||||
os << bformat(_("Emphasis %1$s, "),
|
||||
_(GUIMiscNames[emph()]));
|
||||
if (underbar() != INHERIT)
|
||||
os << bformat(_("Underline %1$s, "),
|
||||
_(GUIMiscNames[underbar()]));
|
||||
if (noun() != INHERIT)
|
||||
os << bformat(_("Noun %1$s, "),
|
||||
_(GUIMiscNames[noun()]));
|
||||
if (bits == inherit)
|
||||
os << _("Default") << ", ";
|
||||
os << lyx::stateText(bits_);
|
||||
if (!params || (language() != params->language))
|
||||
os << bformat(_("Language: %1$s, "),
|
||||
_(language()->display()));
|
||||
if (number() != OFF)
|
||||
if (bits_.number() != FONT_OFF)
|
||||
os << bformat(_(" Number %1$s"),
|
||||
_(GUIMiscNames[number()]));
|
||||
_(GUIMiscNames[bits_.number()]));
|
||||
return rtrim(os.str(), ", ");
|
||||
}
|
||||
|
||||
|
||||
// Set family according to lyx format string
|
||||
Font & Font::setLyXFamily(string const & fam)
|
||||
void setLyXFamily(string const & fam, FontInfo & f)
|
||||
{
|
||||
string const s = ascii_lowercase(fam);
|
||||
|
||||
@ -544,16 +218,15 @@ Font & Font::setLyXFamily(string const & fam)
|
||||
LyXFamilyNames[i] != string("error"))
|
||||
++i;
|
||||
if (s == LyXFamilyNames[i])
|
||||
setFamily(Font::FONT_FAMILY(i));
|
||||
f.setFamily(FontFamily(i));
|
||||
else
|
||||
lyxerr << "Font::setLyXFamily: Unknown family `"
|
||||
lyxerr << "setLyXFamily: Unknown family `"
|
||||
<< s << '\'' << endl;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// Set series according to lyx format string
|
||||
Font & Font::setLyXSeries(string const & ser)
|
||||
void setLyXSeries(string const & ser, FontInfo & f)
|
||||
{
|
||||
string const s = ascii_lowercase(ser);
|
||||
|
||||
@ -561,16 +234,15 @@ Font & Font::setLyXSeries(string const & ser)
|
||||
while (LyXSeriesNames[i] != s &&
|
||||
LyXSeriesNames[i] != string("error")) ++i;
|
||||
if (s == LyXSeriesNames[i]) {
|
||||
setSeries(Font::FONT_SERIES(i));
|
||||
f.setSeries(FontSeries(i));
|
||||
} else
|
||||
lyxerr << "Font::setLyXSeries: Unknown series `"
|
||||
lyxerr << "setLyXSeries: Unknown series `"
|
||||
<< s << '\'' << endl;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// Set shape according to lyx format string
|
||||
Font & Font::setLyXShape(string const & sha)
|
||||
void setLyXShape(string const & sha, FontInfo & f)
|
||||
{
|
||||
string const s = ascii_lowercase(sha);
|
||||
|
||||
@ -578,64 +250,62 @@ Font & Font::setLyXShape(string const & sha)
|
||||
while (LyXShapeNames[i] != s && LyXShapeNames[i] != string("error"))
|
||||
++i;
|
||||
if (s == LyXShapeNames[i])
|
||||
setShape(Font::FONT_SHAPE(i));
|
||||
f.setShape(FontShape(i));
|
||||
else
|
||||
lyxerr << "Font::setLyXShape: Unknown shape `"
|
||||
<< s << '\'' << endl;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// Set size according to lyx format string
|
||||
Font & Font::setLyXSize(string const & siz)
|
||||
void setLyXSize(string const & siz, FontInfo & f)
|
||||
{
|
||||
string const s = ascii_lowercase(siz);
|
||||
int i = 0;
|
||||
while (LyXSizeNames[i] != s && LyXSizeNames[i] != string("error"))
|
||||
++i;
|
||||
if (s == LyXSizeNames[i]) {
|
||||
setSize(Font::FONT_SIZE(i));
|
||||
f.setSize(FontSize(i));
|
||||
} else
|
||||
lyxerr << "Font::setLyXSize: Unknown size `"
|
||||
<< s << '\'' << endl;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// Set size according to lyx format string
|
||||
Font::FONT_MISC_STATE Font::setLyXMisc(string const & siz)
|
||||
FontState Font::setLyXMisc(string const & siz)
|
||||
{
|
||||
string const s = ascii_lowercase(siz);
|
||||
int i = 0;
|
||||
while (LyXMiscNames[i] != s &&
|
||||
LyXMiscNames[i] != string("error")) ++i;
|
||||
if (s == LyXMiscNames[i])
|
||||
return FONT_MISC_STATE(i);
|
||||
return FontState(i);
|
||||
lyxerr << "Font::setLyXMisc: Unknown misc flag `"
|
||||
<< s << '\'' << endl;
|
||||
return OFF;
|
||||
return FONT_OFF;
|
||||
}
|
||||
|
||||
|
||||
/// Sets color after LyX text format
|
||||
Font & Font::setLyXColor(string const & col)
|
||||
void setLyXColor(string const & col, FontInfo & f)
|
||||
{
|
||||
setColor(lcolor.getFromLyXName(col));
|
||||
return *this;
|
||||
f.setColor(lcolor.getFromLyXName(col));
|
||||
}
|
||||
|
||||
|
||||
// Returns size in latex format
|
||||
string const Font::latexSize() const
|
||||
{
|
||||
return LaTeXSizeNames[size()];
|
||||
return LaTeXSizeNames[bits_.size()];
|
||||
}
|
||||
|
||||
|
||||
// Read a font definition from given file in lyx format
|
||||
// Used for layouts
|
||||
Font & Font::lyxRead(Lexer & lex)
|
||||
FontInfo lyxRead(Lexer & lex)
|
||||
{
|
||||
FontInfo f;
|
||||
bool error = false;
|
||||
bool finished = false;
|
||||
while (!finished && lex.isOK() && !error) {
|
||||
@ -649,48 +319,48 @@ Font & Font::lyxRead(Lexer & lex)
|
||||
} else if (tok == "family") {
|
||||
lex.next();
|
||||
string const ttok = lex.getString();
|
||||
setLyXFamily(ttok);
|
||||
setLyXFamily(ttok, f);
|
||||
} else if (tok == "series") {
|
||||
lex.next();
|
||||
string const ttok = lex.getString();
|
||||
setLyXSeries(ttok);
|
||||
setLyXSeries(ttok, f);
|
||||
} else if (tok == "shape") {
|
||||
lex.next();
|
||||
string const ttok = lex.getString();
|
||||
setLyXShape(ttok);
|
||||
setLyXShape(ttok, f);
|
||||
} else if (tok == "size") {
|
||||
lex.next();
|
||||
string const ttok = lex.getString();
|
||||
setLyXSize(ttok);
|
||||
setLyXSize(ttok, f);
|
||||
} else if (tok == "misc") {
|
||||
lex.next();
|
||||
string const ttok = ascii_lowercase(lex.getString());
|
||||
|
||||
if (ttok == "no_bar") {
|
||||
setUnderbar(OFF);
|
||||
f.setUnderbar(FONT_OFF);
|
||||
} else if (ttok == "no_emph") {
|
||||
setEmph(OFF);
|
||||
f.setEmph(FONT_OFF);
|
||||
} else if (ttok == "no_noun") {
|
||||
setNoun(OFF);
|
||||
f.setNoun(FONT_OFF);
|
||||
} else if (ttok == "emph") {
|
||||
setEmph(ON);
|
||||
f.setEmph(FONT_ON);
|
||||
} else if (ttok == "underbar") {
|
||||
setUnderbar(ON);
|
||||
f.setUnderbar(FONT_ON);
|
||||
} else if (ttok == "noun") {
|
||||
setNoun(ON);
|
||||
f.setNoun(FONT_ON);
|
||||
} else {
|
||||
lex.printError("Illegal misc type `$$Token'");
|
||||
}
|
||||
} else if (tok == "color") {
|
||||
lex.next();
|
||||
string const ttok = lex.getString();
|
||||
setLyXColor(ttok);
|
||||
setLyXColor(ttok, f);
|
||||
} else {
|
||||
lex.printError("Unknown tag `$$Token'");
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
@ -699,39 +369,42 @@ void Font::lyxWriteChanges(Font const & orgfont,
|
||||
ostream & os) const
|
||||
{
|
||||
os << "\n";
|
||||
if (orgfont.family() != family())
|
||||
os << "\\family " << LyXFamilyNames[family()] << "\n";
|
||||
if (orgfont.series() != series())
|
||||
os << "\\series " << LyXSeriesNames[series()] << "\n";
|
||||
if (orgfont.shape() != shape())
|
||||
os << "\\shape " << LyXShapeNames[shape()] << "\n";
|
||||
if (orgfont.size() != size())
|
||||
os << "\\size " << LyXSizeNames[size()] << "\n";
|
||||
if (orgfont.emph() != emph())
|
||||
os << "\\emph " << LyXMiscNames[emph()] << "\n";
|
||||
if (orgfont.number() != number())
|
||||
os << "\\numeric " << LyXMiscNames[number()] << "\n";
|
||||
if (orgfont.underbar() != underbar()) {
|
||||
if (orgfont.fontInfo().family() != bits_.family())
|
||||
os << "\\family " << LyXFamilyNames[bits_.family()] << "\n";
|
||||
if (orgfont.fontInfo().series() != bits_.series())
|
||||
os << "\\series " << LyXSeriesNames[bits_.series()] << "\n";
|
||||
if (orgfont.fontInfo().shape() != bits_.shape())
|
||||
os << "\\shape " << LyXShapeNames[bits_.shape()] << "\n";
|
||||
if (orgfont.fontInfo().size() != bits_.size())
|
||||
os << "\\size " << LyXSizeNames[bits_.size()] << "\n";
|
||||
if (orgfont.fontInfo().emph() != bits_.emph())
|
||||
os << "\\emph " << LyXMiscNames[bits_.emph()] << "\n";
|
||||
if (orgfont.fontInfo().number() != bits_.number())
|
||||
os << "\\numeric " << LyXMiscNames[bits_.number()] << "\n";
|
||||
if (orgfont.fontInfo().underbar() != bits_.underbar()) {
|
||||
// This is only for backwards compatibility
|
||||
switch (underbar()) {
|
||||
case OFF: os << "\\bar no\n"; break;
|
||||
case ON: os << "\\bar under\n"; break;
|
||||
case TOGGLE: lyxerr << "Font::lyxWriteFontChanges: "
|
||||
"TOGGLE should not appear here!"
|
||||
switch (bits_.underbar()) {
|
||||
case FONT_OFF: os << "\\bar no\n"; break;
|
||||
case FONT_ON: os << "\\bar under\n"; break;
|
||||
case FONT_TOGGLE: lyxerr << "Font::lyxWriteFontChanges: "
|
||||
"FONT_TOGGLE should not appear here!"
|
||||
<< endl;
|
||||
break;
|
||||
case INHERIT: os << "\\bar default\n"; break;
|
||||
case IGNORE: lyxerr << "Font::lyxWriteFontChanges: "
|
||||
case FONT_INHERIT: os << "\\bar default\n"; break;
|
||||
case FONT_IGNORE: lyxerr << "Font::lyxWriteFontChanges: "
|
||||
"IGNORE should not appear here!"
|
||||
<< endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (orgfont.noun() != noun()) {
|
||||
os << "\\noun " << LyXMiscNames[noun()] << "\n";
|
||||
if (orgfont.fontInfo().noun() != bits_.noun()) {
|
||||
os << "\\noun " << LyXMiscNames[bits_.noun()] << "\n";
|
||||
}
|
||||
if (orgfont.color() != color())
|
||||
os << "\\color " << lcolor.getLyXName(color()) << '\n';
|
||||
if (orgfont.fontInfo().color() != bits_.color())
|
||||
os << "\\color " << lcolor.getLyXName(bits_.color()) << '\n';
|
||||
// FIXME: uncomment this when we support background.
|
||||
//if (orgfont.fontInfo().background() != bits_.background())
|
||||
// os << "\\color " << lcolor.getLyXName(bits_.background()) << '\n';
|
||||
if (orgfont.language() != language() &&
|
||||
language() != latex_language) {
|
||||
if (language())
|
||||
@ -804,7 +477,7 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
|
||||
// the numbers are written Left-to-Right. ArabTeX package
|
||||
// reorders the number automatically but the packages used
|
||||
// for Hebrew and Farsi (Arabi) do not.
|
||||
if (number() == ON && prev.number() != ON
|
||||
if (bits_.number() == FONT_ON && prev.fontInfo().number() != FONT_ON
|
||||
&& (language()->lang() == "hebrew"
|
||||
|| language()->lang() == "farsi"
|
||||
|| language()->lang() == "arabic_arabi")) {
|
||||
@ -812,8 +485,8 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
|
||||
count += 9;
|
||||
}
|
||||
|
||||
Font f = *this;
|
||||
f.reduce(base);
|
||||
FontInfo f = bits_;
|
||||
f.reduce(base.bits_);
|
||||
|
||||
if (f.family() != INHERIT_FAMILY) {
|
||||
os << '\\'
|
||||
@ -843,23 +516,33 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
|
||||
count += lcolor.getLaTeXName(f.color()).length() + 13;
|
||||
env = true; //We have opened a new environment
|
||||
}
|
||||
if (f.emph() == ON) {
|
||||
// FIXME: uncomment this when we support background.
|
||||
/*
|
||||
if (f.background() != Color_inherit && f.background() != Color_ignore) {
|
||||
os << "\\textcolor{"
|
||||
<< from_ascii(lcolor.getLaTeXName(f.background()))
|
||||
<< "}{";
|
||||
count += lcolor.getLaTeXName(f.background()).length() + 13;
|
||||
env = true; //We have opened a new environment
|
||||
}
|
||||
*/
|
||||
if (f.emph() == FONT_ON) {
|
||||
os << "\\emph{";
|
||||
count += 6;
|
||||
env = true; //We have opened a new environment
|
||||
}
|
||||
if (f.underbar() == ON) {
|
||||
if (f.underbar() == FONT_ON) {
|
||||
os << "\\underbar{";
|
||||
count += 10;
|
||||
env = true; //We have opened a new environment
|
||||
}
|
||||
// \noun{} is a LyX special macro
|
||||
if (f.noun() == ON) {
|
||||
if (f.noun() == FONT_ON) {
|
||||
os << "\\noun{";
|
||||
count += 6;
|
||||
env = true; //We have opened a new environment
|
||||
}
|
||||
if (f.size() != INHERIT_SIZE) {
|
||||
if (f.size() != FONT_SIZE_INHERIT) {
|
||||
// If we didn't open an environment above, we open one here
|
||||
if (!env) {
|
||||
os << '{';
|
||||
@ -889,8 +572,8 @@ int Font::latexWriteEndChanges(odocstream & os, BufferParams const & bparams,
|
||||
// reduce the current font to changes against the base
|
||||
// font (of the layout). We use a temporary for this to
|
||||
// avoid changing this font instance, as that would break
|
||||
Font f = *this;
|
||||
f.reduce(base);
|
||||
FontInfo f = bits_;
|
||||
f.reduce(base.bits_);
|
||||
|
||||
if (f.family() != INHERIT_FAMILY) {
|
||||
os << '}';
|
||||
@ -912,22 +595,22 @@ int Font::latexWriteEndChanges(odocstream & os, BufferParams const & bparams,
|
||||
++count;
|
||||
env = true; // Size change need not bother about closing env.
|
||||
}
|
||||
if (f.emph() == ON) {
|
||||
if (f.emph() == FONT_ON) {
|
||||
os << '}';
|
||||
++count;
|
||||
env = true; // Size change need not bother about closing env.
|
||||
}
|
||||
if (f.underbar() == ON) {
|
||||
if (f.underbar() == FONT_ON) {
|
||||
os << '}';
|
||||
++count;
|
||||
env = true; // Size change need not bother about closing env.
|
||||
}
|
||||
if (f.noun() == ON) {
|
||||
if (f.noun() == FONT_ON) {
|
||||
os << '}';
|
||||
++count;
|
||||
env = true; // Size change need not bother about closing env.
|
||||
}
|
||||
if (f.size() != INHERIT_SIZE) {
|
||||
if (f.size() != FONT_SIZE_INHERIT) {
|
||||
// We only have to close if only size changed
|
||||
if (!env) {
|
||||
os << '}';
|
||||
@ -939,7 +622,7 @@ int Font::latexWriteEndChanges(odocstream & os, BufferParams const & bparams,
|
||||
// the numbers are written Left-to-Right. ArabTeX package
|
||||
// reorders the number automatically but the packages used
|
||||
// for Hebrew and Farsi (Arabi) do not.
|
||||
if (number() == ON && next.number() != ON
|
||||
if (bits_.number() == FONT_ON && next.fontInfo().number() != FONT_ON
|
||||
&& (language()->lang() == "hebrew"
|
||||
|| language()->lang() == "farsi"
|
||||
|| language()->lang() == "arabic_arabi")) {
|
||||
@ -970,14 +653,6 @@ int Font::latexWriteEndChanges(odocstream & os, BufferParams const & bparams,
|
||||
}
|
||||
|
||||
|
||||
ColorCode Font::realColor() const
|
||||
{
|
||||
if (color() == Color_none)
|
||||
return Color_foreground;
|
||||
return color();
|
||||
}
|
||||
|
||||
|
||||
std::string Font::toString(bool const toggle) const
|
||||
{
|
||||
string lang = "ignore";
|
||||
@ -985,15 +660,16 @@ std::string Font::toString(bool const toggle) const
|
||||
lang = language()->lang();
|
||||
|
||||
ostringstream os;
|
||||
os << "family " << family() << '\n'
|
||||
<< "series " << series() << '\n'
|
||||
<< "shape " << shape() << '\n'
|
||||
<< "size " << size() << '\n'
|
||||
<< "emph " << emph() << '\n'
|
||||
<< "underbar " << underbar() << '\n'
|
||||
<< "noun " << noun() << '\n'
|
||||
<< "number " << number() << '\n'
|
||||
<< "color " << color() << '\n'
|
||||
os << "font: " << '\n'
|
||||
<< "family " << bits_.family() << '\n'
|
||||
<< "series " << bits_.series() << '\n'
|
||||
<< "shape " << bits_.shape() << '\n'
|
||||
<< "size " << bits_.size() << '\n'
|
||||
<< "emph " << bits_.emph() << '\n'
|
||||
<< "underbar " << bits_.underbar() << '\n'
|
||||
<< "noun " << bits_.noun() << '\n'
|
||||
<< "number " << bits_.number() << '\n'
|
||||
<< "color " << bits_.color() << '\n'
|
||||
<< "language " << lang << '\n'
|
||||
<< "toggleall " << convert<string>(toggle);
|
||||
return os.str();
|
||||
@ -1017,38 +693,44 @@ bool Font::fromString(string const & data, bool & toggle)
|
||||
|
||||
if (token == "family") {
|
||||
int const next = lex.getInteger();
|
||||
setFamily(FONT_FAMILY(next));
|
||||
bits_.setFamily(FontFamily(next));
|
||||
|
||||
} else if (token == "series") {
|
||||
int const next = lex.getInteger();
|
||||
setSeries(FONT_SERIES(next));
|
||||
bits_.setSeries(FontSeries(next));
|
||||
|
||||
} else if (token == "shape") {
|
||||
int const next = lex.getInteger();
|
||||
setShape(FONT_SHAPE(next));
|
||||
bits_.setShape(FontShape(next));
|
||||
|
||||
} else if (token == "size") {
|
||||
int const next = lex.getInteger();
|
||||
setSize(FONT_SIZE(next));
|
||||
bits_.setSize(FontSize(next));
|
||||
|
||||
} else if (token == "emph" || token == "underbar" ||
|
||||
token == "noun" || token == "number") {
|
||||
|
||||
int const next = lex.getInteger();
|
||||
FONT_MISC_STATE const misc = FONT_MISC_STATE(next);
|
||||
FontState const misc = FontState(next);
|
||||
|
||||
if (token == "emph")
|
||||
setEmph(misc);
|
||||
bits_.setEmph(misc);
|
||||
else if (token == "underbar")
|
||||
setUnderbar(misc);
|
||||
bits_.setUnderbar(misc);
|
||||
else if (token == "noun")
|
||||
setNoun(misc);
|
||||
bits_.setNoun(misc);
|
||||
else if (token == "number")
|
||||
setNumber(misc);
|
||||
bits_.setNumber(misc);
|
||||
|
||||
} else if (token == "color") {
|
||||
int const next = lex.getInteger();
|
||||
setColor(ColorCode(next));
|
||||
bits_.setColor(ColorCode(next));
|
||||
|
||||
/**
|
||||
} else if (token == "background") {
|
||||
int const next = lex.getInteger();
|
||||
bits_.setBackground(ColorCode(next));
|
||||
*/
|
||||
|
||||
} else if (token == "language") {
|
||||
string const next = lex.getString();
|
||||
@ -1076,16 +758,16 @@ void Font::validate(LaTeXFeatures & features) const
|
||||
BufferParams const & bparams = features.bufferParams();
|
||||
Language const * doc_language = bparams.language;
|
||||
|
||||
if (noun() == Font::ON) {
|
||||
if (bits_.noun() == FONT_ON) {
|
||||
LYXERR(Debug::LATEX) << "font.noun: "
|
||||
<< noun()
|
||||
<< bits_.noun()
|
||||
<< endl;
|
||||
features.require("noun");
|
||||
LYXERR(Debug::LATEX) << "Noun enabled. Font: "
|
||||
<< to_utf8(stateText(0))
|
||||
<< endl;
|
||||
}
|
||||
switch (color()) {
|
||||
switch (bits_.color()) {
|
||||
case Color_none:
|
||||
case Color_inherit:
|
||||
case Color_ignore:
|
||||
@ -1101,36 +783,46 @@ void Font::validate(LaTeXFeatures & features) const
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (lang->babel() != doc_language->babel() &&
|
||||
lang != ignore_language &&
|
||||
lang != latex_language)
|
||||
// FIXME: Do something for background and soul package?
|
||||
|
||||
if (lang_->babel() != doc_language->babel() &&
|
||||
lang_ != ignore_language &&
|
||||
lang_ != latex_language)
|
||||
{
|
||||
features.useLanguage(lang);
|
||||
features.useLanguage(lang_);
|
||||
LYXERR(Debug::LATEX) << "Found language "
|
||||
<< lang->lang() << endl;
|
||||
<< lang_->lang() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ostream & operator<<(ostream & os, Font::FONT_MISC_STATE fms)
|
||||
ostream & operator<<(ostream & os, FontState fms)
|
||||
{
|
||||
return os << int(fms);
|
||||
}
|
||||
|
||||
|
||||
std::ostream & operator<<(std::ostream & os, Font const & font)
|
||||
ostream & operator<<(std::ostream & os, FontInfo const & f)
|
||||
{
|
||||
return os << "font:"
|
||||
<< " family " << font.bits.family
|
||||
<< " series " << font.bits.series
|
||||
<< " shape " << font.bits.shape
|
||||
<< " size " << font.bits.size
|
||||
<< " color " << font.bits.color
|
||||
<< " emph " << font.bits.emph
|
||||
<< " underbar " << font.bits.underbar
|
||||
<< " noun " << font.bits.noun
|
||||
<< " number " << font.bits.number
|
||||
<< " lang: " << (font.lang ? font.lang->lang() : 0);
|
||||
<< " family " << f.family()
|
||||
<< " series " << f.series()
|
||||
<< " shape " << f.shape()
|
||||
<< " size " << f.size()
|
||||
<< " color " << f.color()
|
||||
// FIXME: uncomment this when we support background.
|
||||
//<< " background " << f.background()
|
||||
<< " emph " << f.emph()
|
||||
<< " underbar " << f.underbar()
|
||||
<< " noun " << f.noun()
|
||||
<< " number " << f.number();
|
||||
}
|
||||
|
||||
|
||||
std::ostream & operator<<(std::ostream & os, Font const & font)
|
||||
{
|
||||
return os << font.bits_
|
||||
<< " lang: " << (font.lang_ ? font.lang_->lang() : 0);
|
||||
}
|
||||
|
||||
|
||||
|
332
src/Font.h
332
src/Font.h
@ -20,6 +20,7 @@
|
||||
#else
|
||||
|
||||
#include "ColorCode.h"
|
||||
#include "FontInfo.h"
|
||||
|
||||
#include "support/docstream.h"
|
||||
|
||||
@ -34,234 +35,27 @@ class OutputParams;
|
||||
|
||||
///
|
||||
class Font {
|
||||
|
||||
public:
|
||||
/** The value INHERIT_* means that the font attribute is
|
||||
inherited from the layout. In the case of layout fonts, the
|
||||
attribute is inherited from the default font.
|
||||
The value IGNORE_* is used with Font::update() when the
|
||||
attribute should not be changed.
|
||||
*/
|
||||
enum FONT_FAMILY {
|
||||
///
|
||||
ROMAN_FAMILY, // fontstruct rely on this to be 0
|
||||
///
|
||||
SANS_FAMILY,
|
||||
///
|
||||
TYPEWRITER_FAMILY,
|
||||
///
|
||||
SYMBOL_FAMILY,
|
||||
///
|
||||
CMR_FAMILY,
|
||||
///
|
||||
CMSY_FAMILY,
|
||||
///
|
||||
CMM_FAMILY,
|
||||
///
|
||||
CMEX_FAMILY,
|
||||
///
|
||||
MSA_FAMILY,
|
||||
///
|
||||
MSB_FAMILY,
|
||||
///
|
||||
EUFRAK_FAMILY,
|
||||
///
|
||||
WASY_FAMILY,
|
||||
///
|
||||
ESINT_FAMILY,
|
||||
///
|
||||
INHERIT_FAMILY,
|
||||
///
|
||||
IGNORE_FAMILY,
|
||||
///
|
||||
NUM_FAMILIES = INHERIT_FAMILY
|
||||
};
|
||||
///
|
||||
Font(FontInfo = sane_font, Language const * l = 0);
|
||||
|
||||
///
|
||||
enum FONT_SERIES {
|
||||
///
|
||||
MEDIUM_SERIES, // fontstruct rely on this to be 0
|
||||
///
|
||||
BOLD_SERIES,
|
||||
///
|
||||
INHERIT_SERIES,
|
||||
///
|
||||
IGNORE_SERIES
|
||||
};
|
||||
|
||||
FontInfo & fontInfo() { return bits_; }
|
||||
///
|
||||
enum FONT_SHAPE {
|
||||
///
|
||||
UP_SHAPE, // fontstruct rely on this to be 0
|
||||
///
|
||||
ITALIC_SHAPE,
|
||||
///
|
||||
SLANTED_SHAPE,
|
||||
///
|
||||
SMALLCAPS_SHAPE,
|
||||
///
|
||||
INHERIT_SHAPE,
|
||||
///
|
||||
IGNORE_SHAPE
|
||||
};
|
||||
|
||||
FontInfo const & fontInfo() const { return bits_; }
|
||||
///
|
||||
enum FONT_SIZE {
|
||||
///
|
||||
SIZE_TINY, // fontstruct rely on this to be 0
|
||||
///
|
||||
SIZE_SCRIPT,
|
||||
///
|
||||
SIZE_FOOTNOTE,
|
||||
///
|
||||
SIZE_SMALL,
|
||||
///
|
||||
SIZE_NORMAL,
|
||||
///
|
||||
SIZE_LARGE,
|
||||
///
|
||||
SIZE_LARGER,
|
||||
///
|
||||
SIZE_LARGEST,
|
||||
///
|
||||
SIZE_HUGE,
|
||||
///
|
||||
SIZE_HUGER,
|
||||
///
|
||||
INCREASE_SIZE,
|
||||
///
|
||||
DECREASE_SIZE,
|
||||
///
|
||||
INHERIT_SIZE,
|
||||
///
|
||||
IGNORE_SIZE
|
||||
};
|
||||
|
||||
/// Used for emph, underbar, noun and latex toggles
|
||||
enum FONT_MISC_STATE {
|
||||
///
|
||||
OFF,
|
||||
///
|
||||
ON,
|
||||
///
|
||||
TOGGLE,
|
||||
///
|
||||
INHERIT,
|
||||
///
|
||||
IGNORE
|
||||
};
|
||||
|
||||
/// Trick to overload constructor and make it megafast
|
||||
enum FONT_INIT1 {
|
||||
///
|
||||
ALL_INHERIT
|
||||
};
|
||||
///
|
||||
enum FONT_INIT2 {
|
||||
///
|
||||
ALL_IGNORE
|
||||
};
|
||||
///
|
||||
enum FONT_INIT3 {
|
||||
///
|
||||
ALL_SANE
|
||||
};
|
||||
|
||||
struct FontBits {
|
||||
///
|
||||
FONT_FAMILY family;
|
||||
///
|
||||
FONT_SERIES series;
|
||||
///
|
||||
FONT_SHAPE shape;
|
||||
///
|
||||
FONT_SIZE size;
|
||||
///
|
||||
ColorCode color;
|
||||
///
|
||||
FONT_MISC_STATE emph;
|
||||
///
|
||||
FONT_MISC_STATE underbar;
|
||||
///
|
||||
FONT_MISC_STATE noun;
|
||||
///
|
||||
FONT_MISC_STATE number;
|
||||
};
|
||||
///
|
||||
Font();
|
||||
|
||||
/// Shortcut initialization
|
||||
explicit Font(Font::FONT_INIT1);
|
||||
/// Shortcut initialization
|
||||
explicit Font(Font::FONT_INIT2);
|
||||
/// Shortcut initialization
|
||||
explicit Font(Font::FONT_INIT3);
|
||||
/// Shortcut initialization
|
||||
Font(Font::FONT_INIT1, Language const * l);
|
||||
/// Shortcut initialization
|
||||
Font(Font::FONT_INIT2, Language const * l);
|
||||
/// Shortcut initialization
|
||||
Font(Font::FONT_INIT3, Language const * l);
|
||||
|
||||
/// Decreases font size by one
|
||||
Font & decSize();
|
||||
/// Increases font size by one
|
||||
Font & incSize();
|
||||
///
|
||||
FONT_FAMILY family() const { return bits.family; }
|
||||
///
|
||||
FONT_SERIES series() const { return bits.series; }
|
||||
///
|
||||
FONT_SHAPE shape() const { return bits.shape; }
|
||||
///
|
||||
FONT_SIZE size() const { return bits.size; }
|
||||
///
|
||||
FONT_MISC_STATE emph() const { return bits.emph; }
|
||||
///
|
||||
FONT_MISC_STATE underbar() const { return bits.underbar; }
|
||||
///
|
||||
FONT_MISC_STATE noun() const { return bits.noun; }
|
||||
///
|
||||
FONT_MISC_STATE number() const { return bits.number; }
|
||||
///
|
||||
ColorCode color() const;
|
||||
///
|
||||
Language const * language() const { return lang; }
|
||||
Language const * language() const { return lang_; }
|
||||
///
|
||||
bool isRightToLeft() const;
|
||||
///
|
||||
bool isVisibleRightToLeft() const;
|
||||
///
|
||||
bool isSymbolFont() const;
|
||||
|
||||
///
|
||||
void setFamily(Font::FONT_FAMILY f);
|
||||
void setSeries(Font::FONT_SERIES s);
|
||||
void setShape(Font::FONT_SHAPE s);
|
||||
void setSize(Font::FONT_SIZE s);
|
||||
void setEmph(Font::FONT_MISC_STATE e);
|
||||
void setUnderbar(Font::FONT_MISC_STATE u);
|
||||
void setNoun(Font::FONT_MISC_STATE n);
|
||||
void setNumber(Font::FONT_MISC_STATE n);
|
||||
void setColor(ColorCode c);
|
||||
void setLanguage(Language const * l);
|
||||
|
||||
/// Set family after LyX text format
|
||||
Font & setLyXFamily(std::string const &);
|
||||
|
||||
/// Set series after LyX text format
|
||||
Font & setLyXSeries(std::string const &);
|
||||
|
||||
/// Set shape after LyX text format
|
||||
Font & setLyXShape(std::string const &);
|
||||
|
||||
/// Set size after LyX text format
|
||||
Font & setLyXSize(std::string const &);
|
||||
|
||||
/// Returns misc flag after LyX text format
|
||||
Font::FONT_MISC_STATE setLyXMisc(std::string const &);
|
||||
FontState setLyXMisc(std::string const &);
|
||||
|
||||
/// Sets color after LyX text format
|
||||
Font & setLyXColor(std::string const &);
|
||||
|
||||
/// Returns size of font in LaTeX text notation
|
||||
std::string const latexSize() const;
|
||||
@ -279,18 +73,6 @@ public:
|
||||
Language const * default_lang,
|
||||
bool toggleall = false);
|
||||
|
||||
/** Reduce font to fall back to template where possible.
|
||||
Equal fields are reduced to INHERIT */
|
||||
void reduce(Font const & tmplt);
|
||||
|
||||
/// Realize font from a template (INHERIT are realized)
|
||||
Font & realize(Font const & tmplt);
|
||||
/// Is a given font fully resolved?
|
||||
bool resolved() const;
|
||||
|
||||
/// Read a font specification from Lexer. Used for layout files.
|
||||
Font & lyxRead(Lexer &);
|
||||
|
||||
/// Writes the changes from this font to orgfont in .lyx format in file
|
||||
void lyxWriteChanges(Font const & orgfont, std::ostream &) const;
|
||||
|
||||
@ -318,9 +100,6 @@ public:
|
||||
/// Build GUI description of font state
|
||||
docstring const stateText(BufferParams * params) const;
|
||||
|
||||
///
|
||||
ColorCode realColor() const;
|
||||
|
||||
///
|
||||
void validate(LaTeXFeatures & features) const;
|
||||
|
||||
@ -331,95 +110,28 @@ public:
|
||||
friend
|
||||
std::ostream & operator<<(std::ostream & os, Font const & font);
|
||||
|
||||
/// Converts logical attributes to concrete shape attribute
|
||||
// Try hard to inline this as it shows up with 4.6 % in the profiler.
|
||||
inline Font::FONT_SHAPE realShape() const {
|
||||
if (bits.noun == ON)
|
||||
return SMALLCAPS_SHAPE;
|
||||
if (bits.emph == ON)
|
||||
return (bits.shape == UP_SHAPE) ? ITALIC_SHAPE : UP_SHAPE;
|
||||
return bits.shape;
|
||||
}
|
||||
|
||||
/// 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);
|
||||
|
||||
/** Compaq cxx 6.5 requires that the definition be public so that
|
||||
it can compile operator==()
|
||||
*/
|
||||
private:
|
||||
///
|
||||
FontBits bits;
|
||||
FontInfo bits_;
|
||||
///
|
||||
Language const * lang;
|
||||
/// Sane font
|
||||
static FontBits sane;
|
||||
/// All inherit font
|
||||
static FontBits inherit;
|
||||
/// All ignore font
|
||||
static FontBits ignore;
|
||||
/// Updates a misc setting according to request
|
||||
Font::FONT_MISC_STATE setMisc(Font::FONT_MISC_STATE newfont,
|
||||
Font::FONT_MISC_STATE org);
|
||||
Language const * lang_;
|
||||
|
||||
/// Did latexWriteStartChanges open an encoding environment?
|
||||
mutable bool open_encoding_;
|
||||
};
|
||||
|
||||
|
||||
/** \c Font_size is a wrapper for Font::FONT_SIZE.
|
||||
* It can be forward-declared and passed as a function argument without
|
||||
* having to expose Font.h.
|
||||
*/
|
||||
class Font_size {
|
||||
public:
|
||||
///
|
||||
Font_size(Font::FONT_SIZE val) : val_(val) {}
|
||||
///
|
||||
operator Font::FONT_SIZE() const { return val_; }
|
||||
private:
|
||||
///
|
||||
Font::FONT_SIZE val_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
inline
|
||||
bool Font::isSymbolFont() const
|
||||
{
|
||||
switch (family()) {
|
||||
case Font::SYMBOL_FAMILY:
|
||||
case Font::CMSY_FAMILY:
|
||||
case Font::CMM_FAMILY:
|
||||
case Font::CMEX_FAMILY:
|
||||
case Font::MSA_FAMILY:
|
||||
case Font::MSB_FAMILY:
|
||||
case Font::WASY_FAMILY:
|
||||
case Font::ESINT_FAMILY:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
std::ostream & operator<<(std::ostream &, Font::FONT_MISC_STATE);
|
||||
|
||||
bool operator==(Font::FontBits const & lhs, Font::FontBits const & rhs);
|
||||
|
||||
inline
|
||||
bool operator!=(Font::FontBits const & lhs, Font::FontBits const & rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
///
|
||||
inline
|
||||
bool operator==(Font const & font1, Font const & font2)
|
||||
{
|
||||
return font1.bits == font2.bits && font1.lang == font2.lang;
|
||||
return font1.bits_ == font2.bits_ && font1.lang_ == font2.lang_;
|
||||
}
|
||||
|
||||
///
|
||||
@ -430,11 +142,29 @@ bool operator!=(Font const & font1, Font const & font2)
|
||||
}
|
||||
|
||||
/** Returns the current freefont, encoded as a std::string to be passed to the
|
||||
* frontends.
|
||||
* frontends. Implemented in Text3.cpp.
|
||||
*/
|
||||
std::string const freefont2string();
|
||||
|
||||
|
||||
/// Set family after LyX text format
|
||||
void setLyXFamily(std::string const &, FontInfo &);
|
||||
|
||||
/// Set series after LyX text format
|
||||
void setLyXSeries(std::string const &, FontInfo &);
|
||||
|
||||
/// Set shape after LyX text format
|
||||
void setLyXShape(std::string const &, FontInfo &);
|
||||
|
||||
/// Set size after LyX text format
|
||||
void setLyXSize(std::string const &, FontInfo &);
|
||||
|
||||
/// Sets color after LyX text format
|
||||
void setLyXColor(std::string const &, FontInfo &);
|
||||
|
||||
/// Read a font specification from Lexer. Used for layout files.
|
||||
FontInfo lyxRead(Lexer &);
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
#endif // TEX2LYX
|
||||
|
136
src/FontEnums.h
Normal file
136
src/FontEnums.h
Normal file
@ -0,0 +1,136 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file src/FontEnums.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_ENUMS_H
|
||||
#define FONT_ENUMS_H
|
||||
|
||||
namespace lyx {
|
||||
|
||||
/** The value INHERIT_* means that the font attribute is
|
||||
inherited from the layout. In the case of layout fonts, the
|
||||
attribute is inherited from the default font.
|
||||
The value IGNORE_* is used with Font::update() when the
|
||||
attribute should not be changed.
|
||||
*/
|
||||
enum FontFamily {
|
||||
///
|
||||
ROMAN_FAMILY = 0,
|
||||
///
|
||||
SANS_FAMILY,
|
||||
///
|
||||
TYPEWRITER_FAMILY,
|
||||
///
|
||||
SYMBOL_FAMILY,
|
||||
///
|
||||
CMR_FAMILY,
|
||||
///
|
||||
CMSY_FAMILY,
|
||||
///
|
||||
CMM_FAMILY,
|
||||
///
|
||||
CMEX_FAMILY,
|
||||
///
|
||||
MSA_FAMILY,
|
||||
///
|
||||
MSB_FAMILY,
|
||||
///
|
||||
EUFRAK_FAMILY,
|
||||
///
|
||||
WASY_FAMILY,
|
||||
///
|
||||
ESINT_FAMILY,
|
||||
///
|
||||
INHERIT_FAMILY,
|
||||
///
|
||||
IGNORE_FAMILY,
|
||||
///
|
||||
NUM_FAMILIES = INHERIT_FAMILY
|
||||
};
|
||||
|
||||
///
|
||||
enum FontSeries {
|
||||
///
|
||||
MEDIUM_SERIES = 0,
|
||||
///
|
||||
BOLD_SERIES,
|
||||
///
|
||||
INHERIT_SERIES,
|
||||
///
|
||||
IGNORE_SERIES
|
||||
};
|
||||
|
||||
///
|
||||
enum FontShape {
|
||||
///
|
||||
UP_SHAPE = 0,
|
||||
///
|
||||
ITALIC_SHAPE,
|
||||
///
|
||||
SLANTED_SHAPE,
|
||||
///
|
||||
SMALLCAPS_SHAPE,
|
||||
///
|
||||
INHERIT_SHAPE,
|
||||
///
|
||||
IGNORE_SHAPE
|
||||
};
|
||||
|
||||
///
|
||||
enum FontSize {
|
||||
///
|
||||
FONT_SIZE_TINY = 0,
|
||||
///
|
||||
FONT_SIZE_SCRIPT,
|
||||
///
|
||||
FONT_SIZE_FOOTNOTE,
|
||||
///
|
||||
FONT_SIZE_SMALL,
|
||||
///
|
||||
FONT_SIZE_NORMAL,
|
||||
///
|
||||
FONT_SIZE_LARGE,
|
||||
///
|
||||
FONT_SIZE_LARGER,
|
||||
///
|
||||
FONT_SIZE_LARGEST,
|
||||
///
|
||||
FONT_SIZE_HUGE,
|
||||
///
|
||||
FONT_SIZE_HUGER,
|
||||
///
|
||||
FONT_SIZE_INCREASE,
|
||||
///
|
||||
FONT_SIZE_DECREASE,
|
||||
///
|
||||
FONT_SIZE_INHERIT,
|
||||
///
|
||||
FONT_SIZE_IGNORE
|
||||
};
|
||||
|
||||
/// Used for emph, underbar, noun and latex toggles
|
||||
enum FontState {
|
||||
///
|
||||
FONT_OFF,
|
||||
///
|
||||
FONT_ON,
|
||||
///
|
||||
FONT_TOGGLE,
|
||||
///
|
||||
FONT_INHERIT,
|
||||
///
|
||||
FONT_IGNORE
|
||||
};
|
||||
|
||||
} // namespace lyx
|
||||
#endif
|
297
src/FontInfo.cpp
Normal file
297
src/FontInfo.cpp
Normal file
@ -0,0 +1,297 @@
|
||||
/**
|
||||
* \file src/FontInfo.cpp
|
||||
* 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 André Pönitz
|
||||
* \author Dekel Tsur
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "FontInfo.h"
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
using std::endl;
|
||||
using std::ostream;
|
||||
using std::ostringstream;
|
||||
using std::istringstream;
|
||||
using std::pair;
|
||||
|
||||
#ifndef CXX_GLOBAL_CSTD
|
||||
using std::strlen;
|
||||
#endif
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
FontInfo const sane_font(
|
||||
ROMAN_FAMILY,
|
||||
MEDIUM_SERIES,
|
||||
UP_SHAPE,
|
||||
FONT_SIZE_NORMAL,
|
||||
Color_none,
|
||||
Color_background,
|
||||
FONT_OFF,
|
||||
FONT_OFF,
|
||||
FONT_OFF,
|
||||
FONT_OFF);
|
||||
|
||||
FontInfo const inherit_font(
|
||||
INHERIT_FAMILY,
|
||||
INHERIT_SERIES,
|
||||
INHERIT_SHAPE,
|
||||
FONT_SIZE_INHERIT,
|
||||
Color_inherit,
|
||||
Color_inherit,
|
||||
FONT_INHERIT,
|
||||
FONT_INHERIT,
|
||||
FONT_INHERIT,
|
||||
FONT_OFF);
|
||||
|
||||
FontInfo const ignore_font(
|
||||
IGNORE_FAMILY,
|
||||
IGNORE_SERIES,
|
||||
IGNORE_SHAPE,
|
||||
FONT_SIZE_IGNORE,
|
||||
Color_ignore,
|
||||
Color_ignore,
|
||||
FONT_IGNORE,
|
||||
FONT_IGNORE,
|
||||
FONT_IGNORE,
|
||||
FONT_IGNORE);
|
||||
|
||||
|
||||
FontInfo::FontInfo()
|
||||
{
|
||||
*this = sane_font;
|
||||
}
|
||||
|
||||
/// Decreases font size_ by one
|
||||
FontInfo & FontInfo::decSize()
|
||||
{
|
||||
switch (size_) {
|
||||
case FONT_SIZE_HUGER: size_ = FONT_SIZE_HUGE; break;
|
||||
case FONT_SIZE_HUGE: size_ = FONT_SIZE_LARGEST; break;
|
||||
case FONT_SIZE_LARGEST: size_ = FONT_SIZE_LARGER; break;
|
||||
case FONT_SIZE_LARGER: size_ = FONT_SIZE_LARGE; break;
|
||||
case FONT_SIZE_LARGE: size_ = FONT_SIZE_NORMAL; break;
|
||||
case FONT_SIZE_NORMAL: size_ = FONT_SIZE_SMALL; break;
|
||||
case FONT_SIZE_SMALL: size_ = FONT_SIZE_FOOTNOTE; break;
|
||||
case FONT_SIZE_FOOTNOTE: size_ = FONT_SIZE_SCRIPT; break;
|
||||
case FONT_SIZE_SCRIPT: size_ = FONT_SIZE_TINY; break;
|
||||
case FONT_SIZE_TINY: break;
|
||||
case FONT_SIZE_INCREASE:
|
||||
lyxerr << "Can't FontInfo::decSize on FONT_SIZE_INCREASE" << endl;
|
||||
break;
|
||||
case FONT_SIZE_DECREASE:
|
||||
lyxerr <<"Can't FontInfo::decSize on FONT_SIZE_DECREASE" << endl;
|
||||
break;
|
||||
case FONT_SIZE_INHERIT:
|
||||
lyxerr <<"Can't FontInfo::decSize on FONT_SIZE_INHERIT" << endl;
|
||||
break;
|
||||
case FONT_SIZE_IGNORE:
|
||||
lyxerr <<"Can't FontInfo::decSize on FONT_SIZE_IGNORE" << endl;
|
||||
break;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/// Increases font size_ by one
|
||||
FontInfo & FontInfo::incSize()
|
||||
{
|
||||
switch (size_) {
|
||||
case FONT_SIZE_HUGER: break;
|
||||
case FONT_SIZE_HUGE: size_ = FONT_SIZE_HUGER; break;
|
||||
case FONT_SIZE_LARGEST: size_ = FONT_SIZE_HUGE; break;
|
||||
case FONT_SIZE_LARGER: size_ = FONT_SIZE_LARGEST; break;
|
||||
case FONT_SIZE_LARGE: size_ = FONT_SIZE_LARGER; break;
|
||||
case FONT_SIZE_NORMAL: size_ = FONT_SIZE_LARGE; break;
|
||||
case FONT_SIZE_SMALL: size_ = FONT_SIZE_NORMAL; break;
|
||||
case FONT_SIZE_FOOTNOTE: size_ = FONT_SIZE_SMALL; break;
|
||||
case FONT_SIZE_SCRIPT: size_ = FONT_SIZE_FOOTNOTE; break;
|
||||
case FONT_SIZE_TINY: size_ = FONT_SIZE_SCRIPT; break;
|
||||
case FONT_SIZE_INCREASE:
|
||||
lyxerr <<"Can't FontInfo::incSize on FONT_SIZE_INCREASE" << endl;
|
||||
break;
|
||||
case FONT_SIZE_DECREASE:
|
||||
lyxerr <<"Can't FontInfo::incSize on FONT_SIZE_DECREASE" << endl;
|
||||
break;
|
||||
case FONT_SIZE_INHERIT:
|
||||
lyxerr <<"Can't FontInfo::incSize on FONT_SIZE_INHERIT" << endl;
|
||||
break;
|
||||
case FONT_SIZE_IGNORE:
|
||||
lyxerr <<"Can't FontInfo::incSize on FONT_SIZE_IGNORE" << endl;
|
||||
break;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/// Reduce font to fall back to template where possible
|
||||
void FontInfo::reduce(FontInfo const & tmplt)
|
||||
{
|
||||
if (family_ == tmplt.family_)
|
||||
family_ = INHERIT_FAMILY;
|
||||
if (series_ == tmplt.series_)
|
||||
series_ = INHERIT_SERIES;
|
||||
if (shape_ == tmplt.shape_)
|
||||
shape_ = INHERIT_SHAPE;
|
||||
if (size_ == tmplt.size_)
|
||||
size_ = FONT_SIZE_INHERIT;
|
||||
if (emph_ == tmplt.emph_)
|
||||
emph_ = FONT_INHERIT;
|
||||
if (underbar_ == tmplt.underbar_)
|
||||
underbar_ = FONT_INHERIT;
|
||||
if (noun_ == tmplt.noun_)
|
||||
noun_ = FONT_INHERIT;
|
||||
if (color_ == tmplt.color_)
|
||||
color_ = Color_inherit;
|
||||
if (background_ == tmplt.background_)
|
||||
background_ = Color_inherit;
|
||||
}
|
||||
|
||||
|
||||
/// Realize font from a template
|
||||
FontInfo & FontInfo::realize(FontInfo const & tmplt)
|
||||
{
|
||||
if ((*this) == inherit_font) {
|
||||
operator=(tmplt);
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (family_ == INHERIT_FAMILY)
|
||||
family_ = tmplt.family_;
|
||||
|
||||
if (series_ == INHERIT_SERIES)
|
||||
series_ = tmplt.series_;
|
||||
|
||||
if (shape_ == INHERIT_SHAPE)
|
||||
shape_ = tmplt.shape_;
|
||||
|
||||
if (size_ == FONT_SIZE_INHERIT)
|
||||
size_ = tmplt.size_;
|
||||
|
||||
if (emph_ == FONT_INHERIT)
|
||||
emph_ = tmplt.emph_;
|
||||
|
||||
if (underbar_ == FONT_INHERIT)
|
||||
underbar_ = tmplt.underbar_;
|
||||
|
||||
if (noun_ == FONT_INHERIT)
|
||||
noun_ = tmplt.noun_;
|
||||
|
||||
if (color_ == Color_inherit)
|
||||
color_ = tmplt.color_;
|
||||
|
||||
if (background_ == Color_inherit)
|
||||
background_ = tmplt.background_;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/// Updates a misc setting according to request
|
||||
static FontState setMisc(FontState newfont,
|
||||
FontState org)
|
||||
{
|
||||
if (newfont == FONT_TOGGLE) {
|
||||
if (org == FONT_ON)
|
||||
return FONT_OFF;
|
||||
else if (org == FONT_OFF)
|
||||
return FONT_ON;
|
||||
else {
|
||||
lyxerr <<"Font::setMisc: Need state"
|
||||
" FONT_ON or FONT_OFF to toggle. Setting to FONT_ON" << endl;
|
||||
return FONT_ON;
|
||||
}
|
||||
} else if (newfont == FONT_IGNORE)
|
||||
return org;
|
||||
else
|
||||
return newfont;
|
||||
}
|
||||
|
||||
/// Updates font settings according to request
|
||||
void FontInfo::update(FontInfo const & newfont, bool toggleall)
|
||||
{
|
||||
if (newfont.family_ == family_ && toggleall)
|
||||
setFamily(INHERIT_FAMILY); // toggle 'back'
|
||||
else if (newfont.family_ != IGNORE_FAMILY)
|
||||
setFamily(newfont.family_);
|
||||
// else it's IGNORE_SHAPE
|
||||
|
||||
// "Old" behaviour: "Setting" bold will toggle bold on/off.
|
||||
switch (newfont.series_) {
|
||||
case BOLD_SERIES:
|
||||
// We toggle...
|
||||
if (series_ == BOLD_SERIES && toggleall)
|
||||
setSeries(MEDIUM_SERIES);
|
||||
else
|
||||
setSeries(BOLD_SERIES);
|
||||
break;
|
||||
case MEDIUM_SERIES:
|
||||
case INHERIT_SERIES:
|
||||
setSeries(newfont.series_);
|
||||
break;
|
||||
case IGNORE_SERIES:
|
||||
break;
|
||||
}
|
||||
|
||||
if (newfont.shape_ == shape_ && toggleall)
|
||||
shape_ = INHERIT_SHAPE; // toggle 'back'
|
||||
else if (newfont.shape_ != IGNORE_SHAPE)
|
||||
shape_ = newfont.shape_;
|
||||
// else it's IGNORE_SHAPE
|
||||
|
||||
if (newfont.size_ != FONT_SIZE_IGNORE) {
|
||||
if (newfont.size_ == FONT_SIZE_INCREASE)
|
||||
incSize();
|
||||
else if (newfont.size_ == FONT_SIZE_DECREASE)
|
||||
decSize();
|
||||
else
|
||||
size_ = newfont.size_;
|
||||
}
|
||||
|
||||
setEmph(setMisc(newfont.emph_, emph_));
|
||||
setUnderbar(setMisc(newfont.underbar_, underbar_));
|
||||
setNoun(setMisc(newfont.noun_, noun_));
|
||||
setNumber(setMisc(newfont.number_, number_));
|
||||
|
||||
if (newfont.color_ == color_ && toggleall)
|
||||
setColor(Color_inherit); // toggle 'back'
|
||||
else if (newfont.color_ != Color_ignore)
|
||||
setColor(newfont.color_);
|
||||
|
||||
if (newfont.background_ == background_ && toggleall)
|
||||
setBackground(Color_inherit); // toggle 'back'
|
||||
else if (newfont.background_ != Color_ignore)
|
||||
setBackground(newfont.background_);
|
||||
}
|
||||
|
||||
/// Is font resolved?
|
||||
bool FontInfo::resolved() const
|
||||
{
|
||||
return (family_ != INHERIT_FAMILY && series_ != INHERIT_SERIES
|
||||
&& shape_ != INHERIT_SHAPE && size_ != FONT_SIZE_INHERIT
|
||||
&& emph_ != FONT_INHERIT && underbar_ != FONT_INHERIT
|
||||
&& noun_ != FONT_INHERIT
|
||||
&& color_ != Color_inherit
|
||||
&& background_ != Color_inherit);
|
||||
}
|
||||
|
||||
|
||||
ColorCode FontInfo::realColor() const
|
||||
{
|
||||
if (color_ == Color_none)
|
||||
return Color_foreground;
|
||||
return color_;
|
||||
}
|
||||
|
||||
} // namespace lyx
|
194
src/FontInfo.h
Normal file
194
src/FontInfo.h
Normal file
@ -0,0 +1,194 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file src/FontInfo.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_PROPERTIES_H
|
||||
#define FONT_PROPERTIES_H
|
||||
|
||||
#ifdef TEX2LYX
|
||||
#include "tex2lyx/Font.h"
|
||||
#else
|
||||
|
||||
#include "ColorCode.h"
|
||||
#include "FontEnums.h"
|
||||
|
||||
namespace lyx {
|
||||
|
||||
///
|
||||
class FontInfo
|
||||
{
|
||||
public:
|
||||
///
|
||||
FontInfo::FontInfo();
|
||||
///
|
||||
FontInfo::FontInfo(
|
||||
FontFamily family,
|
||||
FontSeries series,
|
||||
FontShape shape,
|
||||
FontSize size,
|
||||
ColorCode color,
|
||||
ColorCode background,
|
||||
FontState emph,
|
||||
FontState underbar,
|
||||
FontState noun,
|
||||
FontState number
|
||||
): family_(family), series_(series), shape_(shape), size_(size),
|
||||
color_(color), background_(background), emph_(emph),
|
||||
underbar_(underbar), noun_(noun), number_(number)
|
||||
{}
|
||||
|
||||
/// Decreases font size by one
|
||||
FontInfo & decSize();
|
||||
/// Increases font size by one
|
||||
FontInfo & incSize();
|
||||
|
||||
/// Accessor methods.
|
||||
///@{
|
||||
FontFamily family() const { return family_; }
|
||||
void setFamily(FontFamily f) { family_ = f; }
|
||||
FontSeries series() const { return series_; }
|
||||
void setSeries(FontSeries s) { series_ = s; }
|
||||
FontShape shape() const { return shape_; }
|
||||
void setShape(FontShape s) { shape_ = s; }
|
||||
FontSize size() const { return size_; }
|
||||
void setSize(FontSize s) { size_ = s; }
|
||||
FontState emph() const { return emph_; }
|
||||
void setEmph(FontState e) { emph_ = e; }
|
||||
FontState underbar() const { return underbar_; }
|
||||
void setUnderbar(FontState u) { underbar_ = u; }
|
||||
FontState noun() const { return noun_; }
|
||||
void setNoun(FontState n) { noun_ = n; }
|
||||
FontState number() const { return number_; }
|
||||
void setNumber(FontState n) { number_ = n; }
|
||||
ColorCode color() const { return color_; }
|
||||
void setColor(ColorCode c) { color_ = c; }
|
||||
ColorCode background() const { return background_; }
|
||||
void setBackground(ColorCode b) { background_ = b; }
|
||||
///@}
|
||||
|
||||
///
|
||||
void update(FontInfo const & newfont, bool toggleall);
|
||||
|
||||
/** Reduce font to fall back to template where possible.
|
||||
Equal fields are reduced to INHERIT */
|
||||
void reduce(FontInfo const & tmplt);
|
||||
|
||||
/// Realize font from a template (INHERIT are realized)
|
||||
FontInfo & realize(FontInfo const & tmplt);
|
||||
/// Is a given font fully resolved?
|
||||
bool resolved() const;
|
||||
|
||||
///
|
||||
ColorCode realColor() const;
|
||||
|
||||
/// Converts logical attributes to concrete shape attribute
|
||||
// Try hard to inline this as it shows up with 4.6 % in the profiler.
|
||||
FontShape realShape() const
|
||||
{
|
||||
if (noun_ == FONT_ON)
|
||||
return SMALLCAPS_SHAPE;
|
||||
if (emph_ == FONT_ON)
|
||||
return (shape_ == UP_SHAPE) ? ITALIC_SHAPE : UP_SHAPE;
|
||||
return shape_;
|
||||
}
|
||||
|
||||
bool isSymbolFont() const
|
||||
{
|
||||
switch (family_) {
|
||||
case SYMBOL_FAMILY:
|
||||
case CMSY_FAMILY:
|
||||
case CMM_FAMILY:
|
||||
case CMEX_FAMILY:
|
||||
case MSA_FAMILY:
|
||||
case MSB_FAMILY:
|
||||
case WASY_FAMILY:
|
||||
case ESINT_FAMILY:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
FontInfo & operator=(FontInfo const & rhs)
|
||||
{
|
||||
family_ = rhs.family_;
|
||||
series_ = rhs.series_;
|
||||
shape_ = rhs.shape_;
|
||||
size_ = rhs.size_;
|
||||
color_ = rhs.color_;
|
||||
background_ = rhs.background_;
|
||||
emph_ = rhs.emph_;
|
||||
underbar_ = rhs.underbar_;
|
||||
noun_ = rhs.noun_;
|
||||
number_ = rhs.number_;
|
||||
}
|
||||
*/
|
||||
|
||||
private:
|
||||
friend bool operator==(FontInfo const & lhs, FontInfo const & rhs);
|
||||
|
||||
///
|
||||
FontFamily family_;
|
||||
///
|
||||
FontSeries series_;
|
||||
///
|
||||
FontShape shape_;
|
||||
///
|
||||
FontSize size_;
|
||||
///
|
||||
ColorCode color_;
|
||||
///
|
||||
ColorCode background_;
|
||||
///
|
||||
FontState emph_;
|
||||
///
|
||||
FontState underbar_;
|
||||
///
|
||||
FontState noun_;
|
||||
///
|
||||
FontState number_;
|
||||
};
|
||||
|
||||
|
||||
inline bool operator==(FontInfo const & lhs, FontInfo const & rhs)
|
||||
{
|
||||
return lhs.family_ == rhs.family_
|
||||
&& lhs.series_ == rhs.series_
|
||||
&& lhs.shape_ == rhs.shape_
|
||||
&& lhs.size_ == rhs.size_
|
||||
&& lhs.color_ == rhs.color_
|
||||
&& lhs.background_ == rhs.background_
|
||||
&& lhs.emph_ == rhs.emph_
|
||||
&& lhs.underbar_ == rhs.underbar_
|
||||
&& lhs.noun_ == rhs.noun_
|
||||
&& lhs.number_ == rhs.number_;
|
||||
}
|
||||
|
||||
|
||||
inline bool operator!=(FontInfo const & lhs, FontInfo const & rhs)
|
||||
{
|
||||
return !operator==(lhs, rhs);
|
||||
}
|
||||
|
||||
/// Sane font.
|
||||
extern FontInfo const sane_font;
|
||||
/// All inherit font.
|
||||
extern FontInfo const inherit_font;
|
||||
/// All ignore font.
|
||||
extern FontInfo const ignore_font;
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
#endif // TEX2LYX_FONT_H
|
||||
#endif
|
@ -188,8 +188,8 @@ void FontList::set(pos_type pos, Font const & font)
|
||||
}
|
||||
|
||||
|
||||
Font_size FontList::highestInRange
|
||||
(pos_type startpos, pos_type endpos, Font_size def_size) const
|
||||
FontSize FontList::highestInRange
|
||||
(pos_type startpos, pos_type endpos, FontSize def_size) const
|
||||
{
|
||||
if (list_.empty())
|
||||
return def_size;
|
||||
@ -210,12 +210,12 @@ Font_size FontList::highestInRange
|
||||
break;
|
||||
}
|
||||
|
||||
Font::FONT_SIZE maxsize = Font::SIZE_TINY;
|
||||
FontSize maxsize = FONT_SIZE_TINY;
|
||||
for (; cit != end_it; ++cit) {
|
||||
Font::FONT_SIZE size = cit->font().size();
|
||||
if (size == Font::INHERIT_SIZE)
|
||||
FontSize size = cit->font().fontInfo().size();
|
||||
if (size == FONT_SIZE_INHERIT)
|
||||
size = def_size;
|
||||
if (size > maxsize && size <= Font::SIZE_HUGER)
|
||||
if (size > maxsize && size <= FONT_SIZE_HUGER)
|
||||
maxsize = size;
|
||||
}
|
||||
return maxsize;
|
||||
|
@ -56,7 +56,7 @@ private:
|
||||
paragraph or, in the case of nested paragraphs, from the
|
||||
layout in the environment one level up until completely
|
||||
resolved.
|
||||
The values Font::IGNORE_* and Font::TOGGLE are NOT
|
||||
The values Font::IGNORE_* and FONT_TOGGLE are NOT
|
||||
allowed in these font tables.
|
||||
*/
|
||||
Font font_;
|
||||
@ -104,10 +104,10 @@ public:
|
||||
void decreasePosAfterPos(pos_type pos);
|
||||
|
||||
/// Returns the height of the highest font in range
|
||||
Font_size highestInRange(
|
||||
FontSize highestInRange(
|
||||
pos_type startpos,
|
||||
pos_type endpos,
|
||||
Font_size def_size
|
||||
FontSize def_size
|
||||
) const;
|
||||
|
||||
/// is there a font change in middle of the word?
|
||||
|
@ -19,14 +19,15 @@
|
||||
|
||||
#include "support/lstrings.h"
|
||||
|
||||
using std::endl;
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
using support::subst;
|
||||
using support::trim;
|
||||
|
||||
using std::endl;
|
||||
using std::string;
|
||||
extern FontInfo lyxRead(Lexer &);
|
||||
|
||||
/// Special value of toclevel for layouts that to not belong in a TOC
|
||||
const int Layout::NOT_IN_TOC = -1000;
|
||||
@ -102,10 +103,10 @@ Layout::Layout()
|
||||
optionalargs = 0;
|
||||
needprotect = false;
|
||||
keepempty = false;
|
||||
font = Font(Font::ALL_INHERIT);
|
||||
labelfont = Font(Font::ALL_INHERIT);
|
||||
resfont = Font(Font::ALL_SANE);
|
||||
reslabelfont = Font(Font::ALL_SANE);
|
||||
font = inherit_font;
|
||||
labelfont = inherit_font;
|
||||
resfont = sane_font;
|
||||
reslabelfont = sane_font;
|
||||
nextnoindent = false;
|
||||
parskip = 0.0;
|
||||
itemsep = 0;
|
||||
@ -310,16 +311,16 @@ bool Layout::read(Lexer & lexrc, TextClass const & tclass)
|
||||
break;
|
||||
|
||||
case LT_FONT:
|
||||
font.lyxRead(lexrc);
|
||||
labelfont= font;
|
||||
font = lyxRead(lexrc);
|
||||
labelfont = font;
|
||||
break;
|
||||
|
||||
case LT_TEXTFONT:
|
||||
font.lyxRead(lexrc);
|
||||
font = lyxRead(lexrc);
|
||||
break;
|
||||
|
||||
case LT_LABELFONT:
|
||||
labelfont.lyxRead(lexrc);
|
||||
labelfont = lyxRead(lexrc);
|
||||
break;
|
||||
|
||||
case LT_NEXTNOINDENT: // Indent next paragraph?
|
||||
|
17
src/Layout.h
17
src/Layout.h
@ -14,7 +14,7 @@
|
||||
#ifndef LAYOUT_H
|
||||
#define LAYOUT_H
|
||||
|
||||
#include "Font.h"
|
||||
#include "FontInfo.h"
|
||||
#include "LayoutEnums.h"
|
||||
#include "Spacing.h"
|
||||
#include "support/docstring.h"
|
||||
@ -94,30 +94,30 @@ public:
|
||||
}
|
||||
/** Default font for this layout/environment.
|
||||
The main font for this kind of environment. If an attribute has
|
||||
Font::INHERITED_*, it means that the value is specified by
|
||||
INHERITED_*, it means that the value is specified by
|
||||
the defaultfont for the entire layout. If we are nested, the
|
||||
font is inherited from the font in the environment one level
|
||||
up until the font is resolved. The values Font::IGNORE_*
|
||||
and Font::TOGGLE are illegal here.
|
||||
up until the font is resolved. The values :IGNORE_*
|
||||
and FONT_TOGGLE are illegal here.
|
||||
*/
|
||||
Font font;
|
||||
FontInfo font;
|
||||
|
||||
/** Default font for labels.
|
||||
Interpretation the same as for font above
|
||||
*/
|
||||
Font labelfont;
|
||||
FontInfo labelfont;
|
||||
|
||||
/** Resolved version of the font for this layout/environment.
|
||||
This is a resolved version the default font. The font is resolved
|
||||
against the defaultfont of the entire layout.
|
||||
*/
|
||||
Font resfont;
|
||||
FontInfo resfont;
|
||||
|
||||
/** Resolved version of the font used for labels.
|
||||
This is a resolved version the label font. The font is resolved
|
||||
against the defaultfont of the entire layout.
|
||||
*/
|
||||
Font reslabelfont;
|
||||
FontInfo reslabelfont;
|
||||
|
||||
/// Text that dictates how wide the left margin is on the screen
|
||||
docstring leftmargin;
|
||||
@ -252,7 +252,6 @@ private:
|
||||
docstring preamble_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
#endif
|
||||
|
@ -153,7 +153,7 @@ int Length::inPixels(int text_width, int em_width_base) const
|
||||
? em_width_base
|
||||
: 10*(dpi/72.27)*zoom;
|
||||
// A different estimate for em_width is
|
||||
// theFontMetrics(Font(Font::ALL_SANE)).width('M')
|
||||
// theFontMetrics(FontInfo(sane_font)).width('M')
|
||||
// but this estimate might not be more accurate as the screen font
|
||||
// is different then the latex font.
|
||||
|
||||
|
102
src/LyXRC.cpp
102
src/LyXRC.cpp
@ -28,7 +28,7 @@
|
||||
#include "gettext.h"
|
||||
#include "Session.h"
|
||||
#include "Lexer.h"
|
||||
#include "Font.h"
|
||||
#include "FontEnums.h"
|
||||
#include "Mover.h"
|
||||
|
||||
#include "graphics/GraphicsTypes.h"
|
||||
@ -224,16 +224,16 @@ void LyXRC::setDefaults() {
|
||||
geometry_height = 0;
|
||||
geometry_xysaved = true;
|
||||
// Default LaTeX font size:
|
||||
font_sizes[Font::SIZE_TINY] = "5.0";
|
||||
font_sizes[Font::SIZE_SCRIPT] = "7.0";
|
||||
font_sizes[Font::SIZE_FOOTNOTE] = "8.0";
|
||||
font_sizes[Font::SIZE_SMALL] = "9.0";
|
||||
font_sizes[Font::SIZE_NORMAL] = "10.0";
|
||||
font_sizes[Font::SIZE_LARGE] = "12.0";
|
||||
font_sizes[Font::SIZE_LARGER] = "14.4";
|
||||
font_sizes[Font::SIZE_LARGEST] = "17.26";
|
||||
font_sizes[Font::SIZE_HUGE] = "20.74";
|
||||
font_sizes[Font::SIZE_HUGER] = "24.88";
|
||||
font_sizes[FONT_SIZE_TINY] = "5.0";
|
||||
font_sizes[FONT_SIZE_SCRIPT] = "7.0";
|
||||
font_sizes[FONT_SIZE_FOOTNOTE] = "8.0";
|
||||
font_sizes[FONT_SIZE_SMALL] = "9.0";
|
||||
font_sizes[FONT_SIZE_NORMAL] = "10.0";
|
||||
font_sizes[FONT_SIZE_LARGE] = "12.0";
|
||||
font_sizes[FONT_SIZE_LARGER] = "14.4";
|
||||
font_sizes[FONT_SIZE_LARGEST] = "17.26";
|
||||
font_sizes[FONT_SIZE_HUGE] = "20.74";
|
||||
font_sizes[FONT_SIZE_HUGER] = "24.88";
|
||||
use_scalable_fonts = true;
|
||||
roman_font_name = "";
|
||||
sans_font_name = "";
|
||||
@ -657,43 +657,43 @@ int LyXRC::read(Lexer & lexrc)
|
||||
|
||||
case RC_SCREEN_FONT_SIZES:
|
||||
if (lexrc.next()) {
|
||||
font_sizes[Font::SIZE_TINY] =
|
||||
font_sizes[FONT_SIZE_TINY] =
|
||||
lexrc.getString();
|
||||
}
|
||||
if (lexrc.next()) {
|
||||
font_sizes[Font::SIZE_SCRIPT] =
|
||||
font_sizes[FONT_SIZE_SCRIPT] =
|
||||
lexrc.getString();
|
||||
}
|
||||
if (lexrc.next()) {
|
||||
font_sizes[Font::SIZE_FOOTNOTE] =
|
||||
font_sizes[FONT_SIZE_FOOTNOTE] =
|
||||
lexrc.getString();
|
||||
}
|
||||
if (lexrc.next()) {
|
||||
font_sizes[Font::SIZE_SMALL] =
|
||||
font_sizes[FONT_SIZE_SMALL] =
|
||||
lexrc.getString();
|
||||
}
|
||||
if (lexrc.next()) {
|
||||
font_sizes[Font::SIZE_NORMAL] =
|
||||
font_sizes[FONT_SIZE_NORMAL] =
|
||||
lexrc.getString();
|
||||
}
|
||||
if (lexrc.next()) {
|
||||
font_sizes[Font::SIZE_LARGE] =
|
||||
font_sizes[FONT_SIZE_LARGE] =
|
||||
lexrc.getString();
|
||||
}
|
||||
if (lexrc.next()) {
|
||||
font_sizes[Font::SIZE_LARGER] =
|
||||
font_sizes[FONT_SIZE_LARGER] =
|
||||
lexrc.getString();
|
||||
}
|
||||
if (lexrc.next()) {
|
||||
font_sizes[Font::SIZE_LARGEST] =
|
||||
font_sizes[FONT_SIZE_LARGEST] =
|
||||
lexrc.getString();
|
||||
}
|
||||
if (lexrc.next()) {
|
||||
font_sizes[Font::SIZE_HUGE] =
|
||||
font_sizes[FONT_SIZE_HUGE] =
|
||||
lexrc.getString();
|
||||
}
|
||||
if (lexrc.next()) {
|
||||
font_sizes[Font::SIZE_HUGER] =
|
||||
font_sizes[FONT_SIZE_HUGER] =
|
||||
lexrc.getString();
|
||||
}
|
||||
break;
|
||||
@ -1654,39 +1654,39 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
|
||||
break;
|
||||
case RC_SCREEN_FONT_SIZES:
|
||||
if (ignore_system_lyxrc ||
|
||||
font_sizes[Font::SIZE_TINY]
|
||||
!= system_lyxrc.font_sizes[Font::SIZE_TINY] ||
|
||||
font_sizes[Font::SIZE_SCRIPT]
|
||||
!= system_lyxrc.font_sizes[Font::SIZE_SCRIPT] ||
|
||||
font_sizes[Font::SIZE_FOOTNOTE]
|
||||
!= system_lyxrc.font_sizes[Font::SIZE_FOOTNOTE] ||
|
||||
font_sizes[Font::SIZE_SMALL]
|
||||
!= system_lyxrc.font_sizes[Font::SIZE_SMALL] ||
|
||||
font_sizes[Font::SIZE_NORMAL]
|
||||
!= system_lyxrc.font_sizes[Font::SIZE_NORMAL] ||
|
||||
font_sizes[Font::SIZE_LARGE]
|
||||
!= system_lyxrc.font_sizes[Font::SIZE_LARGE] ||
|
||||
font_sizes[Font::SIZE_LARGER]
|
||||
!= system_lyxrc.font_sizes[Font::SIZE_LARGER] ||
|
||||
font_sizes[Font::SIZE_LARGEST]
|
||||
!= system_lyxrc.font_sizes[Font::SIZE_LARGEST] ||
|
||||
font_sizes[Font::SIZE_HUGE]
|
||||
!= system_lyxrc.font_sizes[Font::SIZE_HUGE] ||
|
||||
font_sizes[Font::SIZE_HUGER]
|
||||
!= system_lyxrc.font_sizes[Font::SIZE_HUGER]) {
|
||||
font_sizes[FONT_SIZE_TINY]
|
||||
!= system_lyxrc.font_sizes[FONT_SIZE_TINY] ||
|
||||
font_sizes[FONT_SIZE_SCRIPT]
|
||||
!= system_lyxrc.font_sizes[FONT_SIZE_SCRIPT] ||
|
||||
font_sizes[FONT_SIZE_FOOTNOTE]
|
||||
!= system_lyxrc.font_sizes[FONT_SIZE_FOOTNOTE] ||
|
||||
font_sizes[FONT_SIZE_SMALL]
|
||||
!= system_lyxrc.font_sizes[FONT_SIZE_SMALL] ||
|
||||
font_sizes[FONT_SIZE_NORMAL]
|
||||
!= system_lyxrc.font_sizes[FONT_SIZE_NORMAL] ||
|
||||
font_sizes[FONT_SIZE_LARGE]
|
||||
!= system_lyxrc.font_sizes[FONT_SIZE_LARGE] ||
|
||||
font_sizes[FONT_SIZE_LARGER]
|
||||
!= system_lyxrc.font_sizes[FONT_SIZE_LARGER] ||
|
||||
font_sizes[FONT_SIZE_LARGEST]
|
||||
!= system_lyxrc.font_sizes[FONT_SIZE_LARGEST] ||
|
||||
font_sizes[FONT_SIZE_HUGE]
|
||||
!= system_lyxrc.font_sizes[FONT_SIZE_HUGE] ||
|
||||
font_sizes[FONT_SIZE_HUGER]
|
||||
!= system_lyxrc.font_sizes[FONT_SIZE_HUGER]) {
|
||||
os.setf(ios::fixed);
|
||||
os.precision(2);
|
||||
os << "\\screen_font_sizes"
|
||||
<< ' ' << font_sizes[Font::SIZE_TINY]
|
||||
<< ' ' << font_sizes[Font::SIZE_SCRIPT]
|
||||
<< ' ' << font_sizes[Font::SIZE_FOOTNOTE]
|
||||
<< ' ' << font_sizes[Font::SIZE_SMALL]
|
||||
<< ' ' << font_sizes[Font::SIZE_NORMAL]
|
||||
<< ' ' << font_sizes[Font::SIZE_LARGE]
|
||||
<< ' ' << font_sizes[Font::SIZE_LARGER]
|
||||
<< ' ' << font_sizes[Font::SIZE_LARGEST]
|
||||
<< ' ' << font_sizes[Font::SIZE_HUGE]
|
||||
<< ' ' << font_sizes[Font::SIZE_HUGER]
|
||||
<< ' ' << font_sizes[FONT_SIZE_TINY]
|
||||
<< ' ' << font_sizes[FONT_SIZE_SCRIPT]
|
||||
<< ' ' << font_sizes[FONT_SIZE_FOOTNOTE]
|
||||
<< ' ' << font_sizes[FONT_SIZE_SMALL]
|
||||
<< ' ' << font_sizes[FONT_SIZE_NORMAL]
|
||||
<< ' ' << font_sizes[FONT_SIZE_LARGE]
|
||||
<< ' ' << font_sizes[FONT_SIZE_LARGER]
|
||||
<< ' ' << font_sizes[FONT_SIZE_LARGEST]
|
||||
<< ' ' << font_sizes[FONT_SIZE_HUGE]
|
||||
<< ' ' << font_sizes[FONT_SIZE_HUGER]
|
||||
<< '\n';
|
||||
}
|
||||
if (tag != RC_LAST)
|
||||
|
@ -143,6 +143,9 @@ liblyxcore_la_SOURCES = \
|
||||
FloatList.h \
|
||||
Font.cpp \
|
||||
Font.h \
|
||||
FontEnums.h \
|
||||
FontInfo.cpp \
|
||||
FontInfo.h \
|
||||
FontIterator.cpp \
|
||||
FontIterator.h \
|
||||
FontList.cpp \
|
||||
|
@ -32,7 +32,7 @@ MetricsBase::MetricsBase()
|
||||
{}
|
||||
|
||||
|
||||
MetricsBase::MetricsBase(BufferView * b, Font const & f, int w)
|
||||
MetricsBase::MetricsBase(BufferView * b, FontInfo const & f, int w)
|
||||
: bv(b), font(f), style(LM_ST_TEXT), fontname("mathnormal"),
|
||||
textwidth(w)
|
||||
{}
|
||||
@ -43,7 +43,7 @@ MetricsInfo::MetricsInfo()
|
||||
{}
|
||||
|
||||
|
||||
MetricsInfo::MetricsInfo(BufferView * bv, Font const & font, int textwidth)
|
||||
MetricsInfo::MetricsInfo(BufferView * bv, FontInfo const & font, int textwidth)
|
||||
: base(bv, font, textwidth)
|
||||
{}
|
||||
|
||||
@ -115,8 +115,8 @@ ArrayChanger::ArrayChanger(MetricsBase & mb)
|
||||
|
||||
|
||||
|
||||
ShapeChanger::ShapeChanger(Font & font, Font::FONT_SHAPE shape)
|
||||
: Changer<Font, Font::FONT_SHAPE>(font)
|
||||
ShapeChanger::ShapeChanger(FontInfo & font, FontShape shape)
|
||||
: Changer<FontInfo, FontShape>(font)
|
||||
{
|
||||
save_ = orig_.shape();
|
||||
orig_.setShape(shape);
|
||||
@ -161,9 +161,9 @@ FontSetChanger::FontSetChanger(MetricsBase & mb, char const * name)
|
||||
: Changer<MetricsBase>(mb)
|
||||
{
|
||||
save_ = mb;
|
||||
Font::FONT_SIZE oldsize = save_.font.size();
|
||||
FontSize oldsize = save_.font.size();
|
||||
mb.fontname = name;
|
||||
mb.font = Font();
|
||||
mb.font = FontInfo();
|
||||
augmentFont(mb.font, from_ascii(name));
|
||||
mb.font.setSize(oldsize);
|
||||
}
|
||||
@ -173,9 +173,9 @@ FontSetChanger::FontSetChanger(MetricsBase & mb, docstring const & name)
|
||||
: Changer<MetricsBase>(mb)
|
||||
{
|
||||
save_ = mb;
|
||||
Font::FONT_SIZE oldsize = save_.font.size();
|
||||
FontSize oldsize = save_.font.size();
|
||||
mb.fontname = to_utf8(name);
|
||||
mb.font = Font();
|
||||
mb.font = FontInfo();
|
||||
augmentFont(mb.font, name);
|
||||
mb.font.setSize(oldsize);
|
||||
}
|
||||
@ -203,8 +203,8 @@ WidthChanger::~WidthChanger()
|
||||
|
||||
|
||||
|
||||
ColorChanger::ColorChanger(Font & font, string const & color)
|
||||
: Changer<Font, string>(font)
|
||||
ColorChanger::ColorChanger(FontInfo & font, string const & color)
|
||||
: Changer<FontInfo, string>(font)
|
||||
{
|
||||
save_ = lcolor.getFromLyXName(color);
|
||||
font.setColor(lcolor.getFromLyXName(color));
|
||||
|
@ -12,7 +12,7 @@
|
||||
#ifndef METRICSINFO_H
|
||||
#define METRICSINFO_H
|
||||
|
||||
#include "Font.h"
|
||||
#include "FontInfo.h"
|
||||
#include "support/docstring.h"
|
||||
#include <string>
|
||||
|
||||
@ -44,12 +44,12 @@ public:
|
||||
///
|
||||
MetricsBase();
|
||||
///
|
||||
MetricsBase(BufferView * bv, Font const & font, int textwidth);
|
||||
MetricsBase(BufferView * bv, FontInfo const & font, int textwidth);
|
||||
|
||||
/// the current view
|
||||
BufferView * bv;
|
||||
/// current font
|
||||
Font font;
|
||||
FontInfo font;
|
||||
/// current math style (display/text/script/..)
|
||||
Styles style;
|
||||
/// name of current font - mathed specific
|
||||
@ -68,7 +68,7 @@ public:
|
||||
///
|
||||
MetricsInfo();
|
||||
///
|
||||
MetricsInfo(BufferView * bv, Font const & font, int textwidth);
|
||||
MetricsInfo(BufferView * bv, FontInfo const & font, int textwidth);
|
||||
|
||||
///
|
||||
MetricsBase base;
|
||||
@ -151,10 +151,10 @@ protected:
|
||||
|
||||
|
||||
// temporarily change some aspect of a font
|
||||
class FontChanger : public Changer<Font> {
|
||||
class FontChanger : public Changer<FontInfo> {
|
||||
public:
|
||||
///
|
||||
FontChanger(Font & orig, docstring const & font);
|
||||
FontChanger(FontInfo & orig, docstring const & font);
|
||||
FontChanger(MetricsBase & mb, char const * const font);
|
||||
///
|
||||
~FontChanger();
|
||||
@ -208,10 +208,10 @@ public:
|
||||
|
||||
|
||||
// temporarily change the shape of a font
|
||||
class ShapeChanger : public Changer<Font, Font::FONT_SHAPE> {
|
||||
class ShapeChanger : public Changer<FontInfo, FontShape> {
|
||||
public:
|
||||
///
|
||||
ShapeChanger(Font & font, Font::FONT_SHAPE shape);
|
||||
ShapeChanger(FontInfo & font, FontShape shape);
|
||||
///
|
||||
~ShapeChanger();
|
||||
};
|
||||
@ -229,10 +229,10 @@ public:
|
||||
|
||||
|
||||
// temporarily change the used color
|
||||
class ColorChanger : public Changer<Font, std::string> {
|
||||
class ColorChanger : public Changer<FontInfo, std::string> {
|
||||
public:
|
||||
///
|
||||
ColorChanger(Font & font, std::string const & color);
|
||||
ColorChanger(FontInfo & font, std::string const & color);
|
||||
///
|
||||
~ColorChanger();
|
||||
};
|
||||
|
@ -551,7 +551,7 @@ bool Paragraph::Private::simpleTeXBlanks(OutputParams const & runparams,
|
||||
&& !owner_->isFreeSpacing()
|
||||
// In typewriter mode, we want to avoid
|
||||
// ! . ? : at the end of a line
|
||||
&& !(font.family() == Font::TYPEWRITER_FAMILY
|
||||
&& !(font.fontInfo().family() == TYPEWRITER_FAMILY
|
||||
&& (text_[i - 1] == '.'
|
||||
|| text_[i - 1] == '?'
|
||||
|| text_[i - 1] == ':'
|
||||
@ -686,7 +686,7 @@ void Paragraph::Private::latexInset(Buffer const & buf,
|
||||
open_font = false;
|
||||
}
|
||||
|
||||
if (running_font.family() == Font::TYPEWRITER_FAMILY)
|
||||
if (running_font.fontInfo().family() == TYPEWRITER_FAMILY)
|
||||
os << '~';
|
||||
|
||||
basefont = owner_->getLayoutFont(bparams, outerfont);
|
||||
@ -813,7 +813,7 @@ void Paragraph::Private::latexSpecialChar(
|
||||
if (lyxrc.fontenc == "T1" && latexSpecialT1(c, os, i, column))
|
||||
return;
|
||||
|
||||
if (running_font.family() == Font::TYPEWRITER_FAMILY
|
||||
if (running_font.fontInfo().family() == TYPEWRITER_FAMILY
|
||||
&& latexSpecialTypewriter(c, os, i, column))
|
||||
return;
|
||||
|
||||
@ -1109,7 +1109,7 @@ void Paragraph::write(Buffer const & buf, ostream & os,
|
||||
|
||||
params().write(os);
|
||||
|
||||
Font font1(Font::ALL_INHERIT, bparams.language);
|
||||
Font font1(inherit_font, bparams.language);
|
||||
|
||||
Change running_change = Change(Change::UNCHANGED);
|
||||
|
||||
@ -1274,6 +1274,11 @@ bool Paragraph::insetAllowed(InsetCode code)
|
||||
}
|
||||
|
||||
|
||||
void Paragraph::resetFonts(Font const & font)
|
||||
{
|
||||
d->fontlist_.setRange(0, d->text_.size(), font);
|
||||
}
|
||||
|
||||
// Gets uninstantiated font setting at position.
|
||||
Font const Paragraph::getFontSettings(BufferParams const & bparams,
|
||||
pos_type pos) const
|
||||
@ -1290,7 +1295,7 @@ Font const Paragraph::getFontSettings(BufferParams const & bparams,
|
||||
if (pos == size() && !empty())
|
||||
return getFontSettings(bparams, pos - 1);
|
||||
|
||||
return Font(Font::ALL_INHERIT, getParLanguage(bparams));
|
||||
return Font(inherit_font, getParLanguage(bparams));
|
||||
}
|
||||
|
||||
|
||||
@ -1327,7 +1332,7 @@ Font const Paragraph::getFirstFontSettings(BufferParams const & bparams) const
|
||||
if (!empty() && !d->fontlist_.empty())
|
||||
return d->fontlist_.begin()->font();
|
||||
|
||||
return Font(Font::ALL_INHERIT, bparams.language);
|
||||
return Font(inherit_font, bparams.language);
|
||||
}
|
||||
|
||||
|
||||
@ -1345,12 +1350,12 @@ Font const Paragraph::getFont(BufferParams const & bparams, pos_type pos,
|
||||
|
||||
pos_type const body_pos = beginOfBody();
|
||||
if (pos < body_pos)
|
||||
font.realize(d->layout_->labelfont);
|
||||
font.fontInfo().realize(d->layout_->labelfont);
|
||||
else
|
||||
font.realize(d->layout_->font);
|
||||
font.fontInfo().realize(d->layout_->font);
|
||||
|
||||
font.realize(outerfont);
|
||||
font.realize(bparams.getFont());
|
||||
font.fontInfo().realize(outerfont.fontInfo());
|
||||
font.fontInfo().realize(bparams.getFont().fontInfo());
|
||||
|
||||
return font;
|
||||
}
|
||||
@ -1361,8 +1366,8 @@ Font const Paragraph::getLabelFont
|
||||
{
|
||||
Font tmpfont = layout()->labelfont;
|
||||
tmpfont.setLanguage(getParLanguage(bparams));
|
||||
tmpfont.realize(outerfont);
|
||||
tmpfont.realize(bparams.getFont());
|
||||
tmpfont.fontInfo().realize(outerfont.fontInfo());
|
||||
tmpfont.fontInfo().realize(bparams.getFont().fontInfo());
|
||||
return tmpfont;
|
||||
}
|
||||
|
||||
@ -1370,17 +1375,16 @@ Font const Paragraph::getLabelFont
|
||||
Font const Paragraph::getLayoutFont
|
||||
(BufferParams const & bparams, Font const & outerfont) const
|
||||
{
|
||||
Font tmpfont = layout()->font;
|
||||
tmpfont.setLanguage(getParLanguage(bparams));
|
||||
tmpfont.realize(outerfont);
|
||||
tmpfont.realize(bparams.getFont());
|
||||
return tmpfont;
|
||||
FontInfo tmpfont = layout()->font;
|
||||
tmpfont.realize(outerfont.fontInfo());
|
||||
tmpfont.realize(bparams.getFont().fontInfo());
|
||||
return Font(tmpfont, getParLanguage(bparams));
|
||||
}
|
||||
|
||||
|
||||
/// Returns the height of the highest font in range
|
||||
Font_size Paragraph::highestFontInRange
|
||||
(pos_type startpos, pos_type endpos, Font_size def_size) const
|
||||
FontSize Paragraph::highestFontInRange
|
||||
(pos_type startpos, pos_type endpos, FontSize def_size) const
|
||||
{
|
||||
return d->fontlist_.highestInRange(startpos, endpos, def_size);
|
||||
}
|
||||
@ -2163,8 +2167,8 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
|
||||
Font font = getFont(buf.params(), i, outerfont);
|
||||
|
||||
// handle <emphasis> tag
|
||||
if (font_old.emph() != font.emph()) {
|
||||
if (font.emph() == Font::ON) {
|
||||
if (font_old.fontInfo().emph() != font.fontInfo().emph()) {
|
||||
if (font.fontInfo().emph() == FONT_ON) {
|
||||
os << "<emphasis>";
|
||||
emph_flag = true;
|
||||
} else if (i != initial) {
|
||||
|
@ -16,6 +16,7 @@
|
||||
#ifndef PARAGRAPH_H
|
||||
#define PARAGRAPH_H
|
||||
|
||||
#include "FontEnums.h"
|
||||
#include "LayoutPtr.h"
|
||||
|
||||
#include "insets/InsetCode.h"
|
||||
@ -225,6 +226,9 @@ public:
|
||||
/// (logically) erase the given range; return the number of chars actually erased
|
||||
int eraseChars(pos_type start, pos_type end, bool trackChanges);
|
||||
|
||||
///
|
||||
void resetFonts(Font const & font);
|
||||
|
||||
/** Get uninstantiated font setting. Returns the difference
|
||||
between the characters font and the layoutfont.
|
||||
This is what is stored in the fonttable
|
||||
@ -238,8 +242,8 @@ public:
|
||||
font attached to this paragraph.
|
||||
If pos == -2, use the label font of the layout attached here.
|
||||
In all cases, the font is instantiated, i.e. does not have any
|
||||
attributes with values Font::INHERIT, Font::IGNORE or
|
||||
Font::TOGGLE.
|
||||
attributes with values FONT_INHERIT, FONT_IGNORE or
|
||||
FONT_TOGGLE.
|
||||
*/
|
||||
Font const getFont(BufferParams const &, pos_type pos,
|
||||
Font const & outerfont) const;
|
||||
@ -261,8 +265,8 @@ public:
|
||||
/// pos <= size() (there is a dummy font change at the end of each par)
|
||||
void setFont(pos_type pos, Font const & font);
|
||||
/// Returns the height of the highest font in range
|
||||
Font_size highestFontInRange(pos_type startpos,
|
||||
pos_type endpos, Font_size def_size) const;
|
||||
FontSize highestFontInRange(pos_type startpos,
|
||||
pos_type endpos, FontSize def_size) const;
|
||||
///
|
||||
void insert(pos_type pos, docstring const & str,
|
||||
Font const & font, Change const & change);
|
||||
|
38
src/Text.cpp
38
src/Text.cpp
@ -106,7 +106,7 @@ void readParToken(Buffer const & buf, Paragraph & par, Lexer & lex,
|
||||
lex.eatLine();
|
||||
docstring layoutname = lex.getDocString();
|
||||
|
||||
font = Font(Font::ALL_INHERIT, bp.language);
|
||||
font = Font(inherit_font, bp.language);
|
||||
change = Change(Change::UNCHANGED);
|
||||
|
||||
TextClass const & tclass = bp.getTextClass();
|
||||
@ -155,16 +155,16 @@ void readParToken(Buffer const & buf, Paragraph & par, Lexer & lex,
|
||||
}
|
||||
} else if (token == "\\family") {
|
||||
lex.next();
|
||||
font.setLyXFamily(lex.getString());
|
||||
setLyXFamily(lex.getString(), font.fontInfo());
|
||||
} else if (token == "\\series") {
|
||||
lex.next();
|
||||
font.setLyXSeries(lex.getString());
|
||||
setLyXSeries(lex.getString(), font.fontInfo());
|
||||
} else if (token == "\\shape") {
|
||||
lex.next();
|
||||
font.setLyXShape(lex.getString());
|
||||
setLyXShape(lex.getString(), font.fontInfo());
|
||||
} else if (token == "\\size") {
|
||||
lex.next();
|
||||
font.setLyXSize(lex.getString());
|
||||
setLyXSize(lex.getString(), font.fontInfo());
|
||||
} else if (token == "\\lang") {
|
||||
lex.next();
|
||||
string const tok = lex.getString();
|
||||
@ -177,29 +177,29 @@ void readParToken(Buffer const & buf, Paragraph & par, Lexer & lex,
|
||||
}
|
||||
} else if (token == "\\numeric") {
|
||||
lex.next();
|
||||
font.setNumber(font.setLyXMisc(lex.getString()));
|
||||
font.fontInfo().setNumber(font.setLyXMisc(lex.getString()));
|
||||
} else if (token == "\\emph") {
|
||||
lex.next();
|
||||
font.setEmph(font.setLyXMisc(lex.getString()));
|
||||
font.fontInfo().setEmph(font.setLyXMisc(lex.getString()));
|
||||
} else if (token == "\\bar") {
|
||||
lex.next();
|
||||
string const tok = lex.getString();
|
||||
|
||||
if (tok == "under")
|
||||
font.setUnderbar(Font::ON);
|
||||
font.fontInfo().setUnderbar(FONT_ON);
|
||||
else if (tok == "no")
|
||||
font.setUnderbar(Font::OFF);
|
||||
font.fontInfo().setUnderbar(FONT_OFF);
|
||||
else if (tok == "default")
|
||||
font.setUnderbar(Font::INHERIT);
|
||||
font.fontInfo().setUnderbar(FONT_INHERIT);
|
||||
else
|
||||
lex.printError("Unknown bar font flag "
|
||||
"`$$Token'");
|
||||
} else if (token == "\\noun") {
|
||||
lex.next();
|
||||
font.setNoun(font.setLyXMisc(lex.getString()));
|
||||
font.fontInfo().setNoun(font.setLyXMisc(lex.getString()));
|
||||
} else if (token == "\\color") {
|
||||
lex.next();
|
||||
font.setLyXColor(lex.getString());
|
||||
setLyXColor(lex.getString(), font.fontInfo());
|
||||
} else if (token == "\\InsetSpace" || token == "\\SpecialChar") {
|
||||
|
||||
// Insets don't make sense in a free-spacing context! ---Kayvan
|
||||
@ -442,13 +442,13 @@ void Text::insertChar(Cursor & cur, char_type c)
|
||||
static docstring const number_unary_operators = from_ascii("+-");
|
||||
static docstring const number_seperators = from_ascii(".,:");
|
||||
|
||||
if (cur.current_font.number() == Font::ON) {
|
||||
if (cur.current_font.fontInfo().number() == FONT_ON) {
|
||||
if (!isDigit(c) && !contains(number_operators, c) &&
|
||||
!(contains(number_seperators, c) &&
|
||||
cur.pos() != 0 &&
|
||||
cur.pos() != cur.lastpos() &&
|
||||
tm.getDisplayFont(pit, cur.pos()).number() == Font::ON &&
|
||||
tm.getDisplayFont(pit, cur.pos() - 1).number() == Font::ON)
|
||||
tm.getDisplayFont(pit, cur.pos()).fontInfo().number() == FONT_ON &&
|
||||
tm.getDisplayFont(pit, cur.pos() - 1).fontInfo().number() == FONT_ON)
|
||||
)
|
||||
number(cur); // Set current_font.number to OFF
|
||||
} else if (isDigit(c) &&
|
||||
@ -466,7 +466,7 @@ void Text::insertChar(Cursor & cur, char_type c)
|
||||
tm.font_);
|
||||
} else if (contains(number_seperators, c)
|
||||
&& cur.pos() >= 2
|
||||
&& tm.getDisplayFont(pit, cur.pos() - 2).number() == Font::ON) {
|
||||
&& tm.getDisplayFont(pit, cur.pos() - 2).fontInfo().number() == FONT_ON) {
|
||||
setCharFont(buffer, pit, cur.pos() - 1, cur.current_font,
|
||||
tm.font_);
|
||||
}
|
||||
@ -499,7 +499,7 @@ void Text::insertChar(Cursor & cur, char_type c)
|
||||
if ((cur.pos() >= 2) && (par.isLineSeparator(cur.pos() - 1))) {
|
||||
// get font in front and behind the space in question. But do NOT
|
||||
// use getFont(cur.pos()) because the character c is not inserted yet
|
||||
Font const & pre_space_font = tm.getDisplayFont(cur.pit(), cur.pos() - 2);
|
||||
Font const pre_space_font = tm.getDisplayFont(cur.pit(), cur.pos() - 2);
|
||||
Font const & post_space_font = cur.real_current_font;
|
||||
bool pre_space_rtl = pre_space_font.isVisibleRightToLeft();
|
||||
bool post_space_rtl = post_space_font.isVisibleRightToLeft();
|
||||
@ -1162,7 +1162,7 @@ bool Text::read(Buffer const & buf, Lexer & lex, ErrorList & errorList)
|
||||
|
||||
Paragraph par;
|
||||
par.params().depth(depth);
|
||||
par.setFont(0, Font(Font::ALL_INHERIT, buf.params().language));
|
||||
par.setFont(0, Font(inherit_font, buf.params().language));
|
||||
pars_.push_back(par);
|
||||
|
||||
// FIXME: goddamn InsetTabular makes us pass a Buffer
|
||||
@ -1212,7 +1212,7 @@ docstring Text::currentState(Cursor & cur)
|
||||
// font. (Asger)
|
||||
// No, from the document font (MV)
|
||||
Font font = cur.real_current_font;
|
||||
font.reduce(buf.params().getFont());
|
||||
font.fontInfo().reduce(buf.params().getFont().fontInfo());
|
||||
|
||||
os << bformat(_("Font: %1$s"), font.stateText(&buf.params()));
|
||||
|
||||
|
@ -25,6 +25,7 @@ class CursorSlice;
|
||||
class DocIterator;
|
||||
class ErrorList;
|
||||
class Font;
|
||||
class FontInfo;
|
||||
class FuncRequest;
|
||||
class FuncStatus;
|
||||
class Inset;
|
||||
@ -46,9 +47,9 @@ public:
|
||||
bool empty() const;
|
||||
|
||||
///
|
||||
Font getLayoutFont(Buffer const & buffer, pit_type pit) const;
|
||||
FontInfo getLayoutFont(Buffer const & buffer, pit_type pit) const;
|
||||
///
|
||||
Font getLabelFont(Buffer const & buffer,
|
||||
FontInfo getLabelFont(Buffer const & buffer,
|
||||
Paragraph const & par) const;
|
||||
/** Set font of character at position \p pos in paragraph \p pit.
|
||||
* Must not be called if \p pos denotes an inset with text contents,
|
||||
|
@ -83,42 +83,42 @@ bool Text::isMainText(Buffer const & buffer) const
|
||||
}
|
||||
|
||||
|
||||
Font Text::getLayoutFont(Buffer const & buffer, pit_type const pit) const
|
||||
FontInfo Text::getLayoutFont(Buffer const & buffer, pit_type const pit) const
|
||||
{
|
||||
LayoutPtr const & layout = pars_[pit].layout();
|
||||
|
||||
if (!pars_[pit].getDepth()) {
|
||||
Font lf = layout->resfont;
|
||||
FontInfo lf = layout->resfont;
|
||||
// In case the default family has been customized
|
||||
if (layout->font.family() == Font::INHERIT_FAMILY)
|
||||
lf.setFamily(buffer.params().getFont().family());
|
||||
if (layout->font.family() == INHERIT_FAMILY)
|
||||
lf.setFamily(buffer.params().getFont().fontInfo().family());
|
||||
return lf;
|
||||
}
|
||||
|
||||
Font font = layout->font;
|
||||
FontInfo font = layout->font;
|
||||
// Realize with the fonts of lesser depth.
|
||||
//font.realize(outerFont(pit, paragraphs()));
|
||||
font.realize(buffer.params().getFont());
|
||||
font.realize(buffer.params().getFont().fontInfo());
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
|
||||
Font Text::getLabelFont(Buffer const & buffer, Paragraph const & par) const
|
||||
FontInfo Text::getLabelFont(Buffer const & buffer, Paragraph const & par) const
|
||||
{
|
||||
LayoutPtr const & layout = par.layout();
|
||||
|
||||
if (!par.getDepth()) {
|
||||
Font lf = layout->reslabelfont;
|
||||
FontInfo lf = layout->reslabelfont;
|
||||
// In case the default family has been customized
|
||||
if (layout->labelfont.family() == Font::INHERIT_FAMILY)
|
||||
lf.setFamily(buffer.params().getFont().family());
|
||||
if (layout->labelfont.family() == INHERIT_FAMILY)
|
||||
lf.setFamily(buffer.params().getFont().fontInfo().family());
|
||||
return lf;
|
||||
}
|
||||
|
||||
Font font = layout->labelfont;
|
||||
FontInfo font = layout->labelfont;
|
||||
// Realize with the fonts of lesser depth.
|
||||
font.realize(buffer.params().getFont());
|
||||
font.realize(buffer.params().getFont().fontInfo());
|
||||
|
||||
return font;
|
||||
}
|
||||
@ -131,7 +131,7 @@ void Text::setCharFont(Buffer const & buffer, pit_type pit,
|
||||
LayoutPtr const & layout = pars_[pit].layout();
|
||||
|
||||
// Get concrete layout font to reduce against
|
||||
Font layoutfont;
|
||||
FontInfo layoutfont;
|
||||
|
||||
if (pos < pars_[pit].beginOfBody())
|
||||
layoutfont = layout->labelfont;
|
||||
@ -153,12 +153,12 @@ void Text::setCharFont(Buffer const & buffer, pit_type pit,
|
||||
// Inside inset, apply the inset's font attributes if any
|
||||
// (charstyle!)
|
||||
if (!isMainText(buffer))
|
||||
layoutfont.realize(display_font);
|
||||
layoutfont.realize(display_font.fontInfo());
|
||||
|
||||
layoutfont.realize(buffer.params().getFont());
|
||||
layoutfont.realize(buffer.params().getFont().fontInfo());
|
||||
|
||||
// Now, reduce font against full layout font
|
||||
font.reduce(layoutfont);
|
||||
font.fontInfo().reduce(layoutfont);
|
||||
|
||||
pars_[pit].setFont(pos, font);
|
||||
}
|
||||
@ -316,7 +316,7 @@ void Text::setFont(Cursor & cur, Font const & font, bool toggleall)
|
||||
BOOST_ASSERT(this == cur.text());
|
||||
// Set the current_font
|
||||
// Determine basis font
|
||||
Font layoutfont;
|
||||
FontInfo layoutfont;
|
||||
pit_type pit = cur.pit();
|
||||
if (cur.pos() < pars_[pit].beginOfBody())
|
||||
layoutfont = getLabelFont(cur.buffer(), pars_[pit]);
|
||||
@ -330,9 +330,9 @@ void Text::setFont(Cursor & cur, Font const & font, bool toggleall)
|
||||
|
||||
// Reduce to implicit settings
|
||||
cur.current_font = cur.real_current_font;
|
||||
cur.current_font.reduce(layoutfont);
|
||||
cur.current_font.fontInfo().reduce(layoutfont);
|
||||
// And resolve it completely
|
||||
cur.real_current_font.realize(layoutfont);
|
||||
cur.real_current_font.fontInfo().realize(layoutfont);
|
||||
|
||||
// if there is no selection that's all we need to do
|
||||
if (!cur.selection())
|
||||
@ -395,7 +395,7 @@ void Text::toggleFree(Cursor & cur, Font const & font, bool toggleall)
|
||||
{
|
||||
BOOST_ASSERT(this == cur.text());
|
||||
// If the mask is completely neutral, tell user
|
||||
if (font == Font(Font::ALL_IGNORE)) {
|
||||
if (font == ignore_font) {
|
||||
// Could only happen with user style
|
||||
cur.message(_("No font change defined."));
|
||||
return;
|
||||
@ -407,7 +407,7 @@ void Text::toggleFree(Cursor & cur, Font const & font, bool toggleall)
|
||||
CursorSlice resetCursor = cur.top();
|
||||
bool implicitSelection =
|
||||
font.language() == ignore_language
|
||||
&& font.number() == Font::IGNORE
|
||||
&& font.fontInfo().number() == FONT_IGNORE
|
||||
&& selectWordWhenUnderCursor(cur, WHOLE_WORD_STRICT);
|
||||
|
||||
// Set font
|
||||
|
@ -90,7 +90,7 @@ using support::isStrUnsignedInt;
|
||||
using support::token;
|
||||
|
||||
// globals...
|
||||
static Font freefont(Font::ALL_IGNORE);
|
||||
static Font freefont(ignore_font);
|
||||
static bool toggleall = false;
|
||||
|
||||
static void toggleAndShow(Cursor & cur, Text * text,
|
||||
@ -99,7 +99,7 @@ static void toggleAndShow(Cursor & cur, Text * text,
|
||||
text->toggleFree(cur, font, toggleall);
|
||||
|
||||
if (font.language() != ignore_language ||
|
||||
font.number() != Font::IGNORE) {
|
||||
font.fontInfo().number() != FONT_IGNORE) {
|
||||
TextMetrics const & tm = cur.bv().textMetrics(text);
|
||||
if (cur.boundary() != tm.isRTLBoundary(cur.pit(),
|
||||
cur.pos(), cur.real_current_font))
|
||||
@ -246,9 +246,9 @@ string const freefont2string()
|
||||
|
||||
void Text::number(Cursor & cur)
|
||||
{
|
||||
Font font(Font::ALL_IGNORE);
|
||||
font.setNumber(Font::TOGGLE);
|
||||
toggleAndShow(cur, this, font);
|
||||
FontInfo font = ignore_font;
|
||||
font.setNumber(FONT_TOGGLE);
|
||||
toggleAndShow(cur, this, Font(font));
|
||||
}
|
||||
|
||||
|
||||
@ -795,9 +795,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
}
|
||||
|
||||
case LFUN_SERVER_GET_FONT:
|
||||
if (cur.current_font.shape() == Font::ITALIC_SHAPE)
|
||||
if (cur.current_font.fontInfo().shape() == ITALIC_SHAPE)
|
||||
cur.message(from_ascii("E"));
|
||||
else if (cur.current_font.shape() == Font::SMALLCAPS_SHAPE)
|
||||
else if (cur.current_font.fontInfo().shape() == SMALLCAPS_SHAPE)
|
||||
cur.message(from_ascii("N"));
|
||||
else
|
||||
cur.message(from_ascii("0"));
|
||||
@ -1307,63 +1307,63 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
}
|
||||
|
||||
case LFUN_FONT_EMPH: {
|
||||
Font font(Font::ALL_IGNORE);
|
||||
font.setEmph(Font::TOGGLE);
|
||||
Font font(ignore_font);
|
||||
font.fontInfo().setEmph(FONT_TOGGLE);
|
||||
toggleAndShow(cur, this, font);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_FONT_BOLD: {
|
||||
Font font(Font::ALL_IGNORE);
|
||||
font.setSeries(Font::BOLD_SERIES);
|
||||
Font font(ignore_font);
|
||||
font.fontInfo().setSeries(BOLD_SERIES);
|
||||
toggleAndShow(cur, this, font);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_FONT_NOUN: {
|
||||
Font font(Font::ALL_IGNORE);
|
||||
font.setNoun(Font::TOGGLE);
|
||||
Font font(ignore_font);
|
||||
font.fontInfo().setNoun(FONT_TOGGLE);
|
||||
toggleAndShow(cur, this, font);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_FONT_TYPEWRITER: {
|
||||
Font font(Font::ALL_IGNORE);
|
||||
font.setFamily(Font::TYPEWRITER_FAMILY); // no good
|
||||
Font font(ignore_font);
|
||||
font.fontInfo().setFamily(TYPEWRITER_FAMILY); // no good
|
||||
toggleAndShow(cur, this, font);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_FONT_SANS: {
|
||||
Font font(Font::ALL_IGNORE);
|
||||
font.setFamily(Font::SANS_FAMILY);
|
||||
Font font(ignore_font);
|
||||
font.fontInfo().setFamily(SANS_FAMILY);
|
||||
toggleAndShow(cur, this, font);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_FONT_ROMAN: {
|
||||
Font font(Font::ALL_IGNORE);
|
||||
font.setFamily(Font::ROMAN_FAMILY);
|
||||
Font font(ignore_font);
|
||||
font.fontInfo().setFamily(ROMAN_FAMILY);
|
||||
toggleAndShow(cur, this, font);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_FONT_DEFAULT: {
|
||||
Font font(Font::ALL_INHERIT, ignore_language);
|
||||
Font font(inherit_font, ignore_language);
|
||||
toggleAndShow(cur, this, font);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_FONT_UNDERLINE: {
|
||||
Font font(Font::ALL_IGNORE);
|
||||
font.setUnderbar(Font::TOGGLE);
|
||||
Font font(ignore_font);
|
||||
font.fontInfo().setUnderbar(FONT_TOGGLE);
|
||||
toggleAndShow(cur, this, font);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_FONT_SIZE: {
|
||||
Font font(Font::ALL_IGNORE);
|
||||
font.setLyXSize(to_utf8(cmd.argument()));
|
||||
Font font(ignore_font);
|
||||
setLyXSize(to_utf8(cmd.argument()), font.fontInfo());
|
||||
toggleAndShow(cur, this, font);
|
||||
break;
|
||||
}
|
||||
@ -1372,7 +1372,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
Language const * lang = languages.getLanguage(to_utf8(cmd.argument()));
|
||||
if (!lang)
|
||||
break;
|
||||
Font font(Font::ALL_IGNORE);
|
||||
Font font(ignore_font);
|
||||
font.setLanguage(lang);
|
||||
toggleAndShow(cur, this, font);
|
||||
break;
|
||||
@ -1613,6 +1613,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
BOOST_ASSERT(cur.text() == this);
|
||||
|
||||
Font const & font = cur.real_current_font;
|
||||
FontInfo const & fontinfo = font.fontInfo();
|
||||
bool enable = true;
|
||||
InsetCode code = NO_CODE;
|
||||
|
||||
@ -1794,27 +1795,27 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
break;
|
||||
|
||||
case LFUN_FONT_EMPH:
|
||||
flag.setOnOff(font.emph() == Font::ON);
|
||||
flag.setOnOff(fontinfo.emph() == FONT_ON);
|
||||
return true;
|
||||
|
||||
case LFUN_FONT_NOUN:
|
||||
flag.setOnOff(font.noun() == Font::ON);
|
||||
flag.setOnOff(fontinfo.noun() == FONT_ON);
|
||||
return true;
|
||||
|
||||
case LFUN_FONT_BOLD:
|
||||
flag.setOnOff(font.series() == Font::BOLD_SERIES);
|
||||
flag.setOnOff(fontinfo.series() == BOLD_SERIES);
|
||||
return true;
|
||||
|
||||
case LFUN_FONT_SANS:
|
||||
flag.setOnOff(font.family() == Font::SANS_FAMILY);
|
||||
flag.setOnOff(fontinfo.family() == SANS_FAMILY);
|
||||
return true;
|
||||
|
||||
case LFUN_FONT_ROMAN:
|
||||
flag.setOnOff(font.family() == Font::ROMAN_FAMILY);
|
||||
flag.setOnOff(fontinfo.family() == ROMAN_FAMILY);
|
||||
return true;
|
||||
|
||||
case LFUN_FONT_TYPEWRITER:
|
||||
flag.setOnOff(font.family() == Font::TYPEWRITER_FAMILY);
|
||||
flag.setOnOff(fontinfo.family() == TYPEWRITER_FAMILY);
|
||||
return true;
|
||||
|
||||
case LFUN_CUT:
|
||||
|
@ -34,6 +34,12 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using std::endl;
|
||||
using std::find_if;
|
||||
using std::remove_if;
|
||||
using std::string;
|
||||
using std::ostream;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
using support::FileName;
|
||||
@ -44,12 +50,7 @@ using support::rtrim;
|
||||
using support::subst;
|
||||
using support::addName;
|
||||
|
||||
using std::endl;
|
||||
using std::find_if;
|
||||
using std::remove_if;
|
||||
using std::string;
|
||||
using std::ostream;
|
||||
|
||||
extern FontInfo lyxRead(Lexer &);
|
||||
|
||||
namespace {
|
||||
|
||||
@ -113,7 +114,7 @@ TextClass::TextClass(string const & fn, string const & cln,
|
||||
secnumdepth_ = 3;
|
||||
tocdepth_ = 3;
|
||||
pagestyle_ = "default";
|
||||
defaultfont_ = Font(Font::ALL_SANE);
|
||||
defaultfont_ = sane_font;
|
||||
opt_fontsize_ = "10|11|12";
|
||||
opt_pagestyle_ = "empty|plain|headings|fancy";
|
||||
titletype_ = TITLE_COMMAND_AFTER;
|
||||
@ -365,11 +366,11 @@ bool TextClass::read(FileName const & filename, ReadType rt)
|
||||
break;
|
||||
|
||||
case TC_DEFAULTFONT:
|
||||
defaultfont_.lyxRead(lexrc);
|
||||
defaultfont_ = lyxRead(lexrc);
|
||||
if (!defaultfont_.resolved()) {
|
||||
lexrc.printError("Warning: defaultfont should "
|
||||
"be fully instantiated!");
|
||||
defaultfont_.realize(Font(Font::ALL_SANE));
|
||||
defaultfont_.realize(sane_font);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -657,8 +658,8 @@ void TextClass::readInsetLayout(Lexer & lexrc, docstring const & name)
|
||||
string decoration;
|
||||
string latexname;
|
||||
string latexparam;
|
||||
Font font(defaultfont());
|
||||
Font labelfont(defaultfont());
|
||||
FontInfo font(defaultfont());
|
||||
FontInfo labelfont(defaultfont());
|
||||
ColorCode bgcolor(Color_background);
|
||||
string preamble;
|
||||
bool multipar(false);
|
||||
@ -702,7 +703,7 @@ void TextClass::readInsetLayout(Lexer & lexrc, docstring const & name)
|
||||
latexparam = subst(lexrc.getString(), """, "\"");
|
||||
break;
|
||||
case IL_LABELFONT:
|
||||
labelfont.lyxRead(lexrc);
|
||||
labelfont = lyxRead(lexrc);
|
||||
labelfont.realize(defaultfont());
|
||||
break;
|
||||
case IL_MULTIPAR:
|
||||
@ -726,7 +727,7 @@ void TextClass::readInsetLayout(Lexer & lexrc, docstring const & name)
|
||||
needprotect = lexrc.getBool();
|
||||
break;
|
||||
case IL_FONT:
|
||||
font.lyxRead(lexrc);
|
||||
font = lyxRead(lexrc);
|
||||
font.realize(defaultfont());
|
||||
// So: define font before labelfont
|
||||
labelfont = font;
|
||||
@ -963,7 +964,7 @@ void TextClass::readCounter(Lexer & lexrc)
|
||||
}
|
||||
|
||||
|
||||
Font const & TextClass::defaultfont() const
|
||||
FontInfo const & TextClass::defaultfont() const
|
||||
{
|
||||
return defaultfont_;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
#define LYXTEXTCLASS_H
|
||||
|
||||
#include "ColorCode.h"
|
||||
#include "Font.h"
|
||||
#include "FontInfo.h"
|
||||
#include "LayoutEnums.h"
|
||||
#include "LayoutPtr.h"
|
||||
|
||||
@ -43,8 +43,8 @@ public:
|
||||
std::string latextype;
|
||||
std::string latexname;
|
||||
std::string latexparam;
|
||||
Font font;
|
||||
Font labelfont;
|
||||
FontInfo font;
|
||||
FontInfo labelfont;
|
||||
ColorCode bgcolor;
|
||||
std::string preamble;
|
||||
bool multipar;
|
||||
@ -178,7 +178,7 @@ public:
|
||||
OutputType outputType() const;
|
||||
|
||||
///
|
||||
Font const & defaultfont() const;
|
||||
FontInfo const & defaultfont() const;
|
||||
|
||||
/// Text that dictates how wide the left margin is on the screen
|
||||
docstring const & leftmargin() const;
|
||||
@ -241,10 +241,10 @@ private:
|
||||
OutputType outputType_;
|
||||
/** Base font. The paragraph and layout fonts are resolved against
|
||||
this font. This has to be fully instantiated. Attributes
|
||||
Font::INHERIT, Font::IGNORE, and Font::TOGGLE are
|
||||
FONT_INHERIT, FONT_IGNORE, and FONT_TOGGLE are
|
||||
extremely illegal.
|
||||
*/
|
||||
Font defaultfont_;
|
||||
FontInfo defaultfont_;
|
||||
/// Text that dictates how wide the left margin is on the screen
|
||||
docstring leftmargin_;
|
||||
|
||||
|
@ -235,8 +235,8 @@ int TextMetrics::rightMargin(pit_type const pit) const
|
||||
void TextMetrics::applyOuterFont(Font & font) const
|
||||
{
|
||||
Font lf(font_);
|
||||
lf.reduce(bv_->buffer().params().getFont());
|
||||
lf.realize(font);
|
||||
lf.fontInfo().reduce(bv_->buffer().params().getFont().fontInfo());
|
||||
lf.fontInfo().realize(font.fontInfo());
|
||||
lf.setLanguage(font.language());
|
||||
font = lf;
|
||||
}
|
||||
@ -261,21 +261,22 @@ Font TextMetrics::getDisplayFont(pit_type pit, pos_type pos) const
|
||||
applyOuterFont(f);
|
||||
bool lab = layout->labeltype == LABEL_MANUAL && pos < body_pos;
|
||||
|
||||
Font const & lf = lab ? layout->labelfont : layout->font;
|
||||
Font rlf = lab ? layout->reslabelfont : layout->resfont;
|
||||
FontInfo const & lf = lab ? layout->labelfont : layout->font;
|
||||
FontInfo rlf = lab ? layout->reslabelfont : layout->resfont;
|
||||
|
||||
// In case the default family has been customized
|
||||
if (lf.family() == Font::INHERIT_FAMILY)
|
||||
rlf.setFamily(params.getFont().family());
|
||||
return f.realize(rlf);
|
||||
if (lf.family() == INHERIT_FAMILY)
|
||||
rlf.setFamily(params.getFont().fontInfo().family());
|
||||
f.fontInfo().realize(rlf);
|
||||
return f;
|
||||
}
|
||||
|
||||
// The uncommon case need not be optimized as much
|
||||
Font const & layoutfont = pos < body_pos ?
|
||||
FontInfo const & layoutfont = pos < body_pos ?
|
||||
layout->labelfont : layout->font;
|
||||
|
||||
Font font = par.getFontSettings(params, pos);
|
||||
font.realize(layoutfont);
|
||||
font.fontInfo().realize(layoutfont);
|
||||
|
||||
if (!text_->isMainText(buffer))
|
||||
applyOuterFont(font);
|
||||
@ -284,10 +285,10 @@ Font TextMetrics::getDisplayFont(pit_type pit, pos_type pos) const
|
||||
// NOTE: the cast to pit_type should be removed when pit_type
|
||||
// changes to a unsigned integer.
|
||||
if (pit < pit_type(pars.size()))
|
||||
font.realize(outerFont(pit, pars));
|
||||
font.fontInfo().realize(outerFont(pit, pars).fontInfo());
|
||||
|
||||
// Realize with the fonts of lesser depth.
|
||||
font.realize(params.getFont());
|
||||
font.fontInfo().realize(params.getFont().fontInfo());
|
||||
|
||||
return font;
|
||||
}
|
||||
@ -389,7 +390,7 @@ bool TextMetrics::redoParagraph(pit_type const pit)
|
||||
- right_margin;
|
||||
Font const & font = ii->inset->noFontChange() ?
|
||||
bufferfont : getDisplayFont(pit, ii->pos);
|
||||
MetricsInfo mi(bv_, font, w);
|
||||
MetricsInfo mi(bv_, font.fontInfo(), w);
|
||||
ii->inset->metrics(mi, dim);
|
||||
Dimension const old_dim = pm.insetDimension(ii->inset);
|
||||
pm.setInsetDimension(ii->inset, dim);
|
||||
@ -844,12 +845,12 @@ boost::tuple<int, int> TextMetrics::rowHeight(pit_type const pit, pos_type const
|
||||
// often.
|
||||
Buffer const & buffer = bv_->buffer();
|
||||
Font font = getDisplayFont(pit, first);
|
||||
Font::FONT_SIZE const tmpsize = font.size();
|
||||
FontSize const tmpsize = font.fontInfo().size();
|
||||
font = text_->getLayoutFont(buffer, pit);
|
||||
Font::FONT_SIZE const size = font.size();
|
||||
font.setSize(tmpsize);
|
||||
FontSize const size = font.fontInfo().size();
|
||||
font.fontInfo().setSize(tmpsize);
|
||||
|
||||
Font labelfont = text_->getLabelFont(buffer, par);
|
||||
FontInfo labelfont = text_->getLabelFont(buffer, par);
|
||||
|
||||
FontMetrics const & labelfont_metrics = theFontMetrics(labelfont);
|
||||
FontMetrics const & fontmetrics = theFontMetrics(font);
|
||||
@ -878,11 +879,11 @@ boost::tuple<int, int> TextMetrics::rowHeight(pit_type const pit, pos_type const
|
||||
// cosmetic error for now.
|
||||
int labeladdon = 0;
|
||||
|
||||
Font::FONT_SIZE maxsize =
|
||||
FontSize maxsize =
|
||||
par.highestFontInRange(first, end, size);
|
||||
if (maxsize > font.size()) {
|
||||
if (maxsize > font.fontInfo().size()) {
|
||||
// use standard paragraph font with the maximal size
|
||||
Font maxfont = font;
|
||||
FontInfo maxfont = font.fontInfo();
|
||||
maxfont.setSize(maxsize);
|
||||
FontMetrics const & maxfontmetrics = theFontMetrics(maxfont);
|
||||
maxasc = max(maxasc, maxfontmetrics.maxAscent());
|
||||
@ -2130,7 +2131,7 @@ void TextMetrics::drawRowSelection(PainterInfo & pi, int x, Row const & row,
|
||||
|
||||
int defaultRowHeight()
|
||||
{
|
||||
return int(theFontMetrics(Font(Font::ALL_SANE)).maxHeight() * 1.2);
|
||||
return int(theFontMetrics(sane_font).maxHeight() * 1.2);
|
||||
}
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -99,6 +99,12 @@ frontend::FontLoader & theFontLoader()
|
||||
|
||||
|
||||
frontend::FontMetrics const & theFontMetrics(Font const & f)
|
||||
{
|
||||
return theFontMetrics(f.fontInfo());
|
||||
}
|
||||
|
||||
|
||||
frontend::FontMetrics const & theFontMetrics(FontInfo const & f)
|
||||
{
|
||||
static frontend::NoGuiFontMetrics no_gui_font_metrics;
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
namespace lyx {
|
||||
|
||||
class Font;
|
||||
class FontInfo;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
@ -33,10 +33,10 @@ public:
|
||||
virtual void update() = 0;
|
||||
|
||||
/// Is the given font available ?
|
||||
virtual bool available(Font const & f) = 0;
|
||||
virtual bool available(FontInfo const & f) = 0;
|
||||
|
||||
/// Get the Font metrics for this Font
|
||||
virtual FontMetrics const & metrics(Font const & f) = 0;
|
||||
/// Get the Font metrics for this FontInfo
|
||||
virtual FontMetrics const & metrics(FontInfo const & f) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -117,9 +117,11 @@ public:
|
||||
} // namespace frontend
|
||||
|
||||
class Font;
|
||||
class FontInfo;
|
||||
|
||||
/// Implementation is in Application.cpp
|
||||
frontend::FontMetrics const & theFontMetrics(Font const & f);
|
||||
frontend::FontMetrics const & theFontMetrics(FontInfo const & fi);
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
|
@ -32,10 +32,10 @@ public:
|
||||
virtual void update() {};
|
||||
|
||||
/// Is the given font available ?
|
||||
virtual bool available(Font const &) { return false; };
|
||||
virtual bool available(FontInfo const &) { return false; };
|
||||
|
||||
/// Get the Font metrics for this Font
|
||||
virtual FontMetrics const & metrics(Font const &) { return metrics_; }
|
||||
/// Get the Font metrics for this FontInfo
|
||||
virtual FontMetrics const & metrics(FontInfo const &) { return metrics_; }
|
||||
|
||||
private:
|
||||
///
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#include "frontends/FontMetrics.h"
|
||||
|
||||
#include "Font.h"
|
||||
#include "FontInfo.h"
|
||||
|
||||
using lyx::docstring;
|
||||
|
||||
@ -46,7 +46,7 @@ void Painter::buttonFrame(int x, int y, int w, int h)
|
||||
|
||||
void Painter::rectText(int x, int y,
|
||||
docstring const & str,
|
||||
Font const & font,
|
||||
FontInfo const & font,
|
||||
ColorCode back,
|
||||
ColorCode frame)
|
||||
{
|
||||
@ -69,7 +69,7 @@ void Painter::rectText(int x, int y,
|
||||
|
||||
|
||||
void Painter::buttonText(int x, int y, docstring const & str,
|
||||
Font const & font, bool mouseHover)
|
||||
FontInfo const & font, bool mouseHover)
|
||||
{
|
||||
int width;
|
||||
int ascent;
|
||||
@ -84,9 +84,9 @@ void Painter::buttonText(int x, int y, docstring const & str,
|
||||
|
||||
|
||||
int Painter::preeditText(int x, int y, char_type c,
|
||||
Font const & font, preedit_style style)
|
||||
FontInfo const & font, preedit_style style)
|
||||
{
|
||||
Font temp_font = font;
|
||||
FontInfo temp_font = font;
|
||||
FontMetrics const & fm = theFontMetrics(font);
|
||||
int ascent = fm.maxAscent();
|
||||
int descent = fm.maxDescent();
|
||||
@ -116,7 +116,7 @@ int Painter::preeditText(int x, int y, char_type c,
|
||||
}
|
||||
|
||||
|
||||
void Painter::underline(Font const & f, int x, int y, int width)
|
||||
void Painter::underline(FontInfo const & f, int x, int y, int width)
|
||||
{
|
||||
FontMetrics const & fm = theFontMetrics(f);
|
||||
|
||||
@ -130,7 +130,7 @@ void Painter::underline(Font const & f, int x, int y, int width)
|
||||
}
|
||||
|
||||
|
||||
void Painter::dashedUnderline(Font const & f, int x, int y, int width)
|
||||
void Painter::dashedUnderline(FontInfo const & f, int x, int y, int width)
|
||||
{
|
||||
FontMetrics const & fm = theFontMetrics(f);
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
namespace lyx {
|
||||
|
||||
class Font;
|
||||
class FontInfo;
|
||||
|
||||
namespace graphics { class Image; }
|
||||
|
||||
@ -139,7 +139,7 @@ public:
|
||||
* \return the width of the drawn text.
|
||||
*/
|
||||
virtual int text(int x, int y,
|
||||
docstring const & str, Font const & f) = 0;
|
||||
docstring const & str, FontInfo const & f) = 0;
|
||||
|
||||
void setDrawingEnabled(bool drawing_enabled = true)
|
||||
{ drawing_enabled_ = drawing_enabled; }
|
||||
@ -148,7 +148,7 @@ public:
|
||||
/**
|
||||
* \return the width of the drawn text.
|
||||
*/
|
||||
virtual int text(int x, int y, char_type c, Font const & f) = 0;
|
||||
virtual int text(int x, int y, char_type c, FontInfo const & f) = 0;
|
||||
|
||||
/**
|
||||
* Draw a string and enclose it inside a rectangle. If
|
||||
@ -158,25 +158,25 @@ public:
|
||||
*/
|
||||
void rectText(int x, int baseline,
|
||||
docstring const & str,
|
||||
Font const & font,
|
||||
FontInfo const & font,
|
||||
ColorCode back,
|
||||
ColorCode frame);
|
||||
|
||||
/// draw a string and enclose it inside a button frame
|
||||
void buttonText(int x, int baseline, docstring const & s,
|
||||
Font const & font, bool mouseHover);
|
||||
FontInfo const & font, bool mouseHover);
|
||||
|
||||
/// draw a character of a preedit string for cjk support.
|
||||
int preeditText(int x, int y,
|
||||
char_type c, Font const & f, preedit_style style);
|
||||
char_type c, FontInfo const & f, preedit_style style);
|
||||
|
||||
protected:
|
||||
/// check the font, and if set, draw an underline
|
||||
void underline(Font const & f,
|
||||
void underline(FontInfo const & f,
|
||||
int x, int y, int width);
|
||||
|
||||
/// check the font, and if set, draw an dashed underline
|
||||
void dashedUnderline(Font const & f,
|
||||
void dashedUnderline(FontInfo const & f,
|
||||
int x, int y, int width);
|
||||
|
||||
/// draw a bevelled button border
|
||||
|
@ -37,27 +37,27 @@ static vector<ShapePair> const getShapeData()
|
||||
ShapePair pr;
|
||||
|
||||
pr.first = qt_("No change");
|
||||
pr.second = Font::IGNORE_SHAPE;
|
||||
pr.second = IGNORE_SHAPE;
|
||||
shape[0] = pr;
|
||||
|
||||
pr.first = qt_("Upright");
|
||||
pr.second = Font::UP_SHAPE;
|
||||
pr.second = UP_SHAPE;
|
||||
shape[1] = pr;
|
||||
|
||||
pr.first = qt_("Italic");
|
||||
pr.second = Font::ITALIC_SHAPE;
|
||||
pr.second = ITALIC_SHAPE;
|
||||
shape[2] = pr;
|
||||
|
||||
pr.first = qt_("Slanted");
|
||||
pr.second = Font::SLANTED_SHAPE;
|
||||
pr.second = SLANTED_SHAPE;
|
||||
shape[3] = pr;
|
||||
|
||||
pr.first = qt_("Small Caps");
|
||||
pr.second = Font::SMALLCAPS_SHAPE;
|
||||
pr.second = SMALLCAPS_SHAPE;
|
||||
shape[4] = pr;
|
||||
|
||||
pr.first = qt_("Reset");
|
||||
pr.second = Font::INHERIT_SHAPE;
|
||||
pr.second = INHERIT_SHAPE;
|
||||
shape[5] = pr;
|
||||
|
||||
return shape;
|
||||
@ -71,59 +71,59 @@ static vector<SizePair> const getSizeData()
|
||||
SizePair pr;
|
||||
|
||||
pr.first = qt_("No change");
|
||||
pr.second = Font::IGNORE_SIZE;
|
||||
pr.second = FONT_SIZE_IGNORE;
|
||||
size[0] = pr;
|
||||
|
||||
pr.first = qt_("Tiny");
|
||||
pr.second = Font::SIZE_TINY;
|
||||
pr.second = FONT_SIZE_TINY;
|
||||
size[1] = pr;
|
||||
|
||||
pr.first = qt_("Smallest");
|
||||
pr.second = Font::SIZE_SCRIPT;
|
||||
pr.second = FONT_SIZE_SCRIPT;
|
||||
size[2] = pr;
|
||||
|
||||
pr.first = qt_("Smaller");
|
||||
pr.second = Font::SIZE_FOOTNOTE;
|
||||
pr.second = FONT_SIZE_FOOTNOTE;
|
||||
size[3] = pr;
|
||||
|
||||
pr.first = qt_("Small");
|
||||
pr.second = Font::SIZE_SMALL;
|
||||
pr.second = FONT_SIZE_SMALL;
|
||||
size[4] = pr;
|
||||
|
||||
pr.first = qt_("Normal");
|
||||
pr.second = Font::SIZE_NORMAL;
|
||||
pr.second = FONT_SIZE_NORMAL;
|
||||
size[5] = pr;
|
||||
|
||||
pr.first = qt_("Large");
|
||||
pr.second = Font::SIZE_LARGE;
|
||||
pr.second = FONT_SIZE_LARGE;
|
||||
size[6] = pr;
|
||||
|
||||
pr.first = qt_("Larger");
|
||||
pr.second = Font::SIZE_LARGER;
|
||||
pr.second = FONT_SIZE_LARGER;
|
||||
size[7] = pr;
|
||||
|
||||
pr.first = qt_("Largest");
|
||||
pr.second = Font::SIZE_LARGEST;
|
||||
pr.second = FONT_SIZE_LARGEST;
|
||||
size[8] = pr;
|
||||
|
||||
pr.first = qt_("Huge");
|
||||
pr.second = Font::SIZE_HUGE;
|
||||
pr.second = FONT_SIZE_HUGE;
|
||||
size[9] = pr;
|
||||
|
||||
pr.first = qt_("Huger");
|
||||
pr.second = Font::SIZE_HUGER;
|
||||
pr.second = FONT_SIZE_HUGER;
|
||||
size[10] = pr;
|
||||
|
||||
pr.first = qt_("Increase");
|
||||
pr.second = Font::INCREASE_SIZE;
|
||||
pr.second = FONT_SIZE_INCREASE;
|
||||
size[11] = pr;
|
||||
|
||||
pr.first = qt_("Decrease");
|
||||
pr.second = Font::DECREASE_SIZE;
|
||||
pr.second = FONT_SIZE_DECREASE;
|
||||
size[12] = pr;
|
||||
|
||||
pr.first = qt_("Reset");
|
||||
pr.second = Font::INHERIT_SIZE;
|
||||
pr.second = FONT_SIZE_INHERIT;
|
||||
size[13] = pr;
|
||||
|
||||
return size;
|
||||
@ -221,19 +221,19 @@ static vector<SeriesPair> const getSeriesData()
|
||||
SeriesPair pr;
|
||||
|
||||
pr.first = qt_("No change");
|
||||
pr.second = Font::IGNORE_SERIES;
|
||||
pr.second = IGNORE_SERIES;
|
||||
series[0] = pr;
|
||||
|
||||
pr.first = qt_("Medium");
|
||||
pr.second = Font::MEDIUM_SERIES;
|
||||
pr.second = MEDIUM_SERIES;
|
||||
series[1] = pr;
|
||||
|
||||
pr.first = qt_("Bold");
|
||||
pr.second = Font::BOLD_SERIES;
|
||||
pr.second = BOLD_SERIES;
|
||||
series[2] = pr;
|
||||
|
||||
pr.first = qt_("Reset");
|
||||
pr.second = Font::INHERIT_SERIES;
|
||||
pr.second = INHERIT_SERIES;
|
||||
series[3] = pr;
|
||||
|
||||
return series;
|
||||
@ -247,23 +247,23 @@ static vector<FamilyPair> const getFamilyData()
|
||||
FamilyPair pr;
|
||||
|
||||
pr.first = qt_("No change");
|
||||
pr.second = Font::IGNORE_FAMILY;
|
||||
pr.second = IGNORE_FAMILY;
|
||||
family[0] = pr;
|
||||
|
||||
pr.first = qt_("Roman");
|
||||
pr.second = Font::ROMAN_FAMILY;
|
||||
pr.second = ROMAN_FAMILY;
|
||||
family[1] = pr;
|
||||
|
||||
pr.first = qt_("Sans Serif");
|
||||
pr.second = Font::SANS_FAMILY;
|
||||
pr.second = SANS_FAMILY;
|
||||
family[2] = pr;
|
||||
|
||||
pr.first = qt_("Typewriter");
|
||||
pr.second = Font::TYPEWRITER_FAMILY;
|
||||
pr.second = TYPEWRITER_FAMILY;
|
||||
family[3] = pr;
|
||||
|
||||
pr.first = qt_("Reset");
|
||||
pr.second = Font::INHERIT_FAMILY;
|
||||
pr.second = INHERIT_FAMILY;
|
||||
family[4] = pr;
|
||||
|
||||
return family;
|
||||
@ -271,7 +271,7 @@ static vector<FamilyPair> const getFamilyData()
|
||||
|
||||
|
||||
GuiCharacter::GuiCharacter(LyXView & lv)
|
||||
: GuiDialog(lv, "character"), font_(Font::ALL_IGNORE),
|
||||
: GuiDialog(lv, "character"), font_(ignore_font),
|
||||
toggleall_(false), reset_lang_(false)
|
||||
{
|
||||
setupUi(this);
|
||||
@ -425,10 +425,10 @@ void GuiCharacter::applyView()
|
||||
bool GuiCharacter::initialiseParams(string const &)
|
||||
{
|
||||
// so that the user can press Ok
|
||||
if (getFamily() != Font::IGNORE_FAMILY
|
||||
|| getSeries() != Font::IGNORE_SERIES
|
||||
|| getShape() != Font::IGNORE_SHAPE
|
||||
|| getSize() != Font::IGNORE_SIZE
|
||||
if (getFamily() != IGNORE_FAMILY
|
||||
|| getSeries() != IGNORE_SERIES
|
||||
|| getShape() != IGNORE_SHAPE
|
||||
|| getSize() != FONT_SIZE_IGNORE
|
||||
|| getBar() != IGNORE
|
||||
|| getColor() != Color_ignore
|
||||
|| font_.language() != ignore_language)
|
||||
@ -444,68 +444,68 @@ void GuiCharacter::dispatchParams()
|
||||
}
|
||||
|
||||
|
||||
Font::FONT_FAMILY GuiCharacter::getFamily() const
|
||||
FontFamily GuiCharacter::getFamily() const
|
||||
{
|
||||
return font_.family();
|
||||
return font_.fontInfo().family();
|
||||
}
|
||||
|
||||
|
||||
void GuiCharacter::setFamily(Font::FONT_FAMILY val)
|
||||
void GuiCharacter::setFamily(FontFamily val)
|
||||
{
|
||||
font_.setFamily(val);
|
||||
font_.fontInfo().setFamily(val);
|
||||
}
|
||||
|
||||
|
||||
Font::FONT_SERIES GuiCharacter::getSeries() const
|
||||
FontSeries GuiCharacter::getSeries() const
|
||||
{
|
||||
return font_.series();
|
||||
return font_.fontInfo().series();
|
||||
}
|
||||
|
||||
|
||||
void GuiCharacter::setSeries(Font::FONT_SERIES val)
|
||||
void GuiCharacter::setSeries(FontSeries val)
|
||||
{
|
||||
font_.setSeries(val);
|
||||
font_.fontInfo().setSeries(val);
|
||||
}
|
||||
|
||||
|
||||
Font::FONT_SHAPE GuiCharacter::getShape() const
|
||||
FontShape GuiCharacter::getShape() const
|
||||
{
|
||||
return font_.shape();
|
||||
return font_.fontInfo().shape();
|
||||
}
|
||||
|
||||
|
||||
void GuiCharacter::setShape(Font::FONT_SHAPE val)
|
||||
void GuiCharacter::setShape(FontShape val)
|
||||
{
|
||||
font_.setShape(val);
|
||||
font_.fontInfo().setShape(val);
|
||||
}
|
||||
|
||||
|
||||
Font::FONT_SIZE GuiCharacter::getSize() const
|
||||
FontSize GuiCharacter::getSize() const
|
||||
{
|
||||
return font_.size();
|
||||
return font_.fontInfo().size();
|
||||
}
|
||||
|
||||
|
||||
void GuiCharacter::setSize(Font::FONT_SIZE val)
|
||||
void GuiCharacter::setSize(FontSize val)
|
||||
{
|
||||
font_.setSize(val);
|
||||
font_.fontInfo().setSize(val);
|
||||
}
|
||||
|
||||
|
||||
FontState GuiCharacter::getBar() const
|
||||
{
|
||||
if (font_.emph() == Font::TOGGLE)
|
||||
if (font_.fontInfo().emph() == FONT_TOGGLE)
|
||||
return EMPH_TOGGLE;
|
||||
|
||||
if (font_.underbar() == Font::TOGGLE)
|
||||
if (font_.fontInfo().underbar() == FONT_TOGGLE)
|
||||
return UNDERBAR_TOGGLE;
|
||||
|
||||
if (font_.noun() == Font::TOGGLE)
|
||||
if (font_.fontInfo().noun() == FONT_TOGGLE)
|
||||
return NOUN_TOGGLE;
|
||||
|
||||
if (font_.emph() == Font::IGNORE
|
||||
&& font_.underbar() == Font::IGNORE
|
||||
&& font_.noun() == Font::IGNORE)
|
||||
if (font_.fontInfo().emph() == FONT_IGNORE
|
||||
&& font_.fontInfo().underbar() == FONT_IGNORE
|
||||
&& font_.fontInfo().noun() == FONT_IGNORE)
|
||||
return IGNORE;
|
||||
|
||||
return INHERIT;
|
||||
@ -516,27 +516,27 @@ void GuiCharacter::setBar(FontState val)
|
||||
{
|
||||
switch (val) {
|
||||
case IGNORE:
|
||||
font_.setEmph(Font::IGNORE);
|
||||
font_.setUnderbar(Font::IGNORE);
|
||||
font_.setNoun(Font::IGNORE);
|
||||
font_.fontInfo().setEmph(FONT_IGNORE);
|
||||
font_.fontInfo().setUnderbar(FONT_IGNORE);
|
||||
font_.fontInfo().setNoun(FONT_IGNORE);
|
||||
break;
|
||||
|
||||
case EMPH_TOGGLE:
|
||||
font_.setEmph(Font::TOGGLE);
|
||||
font_.fontInfo().setEmph(FONT_TOGGLE);
|
||||
break;
|
||||
|
||||
case UNDERBAR_TOGGLE:
|
||||
font_.setUnderbar(Font::TOGGLE);
|
||||
font_.fontInfo().setUnderbar(FONT_TOGGLE);
|
||||
break;
|
||||
|
||||
case NOUN_TOGGLE:
|
||||
font_.setNoun(Font::TOGGLE);
|
||||
font_.fontInfo().setNoun(FONT_TOGGLE);
|
||||
break;
|
||||
|
||||
case INHERIT:
|
||||
font_.setEmph(Font::INHERIT);
|
||||
font_.setUnderbar(Font::INHERIT);
|
||||
font_.setNoun(Font::INHERIT);
|
||||
font_.fontInfo().setEmph(FONT_INHERIT);
|
||||
font_.fontInfo().setUnderbar(FONT_INHERIT);
|
||||
font_.fontInfo().setNoun(FONT_INHERIT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -544,7 +544,7 @@ void GuiCharacter::setBar(FontState val)
|
||||
|
||||
ColorCode GuiCharacter::getColor() const
|
||||
{
|
||||
return font_.color();
|
||||
return font_.fontInfo().color();
|
||||
}
|
||||
|
||||
|
||||
@ -562,7 +562,7 @@ void GuiCharacter::setColor(ColorCode val)
|
||||
case Color_magenta:
|
||||
case Color_yellow:
|
||||
case Color_inherit:
|
||||
font_.setColor(val);
|
||||
font_.fontInfo().setColor(val);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -39,10 +39,10 @@ enum FontState {
|
||||
INHERIT
|
||||
};
|
||||
|
||||
typedef std::pair<QString, Font::FONT_FAMILY> FamilyPair;
|
||||
typedef std::pair<QString, Font::FONT_SERIES> SeriesPair;
|
||||
typedef std::pair<QString, Font::FONT_SHAPE> ShapePair;
|
||||
typedef std::pair<QString, Font::FONT_SIZE> SizePair;
|
||||
typedef std::pair<QString, FontFamily> FamilyPair;
|
||||
typedef std::pair<QString, FontSeries> SeriesPair;
|
||||
typedef std::pair<QString, FontShape> ShapePair;
|
||||
typedef std::pair<QString, FontSize> SizePair;
|
||||
typedef std::pair<QString, FontState> BarPair;
|
||||
typedef std::pair<QString, ColorCode> ColorPair;
|
||||
|
||||
@ -83,13 +83,13 @@ private:
|
||||
kb_action getLfun() const { return LFUN_FONT_FREE_UPDATE; }
|
||||
|
||||
///
|
||||
void setFamily(Font::FONT_FAMILY);
|
||||
void setFamily(FontFamily);
|
||||
///
|
||||
void setSeries(Font::FONT_SERIES);
|
||||
void setSeries(FontSeries);
|
||||
///
|
||||
void setShape(Font::FONT_SHAPE);
|
||||
void setShape(FontShape);
|
||||
///
|
||||
void setSize(Font::FONT_SIZE);
|
||||
void setSize(FontSize);
|
||||
///
|
||||
void setBar(FontState);
|
||||
///
|
||||
@ -98,13 +98,13 @@ private:
|
||||
void setLanguage(std::string const &);
|
||||
|
||||
///
|
||||
Font::FONT_FAMILY getFamily() const;
|
||||
FontFamily getFamily() const;
|
||||
///
|
||||
Font::FONT_SERIES getSeries() const;
|
||||
FontSeries getSeries() const;
|
||||
///
|
||||
Font::FONT_SHAPE getShape() const;
|
||||
FontShape getShape() const;
|
||||
///
|
||||
Font::FONT_SIZE getSize() const;
|
||||
FontSize getSize() const;
|
||||
///
|
||||
FontState getBar() const;
|
||||
///
|
||||
|
@ -93,7 +93,7 @@ GuiDelimiter::GuiDelimiter(LyXView & lv)
|
||||
QChar(ms.fontcode) : toqstr(docstring(1, ms.unicode)));
|
||||
QListWidgetItem * lwi = new QListWidgetItem(symbol);
|
||||
lwi->setToolTip(toqstr(delim));
|
||||
Font lyxfont;
|
||||
FontInfo lyxfont;
|
||||
lyxfont.setFamily(ms.fontfamily);
|
||||
QFont const & symbol_font = guiApp->guiFontLoader().get(lyxfont);
|
||||
lwi->setFont(symbol_font);
|
||||
|
@ -48,54 +48,57 @@ int const num_math_fonts = sizeof(math_fonts) / sizeof(*math_fonts);
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
extern docstring const stateText(FontInfo const & f);
|
||||
|
||||
namespace frontend {
|
||||
|
||||
namespace {
|
||||
|
||||
struct SymbolFont {
|
||||
Font::FONT_FAMILY lyx_family;
|
||||
FontFamily lyx_family;
|
||||
QString family;
|
||||
QString xlfd;
|
||||
};
|
||||
|
||||
SymbolFont symbol_fonts[] = {
|
||||
{ Font::SYMBOL_FAMILY,
|
||||
{ SYMBOL_FAMILY,
|
||||
"symbol",
|
||||
"-*-symbol-*-*-*-*-*-*-*-*-*-*-adobe-fontspecific" },
|
||||
|
||||
{ Font::CMR_FAMILY,
|
||||
{ CMR_FAMILY,
|
||||
"cmr10",
|
||||
"-*-cmr10-medium-*-*-*-*-*-*-*-*-*-*-*" },
|
||||
|
||||
{ Font::CMSY_FAMILY,
|
||||
{ CMSY_FAMILY,
|
||||
"cmsy10",
|
||||
"-*-cmsy10-*-*-*-*-*-*-*-*-*-*-*-*" },
|
||||
|
||||
{ Font::CMM_FAMILY,
|
||||
{ CMM_FAMILY,
|
||||
"cmmi10",
|
||||
"-*-cmmi10-medium-*-*-*-*-*-*-*-*-*-*-*" },
|
||||
|
||||
{ Font::CMEX_FAMILY,
|
||||
{ CMEX_FAMILY,
|
||||
"cmex10",
|
||||
"-*-cmex10-*-*-*-*-*-*-*-*-*-*-*-*" },
|
||||
|
||||
{ Font::MSA_FAMILY,
|
||||
{ MSA_FAMILY,
|
||||
"msam10",
|
||||
"-*-msam10-*-*-*-*-*-*-*-*-*-*-*-*" },
|
||||
|
||||
{ Font::MSB_FAMILY,
|
||||
{ MSB_FAMILY,
|
||||
"msbm10",
|
||||
"-*-msbm10-*-*-*-*-*-*-*-*-*-*-*-*" },
|
||||
|
||||
{ Font::EUFRAK_FAMILY,
|
||||
{ EUFRAK_FAMILY,
|
||||
"eufm10",
|
||||
"-*-eufm10-medium-*-*-*-*-*-*-*-*-*-*-*" },
|
||||
|
||||
{ Font::WASY_FAMILY,
|
||||
{ WASY_FAMILY,
|
||||
"wasy10",
|
||||
"-*-wasy10-medium-*-*-*-*-*-*-*-*-*-*-*" },
|
||||
|
||||
{ Font::ESINT_FAMILY,
|
||||
{ ESINT_FAMILY,
|
||||
"esint10",
|
||||
"-*-esint10-medium-*-*-*-*-*-*-*-*-*-*-*" }
|
||||
};
|
||||
@ -114,7 +117,7 @@ QString getRawName(QString const & family)
|
||||
}
|
||||
|
||||
|
||||
QString const symbolFamily(Font::FONT_FAMILY family)
|
||||
QString const symbolFamily(FontFamily family)
|
||||
{
|
||||
for (size_t i = 0; i < nr_symbol_fonts; ++i) {
|
||||
if (family == symbol_fonts[i].lyx_family)
|
||||
@ -124,10 +127,10 @@ QString const symbolFamily(Font::FONT_FAMILY family)
|
||||
}
|
||||
|
||||
|
||||
bool isSymbolFamily(Font::FONT_FAMILY family)
|
||||
bool isSymbolFamily(FontFamily family)
|
||||
{
|
||||
return family >= Font::SYMBOL_FAMILY &&
|
||||
family <= Font::ESINT_FAMILY;
|
||||
return family >= SYMBOL_FAMILY &&
|
||||
family <= ESINT_FAMILY;
|
||||
}
|
||||
|
||||
|
||||
@ -209,7 +212,7 @@ GuiFontLoader::GuiFontLoader()
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int i1 = 0; i1 < Font::NUM_FAMILIES; ++i1)
|
||||
for (int i1 = 0; i1 < NUM_FAMILIES; ++i1)
|
||||
for (int i2 = 0; i2 < 2; ++i2)
|
||||
for (int i3 = 0; i3 < 4; ++i3)
|
||||
for (int i4 = 0; i4 < 10; ++i4)
|
||||
@ -219,7 +222,7 @@ GuiFontLoader::GuiFontLoader()
|
||||
|
||||
void GuiFontLoader::update()
|
||||
{
|
||||
for (int i1 = 0; i1 < Font::NUM_FAMILIES; ++i1) {
|
||||
for (int i1 = 0; i1 < NUM_FAMILIES; ++i1) {
|
||||
for (int i2 = 0; i2 < 2; ++i2)
|
||||
for (int i3 = 0; i3 < 4; ++i3)
|
||||
for (int i4 = 0; i4 < 10; ++i4) {
|
||||
@ -242,7 +245,7 @@ static QString makeFontName(QString const & family, QString const & foundry)
|
||||
}
|
||||
|
||||
|
||||
GuiFontInfo::GuiFontInfo(Font const & f)
|
||||
GuiFontInfo::GuiFontInfo(FontInfo const & f)
|
||||
{
|
||||
font.setKerning(false);
|
||||
QString const pat = symbolFamily(f.family());
|
||||
@ -251,7 +254,7 @@ GuiFontInfo::GuiFontInfo(Font const & f)
|
||||
boost::tie(font, tmp) = getSymbolFont(pat);
|
||||
} else {
|
||||
switch (f.family()) {
|
||||
case Font::ROMAN_FAMILY: {
|
||||
case ROMAN_FAMILY: {
|
||||
QString family = makeFontName(toqstr(lyxrc.roman_font_name),
|
||||
toqstr(lyxrc.roman_font_foundry));
|
||||
font.setFamily(family);
|
||||
@ -266,11 +269,11 @@ GuiFontInfo::GuiFontInfo(Font const & f)
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case Font::SANS_FAMILY:
|
||||
case SANS_FAMILY:
|
||||
font.setFamily(makeFontName(toqstr(lyxrc.sans_font_name),
|
||||
toqstr(lyxrc.sans_font_foundry)));
|
||||
break;
|
||||
case Font::TYPEWRITER_FAMILY:
|
||||
case TYPEWRITER_FAMILY:
|
||||
font.setFamily(makeFontName(toqstr(lyxrc.typewriter_font_name),
|
||||
toqstr(lyxrc.typewriter_font_foundry)));
|
||||
break;
|
||||
@ -280,10 +283,10 @@ GuiFontInfo::GuiFontInfo(Font const & f)
|
||||
}
|
||||
|
||||
switch (f.series()) {
|
||||
case Font::MEDIUM_SERIES:
|
||||
case MEDIUM_SERIES:
|
||||
font.setWeight(QFont::Normal);
|
||||
break;
|
||||
case Font::BOLD_SERIES:
|
||||
case BOLD_SERIES:
|
||||
font.setWeight(QFont::Bold);
|
||||
break;
|
||||
default:
|
||||
@ -291,15 +294,15 @@ GuiFontInfo::GuiFontInfo(Font const & f)
|
||||
}
|
||||
|
||||
switch (f.realShape()) {
|
||||
case Font::ITALIC_SHAPE:
|
||||
case Font::SLANTED_SHAPE:
|
||||
case ITALIC_SHAPE:
|
||||
case SLANTED_SHAPE:
|
||||
font.setItalic(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
LYXERR(Debug::FONT) << "Font '" << to_utf8(f.stateText(0))
|
||||
LYXERR(Debug::FONT) << "Font '" << to_utf8(stateText(f))
|
||||
<< "' matched by\n" << fromqstr(font.family()) << endl;
|
||||
|
||||
// Is this an exact match?
|
||||
@ -317,13 +320,13 @@ GuiFontInfo::GuiFontInfo(Font const & f)
|
||||
LYXERR(Debug::FONT) << "The font has size: "
|
||||
<< font.pointSizeF() << endl;
|
||||
|
||||
if (f.realShape() != Font::SMALLCAPS_SHAPE) {
|
||||
if (f.realShape() != SMALLCAPS_SHAPE) {
|
||||
metrics.reset(new GuiFontMetrics(font));
|
||||
}
|
||||
else {
|
||||
// handle small caps ourselves ...
|
||||
Font smallfont = f;
|
||||
smallfont.decSize().decSize().setShape(Font::UP_SHAPE);
|
||||
FontInfo smallfont = f;
|
||||
smallfont.decSize().decSize().setShape(UP_SHAPE);
|
||||
QFont font2(font);
|
||||
font2.setKerning(false);
|
||||
font2.setPointSizeF(convert<double>(lyxrc.font_sizes[smallfont.size()])
|
||||
@ -335,12 +338,12 @@ GuiFontInfo::GuiFontInfo(Font const & f)
|
||||
}
|
||||
|
||||
|
||||
bool GuiFontLoader::available(Font const & f)
|
||||
bool GuiFontLoader::available(FontInfo const & f)
|
||||
{
|
||||
static vector<int> cache_set(Font::NUM_FAMILIES, false);
|
||||
static vector<int> cache(Font::NUM_FAMILIES, false);
|
||||
static vector<int> cache_set(NUM_FAMILIES, false);
|
||||
static vector<int> cache(NUM_FAMILIES, false);
|
||||
|
||||
Font::FONT_FAMILY family = f.family();
|
||||
FontFamily family = f.family();
|
||||
if (cache_set[family])
|
||||
return cache[family];
|
||||
cache_set[family] = true;
|
||||
|
@ -14,10 +14,11 @@
|
||||
|
||||
#include "frontends/FontLoader.h"
|
||||
|
||||
#include "FontInfo.h"
|
||||
|
||||
#include "GuiFontMetrics.h"
|
||||
|
||||
#include "Encoding.h"
|
||||
#include "Font.h"
|
||||
|
||||
#include <QFont>
|
||||
|
||||
@ -33,7 +34,7 @@ namespace frontend {
|
||||
class GuiFontInfo
|
||||
{
|
||||
public:
|
||||
GuiFontInfo(Font const & f);
|
||||
GuiFontInfo(FontInfo const & f);
|
||||
|
||||
/// The font instance
|
||||
QFont font;
|
||||
@ -53,19 +54,19 @@ public:
|
||||
virtual ~GuiFontLoader() {}
|
||||
|
||||
virtual void update();
|
||||
virtual bool available(Font const & f);
|
||||
inline virtual FontMetrics const & metrics(Font const & f) {
|
||||
virtual bool available(FontInfo const & f);
|
||||
inline virtual FontMetrics const & metrics(FontInfo const & f) {
|
||||
return *fontinfo(f).metrics.get();
|
||||
}
|
||||
|
||||
/// Get the QFont for this Font
|
||||
QFont const & get(Font const & f) {
|
||||
/// Get the QFont for this FontInfo
|
||||
QFont const & get(FontInfo const & f) {
|
||||
return fontinfo(f).font;
|
||||
}
|
||||
|
||||
|
||||
/// Get font info (font + metrics) for the given LyX font.
|
||||
GuiFontInfo & fontinfo(Font const & f) {
|
||||
GuiFontInfo & fontinfo(FontInfo const & f) {
|
||||
// fi is a reference to the pointer type (GuiFontInfo *) in the
|
||||
// fontinfo_ table.
|
||||
GuiFontInfo * & fi =
|
||||
@ -77,7 +78,7 @@ public:
|
||||
|
||||
private:
|
||||
/// BUTT ugly !
|
||||
GuiFontInfo * fontinfo_[Font::NUM_FAMILIES][2][4][10];
|
||||
GuiFontInfo * fontinfo_[NUM_FAMILIES][2][4][10];
|
||||
};
|
||||
|
||||
|
||||
|
@ -35,25 +35,25 @@ GuiMath::GuiMath(LyXView & lv, std::string const & name)
|
||||
math_symbols_["["] = MathSymbol('[');
|
||||
math_symbols_["]"] = MathSymbol(']');
|
||||
math_symbols_["|"] = MathSymbol('|');
|
||||
math_symbols_["/"] = MathSymbol('/', 54, Font::CMSY_FAMILY);
|
||||
math_symbols_["backslash"] = MathSymbol('\\', 110, Font::CMSY_FAMILY);
|
||||
math_symbols_["lceil"] = MathSymbol(0x2308, 100, Font::CMSY_FAMILY);
|
||||
math_symbols_["rceil"] = MathSymbol(0x2309, 101, Font::CMSY_FAMILY);
|
||||
math_symbols_["lfloor"] = MathSymbol(0x230A, 98, Font::CMSY_FAMILY);
|
||||
math_symbols_["rfloor"] = MathSymbol(0x230B, 99, Font::CMSY_FAMILY);
|
||||
math_symbols_["langle"] = MathSymbol(0x2329, 104, Font::CMSY_FAMILY);
|
||||
math_symbols_["rangle"] = MathSymbol(0x232A, 105, Font::CMSY_FAMILY);
|
||||
math_symbols_["uparrow"] = MathSymbol(0x2191, 34, Font::CMSY_FAMILY);
|
||||
math_symbols_["Uparrow"] = MathSymbol(0x21D1, 42, Font::CMSY_FAMILY);
|
||||
math_symbols_["updownarrow"] = MathSymbol(0x2195, 108, Font::CMSY_FAMILY);
|
||||
math_symbols_["Updownarrow"] = MathSymbol(0x21D5, 109, Font::CMSY_FAMILY);
|
||||
math_symbols_["downarrow"] = MathSymbol(0x2193, 35, Font::CMSY_FAMILY);
|
||||
math_symbols_["Downarrow"] = MathSymbol(0x21D3, 43, Font::CMSY_FAMILY);
|
||||
math_symbols_["downdownarrows"] = MathSymbol(0x21CA, 184, Font::MSA_FAMILY);
|
||||
math_symbols_["downharpoonleft"] = MathSymbol(0x21C3, 188, Font::MSA_FAMILY);
|
||||
math_symbols_["downharpoonright"] = MathSymbol(0x21C2, 186, Font::MSA_FAMILY);
|
||||
math_symbols_["vert"] = MathSymbol(0x007C, 106, Font::CMSY_FAMILY);
|
||||
math_symbols_["Vert"] = MathSymbol(0x2016, 107, Font::CMSY_FAMILY);
|
||||
math_symbols_["/"] = MathSymbol('/', 54, CMSY_FAMILY);
|
||||
math_symbols_["backslash"] = MathSymbol('\\', 110, CMSY_FAMILY);
|
||||
math_symbols_["lceil"] = MathSymbol(0x2308, 100, CMSY_FAMILY);
|
||||
math_symbols_["rceil"] = MathSymbol(0x2309, 101, CMSY_FAMILY);
|
||||
math_symbols_["lfloor"] = MathSymbol(0x230A, 98, CMSY_FAMILY);
|
||||
math_symbols_["rfloor"] = MathSymbol(0x230B, 99, CMSY_FAMILY);
|
||||
math_symbols_["langle"] = MathSymbol(0x2329, 104, CMSY_FAMILY);
|
||||
math_symbols_["rangle"] = MathSymbol(0x232A, 105, CMSY_FAMILY);
|
||||
math_symbols_["uparrow"] = MathSymbol(0x2191, 34, CMSY_FAMILY);
|
||||
math_symbols_["Uparrow"] = MathSymbol(0x21D1, 42, CMSY_FAMILY);
|
||||
math_symbols_["updownarrow"] = MathSymbol(0x2195, 108, CMSY_FAMILY);
|
||||
math_symbols_["Updownarrow"] = MathSymbol(0x21D5, 109, CMSY_FAMILY);
|
||||
math_symbols_["downarrow"] = MathSymbol(0x2193, 35, CMSY_FAMILY);
|
||||
math_symbols_["Downarrow"] = MathSymbol(0x21D3, 43, CMSY_FAMILY);
|
||||
math_symbols_["downdownarrows"] = MathSymbol(0x21CA, 184, MSA_FAMILY);
|
||||
math_symbols_["downharpoonleft"] = MathSymbol(0x21C3, 188, MSA_FAMILY);
|
||||
math_symbols_["downharpoonright"] = MathSymbol(0x21C2, 186, MSA_FAMILY);
|
||||
math_symbols_["vert"] = MathSymbol(0x007C, 106, CMSY_FAMILY);
|
||||
math_symbols_["Vert"] = MathSymbol(0x2016, 107, CMSY_FAMILY);
|
||||
|
||||
std::map<string, MathSymbol>::const_iterator it = math_symbols_.begin();
|
||||
std::map<string, MathSymbol>::const_iterator end = math_symbols_.end();
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include "GuiDialog.h"
|
||||
#include "lfuns.h" // for kb_action
|
||||
#include "Font.h"
|
||||
#include "FontEnums.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
@ -24,12 +24,12 @@ namespace frontend {
|
||||
|
||||
struct MathSymbol {
|
||||
MathSymbol(char_type uc = '?', unsigned char fc = 0,
|
||||
Font::FONT_FAMILY ff = Font::SYMBOL_FAMILY)
|
||||
FontFamily ff = SYMBOL_FAMILY)
|
||||
: unicode(uc), fontcode(fc), fontfamily(ff)
|
||||
{}
|
||||
char_type unicode;
|
||||
unsigned char fontcode;
|
||||
Font::FONT_FAMILY fontfamily;
|
||||
FontFamily fontfamily;
|
||||
};
|
||||
|
||||
|
||||
|
@ -46,7 +46,7 @@ namespace {
|
||||
|
||||
bool const usePixmapCache = USE_PIXMAP_CACHE;
|
||||
|
||||
QString generateStringSignature(QString const & str, Font const & f)
|
||||
QString generateStringSignature(QString const & str, FontInfo const & f)
|
||||
{
|
||||
QString sig = str;
|
||||
sig.append(QChar(static_cast<short>(f.family())));
|
||||
@ -207,7 +207,7 @@ void GuiPainter::image(int x, int y, int w, int h, graphics::Image const & i)
|
||||
}
|
||||
|
||||
|
||||
int GuiPainter::text(int x, int y, char_type c, Font const & f)
|
||||
int GuiPainter::text(int x, int y, char_type c, FontInfo const & f)
|
||||
{
|
||||
docstring s(1, c);
|
||||
return text(x, y, s, f);
|
||||
@ -215,10 +215,10 @@ int GuiPainter::text(int x, int y, char_type c, Font const & f)
|
||||
|
||||
|
||||
int GuiPainter::smallCapsText(int x, int y,
|
||||
QString const & s, Font const & f)
|
||||
QString const & s, FontInfo const & f)
|
||||
{
|
||||
Font smallfont(f);
|
||||
smallfont.decSize().decSize().setShape(Font::UP_SHAPE);
|
||||
FontInfo smallfont(f);
|
||||
smallfont.decSize().decSize().setShape(UP_SHAPE);
|
||||
|
||||
QFont const & qfont = guiApp->guiFontLoader().get(f);
|
||||
QFont const & qsmallfont = guiApp->guiFontLoader().get(smallfont);
|
||||
@ -242,7 +242,7 @@ int GuiPainter::smallCapsText(int x, int y,
|
||||
|
||||
|
||||
int GuiPainter::text(int x, int y, docstring const & s,
|
||||
Font const & f)
|
||||
FontInfo const & f)
|
||||
{
|
||||
if (s.empty())
|
||||
return 0;
|
||||
@ -271,9 +271,9 @@ int GuiPainter::text(int x, int y, docstring const & s,
|
||||
|
||||
int textwidth;
|
||||
|
||||
if (f.realShape() == Font::SMALLCAPS_SHAPE) {
|
||||
if (f.realShape() == SMALLCAPS_SHAPE) {
|
||||
textwidth = smallCapsText(x, y, str, f);
|
||||
if (f.underbar() == Font::ON)
|
||||
if (f.underbar() == FONT_ON)
|
||||
underline(f, x, y, textwidth);
|
||||
return textwidth;
|
||||
}
|
||||
@ -282,7 +282,7 @@ int GuiPainter::text(int x, int y, docstring const & s,
|
||||
// textwidth = fontMetrics().width(str);
|
||||
// because the above is awfully expensive on MacOSX
|
||||
textwidth = fi.metrics->width(s);
|
||||
if (f.underbar() == Font::ON)
|
||||
if (f.underbar() == FONT_ON)
|
||||
underline(f, x, y, textwidth);
|
||||
|
||||
if (!isDrawingEnabled())
|
||||
|
@ -21,7 +21,7 @@ class QString;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
class Font;
|
||||
class FontInfo;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
@ -88,10 +88,10 @@ public:
|
||||
|
||||
/// draw a string at position x, y (y is the baseline)
|
||||
virtual int text(int x, int y,
|
||||
docstring const & str, Font const & f);
|
||||
docstring const & str, FontInfo const & f);
|
||||
|
||||
/// draw a char at position x, y (y is the baseline)
|
||||
virtual int text(int x, int y, char_type c, Font const & f);
|
||||
virtual int text(int x, int y, char_type c, FontInfo const & f);
|
||||
|
||||
private:
|
||||
/// draw small caps text
|
||||
@ -99,7 +99,7 @@ private:
|
||||
\return width of the drawn text.
|
||||
*/
|
||||
int smallCapsText(int x, int y,
|
||||
QString const & str, Font const & f);
|
||||
QString const & str, FontInfo const & f);
|
||||
|
||||
/// set pen parameters
|
||||
void setQPainterPen(ColorCode col,
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "Color.h"
|
||||
#include "ConverterCache.h"
|
||||
#include "debug.h"
|
||||
#include "Font.h"
|
||||
#include "FuncRequest.h"
|
||||
#include "gettext.h"
|
||||
#include "GuiFontExample.h"
|
||||
@ -474,16 +473,16 @@ void PrefScreenFonts::apply(LyXRC & rc) const
|
||||
|
||||
rc.zoom = screenZoomSB->value();
|
||||
rc.dpi = screenDpiSB->value();
|
||||
rc.font_sizes[Font::SIZE_TINY] = fromqstr(screenTinyED->text());
|
||||
rc.font_sizes[Font::SIZE_SCRIPT] = fromqstr(screenSmallestED->text());
|
||||
rc.font_sizes[Font::SIZE_FOOTNOTE] = fromqstr(screenSmallerED->text());
|
||||
rc.font_sizes[Font::SIZE_SMALL] = fromqstr(screenSmallED->text());
|
||||
rc.font_sizes[Font::SIZE_NORMAL] = fromqstr(screenNormalED->text());
|
||||
rc.font_sizes[Font::SIZE_LARGE] = fromqstr(screenLargeED->text());
|
||||
rc.font_sizes[Font::SIZE_LARGER] = fromqstr(screenLargerED->text());
|
||||
rc.font_sizes[Font::SIZE_LARGEST] = fromqstr(screenLargestED->text());
|
||||
rc.font_sizes[Font::SIZE_HUGE] = fromqstr(screenHugeED->text());
|
||||
rc.font_sizes[Font::SIZE_HUGER] = fromqstr(screenHugerED->text());
|
||||
rc.font_sizes[FONT_SIZE_TINY] = fromqstr(screenTinyED->text());
|
||||
rc.font_sizes[FONT_SIZE_SCRIPT] = fromqstr(screenSmallestED->text());
|
||||
rc.font_sizes[FONT_SIZE_FOOTNOTE] = fromqstr(screenSmallerED->text());
|
||||
rc.font_sizes[FONT_SIZE_SMALL] = fromqstr(screenSmallED->text());
|
||||
rc.font_sizes[FONT_SIZE_NORMAL] = fromqstr(screenNormalED->text());
|
||||
rc.font_sizes[FONT_SIZE_LARGE] = fromqstr(screenLargeED->text());
|
||||
rc.font_sizes[FONT_SIZE_LARGER] = fromqstr(screenLargerED->text());
|
||||
rc.font_sizes[FONT_SIZE_LARGEST] = fromqstr(screenLargestED->text());
|
||||
rc.font_sizes[FONT_SIZE_HUGE] = fromqstr(screenHugeED->text());
|
||||
rc.font_sizes[FONT_SIZE_HUGER] = fromqstr(screenHugerED->text());
|
||||
|
||||
if (rc.font_sizes != oldrc.font_sizes
|
||||
|| rc.roman_font_name != oldrc.roman_font_name
|
||||
@ -515,16 +514,16 @@ void PrefScreenFonts::update(LyXRC const & rc)
|
||||
|
||||
screenZoomSB->setValue(rc.zoom);
|
||||
screenDpiSB->setValue(rc.dpi);
|
||||
screenTinyED->setText(toqstr(rc.font_sizes[Font::SIZE_TINY]));
|
||||
screenSmallestED->setText(toqstr(rc.font_sizes[Font::SIZE_SCRIPT]));
|
||||
screenSmallerED->setText(toqstr(rc.font_sizes[Font::SIZE_FOOTNOTE]));
|
||||
screenSmallED->setText(toqstr(rc.font_sizes[Font::SIZE_SMALL]));
|
||||
screenNormalED->setText(toqstr(rc.font_sizes[Font::SIZE_NORMAL]));
|
||||
screenLargeED->setText(toqstr(rc.font_sizes[Font::SIZE_LARGE]));
|
||||
screenLargerED->setText(toqstr(rc.font_sizes[Font::SIZE_LARGER]));
|
||||
screenLargestED->setText(toqstr(rc.font_sizes[Font::SIZE_LARGEST]));
|
||||
screenHugeED->setText(toqstr(rc.font_sizes[Font::SIZE_HUGE]));
|
||||
screenHugerED->setText(toqstr(rc.font_sizes[Font::SIZE_HUGER]));
|
||||
screenTinyED->setText(toqstr(rc.font_sizes[FONT_SIZE_TINY]));
|
||||
screenSmallestED->setText(toqstr(rc.font_sizes[FONT_SIZE_SCRIPT]));
|
||||
screenSmallerED->setText(toqstr(rc.font_sizes[FONT_SIZE_FOOTNOTE]));
|
||||
screenSmallED->setText(toqstr(rc.font_sizes[FONT_SIZE_SMALL]));
|
||||
screenNormalED->setText(toqstr(rc.font_sizes[FONT_SIZE_NORMAL]));
|
||||
screenLargeED->setText(toqstr(rc.font_sizes[FONT_SIZE_LARGE]));
|
||||
screenLargerED->setText(toqstr(rc.font_sizes[FONT_SIZE_LARGER]));
|
||||
screenLargestED->setText(toqstr(rc.font_sizes[FONT_SIZE_LARGEST]));
|
||||
screenHugeED->setText(toqstr(rc.font_sizes[FONT_SIZE_HUGE]));
|
||||
screenHugerED->setText(toqstr(rc.font_sizes[FONT_SIZE_HUGER]));
|
||||
}
|
||||
|
||||
|
||||
|
@ -101,7 +101,7 @@ public:
|
||||
// The font used to display the version info
|
||||
font.setStyleHint(QFont::SansSerif);
|
||||
font.setWeight(QFont::Bold);
|
||||
font.setPointSize(convert<int>(lyxrc.font_sizes[Font::SIZE_LARGE]));
|
||||
font.setPointSize(convert<int>(lyxrc.font_sizes[FONT_SIZE_LARGE]));
|
||||
pain.setFont(font);
|
||||
pain.drawText(260, 270, text);
|
||||
}
|
||||
|
@ -570,7 +570,7 @@ void GuiWorkArea::inputMethodEvent(QInputMethodEvent * e)
|
||||
GuiPainter pain(&screen_);
|
||||
buffer_view_->updateMetrics(false);
|
||||
buffer_view_->draw(pain);
|
||||
Font font = buffer_view_->cursor().getFont();
|
||||
FontInfo font = buffer_view_->cursor().getFont().fontInfo();
|
||||
FontMetrics const & fm = theFontMetrics(font);
|
||||
int height = fm.maxHeight();
|
||||
int cur_x = cursor_->rect().left();
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "Counters.h"
|
||||
#include "DispatchResult.h"
|
||||
#include "FuncRequest.h"
|
||||
#include "Font.h"
|
||||
#include "InsetIterator.h"
|
||||
#include "InsetList.h"
|
||||
#include "Lexer.h"
|
||||
@ -149,11 +148,10 @@ docstring const bibitemWidest(Buffer const & buffer)
|
||||
It is very important that the result of this function is the same both with
|
||||
and without GUI. After thinking about this it is clear that no Font
|
||||
metrics should be used here, since these come from the gui. If we can't
|
||||
easily get the LaTeX font metrics we should make our own poor mans front
|
||||
easily get the LaTeX font metrics we should make our own poor mans font
|
||||
metrics replacement, e.g. by hardcoding the metrics of the standard TeX
|
||||
font.
|
||||
*/
|
||||
Font font;
|
||||
|
||||
ParagraphList::const_iterator it = buffer.paragraphs().begin();
|
||||
ParagraphList::const_iterator end = buffer.paragraphs().end();
|
||||
|
@ -142,7 +142,7 @@ void InsetBox::read(Buffer const & buf, Lexer & lex)
|
||||
|
||||
void InsetBox::setButtonLabel()
|
||||
{
|
||||
Font font(Font::ALL_SANE);
|
||||
FontInfo font = sane_font;
|
||||
font.decSize();
|
||||
font.decSize();
|
||||
|
||||
|
@ -127,8 +127,8 @@ void InsetCaption::addToToc(TocList & toclist, Buffer const & buf, ParConstItera
|
||||
|
||||
void InsetCaption::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
Font tmpfont = mi.base.font;
|
||||
mi.base.font = mi.base.bv->buffer().params().getFont();
|
||||
FontInfo tmpfont = mi.base.font;
|
||||
mi.base.font = mi.base.bv->buffer().params().getFont().fontInfo();
|
||||
labelwidth_ = theFontMetrics(mi.base.font).width(full_label_);
|
||||
// add some space to separate the label from the inset text
|
||||
labelwidth_ += 2 * TEXT_TO_INSET_OFFSET;
|
||||
@ -155,8 +155,8 @@ void InsetCaption::draw(PainterInfo & pi, int x, int y) const
|
||||
|
||||
// Answer: the text inset (in buffer_funcs.cpp: setCaption).
|
||||
|
||||
Font tmpfont = pi.base.font;
|
||||
pi.base.font = pi.base.bv->buffer().params().getFont();
|
||||
FontInfo tmpfont = pi.base.font;
|
||||
pi.base.font = pi.base.bv->buffer().params().getFont().fontInfo();
|
||||
pi.pain.text(x, y, full_label_, pi.base.font);
|
||||
InsetText::draw(pi, x + labelwidth_, y);
|
||||
pi.base.font = tmpfont;
|
||||
|
@ -185,8 +185,8 @@ void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
case SubLabel: {
|
||||
InsetText::metrics(mi, dim);
|
||||
// consider width of the inset label
|
||||
Font font(layout_.labelfont);
|
||||
font.realize(Font(Font::ALL_SANE));
|
||||
FontInfo font(layout_.labelfont);
|
||||
font.realize(sane_font);
|
||||
font.decSize();
|
||||
font.decSize();
|
||||
int w = 0;
|
||||
@ -309,8 +309,8 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
|
||||
|
||||
// the label below the text. Can be toggled.
|
||||
if (geometry() == SubLabel) {
|
||||
Font font(layout_.labelfont);
|
||||
font.realize(Font(Font::ALL_SANE));
|
||||
FontInfo font(layout_.labelfont);
|
||||
font.realize(sane_font);
|
||||
font.decSize();
|
||||
font.decSize();
|
||||
int w = 0;
|
||||
@ -682,7 +682,7 @@ void InsetCollapsable::setStatus(Cursor & cur, CollapseStatus status)
|
||||
}
|
||||
|
||||
|
||||
void InsetCollapsable::setLabelFont(Font const & font)
|
||||
void InsetCollapsable::setLabelFont(FontInfo const & font)
|
||||
{
|
||||
layout_.labelfont = font;
|
||||
}
|
||||
|
@ -19,16 +19,16 @@
|
||||
#include "TextClass.h"
|
||||
|
||||
#include "Box.h"
|
||||
#include "Font.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace lyx {
|
||||
|
||||
class Text;
|
||||
class Paragraph;
|
||||
class CursorSlice;
|
||||
class FontInfo;
|
||||
class InsetLayout;
|
||||
class Paragraph;
|
||||
class Text;
|
||||
|
||||
namespace frontend { class Painter; }
|
||||
|
||||
@ -74,7 +74,7 @@ public:
|
||||
///
|
||||
virtual void setButtonLabel() {}
|
||||
///
|
||||
void setLabelFont(Font const & f);
|
||||
void setLabelFont(FontInfo const & f);
|
||||
///
|
||||
bool isOpen() const { return geometry() != ButtonOnly; }
|
||||
///
|
||||
|
@ -85,7 +85,7 @@ InsetERT::InsetERT(BufferParams const & bp,
|
||||
Language const *, string const & contents, CollapseStatus status)
|
||||
: InsetCollapsable(bp, status)
|
||||
{
|
||||
Font font(Font::ALL_INHERIT, latex_language);
|
||||
Font font(FONT_INHERIT, latex_language);
|
||||
paragraphs().begin()->insert(0, contents, font);
|
||||
|
||||
// the init has to be after the initialization of the paragraph
|
||||
@ -103,7 +103,7 @@ InsetERT::~InsetERT()
|
||||
|
||||
void InsetERT::resetParagraphsFont()
|
||||
{
|
||||
Font font(Font::ALL_INHERIT, latex_language);
|
||||
Font font(inherit_font, latex_language);
|
||||
ParagraphList::iterator par = paragraphs().begin();
|
||||
ParagraphList::iterator const end = paragraphs().end();
|
||||
while (par != end) {
|
||||
@ -287,7 +287,7 @@ bool InsetERT::insetAllowed(InsetCode /* code */) const
|
||||
|
||||
void InsetERT::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
Font tmpfont = mi.base.font;
|
||||
FontInfo tmpfont = mi.base.font;
|
||||
getDrawFont(mi.base.font);
|
||||
mi.base.font.realize(tmpfont);
|
||||
InsetCollapsable::metrics(mi, dim);
|
||||
@ -297,7 +297,7 @@ void InsetERT::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
|
||||
void InsetERT::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
Font tmpfont = pi.base.font;
|
||||
FontInfo tmpfont = pi.base.font;
|
||||
getDrawFont(pi.base.font);
|
||||
pi.base.font.realize(tmpfont);
|
||||
const_cast<InsetERT &>(*this).setButtonLabel();
|
||||
@ -313,9 +313,9 @@ bool InsetERT::showInsetDialog(BufferView * bv) const
|
||||
}
|
||||
|
||||
|
||||
void InsetERT::getDrawFont(Font & font) const
|
||||
void InsetERT::getDrawFont(FontInfo & font) const
|
||||
{
|
||||
font = Font(Font::ALL_INHERIT, latex_language);
|
||||
font = inherit_font;
|
||||
font.realize(layout_.font);
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ public:
|
||||
///
|
||||
bool showInsetDialog(BufferView *) const;
|
||||
///
|
||||
void getDrawFont(Font &) const;
|
||||
void getDrawFont(FontInfo &) const;
|
||||
///
|
||||
bool forceDefaultParagraphs(idx_type) const { return true; }
|
||||
/// should paragraph indendation be ommitted in any case?
|
||||
|
@ -97,9 +97,9 @@ void InsetFlex::read(Buffer const & buf, Lexer & lex)
|
||||
|
||||
void InsetFlex::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
Font tmpfont = mi.base.font;
|
||||
FontInfo tmpfont = mi.base.font;
|
||||
getDrawFont(mi.base.font);
|
||||
mi.base.font.reduce(Font(Font::ALL_SANE));
|
||||
mi.base.font.reduce(sane_font);
|
||||
mi.base.font.realize(tmpfont);
|
||||
InsetCollapsable::metrics(mi, dim);
|
||||
mi.base.font = tmpfont;
|
||||
@ -108,7 +108,7 @@ void InsetFlex::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
|
||||
void InsetFlex::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
Font tmpfont = pi.base.font;
|
||||
FontInfo tmpfont = pi.base.font;
|
||||
getDrawFont(pi.base.font);
|
||||
// I don't understand why the above .reduce and .realize aren't
|
||||
//needed, or even wanted, here. It just works. -- MV 10.04.2005
|
||||
@ -117,7 +117,7 @@ void InsetFlex::draw(PainterInfo & pi, int x, int y) const
|
||||
}
|
||||
|
||||
|
||||
void InsetFlex::getDrawFont(Font & font) const
|
||||
void InsetFlex::getDrawFont(FontInfo & font) const
|
||||
{
|
||||
font = layout_.font;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public:
|
||||
///
|
||||
void draw(PainterInfo &, int, int) const;
|
||||
///
|
||||
void getDrawFont(Font &) const;
|
||||
void getDrawFont(FontInfo &) const;
|
||||
///
|
||||
bool forceDefaultParagraphs(idx_type) const { return true; }
|
||||
|
||||
|
@ -114,7 +114,7 @@ InsetFloat::InsetFloat(BufferParams const & bp, string const & type)
|
||||
: InsetCollapsable(bp), name_(from_utf8(type))
|
||||
{
|
||||
setLabel(_("float: ") + floatName(type, bp));
|
||||
Font font(Font::ALL_SANE);
|
||||
FontInfo font = sane_font;
|
||||
font.decSize();
|
||||
font.decSize();
|
||||
font.setColor(Color_collapsable);
|
||||
|
@ -33,8 +33,8 @@ InsetFootlike::InsetFootlike(InsetFootlike const & in)
|
||||
|
||||
void InsetFootlike::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
Font tmpfont = mi.base.font;
|
||||
mi.base.font = mi.base.bv->buffer().params().getFont();
|
||||
FontInfo tmpfont = mi.base.font;
|
||||
mi.base.font = mi.base.bv->buffer().params().getFont().fontInfo();
|
||||
InsetCollapsable::metrics(mi, dim);
|
||||
mi.base.font = tmpfont;
|
||||
}
|
||||
@ -42,8 +42,8 @@ void InsetFootlike::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
|
||||
void InsetFootlike::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
Font tmpfont = pi.base.font;
|
||||
pi.base.font = pi.base.bv->buffer().params().getFont();
|
||||
FontInfo tmpfont = pi.base.font;
|
||||
pi.base.font = pi.base.bv->buffer().params().getFont().fontInfo();
|
||||
InsetCollapsable::draw(pi, x, y);
|
||||
pi.base.font = tmpfont;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ void InsetIndex::write(Buffer const & buf, std::ostream & os) const
|
||||
|
||||
void InsetIndex::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
Font tmpfont = mi.base.font;
|
||||
FontInfo tmpfont = mi.base.font;
|
||||
getDrawFont(mi.base.font);
|
||||
mi.base.font.realize(tmpfont);
|
||||
InsetCollapsable::metrics(mi, dim);
|
||||
@ -75,7 +75,7 @@ void InsetIndex::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
|
||||
void InsetIndex::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
Font tmpfont = pi.base.font;
|
||||
FontInfo tmpfont = pi.base.font;
|
||||
getDrawFont(pi.base.font);
|
||||
pi.base.font.realize(tmpfont);
|
||||
InsetCollapsable::draw(pi, x, y);
|
||||
@ -83,9 +83,9 @@ void InsetIndex::draw(PainterInfo & pi, int x, int y) const
|
||||
}
|
||||
|
||||
|
||||
void InsetIndex::getDrawFont(Font & font) const
|
||||
void InsetIndex::getDrawFont(FontInfo & font) const
|
||||
{
|
||||
font = Font(Font::ALL_INHERIT);
|
||||
font = inherit_font;
|
||||
font.realize(layout_.font);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
///
|
||||
docstring name() const { return from_ascii("Index"); }
|
||||
///
|
||||
void getDrawFont(Font &) const;
|
||||
void getDrawFont(FontInfo &) const;
|
||||
///
|
||||
void write(Buffer const & buf, std::ostream & os) const;
|
||||
///
|
||||
|
@ -13,10 +13,11 @@
|
||||
#include "InsetLine.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "Text.h"
|
||||
#include "Font.h"
|
||||
#include "MetricsInfo.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "OutputParams.h"
|
||||
#include "Text.h"
|
||||
|
||||
#include "frontends/Painter.h"
|
||||
|
||||
|
@ -47,7 +47,7 @@ char const lstinline_delimiters[] =
|
||||
void InsetListings::init()
|
||||
{
|
||||
setButtonLabel();
|
||||
Font font(Font::ALL_SANE);
|
||||
FontInfo font = sane_font;
|
||||
font.decSize();
|
||||
font.decSize();
|
||||
font.setColor(Color_none);
|
||||
@ -279,7 +279,7 @@ void InsetListings::setButtonLabel()
|
||||
|
||||
void InsetListings::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
Font tmpfont = mi.base.font;
|
||||
FontInfo tmpfont = mi.base.font;
|
||||
getDrawFont(mi.base.font);
|
||||
mi.base.font.realize(tmpfont);
|
||||
InsetCollapsable::metrics(mi, dim);
|
||||
@ -289,7 +289,7 @@ void InsetListings::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
|
||||
void InsetListings::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
Font tmpfont = pi.base.font;
|
||||
FontInfo tmpfont = pi.base.font;
|
||||
getDrawFont(pi.base.font);
|
||||
pi.base.font.realize(tmpfont);
|
||||
InsetCollapsable::draw(pi, x, y);
|
||||
@ -311,10 +311,10 @@ bool InsetListings::showInsetDialog(BufferView * bv) const
|
||||
}
|
||||
|
||||
|
||||
void InsetListings::getDrawFont(Font & font) const
|
||||
void InsetListings::getDrawFont(FontInfo & font) const
|
||||
{
|
||||
font = Font(Font::ALL_INHERIT, latex_language);
|
||||
font.setFamily(Font::TYPEWRITER_FAMILY);
|
||||
font = inherit_font;
|
||||
font.setFamily(TYPEWRITER_FAMILY);
|
||||
// FIXME: define Color_listing?
|
||||
font.setColor(Color_foreground);
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
///
|
||||
bool showInsetDialog(BufferView *) const;
|
||||
///
|
||||
void getDrawFont(Font &) const;
|
||||
void getDrawFont(FontInfo &) const;
|
||||
///
|
||||
InsetListingsParams const & params() const { return params_; }
|
||||
///
|
||||
|
@ -22,7 +22,7 @@ namespace lyx {
|
||||
InsetOptArg::InsetOptArg(BufferParams const & ins)
|
||||
: InsetCollapsable(ins)
|
||||
{
|
||||
Font font(Font::ALL_SANE);
|
||||
FontInfo font = sane_font;
|
||||
font.setColor(Color_collapsable);
|
||||
setLabelFont(font);
|
||||
setLabel(_("opt"));
|
||||
@ -32,7 +32,7 @@ InsetOptArg::InsetOptArg(BufferParams const & ins)
|
||||
InsetOptArg::InsetOptArg(InsetOptArg const & in)
|
||||
: InsetCollapsable(in)
|
||||
{
|
||||
Font font(Font::ALL_SANE);
|
||||
FontInfo font = sane_font;
|
||||
font.setColor(Color_collapsable);
|
||||
setLabelFont(font);
|
||||
setLabel(_("opt"));
|
||||
|
@ -52,7 +52,7 @@ void InsetPagebreak::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
|
||||
void InsetPagebreak::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
Font font;
|
||||
FontInfo font;
|
||||
font.setColor(Color_pagebreak);
|
||||
font.decSize();
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "Buffer.h"
|
||||
#include "BufferParams.h"
|
||||
#include "BufferView.h"
|
||||
#include "debug.h"
|
||||
#include "Language.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
@ -216,14 +217,16 @@ docstring const InsetQuotes::dispString(Language const * loclang) const
|
||||
|
||||
void InsetQuotes::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
Font & font = mi.base.font;
|
||||
FontInfo & font = mi.base.font;
|
||||
frontend::FontMetrics const & fm =
|
||||
theFontMetrics(font);
|
||||
dim.asc = fm.maxAscent();
|
||||
dim.des = fm.maxDescent();
|
||||
dim.wid = 0;
|
||||
|
||||
docstring const text = dispString(font.language());
|
||||
// FIXME: should we add a language or a font parameter member?
|
||||
docstring const text = dispString(
|
||||
mi.base.bv->buffer().params().language);
|
||||
for (string::size_type i = 0; i < text.length(); ++i) {
|
||||
if (text[i] == ' ')
|
||||
dim.wid += fm.width('i');
|
||||
@ -235,22 +238,11 @@ void InsetQuotes::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
Font const InsetQuotes::convertFont(Font const & f) const
|
||||
{
|
||||
#if 1
|
||||
return f;
|
||||
#else
|
||||
Font font(f);
|
||||
return font;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void InsetQuotes::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
docstring const text = dispString(pi.base.font.language());
|
||||
// FIXME: should we add a language or a font parameter member?
|
||||
docstring const text = dispString(
|
||||
pi.base.bv->buffer().params().language);
|
||||
|
||||
if (text.length() == 2 && text[0] == text[1]) {
|
||||
pi.pain.text(x, y, text[0], pi.base.font);
|
||||
|
@ -79,10 +79,6 @@ public:
|
||||
void metrics(MetricsInfo &, Dimension &) const;
|
||||
///
|
||||
void draw(PainterInfo & pi, int x, int y) const;
|
||||
#if 0
|
||||
///
|
||||
Font const convertFont(Font const & font) const;
|
||||
#endif
|
||||
///
|
||||
void write(Buffer const &, std::ostream &) const;
|
||||
///
|
||||
|
@ -66,7 +66,7 @@ void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
|
||||
void InsetSpecialChar::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
Font font = pi.base.font;
|
||||
FontInfo font = pi.base.font;
|
||||
|
||||
switch (kind_) {
|
||||
case HYPHENATION:
|
||||
|
@ -173,7 +173,7 @@ void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
//lyxerr << "InsetText::metrics: width: " << mi.base.textwidth << endl;
|
||||
|
||||
// Hand font through to contained lyxtext:
|
||||
tm.font_ = mi.base.font;
|
||||
tm.font_.fontInfo() = mi.base.font;
|
||||
mi.base.textwidth -= 2 * TEXT_TO_INSET_OFFSET;
|
||||
if (hasFixedWidth())
|
||||
tm.metrics(mi, dim, mi.base.textwidth);
|
||||
|
@ -13,7 +13,6 @@
|
||||
#define INSETTEXT_H
|
||||
|
||||
#include "Inset.h"
|
||||
#include "Font.h"
|
||||
#include "Text.h"
|
||||
|
||||
#include "support/types.h"
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
#include "debug.h"
|
||||
#include "gettext.h"
|
||||
#include "Font.h"
|
||||
#include "FontInfo.h"
|
||||
#include "Text.h"
|
||||
#include "MetricsInfo.h"
|
||||
|
||||
@ -40,7 +40,7 @@ Inset.heorem::InsetTheorem()
|
||||
: InsetCollapsable()
|
||||
{
|
||||
setLabel(_("theorem"));
|
||||
Font font(Font::ALL_SANE);
|
||||
FontInfo font = sane_font;
|
||||
font.decSize();
|
||||
font.decSize();
|
||||
font.setColor(Color_collapsable);
|
||||
|
@ -123,7 +123,7 @@ void InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
if (space_.length().len().value() >= 0.0)
|
||||
height = max(height, space_.inPixels(*mi.base.bv));
|
||||
|
||||
Font font;
|
||||
FontInfo font;
|
||||
font.decSize();
|
||||
font.decSize();
|
||||
|
||||
@ -175,7 +175,7 @@ void InsetVSpace::draw(PainterInfo & pi, int x, int y) const
|
||||
int a = 0;
|
||||
int d = 0;
|
||||
|
||||
Font font;
|
||||
FontInfo font;
|
||||
font.setColor(Color_added_space);
|
||||
font.decSize();
|
||||
font.decSize();
|
||||
|
@ -46,7 +46,7 @@ InsetWrap::InsetWrap(BufferParams const & bp, string const & type)
|
||||
: InsetCollapsable(bp), name_(from_utf8(type))
|
||||
{
|
||||
setLabel(_("wrap: ") + floatName(type, bp));
|
||||
Font font(Font::ALL_SANE);
|
||||
FontInfo font = sane_font;
|
||||
font.decSize();
|
||||
font.decSize();
|
||||
font.setColor(Color_collapsable);
|
||||
|
@ -41,7 +41,7 @@ void RenderButton::update(docstring const & text, bool editable)
|
||||
|
||||
void RenderButton::metrics(MetricsInfo &, Dimension & dim) const
|
||||
{
|
||||
Font font(Font::ALL_SANE);
|
||||
FontInfo font = sane_font;
|
||||
font.decSize();
|
||||
frontend::FontMetrics const & fm =
|
||||
theFontMetrics(font);
|
||||
@ -59,7 +59,7 @@ void RenderButton::metrics(MetricsInfo &, Dimension & dim) const
|
||||
void RenderButton::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
// Draw it as a box with the LaTeX text
|
||||
Font font(Font::ALL_SANE);
|
||||
FontInfo font = sane_font;
|
||||
font.setColor(Color_command);
|
||||
font.decSize();
|
||||
|
||||
|
@ -151,21 +151,21 @@ void RenderGraphic::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
} else {
|
||||
int font_width = 0;
|
||||
|
||||
Font msgFont(mi.base.font);
|
||||
msgFont.setFamily(Font::SANS_FAMILY);
|
||||
FontInfo msgFont(mi.base.font);
|
||||
msgFont.setFamily(SANS_FAMILY);
|
||||
|
||||
// FIXME UNICODE
|
||||
docstring const justname =
|
||||
from_utf8(onlyFilename(params_.filename.absFilename()));
|
||||
if (!justname.empty()) {
|
||||
msgFont.setSize(Font::SIZE_FOOTNOTE);
|
||||
msgFont.setSize(FONT_SIZE_FOOTNOTE);
|
||||
font_width = theFontMetrics(msgFont)
|
||||
.width(justname);
|
||||
}
|
||||
|
||||
docstring const msg = statusMessage(params_, loader_.status());
|
||||
if (!msg.empty()) {
|
||||
msgFont.setSize(Font::SIZE_TINY);
|
||||
msgFont.setSize(FONT_SIZE_TINY);
|
||||
font_width = std::max(font_width,
|
||||
theFontMetrics(msgFont).width(msg));
|
||||
}
|
||||
@ -204,12 +204,12 @@ void RenderGraphic::draw(PainterInfo & pi, int x, int y) const
|
||||
Color_foreground);
|
||||
|
||||
// Print the file name.
|
||||
Font msgFont = pi.base.font;
|
||||
msgFont.setFamily(Font::SANS_FAMILY);
|
||||
FontInfo msgFont = pi.base.font;
|
||||
msgFont.setFamily(SANS_FAMILY);
|
||||
string const justname = onlyFilename(params_.filename.absFilename());
|
||||
|
||||
if (!justname.empty()) {
|
||||
msgFont.setSize(Font::SIZE_FOOTNOTE);
|
||||
msgFont.setSize(FONT_SIZE_FOOTNOTE);
|
||||
pi.pain.text(x + Inset::TEXT_TO_INSET_OFFSET + 6,
|
||||
y - theFontMetrics(msgFont).maxAscent() - 4,
|
||||
from_utf8(justname), msgFont);
|
||||
@ -218,7 +218,7 @@ void RenderGraphic::draw(PainterInfo & pi, int x, int y) const
|
||||
// Print the message.
|
||||
docstring const msg = statusMessage(params_, loader_.status());
|
||||
if (!msg.empty()) {
|
||||
msgFont.setSize(Font::SIZE_TINY);
|
||||
msgFont.setSize(FONT_SIZE_TINY);
|
||||
pi.pain.text(x + Inset::TEXT_TO_INSET_OFFSET + 6,
|
||||
y - 4, msg, msgFont);
|
||||
}
|
||||
|
@ -133,9 +133,9 @@ void RenderPreview::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
dim.asc = 50;
|
||||
dim.des = 0;
|
||||
|
||||
Font font(mi.base.font);
|
||||
font.setFamily(Font::SANS_FAMILY);
|
||||
font.setSize(Font::SIZE_FOOTNOTE);
|
||||
FontInfo font(mi.base.font);
|
||||
font.setFamily(SANS_FAMILY);
|
||||
font.setSize(FONT_SIZE_FOOTNOTE);
|
||||
docstring const stat = statusMessage(mi.base.bv, snippet_);
|
||||
dim.wid = 15 + theFontMetrics(font).width(stat);
|
||||
}
|
||||
@ -165,9 +165,9 @@ void RenderPreview::draw(PainterInfo & pi, int x, int y) const
|
||||
dim_.asc + dim_.des,
|
||||
Color_foreground);
|
||||
|
||||
Font font(pi.base.font);
|
||||
font.setFamily(Font::SANS_FAMILY);
|
||||
font.setSize(Font::SIZE_FOOTNOTE);
|
||||
FontInfo font(pi.base.font);
|
||||
font.setFamily(SANS_FAMILY);
|
||||
font.setSize(FONT_SIZE_FOOTNOTE);
|
||||
|
||||
docstring const stat = statusMessage(pi.base.bv, snippet_);
|
||||
pi.pain.text(x + offset + 6,
|
||||
|
@ -56,7 +56,7 @@ void InsetMathBrace::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
|
||||
void InsetMathBrace::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
Font font = pi.base.font;
|
||||
FontInfo font = pi.base.font;
|
||||
font.setColor(Color_latex);
|
||||
Dimension t = theFontMetrics(font).dimension('{');
|
||||
pi.pain.text(x, y, '{', font);
|
||||
|
@ -66,7 +66,7 @@ void InsetMathChar::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
FontSetChanger dummy(mi.base, "cmm");
|
||||
dim = theFontMetrics(mi.base.font).dimension(char_);
|
||||
} else if (!slanted(char_) && mi.base.fontname == "mathnormal") {
|
||||
ShapeChanger dummy(mi.base.font, Font::UP_SHAPE);
|
||||
ShapeChanger dummy(mi.base.font, UP_SHAPE);
|
||||
dim = theFontMetrics(mi.base.font).dimension(char_);
|
||||
} else {
|
||||
frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
|
||||
@ -106,7 +106,7 @@ void InsetMathChar::draw(PainterInfo & pi, int x, int y) const
|
||||
FontSetChanger dummy(pi.base, "cmm");
|
||||
pi.draw(x, y, char_);
|
||||
} else if (!slanted(char_) && pi.base.fontname == "mathnormal") {
|
||||
ShapeChanger dummy(pi.base.font, Font::UP_SHAPE);
|
||||
ShapeChanger dummy(pi.base.font, UP_SHAPE);
|
||||
pi.draw(x, y, char_);
|
||||
} else {
|
||||
pi.draw(x, y, char_);
|
||||
|
@ -14,8 +14,6 @@
|
||||
|
||||
#include "InsetMath.h"
|
||||
|
||||
#include "Font.h"
|
||||
|
||||
namespace lyx {
|
||||
|
||||
/// The base character inset.
|
||||
|
@ -121,21 +121,21 @@ void InsetMathFrac::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
|
||||
if (kind_ == UNIT || (kind_ == UNITFRAC && nargs() == 3)) {
|
||||
if (nargs() == 1) {
|
||||
ShapeChanger dummy2(mi.base.font, Font::UP_SHAPE);
|
||||
ShapeChanger dummy2(mi.base.font, UP_SHAPE);
|
||||
cell(0).metrics(mi, dim0);
|
||||
dim.wid = dim0.width()+ 3;
|
||||
dim.asc = dim0.asc;
|
||||
dim.des = dim0.des;
|
||||
} else if (nargs() == 2) {
|
||||
cell(0).metrics(mi, dim0);
|
||||
ShapeChanger dummy2(mi.base.font, Font::UP_SHAPE);
|
||||
ShapeChanger dummy2(mi.base.font, UP_SHAPE);
|
||||
cell(1).metrics(mi, dim1);
|
||||
dim.wid = dim0.width() + dim1.wid + 5;
|
||||
dim.asc = std::max(dim0.asc, dim1.asc);
|
||||
dim.des = std::max(dim0.des, dim1.des);
|
||||
} else {
|
||||
cell(2).metrics(mi, dim2);
|
||||
ShapeChanger dummy2(mi.base.font, Font::UP_SHAPE);
|
||||
ShapeChanger dummy2(mi.base.font, UP_SHAPE);
|
||||
FracChanger dummy(mi.base);
|
||||
cell(0).metrics(mi, dim0);
|
||||
cell(1).metrics(mi, dim1);
|
||||
@ -155,7 +155,7 @@ void InsetMathFrac::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
dim.asc = dim0.height() + 5;
|
||||
dim.des = dim1.height() - 5;
|
||||
} else if (kind_ == UNITFRAC) {
|
||||
ShapeChanger dummy2(mi.base.font, Font::UP_SHAPE);
|
||||
ShapeChanger dummy2(mi.base.font, UP_SHAPE);
|
||||
dim.wid = dim0.width() + dim1.wid + 5;
|
||||
dim.asc = dim0.height() + 5;
|
||||
dim.des = dim1.height() - 5;
|
||||
@ -179,15 +179,15 @@ void InsetMathFrac::draw(PainterInfo & pi, int x, int y) const
|
||||
int m = x + dim.wid / 2;
|
||||
if (kind_ == UNIT || (kind_ == UNITFRAC && nargs() == 3)) {
|
||||
if (nargs() == 1) {
|
||||
ShapeChanger dummy2(pi.base.font, Font::UP_SHAPE);
|
||||
ShapeChanger dummy2(pi.base.font, UP_SHAPE);
|
||||
cell(0).draw(pi, x + 1, y);
|
||||
} else if (nargs() == 2) {
|
||||
cell(0).draw(pi, x + 1, y);
|
||||
ShapeChanger dummy2(pi.base.font, Font::UP_SHAPE);
|
||||
ShapeChanger dummy2(pi.base.font, UP_SHAPE);
|
||||
cell(1).draw(pi, x + dim0.width() + 5, y);
|
||||
} else {
|
||||
cell(2).draw(pi, x + 1, y);
|
||||
ShapeChanger dummy2(pi.base.font, Font::UP_SHAPE);
|
||||
ShapeChanger dummy2(pi.base.font, UP_SHAPE);
|
||||
FracChanger dummy(pi.base);
|
||||
Dimension const dim1 = cell(1).dimension(*pi.base.bv);
|
||||
Dimension const dim2 = cell(2).dimension(*pi.base.bv);
|
||||
@ -206,7 +206,7 @@ void InsetMathFrac::draw(PainterInfo & pi, int x, int y) const
|
||||
cell(1).draw(pi, x + dim0.width() + 5,
|
||||
y + dim1.asc / 2);
|
||||
} else if (kind_ == UNITFRAC) {
|
||||
ShapeChanger dummy2(pi.base.font, Font::UP_SHAPE);
|
||||
ShapeChanger dummy2(pi.base.font, UP_SHAPE);
|
||||
cell(0).draw(pi, x + 2,
|
||||
y - dim0.des - 5);
|
||||
cell(1).draw(pi, x + dim0.width() + 5,
|
||||
|
@ -158,7 +158,7 @@ InsetMathHull::InsetMathHull()
|
||||
//lyxerr << "sizeof InsetMath: " << sizeof(InsetMath) << endl;
|
||||
//lyxerr << "sizeof MetricsInfo: " << sizeof(MetricsInfo) << endl;
|
||||
//lyxerr << "sizeof InsetMathChar: " << sizeof(InsetMathChar) << endl;
|
||||
//lyxerr << "sizeof Font: " << sizeof(Font) << endl;
|
||||
//lyxerr << "sizeof FontInfo: " << sizeof(FontInfo) << endl;
|
||||
initMath();
|
||||
setDefaults();
|
||||
}
|
||||
@ -1301,8 +1301,8 @@ void InsetMathHull::handleFont2(Cursor & cur, docstring const & arg)
|
||||
Font font;
|
||||
bool b;
|
||||
font.fromString(to_utf8(arg), b);
|
||||
if (font.color() != Color_inherit) {
|
||||
MathAtom at = MathAtom(new InsetMathColor(true, font.color()));
|
||||
if (font.fontInfo().color() != Color_inherit) {
|
||||
MathAtom at = MathAtom(new InsetMathColor(true, font.fontInfo().color()));
|
||||
cur.handleNest(at, 0);
|
||||
}
|
||||
}
|
||||
|
@ -431,8 +431,8 @@ void InsetMathNest::handleFont2(Cursor & cur, docstring const & arg)
|
||||
Font font;
|
||||
bool b;
|
||||
font.fromString(to_utf8(arg), b);
|
||||
if (font.color() != Color_inherit) {
|
||||
MathAtom at = MathAtom(new InsetMathColor(true, font.color()));
|
||||
if (font.fontInfo().color() != Color_inherit) {
|
||||
MathAtom at = MathAtom(new InsetMathColor(true, font.fontInfo().color()));
|
||||
cur.handleNest(at, 0);
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,6 @@
|
||||
|
||||
#include "InsetMath.h"
|
||||
|
||||
#include "Font.h"
|
||||
|
||||
namespace lyx {
|
||||
|
||||
class latexkeys;
|
||||
|
@ -84,7 +84,7 @@ WordList theWordList;
|
||||
|
||||
bool math_font_available(docstring & name)
|
||||
{
|
||||
Font f;
|
||||
FontInfo f;
|
||||
augmentFont(f, name);
|
||||
|
||||
// Do we have the font proper?
|
||||
|
@ -120,7 +120,7 @@ void MathMacro::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
if (macro.locked()) {
|
||||
mathed_string_dim(mi.base.font, "Self reference: " + name(), dim);
|
||||
} else if (editing(mi.base.bv)) {
|
||||
Font font = mi.base.font;
|
||||
FontInfo font = mi.base.font;
|
||||
augmentFont(font, from_ascii("lyxtex"));
|
||||
tmpl_.metrics(mi, dim);
|
||||
// FIXME UNICODE
|
||||
@ -164,7 +164,7 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const
|
||||
// FIXME UNICODE
|
||||
drawStrRed(pi, x, y, "Self reference: " + name());
|
||||
} else if (editing_) {
|
||||
Font font = pi.base.font;
|
||||
FontInfo font = pi.base.font;
|
||||
augmentFont(font, from_ascii("lyxtex"));
|
||||
Dimension const dim = dimension(*pi.base.bv);
|
||||
Dimension const & dim_tmpl = tmpl_.dimension(*pi.base.bv);
|
||||
|
@ -143,7 +143,7 @@ void MathMacroTemplate::draw(PainterInfo & p, int x, int y) const
|
||||
Dimension const dim = dimension(*p.base.bv);
|
||||
|
||||
// label
|
||||
Font font = p.base.font;
|
||||
FontInfo font = p.base.font;
|
||||
font.setColor(Color_math);
|
||||
|
||||
PainterInfo pi(p.base.bv, p.pain);
|
||||
|
@ -368,20 +368,20 @@ deco_struct const * search_deco(docstring const & name)
|
||||
} // namespace anon
|
||||
|
||||
|
||||
int mathed_char_width(Font const & font, char_type c)
|
||||
int mathed_char_width(FontInfo const & font, char_type c)
|
||||
{
|
||||
return theFontMetrics(font).width(c);
|
||||
}
|
||||
|
||||
|
||||
int mathed_char_kerning(Font const & font, char_type c)
|
||||
int mathed_char_kerning(FontInfo const & font, char_type c)
|
||||
{
|
||||
frontend::FontMetrics const & fm = theFontMetrics(font);
|
||||
return fm.rbearing(c) - fm.width(c);
|
||||
}
|
||||
|
||||
|
||||
void mathed_string_dim(Font const & font,
|
||||
void mathed_string_dim(FontInfo const & font,
|
||||
docstring const & s,
|
||||
Dimension & dim)
|
||||
{
|
||||
@ -398,7 +398,7 @@ void mathed_string_dim(Font const & font,
|
||||
}
|
||||
|
||||
|
||||
int mathed_string_width(Font const & font, docstring const & s)
|
||||
int mathed_string_width(FontInfo const & font, docstring const & s)
|
||||
{
|
||||
return theFontMetrics(font).width(s);
|
||||
}
|
||||
@ -476,7 +476,7 @@ void mathed_draw_deco(PainterInfo & pi, int x, int y, int w, int h,
|
||||
|
||||
void drawStrRed(PainterInfo & pi, int x, int y, docstring const & str)
|
||||
{
|
||||
Font f = pi.base.font;
|
||||
FontInfo f = pi.base.font;
|
||||
f.setColor(Color_latex);
|
||||
pi.pain.text(x, y, str, f);
|
||||
}
|
||||
@ -484,13 +484,13 @@ void drawStrRed(PainterInfo & pi, int x, int y, docstring const & str)
|
||||
|
||||
void drawStrBlack(PainterInfo & pi, int x, int y, docstring const & str)
|
||||
{
|
||||
Font f = pi.base.font;
|
||||
FontInfo f = pi.base.font;
|
||||
f.setColor(Color_foreground);
|
||||
pi.pain.text(x, y, str, f);
|
||||
}
|
||||
|
||||
|
||||
void math_font_max_dim(Font const & font, int & asc, int & des)
|
||||
void math_font_max_dim(FontInfo const & font, int & asc, int & des)
|
||||
{
|
||||
frontend::FontMetrics const & fm = theFontMetrics(font);
|
||||
asc = fm.maxAscent();
|
||||
@ -500,82 +500,82 @@ void math_font_max_dim(Font const & font, int & asc, int & des)
|
||||
|
||||
struct fontinfo {
|
||||
std::string cmd_;
|
||||
Font::FONT_FAMILY family_;
|
||||
Font::FONT_SERIES series_;
|
||||
Font::FONT_SHAPE shape_;
|
||||
FontFamily family_;
|
||||
FontSeries series_;
|
||||
FontShape shape_;
|
||||
ColorCode color_;
|
||||
};
|
||||
|
||||
|
||||
Font::FONT_FAMILY const inh_family = Font::INHERIT_FAMILY;
|
||||
Font::FONT_SERIES const inh_series = Font::INHERIT_SERIES;
|
||||
Font::FONT_SHAPE const inh_shape = Font::INHERIT_SHAPE;
|
||||
FontFamily const inh_family = INHERIT_FAMILY;
|
||||
FontSeries const inh_series = INHERIT_SERIES;
|
||||
FontShape const inh_shape = INHERIT_SHAPE;
|
||||
|
||||
|
||||
// mathnormal should be the first, otherwise the fallback further down
|
||||
// does not work
|
||||
fontinfo fontinfos[] = {
|
||||
// math fonts
|
||||
{"mathnormal", Font::ROMAN_FAMILY, Font::MEDIUM_SERIES,
|
||||
Font::ITALIC_SHAPE, Color_math},
|
||||
{"mathbf", inh_family, Font::BOLD_SERIES,
|
||||
{"mathnormal", ROMAN_FAMILY, MEDIUM_SERIES,
|
||||
ITALIC_SHAPE, Color_math},
|
||||
{"mathbf", inh_family, BOLD_SERIES,
|
||||
inh_shape, Color_math},
|
||||
{"mathcal", Font::CMSY_FAMILY, inh_series,
|
||||
{"mathcal", CMSY_FAMILY, inh_series,
|
||||
inh_shape, Color_math},
|
||||
{"mathfrak", Font::EUFRAK_FAMILY, inh_series,
|
||||
{"mathfrak", EUFRAK_FAMILY, inh_series,
|
||||
inh_shape, Color_math},
|
||||
{"mathrm", Font::ROMAN_FAMILY, inh_series,
|
||||
Font::UP_SHAPE, Color_math},
|
||||
{"mathsf", Font::SANS_FAMILY, inh_series,
|
||||
{"mathrm", ROMAN_FAMILY, inh_series,
|
||||
UP_SHAPE, Color_math},
|
||||
{"mathsf", SANS_FAMILY, inh_series,
|
||||
inh_shape, Color_math},
|
||||
{"mathbb", Font::MSB_FAMILY, inh_series,
|
||||
{"mathbb", MSB_FAMILY, inh_series,
|
||||
inh_shape, Color_math},
|
||||
{"mathtt", Font::TYPEWRITER_FAMILY, inh_series,
|
||||
{"mathtt", TYPEWRITER_FAMILY, inh_series,
|
||||
inh_shape, Color_math},
|
||||
{"mathit", inh_family, inh_series,
|
||||
Font::ITALIC_SHAPE, Color_math},
|
||||
{"cmex", Font::CMEX_FAMILY, inh_series,
|
||||
ITALIC_SHAPE, Color_math},
|
||||
{"cmex", CMEX_FAMILY, inh_series,
|
||||
inh_shape, Color_math},
|
||||
{"cmm", Font::CMM_FAMILY, inh_series,
|
||||
{"cmm", CMM_FAMILY, inh_series,
|
||||
inh_shape, Color_math},
|
||||
{"cmr", Font::CMR_FAMILY, inh_series,
|
||||
{"cmr", CMR_FAMILY, inh_series,
|
||||
inh_shape, Color_math},
|
||||
{"cmsy", Font::CMSY_FAMILY, inh_series,
|
||||
{"cmsy", CMSY_FAMILY, inh_series,
|
||||
inh_shape, Color_math},
|
||||
{"eufrak", Font::EUFRAK_FAMILY, inh_series,
|
||||
{"eufrak", EUFRAK_FAMILY, inh_series,
|
||||
inh_shape, Color_math},
|
||||
{"msa", Font::MSA_FAMILY, inh_series,
|
||||
{"msa", MSA_FAMILY, inh_series,
|
||||
inh_shape, Color_math},
|
||||
{"msb", Font::MSB_FAMILY, inh_series,
|
||||
{"msb", MSB_FAMILY, inh_series,
|
||||
inh_shape, Color_math},
|
||||
{"wasy", Font::WASY_FAMILY, inh_series,
|
||||
{"wasy", WASY_FAMILY, inh_series,
|
||||
inh_shape, Color_math},
|
||||
{"esint", Font::ESINT_FAMILY, inh_series,
|
||||
{"esint", ESINT_FAMILY, inh_series,
|
||||
inh_shape, Color_math},
|
||||
|
||||
// Text fonts
|
||||
{"text", inh_family, inh_series,
|
||||
inh_shape, Color_foreground},
|
||||
{"textbf", inh_family, Font::BOLD_SERIES,
|
||||
{"textbf", inh_family, BOLD_SERIES,
|
||||
inh_shape, Color_foreground},
|
||||
{"textit", inh_family, inh_series,
|
||||
Font::ITALIC_SHAPE, Color_foreground},
|
||||
{"textmd", inh_family, Font::MEDIUM_SERIES,
|
||||
ITALIC_SHAPE, Color_foreground},
|
||||
{"textmd", inh_family, MEDIUM_SERIES,
|
||||
inh_shape, Color_foreground},
|
||||
{"textnormal", inh_family, inh_series,
|
||||
Font::UP_SHAPE, Color_foreground},
|
||||
{"textrm", Font::ROMAN_FAMILY,
|
||||
inh_series, Font::UP_SHAPE,Color_foreground},
|
||||
UP_SHAPE, Color_foreground},
|
||||
{"textrm", ROMAN_FAMILY,
|
||||
inh_series, UP_SHAPE,Color_foreground},
|
||||
{"textsc", inh_family, inh_series,
|
||||
Font::SMALLCAPS_SHAPE, Color_foreground},
|
||||
{"textsf", Font::SANS_FAMILY, inh_series,
|
||||
SMALLCAPS_SHAPE, Color_foreground},
|
||||
{"textsf", SANS_FAMILY, inh_series,
|
||||
inh_shape, Color_foreground},
|
||||
{"textsl", inh_family, inh_series,
|
||||
Font::SLANTED_SHAPE, Color_foreground},
|
||||
{"texttt", Font::TYPEWRITER_FAMILY, inh_series,
|
||||
SLANTED_SHAPE, Color_foreground},
|
||||
{"texttt", TYPEWRITER_FAMILY, inh_series,
|
||||
inh_shape, Color_foreground},
|
||||
{"textup", inh_family, inh_series,
|
||||
Font::UP_SHAPE, Color_foreground},
|
||||
UP_SHAPE, Color_foreground},
|
||||
|
||||
// TIPA support
|
||||
{"textipa", inh_family, inh_series,
|
||||
@ -583,21 +583,21 @@ fontinfo fontinfos[] = {
|
||||
|
||||
// LyX internal usage
|
||||
{"lyxtex", inh_family, inh_series,
|
||||
Font::UP_SHAPE, Color_latex},
|
||||
{"lyxsymbol", Font::SYMBOL_FAMILY, inh_series,
|
||||
UP_SHAPE, Color_latex},
|
||||
{"lyxsymbol", SYMBOL_FAMILY, inh_series,
|
||||
inh_shape, Color_math},
|
||||
{"lyxboldsymbol", Font::SYMBOL_FAMILY, Font::BOLD_SERIES,
|
||||
{"lyxboldsymbol", SYMBOL_FAMILY, BOLD_SERIES,
|
||||
inh_shape, Color_math},
|
||||
{"lyxblacktext", Font::ROMAN_FAMILY, Font::MEDIUM_SERIES,
|
||||
Font::UP_SHAPE, Color_foreground},
|
||||
{"lyxblacktext", ROMAN_FAMILY, MEDIUM_SERIES,
|
||||
UP_SHAPE, Color_foreground},
|
||||
{"lyxnochange", inh_family, inh_series,
|
||||
inh_shape, Color_foreground},
|
||||
{"lyxfakebb", Font::TYPEWRITER_FAMILY, Font::BOLD_SERIES,
|
||||
Font::UP_SHAPE, Color_math},
|
||||
{"lyxfakecal", Font::SANS_FAMILY, Font::MEDIUM_SERIES,
|
||||
Font::ITALIC_SHAPE, Color_math},
|
||||
{"lyxfakefrak", Font::ROMAN_FAMILY, Font::BOLD_SERIES,
|
||||
Font::ITALIC_SHAPE, Color_math}
|
||||
{"lyxfakebb", TYPEWRITER_FAMILY, BOLD_SERIES,
|
||||
UP_SHAPE, Color_math},
|
||||
{"lyxfakecal", SANS_FAMILY, MEDIUM_SERIES,
|
||||
ITALIC_SHAPE, Color_math},
|
||||
{"lyxfakefrak", ROMAN_FAMILY, BOLD_SERIES,
|
||||
ITALIC_SHAPE, Color_math}
|
||||
};
|
||||
|
||||
|
||||
@ -630,9 +630,9 @@ bool isFontName(docstring const & name)
|
||||
}
|
||||
|
||||
|
||||
Font getFont(docstring const & name)
|
||||
FontInfo getFont(docstring const & name)
|
||||
{
|
||||
Font font;
|
||||
FontInfo font;
|
||||
augmentFont(font, name);
|
||||
return font;
|
||||
}
|
||||
@ -654,7 +654,7 @@ void fakeFont(docstring const & orig, docstring const & fake)
|
||||
}
|
||||
|
||||
|
||||
void augmentFont(Font & font, docstring const & name)
|
||||
void augmentFont(FontInfo & font, docstring const & name)
|
||||
{
|
||||
static bool initialized = false;
|
||||
if (!initialized) {
|
||||
|
@ -21,32 +21,32 @@
|
||||
namespace lyx {
|
||||
|
||||
class PainterInfo;
|
||||
class Font;
|
||||
class FontInfo;
|
||||
class Dimension;
|
||||
class MathData;
|
||||
class MathAtom;
|
||||
class InsetMath;
|
||||
|
||||
|
||||
int mathed_char_width(Font const &, char_type c);
|
||||
int mathed_char_width(FontInfo const &, char_type c);
|
||||
|
||||
int mathed_char_kerning(Font const &, char_type c);
|
||||
int mathed_char_kerning(FontInfo const &, char_type c);
|
||||
|
||||
void mathed_draw_deco(PainterInfo & pi, int x, int y, int w, int h,
|
||||
docstring const & name);
|
||||
|
||||
void mathed_string_dim(Font const & font,
|
||||
void mathed_string_dim(FontInfo const & font,
|
||||
docstring const & s,
|
||||
Dimension & dim);
|
||||
|
||||
int mathed_string_width(Font const &, docstring const & s);
|
||||
int mathed_string_width(FontInfo const &, docstring const & s);
|
||||
|
||||
void drawStrRed(PainterInfo & pi, int x, int y, docstring const & s);
|
||||
void drawStrBlack(PainterInfo & pi, int x, int y, docstring const & s);
|
||||
|
||||
void math_font_max_dim(Font const &, int & asc, int & desc);
|
||||
void math_font_max_dim(FontInfo const &, int & asc, int & desc);
|
||||
|
||||
void augmentFont(Font & f, docstring const & cmd);
|
||||
void augmentFont(FontInfo & f, docstring const & cmd);
|
||||
|
||||
bool isFontName(docstring const & name);
|
||||
|
||||
|
@ -474,7 +474,7 @@ TeXOnePar(Buffer const & buf,
|
||||
|
||||
bool is_command = style->isCommand();
|
||||
|
||||
if (style->resfont.size() != font.size()
|
||||
if (style->resfont.size() != font.fontInfo().size()
|
||||
&& boost::next(pit) != paragraphs.end()
|
||||
&& !is_command) {
|
||||
if (!need_par)
|
||||
|
@ -291,7 +291,7 @@ int getEndLabel(pit_type p, ParagraphList const & pars)
|
||||
Font const outerFont(pit_type par_offset, ParagraphList const & pars)
|
||||
{
|
||||
depth_type par_depth = pars[par_offset].getDepth();
|
||||
Font tmpfont(Font::ALL_INHERIT);
|
||||
FontInfo tmpfont = inherit_font;
|
||||
|
||||
// Resolve against environment font information
|
||||
while (par_offset != pit_type(pars.size())
|
||||
@ -304,7 +304,7 @@ Font const outerFont(pit_type par_offset, ParagraphList const & pars)
|
||||
}
|
||||
}
|
||||
|
||||
return tmpfont;
|
||||
return Font(tmpfont);
|
||||
}
|
||||
|
||||
|
||||
|
@ -75,7 +75,7 @@ RowPainter::RowPainter(PainterInfo & pi,
|
||||
}
|
||||
|
||||
|
||||
Font const RowPainter::getLabelFont() const
|
||||
FontInfo const RowPainter::getLabelFont() const
|
||||
{
|
||||
return text_.getLabelFont(pi_.base.bv->buffer(), par_);
|
||||
}
|
||||
@ -124,13 +124,13 @@ void RowPainter::paintHfill(pos_type const pos, pos_type const body_pos)
|
||||
|
||||
void RowPainter::paintInset(Inset const * inset, pos_type const pos)
|
||||
{
|
||||
Font font = text_metrics_.getDisplayFont(pit_, pos);
|
||||
FontInfo font = text_metrics_.getDisplayFont(pit_, pos).fontInfo();
|
||||
|
||||
BOOST_ASSERT(inset);
|
||||
// FIXME: We should always use font, see documentation of
|
||||
// noFontChange() in Inset.h.
|
||||
pi_.base.font = inset->noFontChange() ?
|
||||
pi_.base.bv->buffer().params().getFont() :
|
||||
pi_.base.bv->buffer().params().getFont().fontInfo() :
|
||||
font;
|
||||
pi_.ltr_pos = (bidi_.level(pos) % 2 == 0);
|
||||
pi_.erased_ = erased_ || par_.isDeleted(pos);
|
||||
@ -179,7 +179,7 @@ void RowPainter::paintInset(Inset const * inset, pos_type const pos)
|
||||
}
|
||||
|
||||
|
||||
void RowPainter::paintHebrewComposeChar(pos_type & vpos, Font const & font)
|
||||
void RowPainter::paintHebrewComposeChar(pos_type & vpos, FontInfo const & font)
|
||||
{
|
||||
pos_type pos = bidi_.vis2log(vpos);
|
||||
|
||||
@ -198,7 +198,7 @@ void RowPainter::paintHebrewComposeChar(pos_type & vpos, Font const & font)
|
||||
if (!Encodings::isComposeChar_hebrew(c)) {
|
||||
if (isPrintableNonspace(c)) {
|
||||
int const width2 = pm_.singleWidth(i,
|
||||
text_metrics_.getDisplayFont(pit_, i));
|
||||
text_metrics_.getDisplayFont(pit_, i).fontInfo());
|
||||
dx = (c == 0x05e8 || // resh
|
||||
c == 0x05d3) // dalet
|
||||
? width2 - width
|
||||
@ -213,7 +213,7 @@ void RowPainter::paintHebrewComposeChar(pos_type & vpos, Font const & font)
|
||||
}
|
||||
|
||||
|
||||
void RowPainter::paintArabicComposeChar(pos_type & vpos, Font const & font)
|
||||
void RowPainter::paintArabicComposeChar(pos_type & vpos, FontInfo const & font)
|
||||
{
|
||||
pos_type pos = bidi_.vis2log(vpos);
|
||||
docstring str;
|
||||
@ -232,7 +232,7 @@ void RowPainter::paintArabicComposeChar(pos_type & vpos, Font const & font)
|
||||
if (!Encodings::isComposeChar_arabic(c)) {
|
||||
if (isPrintableNonspace(c)) {
|
||||
int const width2 = pm_.singleWidth(i,
|
||||
text_metrics_.getDisplayFont(pit_, i));
|
||||
text_metrics_.getDisplayFont(pit_, i).fontInfo());
|
||||
dx = (width2 - width) / 2;
|
||||
}
|
||||
break;
|
||||
@ -243,7 +243,7 @@ void RowPainter::paintArabicComposeChar(pos_type & vpos, Font const & font)
|
||||
}
|
||||
|
||||
|
||||
void RowPainter::paintChars(pos_type & vpos, Font const & font,
|
||||
void RowPainter::paintChars(pos_type & vpos, FontInfo const & font,
|
||||
bool hebrew, bool arabic)
|
||||
{
|
||||
// This method takes up 70% of time when typing
|
||||
@ -322,7 +322,7 @@ void RowPainter::paintChars(pos_type & vpos, Font const & font,
|
||||
docstring s(&str[0], str.size());
|
||||
|
||||
if (prev_change != Change::UNCHANGED) {
|
||||
Font copy(font);
|
||||
FontInfo copy(font);
|
||||
if (prev_change == Change::DELETED) {
|
||||
copy.setColor(Color_deletedtext);
|
||||
} else if (prev_change == Change::INSERTED) {
|
||||
@ -352,7 +352,7 @@ void RowPainter::paintForeignMark(double orig_x, Font const & font, int desc)
|
||||
void RowPainter::paintFromPos(pos_type & vpos)
|
||||
{
|
||||
pos_type const pos = bidi_.vis2log(vpos);
|
||||
Font orig_font = text_metrics_.getDisplayFont(pit_, pos);
|
||||
Font orig_font = text_metrics_.getDisplayFont(pit_, pos).fontInfo();
|
||||
double const orig_x = x_;
|
||||
|
||||
// usual characters, no insets
|
||||
@ -368,11 +368,11 @@ void RowPainter::paintFromPos(pos_type & vpos)
|
||||
if ((!hebrew && !arabic)
|
||||
|| (hebrew && !Encodings::isComposeChar_hebrew(c))
|
||||
|| (arabic && !Encodings::isComposeChar_arabic(c))) {
|
||||
paintChars(vpos, orig_font, hebrew, arabic);
|
||||
paintChars(vpos, orig_font.fontInfo(), hebrew, arabic);
|
||||
} else if (hebrew) {
|
||||
paintHebrewComposeChar(vpos, orig_font);
|
||||
paintHebrewComposeChar(vpos, orig_font.fontInfo());
|
||||
} else if (arabic) {
|
||||
paintArabicComposeChar(vpos, orig_font);
|
||||
paintArabicComposeChar(vpos, orig_font.fontInfo());
|
||||
}
|
||||
|
||||
paintForeignMark(orig_x, orig_font);
|
||||
@ -462,7 +462,7 @@ void RowPainter::paintDepthBar()
|
||||
|
||||
int RowPainter::paintAppendixStart(int y)
|
||||
{
|
||||
Font pb_font;
|
||||
FontInfo pb_font;
|
||||
pb_font.setColor(Color_appendix);
|
||||
pb_font.decSize();
|
||||
|
||||
@ -525,7 +525,7 @@ void RowPainter::paintFirst()
|
||||
|| layout->latextype != LATEX_ENVIRONMENT
|
||||
|| is_seq)) {
|
||||
|
||||
Font const font = getLabelFont();
|
||||
FontInfo const font = getLabelFont();
|
||||
FontMetrics const & fm = theFontMetrics(font);
|
||||
|
||||
docstring const str = par_.getLabelstring();
|
||||
@ -573,7 +573,7 @@ void RowPainter::paintFirst()
|
||||
(layout->labeltype == LABEL_TOP_ENVIRONMENT ||
|
||||
layout->labeltype == LABEL_BIBLIO ||
|
||||
layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
|
||||
Font font = getLabelFont();
|
||||
FontInfo font = getLabelFont();
|
||||
if (!par_.getLabelstring().empty()) {
|
||||
docstring const str = par_.getLabelstring();
|
||||
double spacing_val = 1.0;
|
||||
@ -629,7 +629,7 @@ void RowPainter::paintLast()
|
||||
switch (endlabel) {
|
||||
case END_LABEL_BOX:
|
||||
case END_LABEL_FILLED_BOX: {
|
||||
Font const font = getLabelFont();
|
||||
FontInfo const font = getLabelFont();
|
||||
FontMetrics const & fm = theFontMetrics(font);
|
||||
int const size = int(0.75 * fm.maxAscent());
|
||||
int const y = yo_ - size;
|
||||
@ -646,7 +646,7 @@ void RowPainter::paintLast()
|
||||
}
|
||||
|
||||
case END_LABEL_STATIC: {
|
||||
Font font = getLabelFont();
|
||||
FontInfo font = getLabelFont();
|
||||
FontMetrics const & fm = theFontMetrics(font);
|
||||
docstring const & str = par_.layout()->endlabelstring();
|
||||
double const x = is_rtl ?
|
||||
@ -704,7 +704,7 @@ void RowPainter::paintText()
|
||||
|
||||
// Use font span to speed things up, see below
|
||||
FontSpan font_span;
|
||||
Font font;
|
||||
FontInfo font;
|
||||
|
||||
// If the last logical character is a separator, don't paint it, unless
|
||||
// it's in the last row of a paragraph; see skipped_sep_vpos declaration
|
||||
@ -731,7 +731,7 @@ void RowPainter::paintText()
|
||||
// Use font span to speed things up, see above
|
||||
if (vpos < font_span.first || vpos > font_span.last) {
|
||||
font_span = par_.fontSpan(vpos);
|
||||
font = text_metrics_.getDisplayFont(pit_, vpos);
|
||||
font = text_metrics_.getDisplayFont(pit_, vpos).fontInfo();
|
||||
}
|
||||
|
||||
const int width_pos = pm_.singleWidth(pos, font);
|
||||
@ -776,7 +776,7 @@ void RowPainter::paintText()
|
||||
++vpos;
|
||||
|
||||
} else if (par_.isSeparator(pos)) {
|
||||
Font orig_font = text_metrics_.getDisplayFont(pit_, pos);
|
||||
FontInfo orig_font = text_metrics_.getDisplayFont(pit_, pos).fontInfo();
|
||||
double const orig_x = x_;
|
||||
x_ += width_pos;
|
||||
if (pos >= body_pos)
|
||||
|
@ -21,6 +21,7 @@ namespace lyx {
|
||||
class Bidi;
|
||||
class BufferView;
|
||||
class Font;
|
||||
class FontInfo;
|
||||
class Inset;
|
||||
class PainterInfo;
|
||||
class Paragraph;
|
||||
@ -55,9 +56,9 @@ public:
|
||||
|
||||
private:
|
||||
void paintForeignMark(double orig_x, Font const & font, int desc = 0);
|
||||
void paintHebrewComposeChar(pos_type & vpos, Font const & font);
|
||||
void paintArabicComposeChar(pos_type & vpos, Font const & font);
|
||||
void paintChars(pos_type & vpos, Font const & font,
|
||||
void paintHebrewComposeChar(pos_type & vpos, FontInfo const & font);
|
||||
void paintArabicComposeChar(pos_type & vpos, FontInfo const & font);
|
||||
void paintChars(pos_type & vpos, FontInfo const & font,
|
||||
bool hebrew, bool arabic);
|
||||
int paintAppendixStart(int y);
|
||||
void paintFromPos(pos_type & vpos);
|
||||
@ -68,7 +69,7 @@ private:
|
||||
int leftMargin() const;
|
||||
|
||||
/// return the label font for this row
|
||||
Font const getLabelFont() const;
|
||||
FontInfo const getLabelFont() const;
|
||||
|
||||
/// contains painting related information.
|
||||
PainterInfo & pi_;
|
||||
|
@ -14,15 +14,20 @@
|
||||
#include "Lexer.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
using lyx::support::ascii_lowercase;
|
||||
|
||||
using std::string;
|
||||
/// Sane font.
|
||||
FontInfo const sane_font;
|
||||
/// All inherit font.
|
||||
FontInfo const inherit_font;
|
||||
/// All ignore font.
|
||||
FontInfo const ignore_font;
|
||||
|
||||
|
||||
Font & Font::lyxRead(Lexer & lex)
|
||||
FontInfo lyxRead(Lexer & lex)
|
||||
{
|
||||
bool error = false;
|
||||
bool finished = false;
|
||||
@ -51,7 +56,7 @@ Font & Font::lyxRead(Lexer & lex)
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
return FontInfo();
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,26 +17,36 @@
|
||||
#ifndef TEX2LYX_FONT_H
|
||||
#define TEX2LYX_FONT_H
|
||||
|
||||
//#include "FontInfo.h"
|
||||
|
||||
namespace lyx {
|
||||
|
||||
class Lexer;
|
||||
|
||||
class Font {
|
||||
class FontInfo
|
||||
{
|
||||
public:
|
||||
/// Trick to overload constructor and make it megafast
|
||||
enum FONT_INIT1 { ALL_INHERIT };
|
||||
enum FONT_INIT3 { ALL_SANE };
|
||||
|
||||
Font() {}
|
||||
explicit Font(Font::FONT_INIT1) {}
|
||||
explicit Font(Font::FONT_INIT3) {}
|
||||
|
||||
Font & lyxRead(Lexer &);
|
||||
|
||||
Font & realize(Font const &) { return *this; }
|
||||
FontInfo() {}
|
||||
FontInfo & realize(FontInfo const &) { return *this; }
|
||||
bool resolved() const { return true; }
|
||||
};
|
||||
|
||||
/// Sane font.
|
||||
extern FontInfo const sane_font;
|
||||
/// All inherit font.
|
||||
extern FontInfo const inherit_font;
|
||||
/// All ignore font.
|
||||
extern FontInfo const ignore_font;
|
||||
|
||||
class Font
|
||||
{
|
||||
public:
|
||||
Font() {}
|
||||
Font(FontInfo const &) {}
|
||||
};
|
||||
|
||||
/// Read a font specification from Lexer. Used for layout files.
|
||||
FontInfo lyxRead(Lexer &);
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user