Browse Source

text: fix alignment when rendering text with inter-character spacing.

undefined
Sam Hocevar 9 years ago
parent
commit
a6c681d392
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      src/text.cpp

+ 2
- 2
src/text.cpp View File

@@ -102,8 +102,8 @@ void Text::TickDraw(float seconds, Scene &scene)
{ {
Font *font = Forge::GetFont(data->m_font); Font *font = Forge::GetFont(data->m_font);
vec3 delta(0.0f); vec3 delta(0.0f);
float text_width = (length - 0.5f) * font->GetSize().x
+ (length - 1) * data->m_spacing;
float text_width = ((length - 0.5f) + (length - 1) * data->m_spacing)
* font->GetSize().x;


if (data->m_align == TextAlign::Right) if (data->m_align == TextAlign::Right)
delta.x -= text_width * data->m_scale.x; delta.x -= text_width * data->m_scale.x;


Loading…
Cancel
Save