/// Always force the LaTeX command, even if the encoding contains
/// this character?
bool force;
+ /// TIPA shortcut
+ string tipashortcut;
};
}
+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);
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"
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
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),
*/
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.
*/
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;
}
}
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;
}
-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;