Skip to content

Commit 4c849ca

Browse files
committed
I dunno.
1 parent 2ec169a commit 4c849ca

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/Core/TextLayout.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,28 @@ static void ClearLayout() {
497497
LD->textH = 0;
498498
}
499499

500+
static void FindWrapIndex(const char* str, int& index) {
501+
int startIndex = LD->charIndex;
502+
int startNextIndex = LD->nextCharIndex;
503+
int startWidth = LD->lineW;
504+
505+
while (true) {
506+
auto glyph = ReadGlyph(reinterpret_cast<const uint8_t*>(str));
507+
if (!glyph || glyph->isNewline) {
508+
index = INT_MAX;
509+
break;
510+
}
511+
startWidth += glyph->advance;
512+
513+
// Only wrap on whitespace.
514+
if (glyph->isWhitespace) index = LD->charIndex;
515+
if (startWidth > LD->maxLineW) break;
516+
}
517+
518+
LD->charIndex = startIndex;
519+
LD->nextCharIndex = startNextIndex;
520+
}
521+
500522
static void CreateLayout(const char* str) {
501523
// Make a list of every line of glyphs.
502524
bool isMultiline = !(LD->flags & Text::SINGLE_LINE);
@@ -548,28 +570,6 @@ static void CreateLayout(const char* str) {
548570
}
549571
}
550572

551-
static void FindWrapIndex(const char* str, int& index) {
552-
int startIndex = LD->charIndex;
553-
int startNextIndex = LD->nextCharIndex;
554-
int startWidth = LD->lineW;
555-
556-
while (true) {
557-
auto glyph = ReadGlyph(reinterpret_cast<const uint8_t*>(str));
558-
if (!glyph || glyph->isNewline) {
559-
index = INT_MAX;
560-
break;
561-
}
562-
startWidth += glyph->advance;
563-
564-
// Only wrap on whitespace.
565-
if (glyph->isWhitespace) index = LD->charIndex;
566-
if (startWidth > LD->maxLineW) break;
567-
}
568-
569-
LD->charIndex = startIndex;
570-
LD->nextCharIndex = startNextIndex;
571-
}
572-
573573
static void AlignText() {
574574
// Apply horizontal alignments (left = 0, center = 1, right = 2).
575575
static const int alignH[9] = {0, 1, 2, 0, 1, 2, 0, 1, 2};

0 commit comments

Comments
 (0)