mirror of
https://github.com/love2d/love.git
synced 2026-08-20 04:30:09 +02:00
Mostly fixed the center and right wrap alignments for love.graphics.printf.
This commit is contained in:
@@ -698,6 +698,7 @@ void Font::getWrap(const std::string &text, float wraplimit, std::vector<Codepoi
|
|||||||
while (std::getline(iss, line, '\n'))
|
while (std::getline(iss, line, '\n'))
|
||||||
{
|
{
|
||||||
float width = 0.0f;
|
float width = 0.0f;
|
||||||
|
float widthatlastspace = 0.0f;
|
||||||
uint32 prevglyph = 0;
|
uint32 prevglyph = 0;
|
||||||
|
|
||||||
wline.clear();
|
wline.clear();
|
||||||
@@ -732,6 +733,8 @@ void Font::getWrap(const std::string &text, float wraplimit, std::vector<Codepoi
|
|||||||
while (!wline.empty() && wline.back() != ' ')
|
while (!wline.empty() && wline.back() != ' ')
|
||||||
wline.pop_back();
|
wline.pop_back();
|
||||||
|
|
||||||
|
width = widthatlastspace;
|
||||||
|
|
||||||
i = lastspaceit;
|
i = lastspaceit;
|
||||||
++i; // Start the next line after the space.
|
++i; // Start the next line after the space.
|
||||||
}
|
}
|
||||||
@@ -756,7 +759,10 @@ void Font::getWrap(const std::string &text, float wraplimit, std::vector<Codepoi
|
|||||||
// Keep track of the last seen space, so we can "rewind" to it
|
// Keep track of the last seen space, so we can "rewind" to it
|
||||||
// when wrapping.
|
// when wrapping.
|
||||||
if (c == ' ')
|
if (c == ' ')
|
||||||
|
{
|
||||||
|
widthatlastspace = width;
|
||||||
lastspaceit = i;
|
lastspaceit = i;
|
||||||
|
}
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user