Jürgen Spitzmüller wrote:
> I plan to convert the unicode glyphs to TIPA shortcut notation inside the
> IPA  inset (in latex output), i.e. you'll get for the above
> 
> \textipa{Ekspl@neIS@n}

Attached is an approach for this. I think it is best to record the TIPA 
shortcuts in the unicodesymbols file to prevent code duplication. Since adding 
another column would be overkill for this, I propose to record the shortcut 
via a flag.

Opinions?

Jürgen
Index: lib/unicodesymbols
===================================================================
--- lib/unicodesymbols	(Revision 40866)
+++ lib/unicodesymbols	(Arbeitskopie)
@@ -34,6 +34,7 @@
 # - combining This is a combining char that will get combined with a base char
 # - force     Always output replacement command
 # - mathalpha This character is considered as a math variable in mathmode
+# - tipashortcut=<shortcut> Shortcut notation for TIPA
 
 0x00a0 "~"                        "" "" "~" "" # NO-BREAK SPACE
 0x00a1 "\\textexclamdown"         "" "" # INVERTED EXCLAMATION MARK
@@ -472,7 +473,7 @@
 #
 # IPA extensions
 #
-0x0250 "\\textturna"              "tipa" "force" # LATIN SMALL LETTER TURNED A
+0x0250 "\\textturna"              "tipa" "force,tipashortcut=5" # LATIN SMALL LETTER TURNED A
 0x0251 "\\textscripta"            "tipa" "force" # LATIN SMALL LETTER ALPHA
 0x0252 "\\textturnscripta"        "tipa" "force" # LATIN SMALL LETTER TURNED ALPHA
 0x0253 "\\texthtb"                "tipa" "force" # LATIN SMALL LETTER B WITH HOOK
Index: src/insets/InsetIPA.cpp
===================================================================
--- src/insets/InsetIPA.cpp	(Revision 40874)
+++ src/insets/InsetIPA.cpp	(Arbeitskopie)
@@ -194,8 +194,10 @@
 }
 
 
-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;
Index: src/OutputParams.h
===================================================================
--- src/OutputParams.h	(Revision 40866)
+++ src/OutputParams.h	(Arbeitskopie)
@@ -198,6 +198,11 @@
 	 */
 	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: src/Paragraph.cpp
===================================================================
--- src/Paragraph.cpp	(Revision 40866)
+++ src/Paragraph.cpp	(Arbeitskopie)
@@ -1262,13 +1262,21 @@
 			}
 		}
 		string script;
-		docstring const latex = encoding.latexChar(c);
+		docstring latex = encoding.latexChar(c);
+		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] != '-') {
+			 latex[latex.length() - 1] != '-' && !tipas) {
 			// Prevent eating of a following
 			// space or command corruption by
 			// following characters
Index: src/OutputParams.cpp
===================================================================
--- src/OutputParams.cpp	(Revision 40866)
+++ src/OutputParams.cpp	(Arbeitskopie)
@@ -25,7 +25,7 @@
 	  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: src/Encoding.cpp
===================================================================
--- src/Encoding.cpp	(Revision 40866)
+++ src/Encoding.cpp	(Arbeitskopie)
@@ -249,6 +249,8 @@
 	/// Always force the LaTeX command, even if the encoding contains
 	/// this character?
 	bool force;
+	/// TIPA shortcut
+	string tipashortcut;
 };
 
 
@@ -685,6 +687,15 @@
 }
 
 
+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 @@
 				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: src/Encoding.h
===================================================================
--- src/Encoding.h	(Revision 40866)
+++ src/Encoding.h	(Arbeitskopie)
@@ -172,6 +172,8 @@
 	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

Reply via email to