freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] master cc081d7cc: [base] Fix up Mac resource forks and dfont


From: Werner Lemberg
Subject: [freetype2] master cc081d7cc: [base] Fix up Mac resource forks and dfonts.
Date: Sat, 6 Jan 2024 19:33:03 -0500 (EST)

branch: master
commit cc081d7cce78cae1a734e24cb8c245a618d5f3b2
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>

    [base] Fix up Mac resource forks and dfonts.
    
    * src/base/ftobjs.c (IsMacResource): Assign `face_index`.
    * src/base/ftmac.c (FT_New_Face_From_Suitcase): Ditto after rework.
---
 src/base/ftmac.c  | 19 ++++++++++++++-----
 src/base/ftobjs.c |  5 ++++-
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/src/base/ftmac.c b/src/base/ftmac.c
index 492d05538..cc54391b7 100644
--- a/src/base/ftmac.c
+++ b/src/base/ftmac.c
@@ -812,6 +812,7 @@
     ResourceIndex  res_index;
     Handle         fond;
     short          num_faces_in_res;
+    FT_Long        count;
 
 
     if ( noErr != FT_FSPathMakeRes( pathname, &res_ref ) )
@@ -821,8 +822,10 @@
     if ( ResError() )
       return FT_THROW( Cannot_Open_Resource );
 
+    res_index        = 1;
     num_faces_in_res = 0;
-    for ( res_index = 1; ; res_index++ )
+    count            = face_index;
+    while ( count >= 0 )
     {
       short  num_faces_in_fond;
 
@@ -834,15 +837,21 @@
       num_faces_in_fond  = count_faces( fond, pathname );
       num_faces_in_res  += num_faces_in_fond;
 
-      if ( 0 <= face_index && face_index < num_faces_in_fond && error )
-        error = FT_New_Face_From_FOND( library, fond, face_index, aface );
+      if ( count < num_faces_in_fond )
+        error = FT_New_Face_From_FOND( library, fond, count, aface );
 
-      face_index -= num_faces_in_fond;
+      res_index++;
+      count -= num_faces_in_fond;
     }
 
     CloseResFile( res_ref );
+
     if ( !error && aface && *aface )
-      (*aface)->num_faces = num_faces_in_res;
+    {
+      (*aface)->num_faces  = num_faces_in_res;
+      (*aface)->face_index = face_index;
+    }
+
     return error;
   }
 
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 759b95c73..71a976c26 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -2302,7 +2302,10 @@
                                       face_index_internal, aface );
       FT_FREE( data_offsets );
       if ( !error )
-        (*aface)->num_faces = count;
+      {
+        (*aface)->num_faces  = count;
+        (*aface)->face_index = face_index_internal;
+      }
     }
 
     return error;



reply via email to

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