From c1804c48a9d810fb437cf45c5d670c303c06c4cb Mon Sep 17 00:00:00 2001 From: Anurag Thakur Date: Tue, 10 Oct 2023 02:36:17 +0530 Subject: [PATCH] [dense] Add support for preloading in ft_open_face_internal * src/base/ftobjs.c: Add code for loading glyph data into face->glyph_aray after ft_open_face_internal has succeeded --- src/base/ftobjs.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index fc390810b..e48fc7a87 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -1625,6 +1625,7 @@ return FT_THROW( Invalid_Argument ); args.flags = FT_OPEN_PATHNAME; + args.size = 0; args.pathname = (char*)pathname; args.stream = NULL; @@ -3078,6 +3079,33 @@ FT_Error ft_decompose_outline(FT_GlyphSlot* slot){ face->size = size; } + if ( args->size > 0 ) + { + face->glyph_array = (FT_GlyphSlot*)malloc( + face->driver->clazz->slot_object_size * face->num_glyphs ); + error = FT_Set_Pixel_Sizes( face, 0, args->size ); + + for ( int gindex = 0; gindex < face->num_glyphs; gindex++ ) + { + driver = face->driver; + FT_Driver_Class clazz = driver->clazz; + memory = driver->root.memory; + + FT_ALLOC( face->glyph_array[gindex], clazz->slot_object_size ); + + face->glyph_array[gindex]->face = face; + face->glyph_array[gindex]->prel_shifted = 0; + face->glyph_array[gindex]->glyph_index = gindex; + ft_glyphslot_init( face->glyph_array[gindex] ); + + face->glyph_array[gindex]->next = NULL; + *face->glyph = *face->glyph_array[gindex]; + + FT_Load_Glyph( face, gindex, FT_LOAD_NO_HINTING ); + + ft_decompose_outline( &face->glyph_array[gindex] ); + } + } } /* some checks */