mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-25 22:06:15 +00:00
Factor out test for script wrapper in given font enc
This commit is contained in:
parent
a33d957832
commit
4010ccafbd
@ -599,6 +599,20 @@ bool Encodings::isKnownScriptChar(char_type const c, string & preamble)
|
||||
}
|
||||
|
||||
|
||||
bool Encodings::needsScriptWrapper(string const & script, string const & fontenc)
|
||||
{
|
||||
if (script == "textgreek")
|
||||
return (fontenc != "LGR");
|
||||
if (script == "textcyr") {
|
||||
return (fontenc != "T2A" && fontenc != "T2B"
|
||||
&& fontenc != "T2C" && fontenc != "X2");
|
||||
}
|
||||
if (script == "textbaltic")
|
||||
return (fontenc != "L7x");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Encodings::isMathAlpha(char_type c)
|
||||
{
|
||||
return mathalpha.count(c);
|
||||
|
@ -280,6 +280,9 @@ public:
|
||||
* \p c is a known character matching the preamble entry.
|
||||
*/
|
||||
static bool isKnownScriptChar(char_type const c, std::string & preamble);
|
||||
/// Do we need to wrap scripts into \text<script> macros?
|
||||
static bool needsScriptWrapper(std::string const & script,
|
||||
std::string const & fontenc);
|
||||
/**
|
||||
* Do we have to display in italics this character when in mathmode?
|
||||
* This is true if the "mathalpha" flag is set. We use this for
|
||||
|
@ -920,9 +920,7 @@ int Paragraph::Private::latexSurrogatePair(otexstream & os, char_type c,
|
||||
length -= pos;
|
||||
latex2 = latex2.substr(pos, length);
|
||||
// We only need the script macro with non-native font encodings
|
||||
if ((script == "textgreek" && fontenc != "LGR")
|
||||
|| (script == "textcyr" && fontenc != "T2A" && fontenc != "T2B"
|
||||
&& fontenc != "T2C" && fontenc != "X2")) {
|
||||
if (Encodings::needsScriptWrapper(script, fontenc)) {
|
||||
scriptmacro = from_ascii("\\" + script + "{");
|
||||
cb = from_ascii("}");
|
||||
}
|
||||
@ -1013,9 +1011,7 @@ int Paragraph::Private::writeScriptChars(OutputParams const & runparams,
|
||||
int pos = 0;
|
||||
int length = brace2;
|
||||
bool closing_brace = true;
|
||||
if ((script == "textgreek" && fontenc == "LGR")
|
||||
||(script == "textcyr" && (fontenc == "T2A" || fontenc == "T2B"
|
||||
|| fontenc == "T2C" || fontenc == "X2"))) {
|
||||
if (!Encodings::needsScriptWrapper(script, fontenc)) {
|
||||
// Correct font encoding is being used, so we can avoid \text[greek|cyr].
|
||||
pos = brace1 + 1;
|
||||
length -= pos;
|
||||
|
Loading…
Reference in New Issue
Block a user