Skip to content

Commit

Permalink
Fixed bug #299 - Bitmap font spacing incorrect when using Harfbuzz
Browse files Browse the repository at this point in the history
  • Loading branch information
1bsyl authored and slouken committed Aug 1, 2023
1 parent 1d8f776 commit ed71a15
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/SDL_ttf.c
Original file line number Diff line number Diff line change
Expand Up @@ -3153,6 +3153,7 @@ static int TTF_Size_Internal(TTF_Font *font,
hb_glyph_info_t *hb_glyph_info;
hb_glyph_position_t *hb_glyph_position;
int y = 0;
int advance_if_bold = 0;
#else
size_t textlen;
int skip_first = 1;
Expand Down Expand Up @@ -3195,6 +3196,12 @@ static int TTF_Size_Internal(TTF_Font *font,
font->pos_len = 0;

#if TTF_USE_HARFBUZZ

/* Adjust for bold text */
if (TTF_HANDLE_STYLE_BOLD(font)) {
advance_if_bold = F26Dot6(font->glyph_overhang);
}

/* Create a buffer for harfbuzz to use */
hb_buffer = hb_buffer_create();
if (hb_buffer == NULL) {
Expand Down Expand Up @@ -3269,7 +3276,7 @@ static int TTF_Size_Internal(TTF_Font *font,
/* Compute positions */
pos_x = x + x_offset;
pos_y = y + F26Dot6(font->ascent) - y_offset;
x += x_advance;
x += x_advance + advance_if_bold;
y += y_advance;
#else
/* Compute positions */
Expand Down

0 comments on commit ed71a15

Please sign in to comment.