shithub: freetype+ttf2subf

Download patch

ref: 4a3fce93c2a2e154ad7e84f93034240a55df35fa
parent: 6a19a7d332c5446542196e5aeda0ede109ef097b
author: Werner Lemberg <[email protected]>
date: Tue Oct 27 15:27:39 EDT 2015

[pfr] Formatting, improving comments.

git/fs: mount .git/fs: mount/attach disallowed
--- a/src/pfr/pfrcmap.c
+++ b/src/pfr/pfrcmap.c
@@ -130,7 +130,7 @@
         }
 
         if ( gchar->char_code < char_code )
-          min = mid+1;
+          min = mid + 1;
         else
           max = mid;
       }
--- a/src/pfr/pfrgload.c
+++ b/src/pfr/pfrgload.c
@@ -92,8 +92,8 @@
     if ( outline->n_contours > 0 )
       first = outline->contours[outline->n_contours - 1];
 
-    /* if the last point falls on the same location than the first one */
-    /* we need to delete it                                            */
+    /* if the last point falls on the same location as the first one */
+    /* we need to delete it                                          */
     if ( last > first )
     {
       FT_Vector*  p1 = outline->points + first;
@@ -215,8 +215,10 @@
     /* check that there is space for a new contour and a new point */
     error = FT_GLYPHLOADER_CHECK_POINTS( loader, 1, 1 );
     if ( !error )
+    {
       /* add new start point */
       error = pfr_glyph_line_to( glyph, to );
+    }
 
     return error;
   }
@@ -304,8 +306,8 @@
 
     glyph->y_control = glyph->x_control + x_count;
 
-    mask  = 0;
-    x     = 0;
+    mask = 0;
+    x    = 0;
 
     for ( i = 0; i < count; i++ )
     {
@@ -331,9 +333,9 @@
       mask >>= 1;
     }
 
-    /* XXX: for now we ignore the secondary stroke and edge definitions */
-    /*      since we don't want to support native PFR hinting           */
-    /*                                                                  */
+    /* XXX: we ignore the secondary stroke and edge definitions */
+    /*      since we don't support native PFR hinting           */
+    /*                                                          */
     if ( flags & PFR_GLYPH_EXTRA_ITEMS )
     {
       error = pfr_extra_items_skip( &p, limit );
@@ -366,20 +368,20 @@
 
         switch ( format >> 4 )
         {
-        case 0:                             /* end glyph */
+        case 0:                                               /* end glyph */
           FT_TRACE6(( "- end glyph" ));
           args_count = 0;
           break;
 
-        case 1:                             /* general line operation */
+        case 1:                                  /* general line operation */
           FT_TRACE6(( "- general line" ));
           goto Line1;
 
-        case 4:                             /* move to inside contour  */
+        case 4:                                 /* move to inside contour  */
           FT_TRACE6(( "- move to inside" ));
           goto Line1;
 
-        case 5:                             /* move to outside contour */
+        case 5:                                 /* move to outside contour */
           FT_TRACE6(( "- move to outside" ));
         Line1:
           args_format = format_low;
@@ -386,7 +388,7 @@
           args_count  = 1;
           break;
 
-        case 2:                             /* horizontal line to */
+        case 2:                                      /* horizontal line to */
           FT_TRACE6(( "- horizontal line to cx.%d", format_low ));
           if ( format_low >= x_count )
             goto Failure;
@@ -396,7 +398,7 @@
           args_count = 0;
           break;
 
-        case 3:                             /* vertical line to */
+        case 3:                                        /* vertical line to */
           FT_TRACE6(( "- vertical line to cy.%d", format_low ));
           if ( format_low >= y_count )
             goto Failure;
@@ -406,19 +408,19 @@
           args_count = 0;
           break;
 
-        case 6:                             /* horizontal to vertical curve */
+        case 6:                            /* horizontal to vertical curve */
           FT_TRACE6(( "- hv curve " ));
           args_format = 0xB8E;
           args_count  = 3;
           break;
 
-        case 7:                             /* vertical to horizontal curve */
+        case 7:                            /* vertical to horizontal curve */
           FT_TRACE6(( "- vh curve" ));
           args_format = 0xE2B;
           args_count  = 3;
           break;
 
-        default:                            /* general curve to */
+        default:                                       /* general curve to */
           FT_TRACE6(( "- general curve" ));
           args_count  = 4;
           args_format = format_low;
@@ -439,7 +441,7 @@
           {
           case 0:                           /* 8-bit index */
             PFR_CHECK( 1 );
-            idx  = PFR_NEXT_BYTE( p );
+            idx = PFR_NEXT_BYTE( p );
             if ( idx >= x_count )
               goto Failure;
             cur->x = glyph->x_control[idx];
@@ -446,7 +448,7 @@
             FT_TRACE7(( " cx#%d", idx ));
             break;
 
-          case 1:                           /* 16-bit value */
+          case 1:                           /* 16-bit absolute value */
             PFR_CHECK( 2 );
             cur->x = PFR_NEXT_SHORT( p );
             FT_TRACE7(( " x.%d", cur->x ));
@@ -516,22 +518,22 @@
         /*                                                         */
         switch ( format >> 4 )
         {
-        case 0:                             /* end glyph => EXIT */
+        case 0:                                       /* end glyph => EXIT */
           pfr_glyph_end( glyph );
           goto Exit;
 
-        case 1:                             /* line operations */
+        case 1:                                         /* line operations */
         case 2:
         case 3:
           error = pfr_glyph_line_to( glyph, pos );
           goto Test_Error;
 
-        case 4:                             /* move to inside contour  */
-        case 5:                             /* move to outside contour */
+        case 4:                                 /* move to inside contour  */
+        case 5:                                 /* move to outside contour */
           error = pfr_glyph_move_to( glyph, pos );
           goto Test_Error;
 
-        default:                            /* curve operations */
+        default:                                       /* curve operations */
           error = pfr_glyph_curve_to( glyph, pos, pos + 1, pos + 2 );
 
         Test_Error:  /* test error condition */
@@ -580,7 +582,8 @@
     if ( flags & PFR_GLYPH_EXTRA_ITEMS )
     {
       error = pfr_extra_items_skip( &p, limit );
-      if (error) goto Exit;
+      if ( error )
+        goto Exit;
     }
 
     /* we can't rely on the FT_GlyphLoader to load sub-glyphs, because   */
--- a/src/pfr/pfrload.c
+++ b/src/pfr/pfrload.c
@@ -75,7 +75,8 @@
           if ( extra->type == item_type )
           {
             error = extra->parser( p, p + item_size, item_data );
-            if ( error ) goto Exit;
+            if ( error )
+              goto Exit;
 
             break;
           }
@@ -183,7 +184,8 @@
     {
       result = 0;
     }
-    return  result;
+
+    return result;
   }
 
 
@@ -206,7 +208,8 @@
     FT_UInt   result = 0;
 
 
-    if ( FT_STREAM_SEEK( section_offset ) || FT_READ_USHORT( count ) )
+    if ( FT_STREAM_SEEK( section_offset ) ||
+         FT_READ_USHORT( count )          )
       goto Exit;
 
     result = count;
@@ -254,13 +257,14 @@
       FT_UInt   local;
 
 
-      if ( FT_STREAM_SEEK( offset ) || FT_FRAME_ENTER( size ) )
+      if ( FT_STREAM_SEEK( offset ) ||
+           FT_FRAME_ENTER( size )   )
         goto Exit;
 
       p     = stream->cursor;
       limit = p + size;
 
-      PFR_CHECK(13);
+      PFR_CHECK( 13 );
 
       log_font->matrix[0] = PFR_NEXT_LONG( p );
       log_font->matrix[1] = PFR_NEXT_LONG( p );
@@ -308,10 +312,11 @@
       if ( flags & PFR_LOG_EXTRA_ITEMS )
       {
         error = pfr_extra_items_skip( &p, limit );
-        if (error) goto Fail;
+        if ( error )
+          goto Fail;
       }
 
-      PFR_CHECK(5);
+      PFR_CHECK( 5 );
       log_font->phys_size   = PFR_NEXT_USHORT( p );
       log_font->phys_offset = PFR_NEXT_ULONG( p );
       if ( size_increment )
@@ -358,7 +363,7 @@
 
     PFR_CHECK( 5 );
 
-    p += 3;  /* skip bctSize */
+    p     += 3;  /* skip bctSize */
     flags0 = PFR_NEXT_BYTE( p );
     count  = PFR_NEXT_BYTE( p );
 
@@ -434,12 +439,12 @@
   }
 
 
-  /* Load font ID.  This is a so-called "unique" name that is rather
-   * long and descriptive (like "Tiresias ScreenFont v7.51").
+  /* Load font ID.  This is a so-called `unique' name that is rather
+   * long and descriptive (like `Tiresias ScreenFont v7.51').
    *
    * Note that a PFR font's family name is contained in an *undocumented*
-   * string of the "auxiliary data" portion of a physical font record.  This
-   * may also contain the "real" style name!
+   * string of the `auxiliary data' portion of a physical font record.  This
+   * may also contain the `real' style name!
    *
    * If no family name is present, the font ID is used instead for the
    * family.
@@ -612,7 +617,6 @@
   }
 
 
-
   static const PFR_ExtraItemRec  pfr_phy_font_extra_items[] =
   {
     { 1, (PFR_ExtraItem_ParseFunc)pfr_extra_item_load_bitmap_info },
@@ -623,7 +627,8 @@
   };
 
 
-  /* Loads a name from the auxiliary data.  Since this extracts undocumented
+  /*
+   * Load a name from the auxiliary data.  Since this extracts undocumented
    * strings from the font file, we need to be careful here.
    */
   static FT_Error
@@ -729,7 +734,8 @@
     phy_font->kern_items      = NULL;
     phy_font->kern_items_tail = &phy_font->kern_items;
 
-    if ( FT_STREAM_SEEK( offset ) || FT_FRAME_ENTER( size ) )
+    if ( FT_STREAM_SEEK( offset ) ||
+         FT_FRAME_ENTER( size )   )
       goto Exit;
 
     phy_font->cursor = stream->cursor;
@@ -757,16 +763,16 @@
     /* load the extra items when present */
     if ( flags & PFR_PHY_EXTRA_ITEMS )
     {
-      error =  pfr_extra_items_parse( &p, limit,
-                                      pfr_phy_font_extra_items, phy_font );
+      error = pfr_extra_items_parse( &p, limit,
+                                     pfr_phy_font_extra_items, phy_font );
 
       if ( error )
         goto Fail;
     }
 
-    /* In certain fonts, the auxiliary bytes contain interesting  */
-    /* information. These are not in the specification but can be */
-    /* guessed by looking at the content of a few PFR0 fonts.     */
+    /* In certain fonts, the auxiliary bytes contain interesting   */
+    /* information.  These are not in the specification but can be */
+    /* guessed by looking at the content of a few PFR0 fonts.      */
     PFR_CHECK( 3 );
     num_aux = PFR_NEXT_ULONG( p );
 
@@ -797,9 +803,8 @@
         switch ( type )
         {
         case 1:
-          /* this seems to correspond to the font's family name,
-           * padded to 16-bits with one zero when necessary
-           */
+          /* this seems to correspond to the font's family name, padded to */
+          /* an even number of bytes with a zero byte appended if needed   */
           error = pfr_aux_name_load( q, length - 4U, memory,
                                      &phy_font->family_name );
           if ( error )
@@ -817,9 +822,8 @@
           break;
 
         case 3:
-          /* this seems to correspond to the font's style name,
-           * padded to 16-bits with one zero when necessary
-           */
+          /* this seems to correspond to the font's style name, padded to */
+          /* an even number of bytes with a zero byte appended if needed  */
           error = pfr_aux_name_load( q, length - 4U, memory,
                                      &phy_font->style_name );
           if ( error )
--- a/src/pfr/pfrobjs.c
+++ b/src/pfr/pfrobjs.c
@@ -118,9 +118,11 @@
 
     /* load the face */
     error = pfr_log_font_load(
-               &face->log_font, stream, (FT_UInt)( face_index & 0xFFFF ),
-               face->header.log_dir_offset,
-               FT_BOOL( face->header.phy_font_max_size_high != 0 ) );
+              &face->log_font,
+              stream,
+              (FT_UInt)( face_index & 0xFFFF ),
+              face->header.log_dir_offset,
+              FT_BOOL( face->header.phy_font_max_size_high != 0 ) );
     if ( error )
       goto Exit;
 
@@ -141,8 +143,8 @@
 
       pfrface->face_flags |= FT_FACE_FLAG_SCALABLE;
 
-      /* if all characters point to the same gps_offset 0, we */
-      /* assume that the font only contains bitmaps           */
+      /* if gps_offset == 0 for all characters, we  */
+      /* assume that the font only contains bitmaps */
       {
         FT_UInt  nn;
 
@@ -164,7 +166,7 @@
         }
       }
 
-      if ( (phy_font->flags & PFR_PHY_PROPORTIONAL) == 0 )
+      if ( ( phy_font->flags & PFR_PHY_PROPORTIONAL ) == 0 )
         pfrface->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
 
       if ( phy_font->flags & PFR_PHY_VERTICAL )
@@ -178,7 +180,7 @@
       if ( phy_font->num_kern_pairs > 0 )
         pfrface->face_flags |= FT_FACE_FLAG_KERNING;
 
-      /* If no family name was found in the "undocumented" auxiliary
+      /* If no family name was found in the `undocumented' auxiliary
        * data, use the font ID instead.  This sucks but is better than
        * nothing.
        */
@@ -187,7 +189,7 @@
         pfrface->family_name = phy_font->font_id;
 
       /* note that the style name can be NULL in certain PFR fonts,
-       * probably meaning "Regular"
+       * probably meaning `Regular'
        */
       pfrface->style_name = phy_font->style_name;
 
@@ -264,13 +266,13 @@
         error = FT_CMap_New( &pfr_cmap_class_rec, NULL, &charmap, NULL );
 
 #if 0
-        /* Select default charmap */
+        /* select default charmap */
         if ( pfrface->num_charmaps )
           pfrface->charmap = pfrface->charmaps[0];
 #endif
       }
 
-      /* check whether we've loaded any kerning pairs */
+      /* check whether we have loaded any kerning pairs */
       if ( phy_font->num_kern_pairs )
         pfrface->face_flags |= FT_FACE_FLAG_KERNING;
     }
@@ -402,7 +404,7 @@
       pfrslot->linearHoriAdvance = metrics->horiAdvance;
       pfrslot->linearVertAdvance = metrics->vertAdvance;
 
-      /* make-up vertical metrics(?) */
+      /* make up vertical metrics(?) */
       metrics->vertBearingX = 0;
       metrics->vertBearingY = 0;
 
@@ -595,5 +597,6 @@
   Exit:
     return error;
   }
+
 
 /* END */
--- a/src/pfr/pfrsbit.c
+++ b/src/pfr/pfrsbit.c
@@ -37,11 +37,11 @@
 
   typedef struct  PFR_BitWriter_
   {
-    FT_Byte*  line;      /* current line start                    */
-    FT_Int    pitch;     /* line size in bytes                    */
-    FT_UInt   width;     /* width in pixels/bits                  */
-    FT_UInt   rows;      /* number of remaining rows to scan      */
-    FT_UInt   total;     /* total number of bits to draw          */
+    FT_Byte*  line;      /* current line start               */
+    FT_Int    pitch;     /* line size in bytes               */
+    FT_UInt   width;     /* width in pixels/bits             */
+    FT_UInt   rows;      /* number of remaining rows to scan */
+    FT_UInt   total;     /* total number of bits to draw     */
 
   } PFR_BitWriterRec, *PFR_BitWriter;
 
@@ -341,8 +341,8 @@
   }
 
 
-  /* load bitmap metrics.  "*padvance" must be set to the default value */
-  /* before calling this function...                                    */
+  /* load bitmap metrics.  `*padvance' must be set to the default value */
+  /* before calling this function                                       */
   /*                                                                    */
   static FT_Error
   pfr_load_bitmap_metrics( FT_Byte**  pdata,
@@ -544,7 +544,7 @@
 
     character = &phys->chars[glyph_index];
 
-    /* Look-up a bitmap strike corresponding to the current */
+    /* look up a bitmap strike corresponding to the current */
     /* character dimensions                                 */
     {
       FT_UInt  n;
@@ -555,9 +555,7 @@
       {
         if ( strike->x_ppm == (FT_UInt)size->root.metrics.x_ppem &&
              strike->y_ppm == (FT_UInt)size->root.metrics.y_ppem )
-        {
           goto Found_Strike;
-        }
 
         strike++;
       }
@@ -568,7 +566,7 @@
 
   Found_Strike:
 
-    /* Now lookup the glyph's position within the file */
+    /* now look up the glyph's position within the file */
     {
       FT_UInt  char_len;
 
@@ -578,7 +576,7 @@
       if ( strike->flags & 2 ) char_len += 1;
       if ( strike->flags & 4 ) char_len += 1;
 
-      /* Access data directly in the frame to speed lookups */
+      /* access data directly in the frame to speed lookups */
       if ( FT_STREAM_SEEK( phys->bct_offset + strike->bct_offset ) ||
            FT_FRAME_ENTER( char_len * strike->num_bitmaps )        )
         goto Exit;
@@ -595,7 +593,7 @@
 
       if ( gps_size == 0 )
       {
-        /* Could not find a bitmap program string for this glyph */
+        /* could not find a bitmap program string for this glyph */
         error = FT_THROW( Invalid_Argument );
         goto Exit;
       }
@@ -617,8 +615,8 @@
 
       glyph->root.linearHoriAdvance = advance;
 
-      /* compute default advance, i.e., scaled advance.  This can be */
-      /* overridden in the bitmap header of certain glyphs.          */
+      /* compute default advance, i.e., scaled advance; this can be */
+      /* overridden in the bitmap header of certain glyphs          */
       advance = FT_MulDiv( (FT_Fixed)size->root.metrics.x_ppem << 8,
                            character->advance,
                            (FT_Long)phys->metrics_resolution );
@@ -684,7 +682,6 @@
 
           error = ft_glyphslot_alloc_bitmap( &glyph->root, len );
           if ( !error )
-          {
             error = pfr_load_bitmap_bits(
                       p,
                       stream->limit,
@@ -691,7 +688,6 @@
                       format,
                       FT_BOOL(face->header.color_flags & 2),
                       &glyph->root.bitmap );
-          }
         }
       }
 
@@ -701,5 +697,6 @@
   Exit:
     return error;
   }
+
 
 /* END */