[another patch] Re: Feature Request: toolbar for phonetic symbols (IPA)
Jürgen Spitzmüller wrote: \textipa{\textepsilon{}kspl\textschwa{}ne\textsci{}\textesh{}\textschwa{}n} which is not only hardly readable (due to the macros), but also the kerning is broken by the {} which are appended after each macro. The kerning problem is addressed by the attached patch (which is on top of the other, as you can see). It assures the '{}' are only appended when needed (if a space follows). If a normal character follows, a blank is appended, if a macro follows, nothing is appended. So you get: \textipa{\textepsilon kspl\textschwa ne\textsci\textesh\textschwa n} which is the correct output. JürgenIndex: src/Paragraph.cpp === --- src/Paragraph.cpp (Revision 40866) +++ src/Paragraph.cpp (Arbeitskopie) @@ -1253,8 +1253,9 @@ 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,31 @@ } } string script; - docstring const latex = encoding.latexChar(c); + docstring latex = encoding.latexChar(c); + docstring nextlatex = (next == '\0') ? docstring(): 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(\\)) + 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') +os latex {}; + else +os latex ; } else { column += latex.length() - 1; os latex;
[another patch] Re: Feature Request: toolbar for phonetic symbols (IPA)
Jürgen Spitzmüller wrote: > \textipa{\textepsilon{}kspl\textschwa{}ne\textsci{}\textesh{}\textschwa{}n} > > which is not only hardly readable (due to the macros), but also the kerning > is broken by the {} which are appended after each macro. The kerning problem is addressed by the attached patch (which is on top of the other, as you can see). It assures the '{}' are only appended when needed (if a space follows). If a normal character follows, a blank is appended, if a macro follows, nothing is appended. So you get: \textipa{\textepsilon kspl\textschwa ne\textsci\textesh\textschwa n} which is the correct output. JürgenIndex: src/Paragraph.cpp === --- src/Paragraph.cpp (Revision 40866) +++ src/Paragraph.cpp (Arbeitskopie) @@ -1253,8 +1253,9 @@ 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,31 @@ } } string script; - docstring const latex = encoding.latexChar(c); + docstring latex = encoding.latexChar(c); + docstring nextlatex = (next == '\0') ? docstring(): 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("\\")) + && 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') +os << latex << "{}"; + else +os << latex << " "; } else { column += latex.length() - 1; os << latex;