Skip to content

Commit

Permalink
Restored binary compatibility for TTF_GetFontKerningSize().
Browse files Browse the repository at this point in the history
The (corrected) behavior of this function has been moved to a new API,
named TTF_GetFontKerningSizeGlyphs(), and the original function has been
restored to its wrong behavior and marked as deprecated.
  • Loading branch information
icculus committed Jan 29, 2016
1 parent 96a6be4 commit 2b0fd50
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
11 changes: 10 additions & 1 deletion SDL_ttf.c
Expand Up @@ -2196,7 +2196,15 @@ int TTF_WasInit( void )
return TTF_initialized;
}

int TTF_GetFontKerningSize(TTF_Font *font, Uint16 previous_ch, Uint16 ch)
/* don't use this function. It's just here for binary compatibility. */
int TTF_GetFontKerningSize(TTF_Font* font, int prev_index, int index)
{
FT_Vector delta;
FT_Get_Kerning( font->face, prev_index, index, ft_kerning_default, &delta );
return (delta.x >> 6);
}

int TTF_GetFontKerningSizeGlyphs(TTF_Font *font, Uint16 previous_ch, Uint16 ch)
{
int error;
int glyph_index, prev_index;
Expand Down Expand Up @@ -2231,3 +2239,4 @@ int TTF_GetFontKerningSize(TTF_Font *font, Uint16 previous_ch, Uint16 ch)
}
return (delta.x >> 6);
}

14 changes: 13 additions & 1 deletion SDL_ttf.h
Expand Up @@ -24,6 +24,10 @@
http://www.freetype.org/
*/

/* Note: In many places, SDL_ttf will say "glyph" when it means "code point."
Unicode is hard, we learn as we go, and we apologize for adding to the
confusion. */

#ifndef _SDL_TTF_H
#define _SDL_TTF_H

Expand Down Expand Up @@ -247,8 +251,16 @@ extern DECLSPEC void SDLCALL TTF_Quit(void);
/* Check if the TTF engine is initialized */
extern DECLSPEC int SDLCALL TTF_WasInit(void);

/* Get the kerning size of two glyphs indices */
/* DEPRECATED: this function requires FreeType font indexes, not glyphs,
by accident, which we don't expose through this API, so it could give
wildly incorrect results, especially with non-ASCII values.
Going forward, please use TTF_GetFontKerningSizeGlyphs() instead, which
does what you probably expected this function to do. */
extern DECLSPEC int TTF_GetFontKerningSize(TTF_Font *font, int prev_index, int index) SDL_DEPRECATED;

/* Get the kerning size of two glyphs */
extern DECLSPEC int TTF_GetFontKerningSize(TTF_Font *font, Uint16 previous_ch, Uint16 ch);
extern DECLSPEC int TTF_GetFontKerningSizeGlyphs(TTF_Font *font, Uint16 previous_ch, Uint16 ch);

/* We'll use SDL for reporting errors */
#define TTF_SetError SDL_SetError
Expand Down

0 comments on commit 2b0fd50

Please sign in to comment.