From e7c4fb9d136086038f21aa73e29f26db274d8451 Mon Sep 17 00:00:00 2001 From: Anurag Thakur Date: Tue, 10 Oct 2023 02:01:15 +0530 Subject: [PATCH] [dense] Add FT_Refresh_Glyph * include/freetype/freetype.h: Declare FT_Refresh_Glyph * src/base/ftobjs.c: Implement FT_Refresh_Glyph --- include/freetype/freetype.h | 25 +++++++++++++++++++++++++ src/base/ftobjs.c | 8 ++++++++ 2 files changed, 33 insertions(+) diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h index 9ab407296..3f9769976 100644 --- a/include/freetype/freetype.h +++ b/include/freetype/freetype.h @@ -3323,6 +3323,31 @@ FT_BEGIN_HEADER FT_UInt glyph_index, FT_Int32 load_flags ); + /************************************************************************** + * + * @function: + * FT_Refresh_Glyph + * + * @description: + * Prepare the glyph at glyph_index for rendering. Resets the glyph + * if it has already been rendered + * + * @inout: + * face :: + * A handle to the target face object where the glyph is loaded. + * + * @input: + * glyph_index :: + * The index of the glyph in the font file. + * + * @return: + * FreeType error code. 0~means success. + * + */ + FT_EXPORT( FT_Error ) + FT_Refresh_Glyph( FT_Face face, + FT_UInt glyph_index); + /************************************************************************** * diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 89a25bc73..148681f57 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -893,6 +893,14 @@ /* documentation is in freetype.h */ + FT_EXPORT_DEF( FT_Error ) + FT_Refresh_Glyph( FT_Face face, + FT_UInt glyph_index) + + { + ft_glyphslot_free_bitmap( face->glyph_array[glyph_index] ); + face->glyph_array[glyph_index]->format = FT_GLYPH_FORMAT_OUTLINE; + } FT_EXPORT_DEF( FT_Error ) FT_Load_Glyph( FT_Face face,