pango r2819 - in trunk: . pango/opentype



Author: behdad
Date: Thu Jan 29 09:20:08 2009
New Revision: 2819
URL: http://svn.gnome.org/viewvc/pango?rev=2819&view=rev

Log:
2009-01-29  Behdad Esfahbod  <behdad gnome org>

        * pango/opentype/harfbuzz-open.h:
        * pango/opentype/harfbuzz-gdef.c (Make_ClassRange),
        (HB_GDEF_Build_ClassDefinition):
        * pango/opentype/harfbuzz-gpos.c (Load_PosClassRule),
        (Load_ChainPosClassRule):
        * pango/opentype/harfbuzz-gsub.c (Load_SubClassRule),
        (Load_ChainSubClassRule):
        * pango/opentype/harfbuzz-open.c (Load_ClassDef1),
        (Load_ClassDef2), (_HB_OPEN_Load_ClassDefinition),
        (_HB_OPEN_Load_EmptyClassDefinition),
        (_HB_OPEN_Free_ClassDefinition):
        Remove ClassDef->Defined field.  This is the comment accompanying it:

          The `Defined' field is not defined in the OpenType specification
          but apparently needed for processing fonts like trado.ttf: This
          font refers to a class which contains not a single element.  We
          map such classes to class 0.

        The comment is correct that trado.ttf (MS Traditional Arabic) uses
        such classes.  However, in my testing I couldn't identify any
        problems with the font if the special handling is removed.  I also
        processed as many fonts as I could get my hand on and trado.ttf was
        the only not-totally-broken font hitting the special-case code.
        DejaVu fonts hit it too, but I'm sure they do not require the
        special-handling code.  Most probably, that code introduces bugs
        in them.

        The special-casing was consuming lots of memory.  EIGHT MEGABYTES
        for loading DejaVu Sans!  While this could be complete fixed, I
        decided to remove the special-handling code altogether.  I don't
        think it will make any real difference, and if it does, we'll fix
        fonts.  Such hacks will not be in harfbuzz-ng anyway.

        Bug originally reported by nsf.

Modified:
   trunk/ChangeLog
   trunk/pango/opentype/harfbuzz-gdef.c
   trunk/pango/opentype/harfbuzz-gpos.c
   trunk/pango/opentype/harfbuzz-gsub.c
   trunk/pango/opentype/harfbuzz-open.c
   trunk/pango/opentype/harfbuzz-open.h

Modified: trunk/pango/opentype/harfbuzz-gdef.c
==============================================================================
--- trunk/pango/opentype/harfbuzz-gdef.c	(original)
+++ trunk/pango/opentype/harfbuzz-gdef.c	Thu Jan 29 09:20:08 2009
@@ -776,8 +776,6 @@
   crr[index].End   = end;
   crr[index].Class = class;
 
-  cd->Defined[class] = TRUE;
-
   return HB_Err_Ok;
 }
 
@@ -807,11 +805,6 @@
 
   gcd->ClassFormat = 2;
 
-  /* A GlyphClassDef table contains at most 5 different class values */
-
-  if ( ALLOC_ARRAY( gcd->Defined, 5, HB_Bool ) )
-    return error;
-
   gcd->cd.cd2.ClassRangeCount  = 0;
   gcd->cd.cd2.ClassRangeRecord = NULL;
 
@@ -959,7 +952,6 @@
   FREE( gcd->cd.cd2.ClassRangeRecord );
 
 Fail4:
-  FREE( gcd->Defined );
   return error;
 }
 

Modified: trunk/pango/opentype/harfbuzz-gpos.c
==============================================================================
--- trunk/pango/opentype/harfbuzz-gpos.c	(original)
+++ trunk/pango/opentype/harfbuzz-gpos.c	Thu Jan 29 09:20:08 2009
@@ -3362,7 +3362,6 @@
 
   HB_UShort*            c;
   HB_PosLookupRecord*  plr;
-  HB_Bool*              d;
 
 
   if ( ACCESS_Frame( 4L ) )
@@ -3384,22 +3383,13 @@
     return error;
 
   c = pcr->Class;
-  d = cpf2->ClassDef.Defined;
 
   if ( ACCESS_Frame( count * 2L ) )
     goto Fail2;
 
   for ( n = 0; n < count; n++ )
-  {
     c[n] = GET_UShort();
 
-    /* We check whether the specific class is used at all.  If not,
-       class 0 is used instead.                                     */
-
-    if ( !d[c[n]] )
-      c[n] = 0;
-  }
-
   FORGET_Frame();
 
   pcr->PosLookupRecord = NULL;
@@ -4376,7 +4366,6 @@
   HB_UShort*            i;
   HB_UShort*            l;
   HB_PosLookupRecord*  plr;
-  HB_Bool*              d;
 
 
   if ( ACCESS_Frame( 2L ) )
@@ -4397,22 +4386,13 @@
     return error;
 
   b = cpcr->Backtrack;
-  d = ccpf2->BacktrackClassDef.Defined;
 
   if ( ACCESS_Frame( count * 2L ) )
     goto Fail4;
 
   for ( n = 0; n < count; n++ )
-  {
     b[n] = GET_UShort();
 
-    /* We check whether the specific class is used at all.  If not,
-       class 0 is used instead.                                     */
-
-    if ( !d[b[n]] )
-      b[n] = 0;
-  }
-
   FORGET_Frame();
 
   if ( ACCESS_Frame( 2L ) )
@@ -4433,19 +4413,13 @@
     goto Fail4;
 
   i = cpcr->Input;
-  d = ccpf2->InputClassDef.Defined;
 
   if ( ACCESS_Frame( count * 2L ) )
     goto Fail3;
 
   for ( n = 0; n < count; n++ )
-  {
     i[n] = GET_UShort();
 
-    if ( !d[i[n]] )
-      i[n] = 0;
-  }
-
   FORGET_Frame();
 
   if ( ACCESS_Frame( 2L ) )
@@ -4466,19 +4440,13 @@
     goto Fail3;
 
   l = cpcr->Lookahead;
-  d = ccpf2->LookaheadClassDef.Defined;
 
   if ( ACCESS_Frame( count * 2L ) )
     goto Fail2;
 
   for ( n = 0; n < count; n++ )
-  {
     l[n] = GET_UShort();
 
-    if ( !d[l[n]] )
-      l[n] = 0;
-  }
-
   FORGET_Frame();
 
   if ( ACCESS_Frame( 2L ) )

Modified: trunk/pango/opentype/harfbuzz-gsub.c
==============================================================================
--- trunk/pango/opentype/harfbuzz-gsub.c	(original)
+++ trunk/pango/opentype/harfbuzz-gsub.c	Thu Jan 29 09:20:08 2009
@@ -1385,7 +1385,6 @@
 
   HB_UShort*              c;
   HB_SubstLookupRecord*  slr;
-  HB_Bool*                d;
 
 
   if ( ACCESS_Frame( 4L ) )
@@ -1407,21 +1406,13 @@
     return error;
 
   c = scr->Class;
-  d = csf2->ClassDef.Defined;
 
   if ( ACCESS_Frame( count * 2L ) )
     goto Fail2;
 
   for ( n = 0; n < count; n++ )
-  {
     c[n] = GET_UShort();
 
-    /* We check whether the specific class is used at all.  If not,
-       class 0 is used instead.                                     */
-    if ( !d[c[n]] )
-      c[n] = 0;
-  }
-
   FORGET_Frame();
 
   scr->SubstLookupRecord = NULL;
@@ -2379,7 +2370,6 @@
   HB_UShort*              i;
   HB_UShort*              l;
   HB_SubstLookupRecord*  slr;
-  HB_Bool*                d;
 
 
   if ( ACCESS_Frame( 2L ) )
@@ -2400,22 +2390,13 @@
     return error;
 
   b = cscr->Backtrack;
-  d = ccsf2->BacktrackClassDef.Defined;
 
   if ( ACCESS_Frame( count * 2L ) )
     goto Fail4;
 
   for ( n = 0; n < count; n++ )
-  {
     b[n] = GET_UShort();
 
-    /* We check whether the specific class is used at all.  If not,
-       class 0 is used instead.                                     */
-
-    if ( !d[b[n]] )
-      b[n] = 0;
-  }
-
   FORGET_Frame();
 
   if ( ACCESS_Frame( 2L ) )
@@ -2436,19 +2417,13 @@
     goto Fail4;
 
   i = cscr->Input;
-  d = ccsf2->InputClassDef.Defined;
 
   if ( ACCESS_Frame( count * 2L ) )
     goto Fail3;
 
   for ( n = 0; n < count; n++ )
-  {
     i[n] = GET_UShort();
 
-    if ( !d[i[n]] )
-      i[n] = 0;
-  }
-
   FORGET_Frame();
 
   if ( ACCESS_Frame( 2L ) )
@@ -2469,19 +2444,13 @@
     goto Fail3;
 
   l = cscr->Lookahead;
-  d = ccsf2->LookaheadClassDef.Defined;
 
   if ( ACCESS_Frame( count * 2L ) )
     goto Fail2;
 
   for ( n = 0; n < count; n++ )
-  {
     l[n] = GET_UShort();
 
-    if ( !d[l[n]] )
-      l[n] = 0;
-  }
-
   FORGET_Frame();
 
   if ( ACCESS_Frame( 2L ) )

Modified: trunk/pango/opentype/harfbuzz-open.c
==============================================================================
--- trunk/pango/opentype/harfbuzz-open.c	(original)
+++ trunk/pango/opentype/harfbuzz-open.c	Thu Jan 29 09:20:08 2009
@@ -942,7 +942,6 @@
   HB_UShort             n, count;
 
   HB_UShort*            cva;
-  HB_Bool*              d;
 
   HB_ClassDefFormat1*  cdf1;
 
@@ -967,7 +966,6 @@
   if ( ALLOC_ARRAY( cdf1->ClassValueArray, count, HB_UShort ) )
     return error;
 
-  d   = cd->Defined;
   cva = cdf1->ClassValueArray;
 
   if ( ACCESS_Frame( count * 2L ) )
@@ -981,7 +979,6 @@
       error = ERR(HB_Err_Invalid_SubTable);
       goto Fail;
     }
-    d[cva[n]] = TRUE;
   }
 
   FORGET_Frame();
@@ -1012,7 +1009,6 @@
   HB_UShort              n, count;
 
   HB_ClassRangeRecord*  crr;
-  HB_Bool*               d;
 
   HB_ClassDefFormat2*   cdf2;
 
@@ -1032,7 +1028,6 @@
   if ( ALLOC_ARRAY( cdf2->ClassRangeRecord, count, HB_ClassRangeRecord ) )
     return error;
 
-  d   = cd->Defined;
   crr = cdf2->ClassRangeRecord;
 
   if ( ACCESS_Frame( count * 6L ) )
@@ -1056,8 +1051,6 @@
        n--;
        count--;
     }
-    else
-      d[crr[n].Class] = TRUE;
   }
 
   FORGET_Frame();
@@ -1088,11 +1081,8 @@
 {
   HB_Error   error;
 
-  if ( ALLOC_ARRAY( cd->Defined, limit, HB_Bool ) )
-    return error;
-
   if ( ACCESS_Frame( 2L ) )
-    goto Fail;
+    return error;
 
   cd->ClassFormat = GET_UShort();
 
@@ -1106,15 +1096,11 @@
   }
 
   if ( error )
-    goto Fail;
+    return error;
 
   cd->loaded = TRUE;
 
   return HB_Err_Ok;
-
-Fail:
-  FREE( cd->Defined );
-  return error;
 }
 
 
@@ -1123,20 +1109,12 @@
 {
   HB_Error   error;
 
-  if ( ALLOC_ARRAY( cd->Defined, 1, HB_Bool ) )
-    return error;
-
   cd->ClassFormat = 1; /* Meaningless */
-  cd->Defined[0] = FALSE;
 
   if ( ALLOC_ARRAY( cd->cd.cd1.ClassValueArray, 1, HB_UShort ) )
-    goto Fail;
+    return error;
 
   return HB_Err_Ok;
-
-Fail:
-  FREE( cd->Defined );
-  return error;
 }
 
 HB_INTERNAL HB_Error
@@ -1171,8 +1149,6 @@
   if ( !cd->loaded )
     return;
 
-  FREE( cd->Defined );
-
   switch ( cd->ClassFormat )
   {
   case 1:  Free_ClassDef1( &cd->cd.cd1 ); break;

Modified: trunk/pango/opentype/harfbuzz-open.h
==============================================================================
--- trunk/pango/opentype/harfbuzz-open.h	(original)
+++ trunk/pango/opentype/harfbuzz-open.h	Thu Jan 29 09:20:08 2009
@@ -240,18 +240,10 @@
 typedef struct HB_ClassDefFormat2_  HB_ClassDefFormat2;
 
 
-/* The `Defined' field is not defined in the OpenType specification but
-   apparently needed for processing fonts like trado.ttf: This font
-   refers to a class which contains not a single element.  We map such
-   classes to class 0.                                                 */
-
 struct  HB_ClassDefinition_
 {
   HB_Bool    loaded;
 
-  HB_Bool*   Defined;                 /* array of Booleans.
-					 If Defined[n] is FALSE,
-					 class n contains no glyphs. */
   HB_UShort  ClassFormat;             /* 1 or 2                      */
 
   union



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