X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FEncoding.cpp;h=ad380d78039d69f83ffa048bb14b3ed9a54c51b5;hb=1e519d1115f41f71c253cb9e2fbb7803e9a583a9;hp=96e35ecbb707e04e75fee87cb30211fbbdc8173e;hpb=e30f3d76d2bee0011ceaeb5f0cc221156458cbad;p=lyx.git diff --git a/src/Encoding.cpp b/src/Encoding.cpp index 96e35ecbb7..ad380d7803 100644 --- a/src/Encoding.cpp +++ b/src/Encoding.cpp @@ -189,9 +189,16 @@ bool Encoding::encodable(char_type c) const { // assure the used encoding is properly initialized init(); - if (iconvName_ == "UTF-8" && package_ == none) return true; + // platex does not load inputenc: force conversion of supported characters + if (package_ == Encoding::japanese + && ((0xb7 <= c && c <= 0x05ff) // Latin-1 Supplement ... Hebrew + || (0x1d00 <= c && c <= 0x218f) // Phonetic Extensions ... Number Forms + || (0x2193 <= c && c <= 0x2aff) // Arrows ... Supplemental Mathematical Operators + || (0xfb00 <= c && c <= 0xfb4f) // Alphabetic Presentation Forms + || (0x1d400 <= c && c <= 0x1d7ff))) // Mathematical Alphanumeric Symbols + return false; if (c < start_encodable_ && !isForced(c)) return true; if (encodable_.find(c) != encodable_.end()) @@ -223,8 +230,8 @@ pair Encoding::latexString(docstring const & input, bool d docstring uncodable; bool terminate = false; for (size_t n = 0; n < input.size(); ++n) { + char_type const c = input[n]; try { - char_type const c = input[n]; pair latex_char = latexChar(c); docstring const latex = latex_char.first; if (terminate && !prefixIs(latex, '\\') @@ -241,7 +248,8 @@ pair Encoding::latexString(docstring const & input, bool d result += latex; terminate = latex_char.second; } catch (EncodingException & /* e */) { - LYXERR0("Uncodable character in latexString!"); + LYXERR0("Uncodable character <" << docstring(1, c) + << "> in latexString!"); if (dryrun) { result += "<" + _("LyX Warning: ") + _("uncodable character") + " '"; @@ -306,10 +314,11 @@ bool Encodings::latexMathChar(char_type c, bool mathmode, if (!encoding || command.empty()) { command = it->second.textcommand(); needsTermination = !it->second.textnotermination(); - addTextCmd(c); } if (mathmode) addMathSym(c); + else + addTextCmd(c); } return use_math; } @@ -581,21 +590,29 @@ string const Encodings::TIPAShortcut(char_type c) } -bool Encodings::isKnownScriptChar(char_type const c, string & preamble) +string const Encodings::isKnownScriptChar(char_type const c) { CharInfoMap::const_iterator const it = unicodesymbols.find(c); if (it == unicodesymbols.end()) - return false; + return string(); + // FIXME: parse complex textpreamble (may be list or alternatives, + // e.g., "subscript,textgreek" or "textcomp|textgreek") + if (it->second.textpreamble() == "textgreek" + || it->second.textpreamble() == "textcyrillic") + return it->second.textpreamble(); + return string(); +} - if (it->second.textpreamble() != "textgreek" && it->second.textpreamble() != "textcyr") - return false; - if (preamble.empty()) { - preamble = it->second.textpreamble(); - return true; - } - return it->second.textpreamble() == preamble; +bool Encodings::fontencSupportsScript(string const & fontenc, string const & script) +{ + if (script == "textgreek") + return (fontenc == "LGR" || fontenc == "TU"); + if (script == "textcyrillic") + return (fontenc == "T2A" || fontenc == "T2B" || fontenc == "T2C" + || fontenc == "X2" || fontenc == "TU"); + return false; } @@ -715,16 +732,16 @@ void Encodings::read(FileName const & encfile, FileName const & symbolsfile) flags |= CharInfoForce; forced.insert(symbol); } else if (prefixIs(flag, "force=")) { - vector encodings = + vector encs = getVectorFromString(flag.substr(6), ";"); - for (size_t i = 0; i < encodings.size(); ++i) - forcedselected[encodings[i]].insert(symbol); + for (size_t i = 0; i < encs.size(); ++i) + forcedselected[encs[i]].insert(symbol); flags |= CharInfoForceSelected; } else if (prefixIs(flag, "force!=")) { - vector encodings = + vector encs = getVectorFromString(flag.substr(7), ";"); - for (size_t i = 0; i < encodings.size(); ++i) - forcednotselected[encodings[i]].insert(symbol); + for (size_t i = 0; i < encs.size(); ++i) + forcednotselected[encs[i]].insert(symbol); flags |= CharInfoForceSelected; } else if (flag == "mathalpha") { mathalpha.insert(symbol);