freetype-devel
[Top][All Lists]
Advanced

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

Re: [ft-devel] LLP64 model outside Win64


From: Alexei Podtelezhnikov
Subject: Re: [ft-devel] LLP64 model outside Win64
Date: Mon, 19 Feb 2018 11:35:23 -0500

On Mon, Feb 12, 2018 at 4:39 PM, Werner LEMBERG <address@hidden> wrote:
>> Can we properly use the FT_List data field as an actual pointer to
>> the glyph index instead of stuffing the integer into the pointer?
>
> Certainly, if you are going to dynamically allocate a slot for it.
> I tried to avoid that.

Totally untested, but why wouldn't this work?

diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 32ed34a..efb7c3c 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -1508,7 +1508,7 @@
   /*                                                                       */
   static FT_Error
   load_truetype_glyph( TT_Loader  loader,
-                       FT_UInt    glyph_index,
+                       FT_UInt*   index,
                        FT_UInt    recurse_count,
                        FT_Bool    header_only )
   {
@@ -1518,6 +1518,7 @@
     TT_Face         face         = loader->face;
     FT_GlyphLoader  gloader      = loader->gloader;
     FT_Bool         opened_frame = 0;
+    FT_UInt         glyph_index  = *index;

 #ifdef FT_CONFIG_OPTION_INCREMENTAL
     FT_StreamRec    inc_stream;
@@ -1783,22 +1784,13 @@
       /* normalize the `n_contours' value */
       loader->n_contours = -1;

-      /*
-       * We store the glyph index directly in the `node->data' pointer,
-       * following the glib solution (cf. macro `GUINT_TO_POINTER') with a
-       * double cast to make this portable.  Note, however, that this needs
-       * pointers with a width of at least 32 bits.
-       */
-
-
       /* clear the nodes filled by sibling chains */
       node = ft_list_get_node_at( &loader->composites, recurse_count );
       for ( node2 = node; node2; node2 = node2->next )
-        node2->data = (void*)FT_ULONG_MAX;
+        node2->data = NULL;

       /* check whether we already have a composite glyph with this index */
-      if ( FT_List_Find( &loader->composites,
-                         FT_UINT_TO_POINTER( glyph_index ) ) )
+      if ( FT_List_Find( &loader->composites, index ) )
       {
         FT_TRACE1(( "TT_Load_Composite_Glyph:"
                     " infinite recursion detected\n" ));
@@ -1807,13 +1799,13 @@
       }

       else if ( node )
-        node->data = FT_UINT_TO_POINTER( glyph_index );
+        node->data = (void*)index;

       else
       {
         if ( FT_NEW( node ) )
           goto Exit;
-        node->data = FT_UINT_TO_POINTER( glyph_index );
+        node->data = (void*)index;
         FT_List_Add( &loader->composites, node );
       }

@@ -2019,7 +2011,7 @@
           num_base_points = (FT_UInt)gloader->base.outline.n_points;

           error = load_truetype_glyph( loader,
-                                       (FT_UInt)subglyph->index,
+                                       &subglyph->index,
                                        recurse_count + 1,
                                        FALSE );
           if ( error )
@@ -2773,7 +2765,7 @@
         {
           /* for the bbox we need the header only */
           (void)tt_loader_init( &loader, size, glyph, load_flags, TRUE );
-          (void)load_truetype_glyph( &loader, glyph_index, 0, TRUE );
+          (void)load_truetype_glyph( &loader, &glyph_index, 0, TRUE );
           tt_loader_done( &loader );
           glyph->linearHoriAdvance = loader.linear;
           glyph->linearVertAdvance = loader.vadvance;
@@ -2818,7 +2810,7 @@
     glyph->outline.flags = 0;

     /* main loading loop */
-    error = load_truetype_glyph( &loader, glyph_index, 0, FALSE );
+    error = load_truetype_glyph( &loader, &glyph_index, 0, FALSE );
     if ( !error )
     {
       if ( glyph->format == FT_GLYPH_FORMAT_COMPOSITE )



reply via email to

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