]> git.lyx.org Git - lyx.git/blobdiff - src/Encoding.cpp
Fix some group boxes.
[lyx.git] / src / Encoding.cpp
index 7dc12af0271fb1849f1212a6a654980eb566b3c4..750a2ba3cd6431bcf83fcc07f450914548368d01 100644 (file)
@@ -59,7 +59,7 @@ MathAlphaSet mathalpha;
 /// The highest code point in UCS4 encoding (1<<20 + 1<<16)
 char_type const max_ucs4 = 0x110000;
 
-} // namespace anon
+} // namespace
 
 
 EncodingException::EncodingException(char_type c)
@@ -306,10 +306,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 +582,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 +724,16 @@ void Encodings::read(FileName const & encfile, FileName const & symbolsfile)
                                flags |= CharInfoForce;
                                forced.insert(symbol);
                        } else if (prefixIs(flag, "force=")) {
-                               vector<string> encodings =
+                               vector<string> 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<string> encodings =
+                               vector<string> 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);