From b2f570a2bbcd7c3872dbb5dfa8240d8edbc6bade Mon Sep 17 00:00:00 2001 From: Anurag Thakur Date: Tue, 10 Oct 2023 02:12:54 +0530 Subject: [PATCH] [dense] Implement FT_New_Face2 and fix glyph loading * include/freetype/freetype.h: Add filed "size" to FT_Open_Args * src/base/ftobjs.c: Use slot from face's glyph_array in FT_Load_Glyph Implement FT_New_Face2 --- include/freetype/freetype.h | 5 +++++ src/base/ftobjs.c | 23 ++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h index 3f9769976..2079ae663 100644 --- a/include/freetype/freetype.h +++ b/include/freetype/freetype.h @@ -2534,6 +2534,10 @@ FT_BEGIN_HEADER * params :: * Extra parameters passed to the font driver when opening a new face. * + * size :: + * Size at which the glyphs will be rendered. Use same value as + * @FT_Set_Pixel_Sizes + * * @note: * The stream type is determined by the contents of `flags`: * @@ -2571,6 +2575,7 @@ FT_BEGIN_HEADER FT_Module driver; FT_Int num_params; FT_Parameter* params; + FT_UInt size; } FT_Open_Args; diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 148681f57..9bec44fd5 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -922,7 +922,7 @@ /* The validity test for `glyph_index' is performed by the */ /* font drivers. */ - slot = face->glyph; + slot = face->glyph_array[glyph_index]; ft_glyphslot_clear( slot ); driver = face->driver; @@ -1630,6 +1630,27 @@ return ft_open_face_internal( library, &args, face_index, aface, 1 ); } + FT_EXPORT_DEF( FT_Error ) + FT_New_Face2( FT_Library library, + const char* pathname, + FT_Long face_index, + FT_Face *aface, + FT_UInt size) + { + FT_Open_Args args; + + /* test for valid `library' and `aface' delayed to `FT_Open_Face' */ + if ( !pathname ) + return FT_THROW( Invalid_Argument ); + + args.flags = FT_OPEN_PATHNAME; + args.size = size; + args.pathname = (char*)pathname; + args.stream = NULL; + + return ft_open_face_internal( library, &args, face_index, aface, 1 ); + } + #endif