|
a/HelperStructs/Style.cpp |
|
b/HelperStructs/Style.cpp |
|
... |
|
... |
78 |
static regex bdmrg_regex(bdmrg_exp);
|
78 |
static regex bdmrg_regex(bdmrg_exp);
|
79 |
#endif
|
79 |
#endif
|
80 |
|
80 |
|
81 |
string Style::scale_fonts(const string& style, float multiplier)
|
81 |
string Style::scale_fonts(const string& style, float multiplier)
|
82 |
{
|
82 |
{
|
|
|
83 |
//cerr << "Style::scale_fonts: multiplier: " << multiplier << endl;
|
83 |
vector<string> lines;
|
84 |
vector<string> lines;
|
84 |
stringToTokens(style, lines, "\n");
|
85 |
stringToTokens(style, lines, "\n");
|
85 |
#if USE_REGEX
|
86 |
#if USE_REGEX
|
86 |
for (unsigned int ln = 0; ln < lines.size(); ln++) {
|
87 |
for (unsigned int ln = 0; ln < lines.size(); ln++) {
|
87 |
const string& line = lines[ln];
|
88 |
const string& line = lines[ln];
|
|
... |
|
... |
97 |
}
|
98 |
}
|
98 |
m = smatch();
|
99 |
m = smatch();
|
99 |
if (regex_match(line, m, bdmrg_regex) && m.size() == 4) {
|
100 |
if (regex_match(line, m, bdmrg_regex) && m.size() == 4) {
|
100 |
//cerr << "Got match (sz " << m.size() << ") for " << line << endl;
|
101 |
//cerr << "Got match (sz " << m.size() << ") for " << line << endl;
|
101 |
int fs = atoi(m[2].str().c_str());
|
102 |
int fs = atoi(m[2].str().c_str());
|
102 |
int nfs = round(fs * multiplier);
|
103 |
int nfs = ceil(fs * multiplier);
|
103 |
char buf[20];
|
104 |
char buf[20];
|
104 |
snprintf(buf, 20, "%d", nfs);
|
105 |
snprintf(buf, 20, "%d", nfs);
|
105 |
lines[ln] = m[1].str() + buf + m[3].str();
|
106 |
lines[ln] = m[1].str() + buf + m[3].str();
|
106 |
//cerr << "New line: [" << lines[ln] << "]\n";
|
107 |
//cerr << "New line: [" << lines[ln] << "]\n";
|
107 |
}
|
108 |
}
|