mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[reader] Fixed bug when a word is too big
This commit is contained in:
@@ -120,6 +120,7 @@ size_t StringGlyphLength(const char * s, int maxSize = -1);
|
||||
const char * BeginningOfWord(const char * text, const char * word);
|
||||
// Returns the position of the first following char ' ', '\n' or 0
|
||||
const char * EndOfWord(const char * word);
|
||||
const char * EndOfWord(const char * word, const char * end);
|
||||
|
||||
// On a line, count number of glyphs before and after locations
|
||||
void countGlyphsInLine(const char * text, int * before, int * after, const char * beforeLocation, const char *afterLocation = nullptr);
|
||||
|
||||
@@ -475,6 +475,20 @@ const char * EndOfWord(const char * word) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const char * EndOfWord(const char * word, const char * end) {
|
||||
UTF8Decoder decoder(word);
|
||||
CodePoint codePoint = decoder.nextCodePoint();
|
||||
const char * result = word;
|
||||
while (!CodePointIsEndOfWord(codePoint)) {
|
||||
result = decoder.stringPosition();
|
||||
if (result >= end) {
|
||||
break;
|
||||
}
|
||||
codePoint = decoder.nextCodePoint();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void countGlyphsInLine(const char * text, int * before, int * after, const char * beforeLocation, const char *afterLocation) {
|
||||
UTF8Helper::CodePointAction countGlyph = [](int, void * glyphCount, int, int) {
|
||||
int * castedCount = (int *) glyphCount;
|
||||
|
||||
Reference in New Issue
Block a user