diff --git a/SDL_ttf.c b/SDL_ttf.c --- a/SDL_ttf.c +++ b/SDL_ttf.c @@ -2196,18 +2196,25 @@ return TTF_initialized; } -int TTF_GetFontKerningSize(TTF_Font *font, Uint16 previous_ch, Uint16 ch) +int TTF_GetFontKerningSize( TTF_Font *font, Uint16 previous_ch, Uint16 ch, + int* kerning ) { int error; int glyph_index, prev_index; FT_Vector delta; if (ch == UNICODE_BOM_NATIVE || ch == UNICODE_BOM_SWAPPED) { - return 0; + if (kerning) { + *kerning = 0; + } + return 0; // Success! } if (previous_ch == UNICODE_BOM_NATIVE || previous_ch == UNICODE_BOM_SWAPPED) { - return 0; + if (kerning) { + *kerning = 0; + } + return 0; // Success! } error = Find_Glyph(font, ch, CACHED_METRICS); @@ -2229,5 +2236,10 @@ TTF_SetFTError("Couldn't get glyph kerning", error); return -1; } - return (delta.x >> 6); + + if (kerning) { + *kerning = delta.x >> 6; + } + + return 0; // Success! } diff --git a/SDL_ttf.h b/SDL_ttf.h --- a/SDL_ttf.h +++ b/SDL_ttf.h @@ -247,8 +247,15 @@ /* Check if the TTF engine is initialized */ extern DECLSPEC int SDLCALL TTF_WasInit(void); -/* Get the kerning size of two glyphs */ -extern DECLSPEC int TTF_GetFontKerningSize(TTF_Font *font, Uint16 previous_ch, Uint16 ch); +/* Get the kerning size of two glyphs. + + kerning A pointer filled in with the kerning pair size (in pixel units). + + This function returns zero (0) on success, or a negative error code on + failure; call TTF_GetError() for more information. +*/ +extern DECLSPEC int TTF_GetFontKerningSize( TTF_Font *font, Uint16 previous_ch, + Uint16 ch, int* kerning ); /* We'll use SDL for reporting errors */ #define TTF_SetError SDL_SetError