freetype-devel
[Top][All Lists]
Advanced

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

A patch to fix sbit's bugs (FreeType2).


From: Yamano-uchi, Hidetoshi
Subject: A patch to fix sbit's bugs (FreeType2).
Date: Wed, 17 May 2000 23:27:19 +0900

Hi David,

Here is a patch fot ttsbit, please review and commit it.

Summary:
* ftview works well but slowly.
* face->num_fixed_sizes = num_strikes
* face->available_sizes is filled.
* other minor fixes.

Bugs:
* ftview with some sfntCID bitmap (without outline) files fails.
  Because there are invalied with TrueType specification.
  (head, hhea, hdmx, etc. are missing)
  It is convinient to support these font files with FreeType2.
* The way to get bitmap without cropping is not supported yet.

---- Yamano-uchi, Hidetoshi

diff -ur freetype2/src/sfnt/ttsbit.c freetype2_compile/src/sfnt/ttsbit.c
--- freetype2/src/sfnt/ttsbit.c Tue May 16 00:40:45 2000
+++ freetype2_compile/src/sfnt/ttsbit.c Wed May 17 23:19:05 2000
@@ -115,7 +115,7 @@
             /* ensure that there are at least 8 bits in the accumulator */
             if ( loaded < 8 )
             {
-              acc    |= ((FT_UShort)*source++) << (8 - loaded);
+              acc    |= ((FT_Byte)*source++) << (8 - loaded);
               loaded += 8;
             }
 
@@ -127,7 +127,7 @@
               cur[1] |= val << space;
             }
             else
-              cur[0] = val;
+              cur[0] |= val;
 
             cur++;
             acc   <<= 8;  /* remove bits from accumulator */
@@ -150,7 +150,7 @@
         /* ensure that there are at least `count' bits in the accumulator */
         if ( loaded < count )
         {
-          acc    |= ((FT_UShort)*source++) << (8 - loaded);
+          acc    |= ((FT_Byte)*source++) << (8 - loaded);
           loaded += 8;
         }
 
@@ -464,6 +464,7 @@
     TT_ULong   num_strikes;
     TT_ULong   table_base;
 
+    face->num_sbit_strikes = 0;
 
     /* this table is optional */
     error = face->goto_table( face, TTAG_EBLC, stream, 0 );
@@ -724,7 +725,7 @@
                 else
                   *aglyph_offset = range->image_offset +
                                    n * range->image_size;
-                break;
+                goto Found;
               }
             }
           }
@@ -733,7 +734,7 @@
           default:
             goto Fail;
         }
-
+  Found:
         /* return successfully! */
         *arange  = range;
 
@@ -851,53 +852,53 @@
     TT_Error  error = TT_Err_Ok;
 
 
-    switch ( range->index_format )
+    switch ( range->image_format )
     {
-    case 1:  /* variable metrics */
-    case 3:
-    case 4:
+    case 1:
+    case 2:
+    case 8:
+      /* variable small metrics */
       {
-        switch ( range->image_format )
-        {
-        case 1:  /* small metrics */
-        case 2:
-        case 8:
-          {
-            TT_SBit_Small_Metrics  smetrics;
-
+       TT_SBit_Small_Metrics  smetrics;
 
-            /* read small metrics */
-            if ( ACCESS_Frame( 5L ) )
-              goto Exit;
-            TT_Load_Small_SBit_Metrics( &smetrics, stream );
-            FORGET_Frame();
-
-            /* convert it to a big metrics */
-            metrics->height       = smetrics.height;
-            metrics->width        = smetrics.width;
-            metrics->horiBearingX = smetrics.bearingX;
-            metrics->horiBearingY = smetrics.bearingY;
-            metrics->horiAdvance  = smetrics.advance;
-
-            /* these metrics are made up at a higher level when */
-            /* needed.                                          */
-            metrics->vertBearingX = 0;
-            metrics->vertBearingY = 0;
-            metrics->vertAdvance  = 0;
-          }
-          break;
 
-        default:  /* big metrics */
-          if ( ACCESS_Frame( 8L ) )
-            goto Exit;
-          TT_Load_SBit_Metrics( metrics, stream );
-          FORGET_Frame();
-        }
+       /* read small metrics */
+       if ( ACCESS_Frame( 5L ) )
+         goto Exit;
+       TT_Load_Small_SBit_Metrics( &smetrics, stream );
+       FORGET_Frame();
+
+       /* convert it to a big metrics */
+       metrics->height       = smetrics.height;
+       metrics->width        = smetrics.width;
+       metrics->horiBearingX = smetrics.bearingX;
+       metrics->horiBearingY = smetrics.bearingY;
+       metrics->horiAdvance  = smetrics.advance;
+
+       /* these metrics are made up at a higher level when */
+       /* needed.                                          */
+       metrics->vertBearingX = 0;
+       metrics->vertBearingY = 0;
+       metrics->vertAdvance  = 0;
       }
       break;
 
+    case 6:
+    case 7:
+    case 9:
+      /* valiable big metrics */
+      if ( ACCESS_Frame( 8L ) )
+       goto Exit;
+      TT_Load_SBit_Metrics( metrics, stream );
+      FORGET_Frame();
+      break;
+
+    case 5:
     default:  /* constant metrics */
-      *metrics = range->metrics;
+      if ( range->index_format == 2 || range->index_format == 5 )
+       *metrics = range->metrics;
+      else
+       return FT_Err_Invalid_File_Format;
     }
 
   Exit:
@@ -1254,6 +1255,8 @@
 
       if ( ALLOC( map->buffer, size ) )
         goto Exit;
+
+      MEM_Set( map->buffer, 0, size );
     }
 
     switch ( range->image_format )
@@ -1267,6 +1270,7 @@
                                range->image_format, metrics, stream );
 
     case 8:  /* compound format */
+      FT_Skip_Stream( stream, 1L );
     case 9:
       break;
 
@@ -1281,7 +1285,6 @@
       TT_SBit_Component*  comp;
       TT_UShort           num_components, count;
 
-
       if ( READ_UShort( num_components )                                ||
            ALLOC_ARRAY( components, num_components, TT_SBit_Component ) )
         goto Exit;
@@ -1433,6 +1436,8 @@
     }
 
     /* Crop the bitmap now */
+    /* It has better to provide the way without cropping */
+    /* like providing bbox and cbox */
     Crop_Bitmap( map, metrics );
 
   Exit:
diff -ur freetype2/src/truetype/ttdriver.c 
freetype2_compile/src/truetype/ttdriver.c
--- freetype2/src/truetype/ttdriver.c   Tue May 16 00:40:47 2000
+++ freetype2_compile/src/truetype/ttdriver.c   Tue May 16 22:57:17 2000
@@ -239,8 +239,30 @@
         root->charmaps[n] = (FT_CharMap)charmap;
       }
 
-      root->num_fixed_sizes = 0;
-      root->available_sizes = 0;
+#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
+      if ( face->num_sbit_strikes )
+      {
+       face->root.num_fixed_sizes = face->num_sbit_strikes; 
+       if ( ALLOC_ARRAY( face->root.available_sizes,
+                         face->num_sbit_strikes,
+                         FT_Bitmap_Size ) )
+         return error;
+
+       for ( n = 0 ; n < face->num_sbit_strikes ; n++ )
+       {
+         face->root.available_sizes[n].width =
+           face->sbit_strikes[n].x_ppem;
+         face->root.available_sizes[n].height =
+           face->sbit_strikes[n].y_ppem;
+       }
+      }
+      else
+#else
+      {
+       root->num_fixed_sizes = 0;
+       root->available_sizes = 0;
+      }
+#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
 
       /*****************************************************************/
       /*                                                               */
diff -ur freetype2/src/truetype/ttobjs.c freetype2_compile/src/truetype/ttobjs.c
--- freetype2/src/truetype/ttobjs.c     Tue May 16 00:41:03 2000
+++ freetype2_compile/src/truetype/ttobjs.c     Tue May 16 22:51:51 2000
@@ -373,6 +373,11 @@
     FREE( face->root.family_name );
     FREE( face->root.style_name );
 
+    /* freeing sbit size table */
+    face->root.num_fixed_sizes = 0;
+    if ( face->root.available_sizes )
+      FREE( face->root.available_sizes );
+
     face->sfnt = 0;
   }
 


reply via email to

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