fixed alignment of empty text

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@129 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-12-19 17:53:02 +00:00
parent 6f852e5846
commit 2552afe8be
2 changed files with 12 additions and 3 deletions
+11 -2
View File
@@ -128,7 +128,7 @@ void TextViewer::prepare(RotatedDC& dc, const String& text, const TextStyle& sty
// not prepared yet
Rotater r(dc, style.getRotation());
prepareElements(text, style, ctx);
prepareLines(dc, text, style);
prepareLines(dc, text, style, ctx);
}
}
void TextViewer::reset() {
@@ -243,13 +243,22 @@ void TextViewer::prepareElements(const String& text, const TextStyle& style, Con
// ----------------------------------------------------------------------------- : Layout
void TextViewer::prepareLines(RotatedDC& dc, const String& text, const TextStyle& style) {
void TextViewer::prepareLines(RotatedDC& dc, const String& text, const TextStyle& style, Context& ctx) {
scale = 1;
// find character sizes
vector<CharInfo> chars;
elements.getCharInfo(dc, scale, 0, text.size(), chars);
// try to layout
prepareLinesScale(dc, chars, style, false);
// no text, find a dummy height for the single line we have
if (lines.size() == 1 && lines[0].width() < 0.0001) {
if (style.always_symbol && style.symbol_font.valid()) {
lines[0].line_height = style.symbol_font.font->defaultSymbolSize(ctx, style.symbol_font.size).height;
} else {
dc.SetFont(style.font.font);
lines[0].line_height = dc.GetTextExtent(_(" ")).height;
}
}
// align
alignLines(dc, chars, style);
}