mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
Fixed bug in fields in style file;
No longer doing GetTextExtent("\n");
Moved pt boxes to style files;
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@390 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -33,14 +33,20 @@ void FontTextElement::getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>&
|
||||
dc.SetFont(*font, scale);
|
||||
// find sizes & breaks
|
||||
double prev_width = 0;
|
||||
size_t line_start = start; // start of the current line
|
||||
for (size_t i = start ; i < end ; ++i) {
|
||||
Char c = content.GetChar(i - this->start);
|
||||
RealSize s = dc.GetTextExtent(content.substr(start - this->start, i - start + 1));
|
||||
out.push_back(CharInfo(RealSize(s.width - prev_width, s.height),
|
||||
c == _('\n') ? break_style :
|
||||
c == _(' ') ? BREAK_SOFT : BREAK_MAYBE
|
||||
));
|
||||
prev_width = s.width;
|
||||
if (c == _('\n')) {
|
||||
out.push_back(CharInfo(RealSize(0, dc.GetCharHeight()), break_style));
|
||||
line_start = i + 1;
|
||||
prev_width = 0;
|
||||
} else {
|
||||
RealSize s = dc.GetTextExtent(content.substr(line_start - this->start, i - line_start + 1));
|
||||
out.push_back(CharInfo(RealSize(s.width - prev_width, s.height),
|
||||
c == _(' ') ? BREAK_SOFT : BREAK_MAYBE
|
||||
));
|
||||
prev_width = s.width;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,11 @@ class IndexMap : private vector<Value> {
|
||||
/// Initialize this map with default values given a list of keys
|
||||
/** has no effect if already initialized with the given keys */
|
||||
bool init(const vector<Key>& keys) {
|
||||
if (this->size() == keys.size() && (this->empty() || get_key(this->front()) == keys.front())) return false;
|
||||
if (!this->empty() && (keys.empty() || get_key(this->front()) != keys.front())) {
|
||||
// switch to different keys
|
||||
clear();
|
||||
}
|
||||
if (this->size() == keys.size()) return false;
|
||||
this->reserve(keys.size());
|
||||
for(typename vector<Key>::const_iterator it = keys.begin() ; it != keys.end() ; ++it) {
|
||||
const Key& key = *it;
|
||||
|
||||
Reference in New Issue
Block a user