* implement possibility to use IPA shortcut notation (the actual shortcuts will follow)

* 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
This commit is contained in:
Jürgen Spitzmüller 2012-03-09 09:05:13 +00:00
parent 50902c2628
commit 84971fb27e
6 changed files with 50 additions and 8 deletions

View 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"

View 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

View 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),

View 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.
*/

View 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;

View 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;