mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Provide option to prevent unnecessary font loading.
If an OSF font is an alternative to a non-OSF one, only load the OSFFont if osf is requested.
This commit is contained in:
parent
7ed43d751a
commit
3335344261
@ -19,6 +19,7 @@
|
||||
# OsfOption <option for oldstyle figure support>
|
||||
# OsfFont <extra font for oldstyle figures>
|
||||
# OsfDefault <0|1>
|
||||
# OsfFontOnly <0|1>
|
||||
# ScOption <option for true smallcaps support>
|
||||
# OsfScOption <option for combined osf and true smallcaps support>
|
||||
# ScaleOption <option for font scaling>
|
||||
@ -65,6 +66,9 @@
|
||||
# tags.
|
||||
# * OsfFont is a font that is loaded additionally in and that provides
|
||||
# Old Style Figures for a given font (e.g. eco).
|
||||
# * If OsfFontOnly is true, then the OsfFont will replace the non-OsF
|
||||
# one (only OsfFont is loaded if osf is true). Otherwise it will
|
||||
# complement the non-osf font.
|
||||
# * OsfScOption overrides any OsfOption and ScOption if both features
|
||||
# are selected.
|
||||
# * ScOption and OsfScOption are currently only supported for rm fonts.
|
||||
@ -500,6 +504,7 @@ AltFont ppl
|
||||
GuiName "Palatino"
|
||||
Family rm
|
||||
OsfFont pplj
|
||||
OsfFontOnly 1
|
||||
SwitchDefault 1
|
||||
EndFont
|
||||
|
||||
@ -600,6 +605,7 @@ AltFont futs
|
||||
Family rm
|
||||
SwitchDefault 1
|
||||
OsfFont futj
|
||||
OsfFontOnly 1
|
||||
EndFont
|
||||
|
||||
AltFont futj
|
||||
|
@ -68,7 +68,7 @@ bool LaTeXFont::available(bool ot1, bool nomath)
|
||||
|
||||
bool LaTeXFont::providesNoMath(bool ot1, bool complete)
|
||||
{
|
||||
docstring const usedfont = getUsedFont(ot1, complete, false);
|
||||
docstring const usedfont = getUsedFont(ot1, complete, false, false);
|
||||
|
||||
if (usedfont.empty())
|
||||
return false;
|
||||
@ -81,7 +81,7 @@ bool LaTeXFont::providesNoMath(bool ot1, bool complete)
|
||||
|
||||
bool LaTeXFont::providesOSF(bool ot1, bool complete, bool nomath)
|
||||
{
|
||||
docstring const usedfont = getUsedFont(ot1, complete, nomath);
|
||||
docstring const usedfont = getUsedFont(ot1, complete, nomath, false);
|
||||
|
||||
if (usedfont.empty())
|
||||
return false;
|
||||
@ -98,7 +98,7 @@ bool LaTeXFont::providesOSF(bool ot1, bool complete, bool nomath)
|
||||
|
||||
bool LaTeXFont::providesSC(bool ot1, bool complete, bool nomath)
|
||||
{
|
||||
docstring const usedfont = getUsedFont(ot1, complete, nomath);
|
||||
docstring const usedfont = getUsedFont(ot1, complete, nomath, false);
|
||||
|
||||
if (usedfont.empty())
|
||||
return false;
|
||||
@ -113,7 +113,7 @@ bool LaTeXFont::providesSC(bool ot1, bool complete, bool nomath)
|
||||
|
||||
bool LaTeXFont::hasMonolithicExpertSet(bool ot1, bool complete, bool nomath)
|
||||
{
|
||||
docstring const usedfont = getUsedFont(ot1, complete, nomath);
|
||||
docstring const usedfont = getUsedFont(ot1, complete, nomath, false);
|
||||
|
||||
if (usedfont.empty())
|
||||
return false;
|
||||
@ -126,7 +126,7 @@ bool LaTeXFont::hasMonolithicExpertSet(bool ot1, bool complete, bool nomath)
|
||||
|
||||
bool LaTeXFont::providesScale(bool ot1, bool complete, bool nomath)
|
||||
{
|
||||
docstring const usedfont = getUsedFont(ot1, complete, nomath);
|
||||
docstring const usedfont = getUsedFont(ot1, complete, nomath, false);
|
||||
|
||||
if (usedfont.empty())
|
||||
return false;
|
||||
@ -140,7 +140,7 @@ bool LaTeXFont::providesScale(bool ot1, bool complete, bool nomath)
|
||||
|
||||
bool LaTeXFont::providesMoreOptions(bool ot1, bool complete, bool nomath)
|
||||
{
|
||||
docstring const usedfont = getUsedFont(ot1, complete, nomath);
|
||||
docstring const usedfont = getUsedFont(ot1, complete, nomath, false);
|
||||
|
||||
if (usedfont.empty())
|
||||
return false;
|
||||
@ -154,7 +154,7 @@ bool LaTeXFont::providesMoreOptions(bool ot1, bool complete, bool nomath)
|
||||
|
||||
bool LaTeXFont::provides(std::string const & name, bool ot1, bool complete, bool nomath)
|
||||
{
|
||||
docstring const usedfont = getUsedFont(ot1, complete, nomath);
|
||||
docstring const usedfont = getUsedFont(ot1, complete, nomath, false);
|
||||
|
||||
if (usedfont.empty())
|
||||
return false;
|
||||
@ -171,9 +171,11 @@ bool LaTeXFont::provides(std::string const & name, bool ot1, bool complete, bool
|
||||
}
|
||||
|
||||
|
||||
docstring const LaTeXFont::getUsedFont(bool ot1, bool complete, bool nomath)
|
||||
docstring const LaTeXFont::getUsedFont(bool ot1, bool complete, bool nomath, bool osf)
|
||||
{
|
||||
if (nomath && !nomathfont_.empty() && available(ot1, true))
|
||||
if (osf && osfFontOnly())
|
||||
return osffont_;
|
||||
else if (nomath && !nomathfont_.empty() && available(ot1, true))
|
||||
return nomathfont_;
|
||||
else if (ot1 && !ot1font_.empty())
|
||||
return (ot1font_ == "none") ? docstring() : ot1font_;
|
||||
@ -201,7 +203,7 @@ docstring const LaTeXFont::getUsedFont(bool ot1, bool complete, bool nomath)
|
||||
for (size_t i = 0; i < altfonts_.size(); ++i) {
|
||||
LaTeXFont altf = altFont(altfonts_[i]);
|
||||
if (altf.available(ot1, nomath))
|
||||
return altf.getUsedFont(ot1, complete, nomath);
|
||||
return altf.getUsedFont(ot1, complete, nomath, osf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,7 +213,7 @@ docstring const LaTeXFont::getUsedFont(bool ot1, bool complete, bool nomath)
|
||||
|
||||
docstring const LaTeXFont::getUsedPackage(bool ot1, bool complete, bool nomath)
|
||||
{
|
||||
docstring const usedfont = getUsedFont(ot1, complete, nomath);
|
||||
docstring const usedfont = getUsedFont(ot1, complete, nomath, false);
|
||||
if (usedfont.empty())
|
||||
return docstring();
|
||||
return theLaTeXFonts().getLaTeXFont(usedfont).package();
|
||||
@ -295,7 +297,7 @@ string const LaTeXFont::getLaTeXCode(bool dryrun, bool ot1, bool complete, bool
|
||||
{
|
||||
ostringstream os;
|
||||
|
||||
docstring const usedfont = getUsedFont(ot1, complete, nomath);
|
||||
docstring const usedfont = getUsedFont(ot1, complete, nomath, osf);
|
||||
if (usedfont.empty())
|
||||
return string();
|
||||
else if (usedfont != name_)
|
||||
@ -357,6 +359,7 @@ bool LaTeXFont::readFont(Lexer & lex)
|
||||
LF_NOMATHFONT,
|
||||
LF_OSFDEFAULT,
|
||||
LF_OSFFONT,
|
||||
LF_OSFFONTONLY,
|
||||
LF_OSFOPTION,
|
||||
LF_OSFSCOPTION,
|
||||
LF_OT1_FONT,
|
||||
@ -383,6 +386,7 @@ bool LaTeXFont::readFont(Lexer & lex)
|
||||
{ "nomathfont", LF_NOMATHFONT },
|
||||
{ "osfdefault", LF_OSFDEFAULT },
|
||||
{ "osffont", LF_OSFFONT },
|
||||
{ "osffontonly", LF_OSFFONTONLY },
|
||||
{ "osfoption", LF_OSFOPTION },
|
||||
{ "osfscoption", LF_OSFSCOPTION },
|
||||
{ "ot1font", LF_OT1_FONT },
|
||||
@ -452,6 +456,9 @@ bool LaTeXFont::readFont(Lexer & lex)
|
||||
case LF_OSFDEFAULT:
|
||||
lex >> osfdefault_;
|
||||
break;
|
||||
case LF_OSFFONTONLY:
|
||||
lex >> osffontonly_;
|
||||
break;
|
||||
case LF_OSFSCOPTION:
|
||||
lex >> osfscoption_;
|
||||
break;
|
||||
@ -504,6 +511,7 @@ bool LaTeXFont::read(Lexer & lex)
|
||||
switchdefault_ = 0;
|
||||
osfdefault_ = 0;
|
||||
moreopts_ = 0;
|
||||
osffontonly_ = 0;
|
||||
|
||||
if (!lex.next()) {
|
||||
lex.printError("No name given for LaTeX font: `$$Token'.");
|
||||
|
@ -27,7 +27,8 @@ class LaTeXFont {
|
||||
public:
|
||||
/// TeX font
|
||||
// FIXME Add fontenc tag to classes which is used if no font is specified?
|
||||
LaTeXFont() : osfdefault_(false), switchdefault_(false), moreopts_(false) { fontenc_.push_back("T1"); }
|
||||
LaTeXFont() : osfdefault_(false), switchdefault_(false), moreopts_(false),
|
||||
osffontonly_(false) { fontenc_.push_back("T1"); }
|
||||
/// The font name
|
||||
docstring const & name() { return name_; }
|
||||
/// The name to appear in the document dialog
|
||||
@ -67,6 +68,8 @@ public:
|
||||
bool switchdefault() const { return switchdefault_; }
|
||||
/// Does the font provide Old Style Figures as default?
|
||||
bool osfDefault() const { return osfdefault_; }
|
||||
/// Does OSF font replace (rather than complement) the non-OSF one?
|
||||
bool osfFontOnly() const { return osffontonly_; }
|
||||
/// Is this font available?
|
||||
bool available(bool ot1, bool nomath);
|
||||
/// Does this font provide an alternative without math?
|
||||
@ -87,7 +90,7 @@ public:
|
||||
std::string const & extraopts = std::string(),
|
||||
int const & scale = 100);
|
||||
/// Return the actually used font
|
||||
docstring const getUsedFont(bool ot1, bool complete, bool nomath);
|
||||
docstring const getUsedFont(bool ot1, bool complete, bool nomath, bool osf);
|
||||
/// Return the actually used package
|
||||
docstring const getUsedPackage(bool ot1, bool complete, bool nomath);
|
||||
///
|
||||
@ -149,6 +152,8 @@ private:
|
||||
bool switchdefault_;
|
||||
///
|
||||
bool moreopts_;
|
||||
///
|
||||
bool osffontonly_;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user