update
This commit is contained in:
parent
ef8d623525
commit
c9ebd448f9
7 changed files with 278 additions and 73 deletions
|
|
@ -363,8 +363,14 @@ export namespace Crafter {
|
|||
int baseline = (int)(font.ascent * scale);
|
||||
std::uint32_t lineHeight = (font.ascent - font.descent) * scale;
|
||||
std::uint32_t currentY = baseline;
|
||||
for(std::string_view line : lines) {
|
||||
|
||||
std::uint32_t ogOffsetX = offsetX;
|
||||
std::uint32_t ogOffsetY = offsetY;
|
||||
|
||||
for(std::string_view line : lines) {
|
||||
offsetX = ogOffsetX;
|
||||
offsetY = ogOffsetY;
|
||||
|
||||
std::int32_t lineWidth = 0;
|
||||
for (const char c : line) {
|
||||
int advance, lsb;
|
||||
|
|
@ -379,7 +385,7 @@ export namespace Crafter {
|
|||
offsetX -= lineWidth / 2;
|
||||
break;
|
||||
case TextAlignment::Right:
|
||||
offsetX += lineWidth;
|
||||
offsetX -= lineWidth;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -456,21 +462,12 @@ export namespace Crafter {
|
|||
}
|
||||
}
|
||||
|
||||
if(alignment != TextAlignment::Right) {
|
||||
offsetX += (int)(ax * scale);
|
||||
offsetX += (int)(ax * scale);
|
||||
|
||||
if (p + 1 < end) {
|
||||
int next;
|
||||
offsetX += (int)stbtt_GetGlyphKernAdvance(&font.font, codepoint, utf8_decode(p+1, &next));
|
||||
}
|
||||
} else {
|
||||
offsetX -= (int)(ax * scale);
|
||||
|
||||
if (p + 1 < end) {
|
||||
int next;
|
||||
offsetX -= (int)stbtt_GetGlyphKernAdvance(&font.font, codepoint, utf8_decode(p+1, &next));
|
||||
}
|
||||
}
|
||||
if (p + 1 < end) {
|
||||
int next;
|
||||
offsetX += (int)stbtt_GetGlyphKernAdvance(&font.font, codepoint, utf8_decode(p+1, &next));
|
||||
}
|
||||
}
|
||||
currentY += lineHeight;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue