Re: Font Problems



At 09:03 AM 8/27/2002, Owen Taylor wrote:

Eric Mader <mader jtcsv com> writes:

> At 05:47 AM 8/24/2002, Owen Taylor wrote:
> >We should most likely accept "well formed but useless" tables. Can
> >you provide your patch so I can take a look at it?
> >
> >                                         Owen
>
> Here is the patch. It contains some extra debugging statements, and
> has the old code partly #if 0'd out... The basic idea is that it will
> only fail if there are no valid scripts in the file.

I think the basic idea is OK; in detail:

 - A new TTO_Err should be defined, maybe:

   TTO_Err_No_Langs_in_Script

   And we should only ignore that error, and no other errors.
   We shouln't accept script tables that are invalid for other
   reason than having no languages in them.

 - Doesn't sl->ScriptCount needs to be adjusted if you ignore scripts?

 - I think it gets unreadable with m,n,o -- maybe just use
   sl->ScriptCount for what you are using 'o' for in your patch?

Regards,
                                        Owen

Here is the new-and-improved(tm) patch.

Regards,
Eric

Index: ftxopen.c
===================================================================
RCS file: /cvs/gnome/pango/pango/opentype/ftxopen.c,v
retrieving revision 1.6
diff -u -p -r1.6 ftxopen.c
--- ftxopen.c   7 Aug 2002 17:01:52 -0000       1.6
+++ ftxopen.c   28 Aug 2002 21:49:31 -0000
@@ -130,7 +130,7 @@

     if ( s->LangSysCount == 0 && s->DefaultLangSys.FeatureCount == 0 )
     {
-      error = TTO_Err_Invalid_SubTable;
+      error = TTO_Err_Empty_Script;
       goto Fail2;
     }

@@ -205,7 +205,7 @@
     FT_Error   error;
     FT_Memory  memory = stream->memory;

-    FT_UShort          n, m, count;
+    FT_UShort          n, script_count;
     FT_ULong           cur_offset, new_offset, base_offset;

     TTO_ScriptRecord*  sr;
@@ -216,39 +216,53 @@
     if ( ACCESS_Frame( 2L ) )
       return error;

-    count = sl->ScriptCount = GET_UShort();
+    script_count = GET_UShort();

     FORGET_Frame();

     sl->ScriptRecord = NULL;

-    if ( ALLOC_ARRAY( sl->ScriptRecord, count, TTO_ScriptRecord ) )
+    if ( ALLOC_ARRAY( sl->ScriptRecord, script_count, TTO_ScriptRecord ) )
       return error;

     sr = sl->ScriptRecord;

-    for ( n = 0; n < count; n++ )
+    sl->ScriptCount= 0;
+    for ( n = 0; n < script_count; n++ )
     {
       if ( ACCESS_Frame( 6L ) )
         goto Fail;

-      sr[n].ScriptTag = GET_ULong();
+      sr[sl->ScriptCount].ScriptTag = GET_ULong();
       new_offset = GET_UShort() + base_offset;

       FORGET_Frame();

       cur_offset = FILE_Pos();
-      if ( FILE_Seek( new_offset ) ||
-           ( error = Load_Script( &sr[n].Script, stream ) ) != TT_Err_Ok )
-        goto Fail;
+
+      if ( FILE_Seek( new_offset ) )
+       goto Fail;
+
+      error = Load_Script( &sr[sl->ScriptCount].Script, stream );
+      if ( error != TT_Err_Ok &&  error != TTO_Err_Empty_Script )
+       goto Fail;
+
+      sl->ScriptCount += 1;
+
       (void)FILE_Seek( cur_offset );
     }

+    if ( sl->ScriptCount == 0 )
+    {
+      error = TTO_Err_Invalid_SubTable;
+      goto Fail;
+    }
+
     return TT_Err_Ok;

   Fail:
-    for ( m = 0; m < n; m++ )
-      Free_Script( &sr[m].Script, memory );
+    for ( n = 0; n < sl->ScriptCount; n++ )
+      Free_Script( &sr[n].Script, memory );

     FREE( sl->ScriptRecord );
     return error;
Index: ftxopen.h
===================================================================
RCS file: /cvs/gnome/pango/pango/opentype/ftxopen.h,v
retrieving revision 1.1
diff -u -p -r1.1 ftxopen.h
--- ftxopen.h   20 Dec 2000 04:41:36 -0000      1.1
+++ ftxopen.h   28 Aug 2002 21:49:31 -0000
@@ -38,6 +38,7 @@ extern "C" {
 #define TTO_Err_Not_Covered               0x1002
 #define TTO_Err_Too_Many_Nested_Contexts  0x1003
 #define TTO_Err_No_MM_Interpreter         0x1004
+#define TTO_Err_Empty_Script              0x1005


   /* Script list related structures */




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