freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] gsoc-anurag-2023 36f6131c2: Work on preloading font outlines


From: Werner Lemberg
Subject: [freetype2] gsoc-anurag-2023 36f6131c2: Work on preloading font outlines
Date: Mon, 14 Aug 2023 10:21:55 -0400 (EDT)

branch: gsoc-anurag-2023
commit 36f6131c232932614dc4dbf77aa1122a082759fe
Author: Anurag Thakur <anurag105csec21@bpitindia.edu.in>
Commit: Anurag Thakur <anurag105csec21@bpitindia.edu.in>

    Work on preloading font outlines
---
 include/freetype/freetype.h |  5 ++++-
 src/base/ftobjs.c           | 29 +++++++++++++++++++++++++++--
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index 4a074a444..1e6d32548 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -2399,6 +2399,9 @@ FT_BEGIN_HEADER
    *   FT_OPEN_PARAMS ::
    *     Use the `num_params` and `params` fields.
    *
+   *   FT_OPEN_PRELOAD ::
+   *     Preprocess the font outline to save cpu time later.
+   *
    * @note:
    *   The `FT_OPEN_MEMORY`, `FT_OPEN_STREAM`, and `FT_OPEN_PATHNAME` flags
    *   are mutually exclusive.
@@ -2408,7 +2411,7 @@ FT_BEGIN_HEADER
 #define FT_OPEN_PATHNAME  0x4
 #define FT_OPEN_DRIVER    0x8
 #define FT_OPEN_PARAMS    0x10
-
+#define FT_OPEN_PRELOAD   0x12
 
   /* these constants are deprecated; use the corresponding `FT_OPEN_XXX` */
   /* values instead                                                      */
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index e9566a819..ef345fc46 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -1622,6 +1622,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_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.pathname = (char*)pathname;
+    args.stream   = NULL;
+
+    return ft_open_face_internal( library, &args, face_index, aface, 1 );
+  }
+
+
 #endif
 
 
@@ -2636,7 +2657,6 @@
 
           driver = FT_DRIVER( cur[0] );
 
-          // TODO: Check the args for a "preload" flag and act accordingly
           if ( args->flags & FT_OPEN_PARAMS )
           {
             num_params = args->num_params;
@@ -2727,7 +2747,12 @@
     /* face->driver instead.                                   */
     FT_List_Add( &face->driver->faces_list, node );
 
-    // TODO: The preload logic should be performed here
+    if (args->flags & FT_OPEN_PRELOAD)
+    {
+      /* Preload the font here */
+    }
+    
+
     /* now allocate a glyph slot object for the face */
     FT_TRACE4(( "FT_Open_Face: Creating glyph slot\n" ));
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]