freetype-commit
[Top][All Lists]
Advanced

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

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


From: Werner Lemberg
Subject: [freetype2] gsoc-anurag-2023 d23d82d84: Work on preloading font outlines
Date: Mon, 14 Aug 2023 15:45:39 -0400 (EDT)

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

    Work on preloading font outlines
---
 include/freetype/freetype.h | 11 ++++++++++-
 src/base/ftobjs.c           | 38 +++++++++++++++++++++++++++++++++++---
 2 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index 4a074a444..75f87bca6 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   0x20
 
   /* these constants are deprecated; use the corresponding `FT_OPEN_XXX` */
   /* values instead                                                      */
@@ -2572,6 +2575,12 @@ FT_BEGIN_HEADER
                FT_Long      face_index,
                FT_Face     *aface );
 
+  FT_EXPORT( FT_Error )
+  FT_New_Face2( FT_Library   library,
+               const char*  filepathname,
+               FT_Long      face_index,
+               FT_Face     *aface,
+               FT_UInt      flags);
 
   /**************************************************************************
    *
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index e9566a819..43681a2af 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -1610,18 +1610,40 @@
   {
     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 );
+  }
+
+
+  FT_EXPORT_DEF( FT_Error )
+  FT_New_Face2( FT_Library   library,
+                const char*  pathname,
+                FT_Long      face_index,
+                FT_Face     *aface,
+                FT_UInt      flags)
+  {
+    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.flags   |= flags;
     args.pathname = (char*)pathname;
     args.stream   = NULL;
 
     return ft_open_face_internal( library, &args, face_index, aface, 1 );
   }
 
+
 #endif
 
 
@@ -2540,7 +2562,11 @@
     FT_UNUSED( test_mac_fonts );
 #endif
 
-
+    if (args->flags & FT_OPEN_PRELOAD)
+    {
+      FT_TRACE0(("Requested Preload\n"));
+    }
+    
     /* only use lower 31 bits together with sign bit */
     if ( face_index > 0 )
       face_index &= 0x7FFFFFFFL;
@@ -2636,7 +2662,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 +2752,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" ));
 
@@ -2749,6 +2779,8 @@
           goto Fail;
 
         face->size = size;
+        // FT_Outline_Decompose here
+
       }
     }
 



reply via email to

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