mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
preamble.cpp: code simplification to r21970 suggested by Angus
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22034 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2ea605f85a
commit
0667412a89
@ -200,11 +200,25 @@ void add_package(string const & name, vector<string> & options)
|
||||
}
|
||||
|
||||
|
||||
// Given is a string like "scaled=0.9", return 0.9 * 100
|
||||
string const scale_as_percentage(string const & scale)
|
||||
{
|
||||
string::size_type pos = scale.find('=');
|
||||
if (pos != string::npos) {
|
||||
string value = scale.substr(pos + 1);
|
||||
if (isStrDbl(value))
|
||||
return convert<string>(100 * convert<double>(value));
|
||||
}
|
||||
// If the input string didn't match our expectations.
|
||||
// return the default value "100"
|
||||
return "100";
|
||||
}
|
||||
|
||||
|
||||
void handle_package(string const & name, string const & opts)
|
||||
{
|
||||
vector<string> options = split_options(opts);
|
||||
add_package(name, options);
|
||||
size_t pos;
|
||||
string scale;
|
||||
|
||||
// roman fonts
|
||||
@ -225,17 +239,7 @@ void handle_package(string const & name, string const & opts)
|
||||
h_font_sans = name;
|
||||
if (!opts.empty()) {
|
||||
scale = opts;
|
||||
// the option is in the form "scaled=0.9"
|
||||
// therefore cut of before the "="
|
||||
pos = scale.find("=");
|
||||
if (pos != string::npos) {
|
||||
scale.erase(0, pos + 1);
|
||||
if (isStrDbl(scale)) {
|
||||
// LyX needs the scale as integer, therfore multiply by 100
|
||||
scale = convert<string>(100 * convert<double>(scale));
|
||||
h_font_sf_scale = scale;
|
||||
}
|
||||
}
|
||||
h_font_sf_scale = scale_as_percentage(scale);
|
||||
}
|
||||
}
|
||||
// typewriter fonts
|
||||
@ -243,17 +247,7 @@ void handle_package(string const & name, string const & opts)
|
||||
h_font_typewriter = name;
|
||||
if (!opts.empty()) {
|
||||
scale = opts;
|
||||
// the option is in the form "scaled=0.9"
|
||||
// therefore cut of before the "="
|
||||
pos = scale.find("=");
|
||||
if (pos != string::npos) {
|
||||
scale.erase(0, pos + 1);
|
||||
if (isStrDbl(scale)) {
|
||||
// LyX needs the scale as integer, therfore multiply by 100
|
||||
scale = convert<string>(100 * convert<double>(scale));
|
||||
h_font_tt_scale = scale;
|
||||
}
|
||||
}
|
||||
h_font_tt_scale = scale_as_percentage(scale);
|
||||
}
|
||||
}
|
||||
// font uses old-style figure
|
||||
|
Loading…
Reference in New Issue
Block a user