[EMAIL PROTECTED] wrote:
// special columntypes
extern std::map<char, int> special_columns;
@@ -218,8 +220,17 @@
h_font_sans = name;
if (!opts.empty()) {
scale = opts;
- pos = scale.find(".");
- h_font_sf_scale = scale.erase(0, pos + 1);
+ // 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;
+ }
+ }
}
}
// typewriter fonts
@@ -227,8 +238,17 @@
h_font_typewriter = name;
if (!opts.empty()) {
scale = opts;
- pos = scale.find(".");
- h_font_tt_scale = scale.erase(0, pos + 1);
+ // 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;
+ }
+ }
}
}
Couldn't you put this code in a function and call it from both places?
h_font_sf_scale = extract_scale_as_percentage(scale);
h_font_tt_scale = extract_scale_as_percentage(scale);
// Given a string "scaled=0.9", return 0.9 * 100
string const extract_scale_as_percentage(string const & scale)
{
string::size_type pos = scale.find('=');
if (pos != string::npos)
{
string value = scale.substr(pos);
if (isStrDbl(value))
return convert<string>(100 * convert<double>(value));
}
// The input data didn't match our expectations.
// return it unaltered.
return scale;
}
Angus