mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-28 20:45:47 +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)
|
bool Encodings::isMathAlpha(char_type c)
|
||||||
{
|
{
|
||||||
return mathalpha.count(c);
|
return mathalpha.count(c);
|
||||||
|
@ -280,6 +280,9 @@ public:
|
|||||||
* \p c is a known character matching the preamble entry.
|
* \p c is a known character matching the preamble entry.
|
||||||
*/
|
*/
|
||||||
static bool isKnownScriptChar(char_type const c, std::string & preamble);
|
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?
|
* 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
|
* 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;
|
length -= pos;
|
||||||
latex2 = latex2.substr(pos, length);
|
latex2 = latex2.substr(pos, length);
|
||||||
// We only need the script macro with non-native font encodings
|
// We only need the script macro with non-native font encodings
|
||||||
if ((script == "textgreek" && fontenc != "LGR")
|
if (Encodings::needsScriptWrapper(script, fontenc)) {
|
||||||
|| (script == "textcyr" && fontenc != "T2A" && fontenc != "T2B"
|
|
||||||
&& fontenc != "T2C" && fontenc != "X2")) {
|
|
||||||
scriptmacro = from_ascii("\\" + script + "{");
|
scriptmacro = from_ascii("\\" + script + "{");
|
||||||
cb = from_ascii("}");
|
cb = from_ascii("}");
|
||||||
}
|
}
|
||||||
@ -1013,9 +1011,7 @@ int Paragraph::Private::writeScriptChars(OutputParams const & runparams,
|
|||||||
int pos = 0;
|
int pos = 0;
|
||||||
int length = brace2;
|
int length = brace2;
|
||||||
bool closing_brace = true;
|
bool closing_brace = true;
|
||||||
if ((script == "textgreek" && fontenc == "LGR")
|
if (!Encodings::needsScriptWrapper(script, fontenc)) {
|
||||||
||(script == "textcyr" && (fontenc == "T2A" || fontenc == "T2B"
|
|
||||||
|| fontenc == "T2C" || fontenc == "X2"))) {
|
|
||||||
// Correct font encoding is being used, so we can avoid \text[greek|cyr].
|
// Correct font encoding is being used, so we can avoid \text[greek|cyr].
|
||||||
pos = brace1 + 1;
|
pos = brace1 + 1;
|
||||||
length -= pos;
|
length -= pos;
|
||||||
|
Loading…
Reference in New Issue
Block a user