The attached patch adds font support for tex2lyx. This font stuff as introduced 
with lyxformat 247.

regards Uwe
Index: Context.h
===================================================================
--- Context.h	(revision 21959)
+++ Context.h	(working copy)
@@ -36,7 +36,7 @@
 	}
 	void init()
 	{
-		size = "normal";
+		size = "default";
 		family = "default";
 		series = "default";
 		shape = "default";
Index: preamble.cpp
===================================================================
--- preamble.cpp	(revision 21959)
+++ preamble.cpp	(working copy)
@@ -68,13 +68,30 @@
 					       "frenchle", "frenchpro", 0};
 char const * const known_fontsizes[] = { "10pt", "11pt", "12pt", 0 };
 
+const char * const known_roman_fonts[] = { "ae", "bookman", "charter",
+"cmr", "fourier", "lmodern", "mathpazo", "mathptmx", "newcent", 0};
+
+const char * const known_sans_fonts[] = { "avant", "berasans", "cmbr", "cmss",
+"helvet", "lmss", 0};
+
+const char * const known_typewriter_fonts[] = { "beramono", "cmtl", "cmtt",
+"courier", "lmtt", "luximono", "fourier", "lmodern", "mathpazo", "mathptmx",
+"newcent", 0};
+
 // some ugly stuff
 ostringstream h_preamble;
 string h_textclass               = "article";
 string h_options                 = string();
 string h_language                = "english";
 string h_inputencoding           = "auto";
-string h_fontscheme              = "default";
+string h_font_roman              = "default";
+string h_font_sans               = "default";
+string h_font_typewriter         = "default";
+string h_font_default_family     = "default";
+string h_font_sc                 = "false";
+string h_font_osf                = "false";
+string h_font_sf_scale           = "100";
+string h_font_tt_scale           = "100";
 string h_graphics                = "default";
 string h_paperfontsize           = "default";
 string h_spacing                 = "single";
@@ -180,16 +197,39 @@
 {
 	vector<string> options = split_options(opts);
 	add_package(name, options);
+	size_t pos;
+	string scale;
 
-	//cerr << "handle_package: '" << name << "'\n";
-	if (name == "ae")
-		h_fontscheme = "ae";
-	else if (name == "aecompl")
-		h_fontscheme = "ae";
-	else if (name == "amsmath")
+	// roman fonts
+	if (is_known(name, known_roman_fonts))
+		h_font_roman = name;
+	if (name == "fourier")
+		h_font_roman = "utopia";
+	if (name == "mathpazo")
+		h_font_roman = "palatino";
+	if (name == "mathptmx")
+		h_font_roman = "times";
+	// sansserif fonts
+	if (is_known(name, known_sans_fonts)) {
+		h_font_sans = name;
+		if (!opts.empty()) {
+			scale = opts;
+			pos = scale.find(".", 0);
+			h_font_sf_scale = scale.erase(0, pos + 1);
+		}
+	}
+	// typewriter fonts
+	if (is_known(name, known_typewriter_fonts)) {
+		h_font_typewriter = name;
+		if (!opts.empty()) {
+			scale = opts;
+			pos = scale.find(".", 0);
+			h_font_tt_scale = scale.erase(0, pos + 1);
+		}
+	}
+
+	else if (name == "amsmath" || name == "amssymb")
 		h_use_amsmath = "1";
-	else if (name == "amssymb")
-		h_use_amsmath = "1";
 	else if (name == "babel")
 		; // ignore this
 	else if (name == "fontenc")
@@ -248,7 +288,7 @@
 void end_preamble(ostream & os, TextClass const & /*textclass*/)
 {
 	os << "#LyX file created by tex2lyx " << PACKAGE_VERSION << "\n"
-	   << "\\lyxformat 246\n"
+	   << "\\lyxformat 247\n"
 	   << "\\begin_document\n"
 	   << "\\begin_header\n"
 	   << "\\textclass " << h_textclass << "\n";
@@ -258,7 +298,14 @@
 		os << "\\options " << h_options << "\n";
 	os << "\\language " << h_language << "\n"
 	   << "\\inputencoding " << h_inputencoding << "\n"
-	   << "\\fontscheme " << h_fontscheme << "\n"
+	   << "\\font_roman " << h_font_roman << "\n"
+	   << "\\font_sans " << h_font_sans << "\n"
+	   << "\\font_typewriter " << h_font_typewriter << "\n"
+	   << "\\font_default_family " << h_font_default_family << "\n"
+	   << "\\font_sc " << h_font_sc << "\n"
+	   << "\\font_osf " << h_font_osf << "\n"
+	   << "\\font_sf_scale " << h_font_sf_scale << "\n"
+	   << "\\font_tt_scale " << h_font_tt_scale << "\n"
 	   << "\\graphics " << h_graphics << "\n"
 	   << "\\paperfontsize " << h_paperfontsize << "\n"
 	   << "\\spacing " << h_spacing << "\n"
@@ -355,16 +402,38 @@
 			string const opt1 = p.getOpt();
 			string const opt2 = p.getFullOpt();
 			string const body = p.verbatim_item();
+			// font settings
+			if (name == "\\rmdefault")
+				if (is_known(body, known_roman_fonts))
+					h_font_roman = body;
+
+			if (name == "\\sfdefault")
+				if (is_known(body, known_sans_fonts))
+					h_font_sans = body;
+
+			if (name == "\\ttdefault")
+				if (is_known(body, known_typewriter_fonts))
+					h_font_typewriter = body;
+
+			if (name == "\\familydefault") {
+				string family = body;
+				// remove leading "\"
+				h_font_default_family = family.erase(0,1);
+			}
 			// only non-lyxspecific stuff
 			if (   name != "\\noun"
-			    && name != "\\tabularnewline"
-			    && name != "\\LyX"
-			    && name != "\\lyxline"
-			    && name != "\\lyxaddress"
-			    && name != "\\lyxrightaddress"
-			    && name != "\\lyxdot"
-			    && name != "\\boldsymbol"
-			    && name != "\\lyxarrow") {
+				&& name != "\\tabularnewline"
+				&& name != "\\LyX"
+				&& name != "\\lyxline"
+				&& name != "\\lyxaddress"
+				&& name != "\\lyxrightaddress"
+				&& name != "\\lyxdot"
+				&& name != "\\boldsymbol"
+				&& name != "\\lyxarrow"
+				&& name != "\\rmdefault"
+				&& name != "\\sfdefault"
+				&& name != "\\ttdefault"
+				&& name != "\\familydefault") {
 				ostringstream ss;
 				ss << '\\' << t.cs();
 				if (star)
Index: text.cpp
===================================================================
--- text.cpp	(revision 21959)
+++ text.cpp	(working copy)
@@ -144,7 +144,7 @@
 "small", "normalsize", "large", "Large", "LARGE", "huge", "Huge", 0};
 
 /// the same as known_sizes with .lyx names
-char const * const known_coded_sizes[] = { "tiny", "scriptsize", "footnotesize",
+char const * const known_coded_sizes[] = { "default", "tiny", "scriptsize", "footnotesize",
 "small", "normal", "large", "larger", "largest",  "huge", "giant", 0};
 
 /// LaTeX 2.09 names for font families

Reply via email to