Le 14/02/2012 00:47, Richard Heck a écrit :
Try out the enclosed minimal lyx file.

1. exporting to latex and reimporting into lyx from
FIle>>Import>>Latex(plain) produces garbage characters for the dashes

2. However, calling>tex2lyx -e UTF8 from the command line produces
the correct file.
Still, it's surprising we fail in this particular case, so I'd guess it
is indeed a bug. I'll cross-post to devel.

tex2lyx is not really the culprit. The file you attach is broken : it does not use xetex/luatex, but it does use "Unicode (XeTeX) (utf8)" as encoding. As a result, the latex export of the file does not specify any encoding, and tex2lyx is not able to guess it.

Even better, try to visualize the file: the encoding will be bogus, without any intervention of tex2lyx.

What happens in this case is that the encoding is set to latin1 (utf8 is a better default in some sense, but if you guess it wrong, you can bet convertion errors, see bug #7509).

Unfortuantely, it seems that the encodings utf8 and utf8x (handled by plain latex), do not understand some of your hyphens, and produce a document that does not compile.

So your best bet is probably to produce a file that will be imported as XeTeX/LuaTeX. This will happen when some characteristic packages are recognized, which will happen after the followinf patch is applied.

Georg, Juergen, I'd like some feedback on the soundness of the patch. I know next to nil about xetex, and I do not know what is the current state of the art wrt tex2lyx.

JMarc


Index: src/tex2lyx/Preamble.cpp
===================================================================
--- src/tex2lyx/Preamble.cpp	(révision 40747)
+++ src/tex2lyx/Preamble.cpp	(copie de travail)
@@ -401,6 +401,7 @@
 	h_font_sans               = "default";
 	h_font_typewriter         = "default";
 	h_font_default_family     = "default";
+	h_use_non_tex_fonts       = "false";
 	h_font_sc                 = "false";
 	h_font_osf                = "false";
 	h_font_sf_scale           = "100";
@@ -581,8 +582,11 @@
 	add_package(name, options);
 	string scale;
 
-	if (is_known(name, known_xetex_packages))
+	if (is_known(name, known_xetex_packages)) {
 		xetex = true;
+		h_use_non_tex_fonts = "true";
+		p.setEncoding("utf8");
+	}
 
 	// roman fonts
 	if (is_known(name, known_roman_fonts)) {
@@ -901,6 +905,7 @@
 	   << "\\font_sans " << h_font_sans << "\n"
 	   << "\\font_typewriter " << h_font_typewriter << "\n"
 	   << "\\font_default_family " << h_font_default_family << "\n"
+	   << "\\use_non_tex_fonts " << h_use_non_tex_fonts << "\n"
 	   << "\\font_sc " << h_font_sc << "\n"
 	   << "\\font_osf " << h_font_osf << "\n"
 	   << "\\font_sf_scale " << h_font_sf_scale << "\n"
Index: src/tex2lyx/Preamble.h
===================================================================
--- src/tex2lyx/Preamble.h	(révision 40747)
+++ src/tex2lyx/Preamble.h	(copie de travail)
@@ -90,6 +90,7 @@
 	std::string h_font_sans;
 	std::string h_font_typewriter;
 	std::string h_font_default_family;
+	std::string h_use_non_tex_fonts;
 	std::string h_font_sc;
 	std::string h_font_osf;
 	std::string h_font_sf_scale;

Reply via email to