mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-08 10:51:03 +00:00
tex2lyx: support font settings -> move fileformat to 247
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21970 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
6ef3177bef
commit
cdffbf18bd
@ -36,7 +36,7 @@ public:
|
||||
}
|
||||
void init()
|
||||
{
|
||||
size = "normal";
|
||||
size = "default";
|
||||
family = "default";
|
||||
series = "default";
|
||||
shape = "default";
|
||||
|
@ -68,13 +68,30 @@ const char * const known_french_languages[] = {"french", "frenchb", "francais",
|
||||
"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,15 +197,38 @@ void handle_package(string const & name, string const & opts)
|
||||
{
|
||||
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")
|
||||
h_use_amsmath = "1";
|
||||
else if (name == "amssymb")
|
||||
// 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 == "babel")
|
||||
; // ignore this
|
||||
@ -248,7 +288,7 @@ void handle_package(string const & name, string const & opts)
|
||||
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 @@ void end_preamble(ostream & os, TextClass const & /*textclass*/)
|
||||
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,6 +402,24 @@ TextClass const parse_preamble(Parser & p, ostream & os, string const & forcecla
|
||||
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"
|
||||
@ -364,7 +429,11 @@ TextClass const parse_preamble(Parser & p, ostream & os, string const & forcecla
|
||||
&& name != "\\lyxrightaddress"
|
||||
&& name != "\\lyxdot"
|
||||
&& name != "\\boldsymbol"
|
||||
&& name != "\\lyxarrow") {
|
||||
&& name != "\\lyxarrow"
|
||||
&& name != "\\rmdefault"
|
||||
&& name != "\\sfdefault"
|
||||
&& name != "\\ttdefault"
|
||||
&& name != "\\familydefault") {
|
||||
ostringstream ss;
|
||||
ss << '\\' << t.cs();
|
||||
if (star)
|
||||
|
@ -144,7 +144,7 @@ char const * const known_sizes[] = { "tiny", "scriptsize", "footnotesize",
|
||||
"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
|
||||
|
Loading…
Reference in New Issue
Block a user