]> git.lyx.org Git - lyx.git/commitdiff
* implement possibility to use IPA shortcut notation (the actual shortcuts will follow)
authorJürgen Spitzmüller <spitz@lyx.org>
Fri, 9 Mar 2012 09:05:13 +0000 (09:05 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Fri, 9 Mar 2012 09:05:13 +0000 (09:05 +0000)
* do not terminate macros by {} if not necessary (prevent kerning violation)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40891 a592a061-630c-0410-9148-cb99ea01b6c8

src/Encoding.cpp
src/Encoding.h
src/OutputParams.cpp
src/OutputParams.h
src/Paragraph.cpp
src/insets/InsetIPA.cpp

index eda99026d4dd2253e692d0aba90d5157b79118d7..8b1eaca96d3d719a5011c58261c18ccda2bf76af 100644 (file)
@@ -249,6 +249,8 @@ struct CharInfo {
        /// Always force the LaTeX command, even if the encoding contains
        /// this character?
        bool force;
+       /// TIPA shortcut
+       string tipashortcut;
 };
 
 
@@ -685,6 +687,15 @@ bool Encodings::isCombiningChar(char_type c)
 }
 
 
+string const Encodings::TIPAShortcut(char_type c)
+{
+       CharInfoMap::const_iterator const it = unicodesymbols.find(c);
+       if (it != unicodesymbols.end())
+               return it->second.tipashortcut;
+       return string();
+}
+
+
 bool Encodings::isKnownScriptChar(char_type const c, string & preamble)
 {
        CharInfoMap::const_iterator const it = unicodesymbols.find(c);
@@ -797,6 +808,8 @@ void Encodings::read(FileName const & encfile, FileName const & symbolsfile)
                                forced.insert(symbol);
                        } else if (flag == "mathalpha") {
                                mathalpha.insert(symbol);
+                       } else if (contains(flag, "tipashortcut=")) {
+                               info.tipashortcut = split(flag, '=');
                        } else {
                                lyxerr << "Ignoring unknown flag `" << flag
                                       << "' for symbol `0x"
index effde73ffc7e7cc645b7472e6abed57f586756f2..4d68c3b7218e979f1befe1f67e2eac13332f2ddf 100644 (file)
@@ -172,6 +172,8 @@ public:
        static char_type transformChar(char_type c, LetterForm form);
        /// Is this a combining char?
        static bool isCombiningChar(char_type c);
+       /// Return the TIPA shortcut
+       static std::string const TIPAShortcut(char_type c);
        /**
         * Is this a known char from some language?
         * If \p preamble is empty and code point \p c is known to belong
index a0e7a1c40a2f590d4dbbeb90a9adeb4c7313e530..5e7d9f239d73f157bd6258d06f4012e85cf02149 100644 (file)
@@ -25,7 +25,7 @@ OutputParams::OutputParams(Encoding const * enc)
          use_indices(false), use_japanese(false), linelen(0), depth(0),
          exportdata(new ExportData),
          inComment(false), inTableCell(NO), inFloat(NONFLOAT),
-         inIndexEntry(false), inDeletedInset(0),
+         inIndexEntry(false), inIPA(false), inDeletedInset(0),
          changeOfDeletedInset(Change::UNCHANGED),
          par_begin(0), par_end(0), lastid(-1), lastpos(-1), isLastPar(false),
          dryrun(false), pass_thru(false), 
index 5f57ac1f830a2509b96746e019ea6a0eb907e1f5..15736f667da4a11fc884036bcc92d3276f83a7b9 100644 (file)
@@ -198,6 +198,11 @@ public:
         */
        bool inIndexEntry;
 
+       /** Whether we are inside an IPA inset.
+        *  Needed for proper IPA output.
+        */
+       bool inIPA;
+
        /** Whether we are inside an inset that is logically deleted.
         *  A value > 0 indicates a deleted inset.
          */
index fa274e3f45ac4a09f820230b75b8ecd46389e5ea..37c078b9c5a9d057e9695a87026625d1570d3414 100644 (file)
@@ -1253,8 +1253,9 @@ void Paragraph::Private::latexSpecialChar(otexstream & os,
                        return;
 
                Encoding const & encoding = *(runparams.encoding);
+               char_type next = '\0';
                if (i + 1 < int(text_.size())) {
-                       char_type next = text_[i + 1];
+                       next = text_[i + 1];
                        if (Encodings::isCombiningChar(next)) {
                                column += latexSurrogatePair(os, c, next, runparams) - 1;
                                ++i;
@@ -1262,18 +1263,37 @@ void Paragraph::Private::latexSpecialChar(otexstream & os,
                        }
                }
                string script;
-               docstring const latex = encoding.latexChar(c);
+               docstring latex = encoding.latexChar(c);
+               docstring nextlatex;
+               if (next != '\0' && next != META_INSET)
+                       nextlatex = encoding.latexChar(next);
+               bool tipas = false;
+               if (runparams.inIPA) {
+                       string const tipashortcut = Encodings::TIPAShortcut(c);
+                       if (!tipashortcut.empty()) {
+                               latex = from_ascii(tipashortcut);
+                               tipas = true;
+                       }
+               }
                if (Encodings::isKnownScriptChar(c, script)
                    && prefixIs(latex, from_ascii("\\" + script)))
                        column += writeScriptChars(os, latex,
                                        running_change, encoding, i) - 1;
-               else if (latex.length() > 1 && latex[latex.length() - 1] != '}' &&
-                        latex[latex.length() - 1] != '-') {
+               else if (!prefixIs(nextlatex, from_ascii("\\"))
+                        && !prefixIs(nextlatex, from_ascii("{"))
+                        && !prefixIs(nextlatex, from_ascii("}"))
+                        && latex.length() > 1 && latex[latex.length() - 1] != '}'
+                        && latex[latex.length() - 1] != '-' && !tipas) {
                        // Prevent eating of a following
                        // space or command corruption by
                        // following characters
-                       column += latex.length() + 1;
-                       os << latex << "{}";
+                       if (next == ' ' || next == '\0') {
+                               column += latex.length() + 1;
+                               os << latex << "{}";
+                       } else {
+                               column += latex.length();
+                               os << latex << " ";
+                       }
                } else {
                        column += latex.length() - 1;
                        os << latex;
index bfa0ca9d5c3408aee59e616e87eb123cfc163876..edee27e4b4d6a101314e3124ae75698c4270f58f 100644 (file)
@@ -194,8 +194,10 @@ void InsetIPA::validate(LaTeXFeatures & features) const
 }
 
 
-void InsetIPA::latex(otexstream & os, OutputParams const & runparams) const
+void InsetIPA::latex(otexstream & os, OutputParams const & runparams_in) const
 {
+       OutputParams runparams(runparams_in);
+       runparams.inIPA = true;
        bool const multipar = (text().paragraphs().size() > 1);
        // fontspec knows \textipa, but not the IPA environment
        bool const nontexfonts = buffer_->params().useNonTeXFonts;