From bf24f6cba229916a4782678d8b6ec7fde59246f7 Mon Sep 17 00:00:00 2001 From: Pieter Hulshoff Date: Sat, 28 May 2016 08:55:24 +0200 Subject: [PATCH] Fixed vertical alignment for text wider than the maximum width. --- RetroFE/Source/Graphics/Component/Text.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/RetroFE/Source/Graphics/Component/Text.cpp b/RetroFE/Source/Graphics/Component/Text.cpp index 5e78063..0954a5c 100644 --- a/RetroFE/Source/Graphics/Component/Text.cpp +++ b/RetroFE/Source/Graphics/Component/Text.cpp @@ -66,6 +66,9 @@ void Text::draw() float imageHeight = 0; float imageWidth = 0; + imageHeight = (float)font->getHeight(); + float scale = (float)baseViewInfo.FontSize / (float)imageHeight; + // determine image width for(unsigned int i = 0; i < textData_.size(); ++i) { @@ -77,14 +80,14 @@ void Text::draw() imageWidth += glyph.minX; } + if ((imageWidth + glyph.advance)*scale > baseViewInfo.MaxWidth ) + break; + imageWidth += glyph.advance; } } - imageHeight = (float)font->getHeight(); - float scale = (float)baseViewInfo.FontSize / (float)imageHeight; - float oldWidth = baseViewInfo.Width; float oldHeight = baseViewInfo.Height; float oldImageWidth = baseViewInfo.ImageHeight;