LaTeXFonts: Add ScaleCommand

This is needed to add support for scaling to fonts that are switched
via command
This commit is contained in:
Juergen Spitzmueller 2020-07-09 11:41:21 +02:00
parent 3335344261
commit 780d9a5f4c
3 changed files with 22 additions and 2 deletions

View File

@ -23,6 +23,7 @@
# ScOption <option for true smallcaps support>
# OsfScOption <option for combined osf and true smallcaps support>
# ScaleOption <option for font scaling>
# ScaleCommand <command sequence to set scale value of the font>
# MoreOptions <0|1>
# Provides <features provided by the font packages (comma-separated)>
# Preamble
@ -75,7 +76,8 @@
# * Set OsfDefault to true for fonts which have Old Style Figures by
# default and provide an option for lining figures. Pass this option
# to OsfOption.
# * ScaleOption supports the placeholder $$val for the scale value.
# * ScaleOption and ScaleCommand support the placeholder $$val for the
# scale value.
# * If MoreOptions is true, then the user can insert additional options to
# the font package via the Document Settings.
# * The Preamble code is output immediately after the respective font

View File

@ -134,7 +134,7 @@ bool LaTeXFont::providesScale(bool ot1, bool complete, bool nomath)
return altFont(usedfont).providesScale(ot1, complete, nomath);
else if (!available(ot1, nomath))
return false;
return (!scaleoption_.empty());
return (!scaleoption_.empty() || !scalecmd_.empty());
}
@ -329,6 +329,15 @@ string const LaTeXFont::getLaTeXCode(bool dryrun, bool ot1, bool complete, bool
if (osf && providesOSF(ot1, complete, nomath) && !osffont_.empty())
os << altFont(osffont_).getLaTeXCode(dryrun, ot1, complete, sc, osf,
nomath, extraopts, scale);
if (scale != 100 && !scalecmd_.empty()
&& providesScale(ot1, complete, nomath)) {
if (contains(scalecmd_, '@'))
os << "\\makeatletter\n";
os << subst(to_ascii(scalecmd_), "$$val",
convert<std::string>(float(scale) / 100)) << '\n';
if (contains(scalecmd_, '@'))
os << "\\makeatother\n";
}
if (!preamble_.empty())
os << to_utf8(preamble_);
@ -369,6 +378,7 @@ bool LaTeXFont::readFont(Lexer & lex)
LF_PREAMBLE,
LF_PROVIDES,
LF_REQUIRES,
LF_SCALECMD,
LF_SCALEOPTION,
LF_SCOPTION,
LF_SWITCHDEFAULT
@ -395,6 +405,7 @@ bool LaTeXFont::readFont(Lexer & lex)
{ "preamble", LF_PREAMBLE },
{ "provides", LF_PROVIDES },
{ "requires", LF_REQUIRES },
{ "scalecommand", LF_SCALECMD },
{ "scaleoption", LF_SCALEOPTION },
{ "scoption", LF_SCOPTION },
{ "switchdefault", LF_SWITCHDEFAULT }
@ -483,6 +494,9 @@ bool LaTeXFont::readFont(Lexer & lex)
case LF_REQUIRES:
lex >> required_;
break;
case LF_SCALECMD:
lex >> scalecmd_;
break;
case LF_SCALEOPTION:
lex >> scaleoption_;
break;

View File

@ -57,6 +57,8 @@ public:
docstring const & osfscoption() { return osfscoption_; }
/// A package option for font scaling
docstring const & scaleoption() { return scaleoption_; }
/// A macro for font scaling
docstring const & scalecmd() { return scalecmd_; }
/// Does this provide additional options?
bool providesMoreOptions(bool ot1, bool complete, bool nomath);
/// Alternative requirement to test for
@ -141,6 +143,8 @@ private:
///
docstring scaleoption_;
///
docstring scalecmd_;
///
std::vector<std::string> provides_;
///
docstring required_;