Skip to content

Commit

Permalink
Fixed offset calculation when TTF_USE_HARFBUZZ is OFF
Browse files Browse the repository at this point in the history
Fixes #429
  • Loading branch information
slouken committed Dec 7, 2024
1 parent f5a12f1 commit fc3e109
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/SDL_ttf.c
Original file line number Diff line number Diff line change
Expand Up @@ -3104,14 +3104,13 @@ static bool TTF_Size_Internal(TTF_Font *font, const char *text, size_t length, i
offset = (int)hb_glyph_info[g].cluster;
#else
// Load each character and sum it's bounding box
const char *start = text;
int offset = 0;
while (length > 0) {
const char *last = text;
offset = (int)(text - start);
Uint32 c = SDL_StepUTF8(&text, &length);
FT_UInt idx = get_char_index(font, c);

offset += (text - last);

if (c == UNICODE_BOM_NATIVE || c == UNICODE_BOM_SWAPPED) {
continue;
}
Expand Down

0 comments on commit fc3e109

Please sign in to comment.