Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Client|GLTextComposer: Apply line alignment
  • Loading branch information
skyjake committed Jun 8, 2013
1 parent 948cbdf commit 1c34193
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions doomsday/client/src/ui/widgets/gltextcomposer.cpp
Expand Up @@ -322,7 +322,7 @@ void GLTextComposer::makeVertices(Vertices &triStrip,
continue;

Instance::Line::Segment &seg = line.segs.last();
if(seg.right() > d->wraps->maximumWidth())
if(seg.right() > d->wraps->maximumWidth() + 1)
{
// Needs compressing (up to 15%).
seg.compressed = true;
Expand Down Expand Up @@ -351,7 +351,21 @@ void GLTextComposer::makeVertices(Vertices &triStrip,
size.x = seg.width;
}

Rectanglef const uv = d->atlas->imageRectf(seg.id);
// Line alignment.
/// @todo How to center/right-align text that uses tab stops?
if(line.segs.size() == 1 && !d->wraps->lineInfo(0).segs[0].tabStop)
{
if(lineAlign.testFlag(AlignRight))
{
linePos.x += int(rect.width()) - int(size.x);
}
else if(!lineAlign.testFlag(AlignLeft))
{
linePos.x += (int(rect.width()) - int(size.x)) / 2;
}
}

Rectanglef const uv = d->atlas->imageRectf(seg.id);

triStrip.makeQuad(Rectanglef::fromSize(linePos + Vector2f(seg.x, 0), size),
color, uv);
Expand Down

0 comments on commit 1c34193

Please sign in to comment.