# HG changeset patch # Parent c334ce6c2bca9a332bc0c263bc9aa420d46d35ae -Fix [FS#5617] (r25344): Texts using font size modifiers caused problems with content height calculation diff -r c334ce6c2bca src/story_gui.cpp --- a/src/story_gui.cpp Fri Sep 13 14:53:34 2013 +0200 +++ b/src/story_gui.cpp Fri Sep 13 15:31:30 2013 +0200 @@ -317,17 +317,20 @@ */ uint CountPageElementLines(const StoryPageElement &pe, int max_width) { + int line_height = GetStringHeight(STR_JUST_NOTHING, INT_MAX); + if (line_height == 0) return 1; + switch (pe.type) { - case SPET_TEXT: + case SPET_TEXT: { SetDParamStr(0, pe.text); - return GetStringLineCount(STR_BLACK_RAW_STRING, max_width); + int height = GetStringHeight(STR_BLACK_RAW_STRING, max_width); + int rest = height % line_height; + return height / line_height + (rest > 0 ? 1 : 0); break; - + } case SPET_GOAL: case SPET_LOCATION: { Dimension sprite_dim = GetSpriteSize(GetPageElementSprite(pe)); - int line_height = GetStringHeight(STR_JUST_NOTHING, INT_MAX); - if (line_height == 0) return 1; return max((uint)1, sprite_dim.height / (uint)line_height); break; } @@ -499,6 +502,7 @@ /* Draw content (now coordinates given to Draw** are local to the new clipping region). */ int line_height = GetStringHeight(STR_JUST_NOTHING, INT_MAX); + assert(line_height > 0); int y_offset = - this->vscroll->GetPosition() * line_height; /* Date */ @@ -516,10 +520,15 @@ y_offset += line_height; // margin to previous element switch (pe->type) { - case SPET_TEXT: + case SPET_TEXT: { SetDParamStr(0, pe->text); - y_offset = DrawStringMultiLine(0, right - x, y_offset, bottom - y, STR_JUST_RAW_STRING, TC_BLACK, SA_TOP | SA_LEFT); + int height = GetStringHeight(STR_BLACK_RAW_STRING, right - x); + int y_padding = line_height - (height % line_height); + int text_y_offset = y_padding / 2; + SetDParamStr(0, pe->text); + y_offset = DrawStringMultiLine(0, right - x, y_offset + text_y_offset, bottom - y, STR_JUST_RAW_STRING, TC_BLACK, SA_TOP | SA_LEFT); break; + } case SPET_GOAL: { Goal *g = Goal::Get((GoalID) pe->referenced_id);