mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
parent
7bcb78a778
commit
a6c6bffbed
@ -483,6 +483,7 @@ Converters::RetVal Converters::convert(Buffer const * buffer,
|
|||||||
runparams.index_command = (buffer->params().index_command == "default") ?
|
runparams.index_command = (buffer->params().index_command == "default") ?
|
||||||
string() : buffer->params().index_command;
|
string() : buffer->params().index_command;
|
||||||
runparams.document_language = buffer->params().language->babel();
|
runparams.document_language = buffer->params().language->babel();
|
||||||
|
runparams.main_fontenc = buffer->params().main_font_encoding();
|
||||||
runparams.only_childbibs = !buffer->params().useBiblatex()
|
runparams.only_childbibs = !buffer->params().useBiblatex()
|
||||||
&& !buffer->params().useBibtopic()
|
&& !buffer->params().useBibtopic()
|
||||||
&& buffer->params().multibib == "child";
|
&& buffer->params().multibib == "child";
|
||||||
|
@ -118,6 +118,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
std::string document_language;
|
std::string document_language;
|
||||||
|
|
||||||
|
/// main font encoding of the document
|
||||||
|
std::string main_fontenc;
|
||||||
|
|
||||||
/** The master language. Non-null only for child documents.
|
/** The master language. Non-null only for child documents.
|
||||||
Note that this is not the language of the top level master, but
|
Note that this is not the language of the top level master, but
|
||||||
of the direct parent for nested includes.
|
of the direct parent for nested includes.
|
||||||
|
@ -331,7 +331,8 @@ public:
|
|||||||
/// specified by the latex macro \p ltx, to \p os starting from \p i.
|
/// specified by the latex macro \p ltx, to \p os starting from \p i.
|
||||||
/// \return the number of characters written.
|
/// \return the number of characters written.
|
||||||
int writeScriptChars(otexstream & os, docstring const & ltx,
|
int writeScriptChars(otexstream & os, docstring const & ltx,
|
||||||
Change const &, Encoding const &, pos_type & i);
|
Change const &, Encoding const &,
|
||||||
|
std::string const, pos_type & i);
|
||||||
|
|
||||||
/// This could go to ParagraphParameters if we want to.
|
/// This could go to ParagraphParameters if we want to.
|
||||||
int startTeXParParams(BufferParams const &, otexstream &,
|
int startTeXParParams(BufferParams const &, otexstream &,
|
||||||
@ -883,7 +884,27 @@ int Paragraph::Private::latexSurrogatePair(otexstream & os, char_type c,
|
|||||||
latex1 = from_ascii(tipashortcut);
|
latex1 = from_ascii(tipashortcut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
docstring const latex2 = encoding.latexChar(c).first;
|
docstring latex2 = encoding.latexChar(c).first;
|
||||||
|
|
||||||
|
docstring::size_type const brace1 = latex2.find_first_of(from_ascii("{"));
|
||||||
|
docstring::size_type const brace2 = latex2.find_last_of(from_ascii("}"));
|
||||||
|
string script = to_ascii(latex2.substr(1, brace1 - 1));
|
||||||
|
int pos = 0;
|
||||||
|
int length = brace2;
|
||||||
|
string fontenc;
|
||||||
|
if (runparams.local_font)
|
||||||
|
fontenc = runparams.local_font->language()->fontenc();
|
||||||
|
else
|
||||||
|
fontenc = runparams.main_fontenc;
|
||||||
|
if ((script == "textgreek" && fontenc == "LGR")
|
||||||
|
||(script == "textcyr" && (fontenc == "T2A" || fontenc == "T2B"
|
||||||
|
|| fontenc == "T2C" || fontenc == "X2"))) {
|
||||||
|
// Correct font encoding is being used, so we can avoid \text[greek|cyr].
|
||||||
|
pos = brace1 + 1;
|
||||||
|
length -= pos;
|
||||||
|
latex2 = latex2.substr(pos, length);
|
||||||
|
}
|
||||||
|
|
||||||
if (docstring(1, next) == latex1) {
|
if (docstring(1, next) == latex1) {
|
||||||
// the encoding supports the combination
|
// the encoding supports the combination
|
||||||
os << latex2 << latex1;
|
os << latex2 << latex1;
|
||||||
@ -948,6 +969,7 @@ int Paragraph::Private::writeScriptChars(otexstream & os,
|
|||||||
docstring const & ltx,
|
docstring const & ltx,
|
||||||
Change const & runningChange,
|
Change const & runningChange,
|
||||||
Encoding const & encoding,
|
Encoding const & encoding,
|
||||||
|
string const fontenc,
|
||||||
pos_type & i)
|
pos_type & i)
|
||||||
{
|
{
|
||||||
// FIXME: modifying i here is not very nice...
|
// FIXME: modifying i here is not very nice...
|
||||||
@ -955,10 +977,6 @@ int Paragraph::Private::writeScriptChars(otexstream & os,
|
|||||||
// We only arrive here when character text_[i] could not be translated
|
// We only arrive here when character text_[i] could not be translated
|
||||||
// into the current latex encoding (or its latex translation has been forced,)
|
// into the current latex encoding (or its latex translation has been forced,)
|
||||||
// and it belongs to a known script.
|
// and it belongs to a known script.
|
||||||
// TODO: We need \textcyr and \textgreek wrappers also for characters
|
|
||||||
// that can be encoded in the "LaTeX encoding" but not in the
|
|
||||||
// current *font encoding*.
|
|
||||||
// (See #9681 for details and test)
|
|
||||||
// Parameter ltx contains the latex translation of text_[i] as specified
|
// Parameter ltx contains the latex translation of text_[i] as specified
|
||||||
// in the unicodesymbols file and is something like "\textXXX{<spec>}".
|
// in the unicodesymbols file and is something like "\textXXX{<spec>}".
|
||||||
// The latex macro name "textXXX" specifies the script to which text_[i]
|
// The latex macro name "textXXX" specifies the script to which text_[i]
|
||||||
@ -972,12 +990,10 @@ int Paragraph::Private::writeScriptChars(otexstream & os,
|
|||||||
int pos = 0;
|
int pos = 0;
|
||||||
int length = brace2;
|
int length = brace2;
|
||||||
bool closing_brace = true;
|
bool closing_brace = true;
|
||||||
if (script == "textgreek" && encoding.latexName() == "iso-8859-7") {
|
if ((script == "textgreek" && fontenc == "LGR")
|
||||||
// Correct encoding is being used, so we can avoid \textgreek.
|
||(script == "textcyr" && (fontenc == "T2A" || fontenc == "T2B"
|
||||||
// TODO: wrong test: we need to check the *font encoding*
|
|| fontenc == "T2C" || fontenc == "X2"))) {
|
||||||
// (i.e. the active language and its FontEncoding tag)
|
// Correct font encoding is being used, so we can avoid \text[greek|cyr].
|
||||||
// instead of the LaTeX *input encoding*!
|
|
||||||
// See #9637 for details and test-cases.
|
|
||||||
pos = brace1 + 1;
|
pos = brace1 + 1;
|
||||||
length -= pos;
|
length -= pos;
|
||||||
closing_brace = false;
|
closing_brace = false;
|
||||||
@ -1341,10 +1357,16 @@ void Paragraph::Private::latexSpecialChar(otexstream & os,
|
|||||||
tipas = true;
|
tipas = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
string fontenc;
|
||||||
|
if (running_font.language()->lang() == runparams.document_language)
|
||||||
|
fontenc = runparams.main_fontenc;
|
||||||
|
else
|
||||||
|
fontenc = running_font.language()->fontenc();
|
||||||
if (Encodings::isKnownScriptChar(c, script)
|
if (Encodings::isKnownScriptChar(c, script)
|
||||||
&& prefixIs(latex.first, from_ascii("\\" + script)))
|
&& prefixIs(latex.first, from_ascii("\\" + script)))
|
||||||
column += writeScriptChars(os, latex.first,
|
column += writeScriptChars(os, latex.first,
|
||||||
running_change, encoding, i) - 1;
|
running_change, encoding,
|
||||||
|
fontenc, i) - 1;
|
||||||
else if (latex.second
|
else if (latex.second
|
||||||
&& ((!prefixIs(nextlatex, '\\')
|
&& ((!prefixIs(nextlatex, '\\')
|
||||||
&& !prefixIs(nextlatex, '{')
|
&& !prefixIs(nextlatex, '{')
|
||||||
|
Loading…
Reference in New Issue
Block a user