[Xorg-commit] xc/extras/freetype2/src/sfnt rules.mk,1.1,1.1.4.1 sfdriver.c,1.1.4.1,1.1.4.2 sfobjs.c,1.1.4.1,1.1.4.2 ttcmap0.c,1.1.4.1,1.1.4.2 ttload.c,1.1.4.1,1.1.4.2 ttpost.c,1.1.4.1,1.1.4.2 ttsbit.c,1.1.4.1,1.1.4.2

Kaleb Keithley xorg-commit at pdx.freedesktop.org
Wed May 9 17:30:30 EEST 2007


Committed by: kaleb

Update of /cvs/xorg/xc/extras/freetype2/src/sfnt
In directory pdx:/home/kaleb/xorg/xc.XORG-CURRENT/extras/freetype2/src/sfnt

Modified Files:
      Tag: XORG-CURRENT
	rules.mk sfdriver.c sfobjs.c ttcmap0.c ttload.c ttpost.c 
	ttsbit.c 
Log Message:
merge most of XFree86 RC3 (4.3.99.903) from vendor branch.
bug #214


Index: rules.mk
===================================================================
RCS file: /cvs/xorg/xc/extras/freetype2/src/sfnt/rules.mk,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -u -d -r1.1 -r1.1.4.1
--- a/rules.mk	14 Nov 2003 16:48:24 -0000	1.1
+++ b/rules.mk	23 Feb 2004 21:33:05 -0000	1.1.4.1
@@ -3,7 +3,7 @@
 #
 
 
-# Copyright 1996-2000, 2002 by
+# Copyright 1996-2000, 2002, 2003 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -15,29 +15,28 @@
 
 # SFNT driver directory
 #
-SFNT_DIR  := $(SRC_)sfnt
-SFNT_DIR_ := $(SFNT_DIR)$(SEP)
+SFNT_DIR := $(SRC_DIR)/sfnt
 
 
 # compilation flags for the driver
 #
-SFNT_COMPILE := $(FT_COMPILE) $I$(SFNT_DIR)
+SFNT_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(SFNT_DIR))
 
 
 # SFNT driver sources (i.e., C files)
 #
-SFNT_DRV_SRC := $(SFNT_DIR_)ttload.c   \
-                $(SFNT_DIR_)ttcmap.c   \
-                $(SFNT_DIR_)ttcmap0.c  \
-                $(SFNT_DIR_)ttsbit.c   \
-                $(SFNT_DIR_)ttpost.c   \
-                $(SFNT_DIR_)sfobjs.c   \
-                $(SFNT_DIR_)sfdriver.c
+SFNT_DRV_SRC := $(SFNT_DIR)/ttload.c   \
+                $(SFNT_DIR)/ttcmap.c   \
+                $(SFNT_DIR)/ttcmap0.c  \
+                $(SFNT_DIR)/ttsbit.c   \
+                $(SFNT_DIR)/ttpost.c   \
+                $(SFNT_DIR)/sfobjs.c   \
+                $(SFNT_DIR)/sfdriver.c
 
 # SFNT driver headers
 #
 SFNT_DRV_H := $(SFNT_DRV_SRC:%c=%h) \
-              $(SFNT_DIR_)sferrors.h
+              $(SFNT_DIR)/sferrors.h
 
 
 # SFNT driver object(s)
@@ -45,25 +44,25 @@
 #   SFNT_DRV_OBJ_M is used during `multi' builds.
 #   SFNT_DRV_OBJ_S is used during `single' builds.
 #
-SFNT_DRV_OBJ_M := $(SFNT_DRV_SRC:$(SFNT_DIR_)%.c=$(OBJ_)%.$O)
-SFNT_DRV_OBJ_S := $(OBJ_)sfnt.$O
+SFNT_DRV_OBJ_M := $(SFNT_DRV_SRC:$(SFNT_DIR)/%.c=$(OBJ_DIR)/%.$O)
+SFNT_DRV_OBJ_S := $(OBJ_DIR)/sfnt.$O
 
 # SFNT driver source file for single build
 #
-SFNT_DRV_SRC_S := $(SFNT_DIR_)sfnt.c
+SFNT_DRV_SRC_S := $(SFNT_DIR)/sfnt.c
 
 
 # SFNT driver - single object
 #
 $(SFNT_DRV_OBJ_S): $(SFNT_DRV_SRC_S) $(SFNT_DRV_SRC) \
                    $(FREETYPE_H) $(SFNT_DRV_H)
-	$(SFNT_COMPILE) $T$@ $(SFNT_DRV_SRC_S)
+	$(SFNT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(SFNT_DRV_SRC_S))
 
 
 # SFNT driver - multiple objects
 #
-$(OBJ_)%.$O: $(SFNT_DIR_)%.c $(FREETYPE_H) $(SFNT_DRV_H)
-	$(SFNT_COMPILE) $T$@ $<
+$(OBJ_DIR)/%.$O: $(SFNT_DIR)/%.c $(FREETYPE_H) $(SFNT_DRV_H)
+	$(SFNT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
 
 
 # update main driver object lists

Index: sfdriver.c
===================================================================
RCS file: /cvs/xorg/xc/extras/freetype2/src/sfnt/sfdriver.c,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/sfdriver.c	26 Nov 2003 22:48:28 -0000	1.1.4.1
+++ b/sfdriver.c	23 Feb 2004 21:33:05 -0000	1.1.4.2
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    High-level SFNT driver interface (body).                             */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002 by                                           */
+/*  Copyright 1996-2001, 2002, 2003 by                                     */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -14,7 +14,7 @@
 /*  understand and accept it fully.                                        */
 /*                                                                         */
 /***************************************************************************/
-/* $XFree86: xc/extras/freetype2/src/sfnt/sfdriver.c,v 1.3 2003/05/29 02:13:05 dawes Exp $ */
+
 
 #include <ft2build.h>
 #include FT_INTERNAL_SFNT_H
@@ -25,6 +25,8 @@
 #include "ttcmap.h"
 #include "sfobjs.h"
 
+#include "sferrors.h"
+
 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
 #include "ttsbit.h"
 #endif
@@ -33,6 +35,15 @@
 #include "ttpost.h"
 #endif
 
+#include FT_SERVICE_GLYPH_DICT_H
+#include FT_SERVICE_POSTSCRIPT_NAME_H
+#include FT_SERVICE_SFNT_H
+
+
+ /*
+  *  SFNT TABLE SERVICE
+  *
+  */
 
   static void*
   get_sfnt_table( TT_Face      face,
@@ -79,11 +90,22 @@
   }
 
 
+  static const FT_Service_SFNT_TableRec  sfnt_service_sfnt_table =
+  {
+    (FT_SFNT_TableLoadFunc)tt_face_load_any,
+    (FT_SFNT_TableGetFunc) get_sfnt_table
+  };
+
+
 #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
 
+ /*
+  *  GLYPH DICT SERVICE
+  *
+  */
 
   static FT_Error
-  get_sfnt_glyph_name( TT_Face     face,
+  sfnt_get_glyph_name( TT_Face     face,
                        FT_UInt     glyph_index,
                        FT_Pointer  buffer,
                        FT_UInt     buffer_max )
@@ -109,16 +131,30 @@
   }
 
 
+  static const FT_Service_GlyphDictRec  sfnt_service_glyph_dict =
+  {
+    (FT_GlyphDict_GetNameFunc)  sfnt_get_glyph_name,
+    (FT_GlyphDict_NameIndexFunc)NULL
+  };
+
+#endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
+
+
+ /*
+  *  POSTSCRIPT NAME SERVICE
+  *
+  */
+
   static const char*
-  get_sfnt_postscript_name( TT_Face  face )
+  sfnt_get_ps_name( TT_Face  face )
   {
     FT_Int       n, found_win, found_apple;
     const char*  result = NULL;
 
 
     /* shouldn't happen, but just in case to avoid memory leaks */
-    if ( face->root.internal->postscript_name )
-      return face->root.internal->postscript_name;
+    if ( face->postscript_name )
+      return face->postscript_name;
 
     /* scan the name table to see whether we have a Postscript name here, */
     /* either in Macintosh or Windows platform encodings                  */
@@ -149,7 +185,9 @@
       FT_Memory         memory = face->root.memory;
       TT_NameEntryRec*  name   = face->name_table.names + found_win;
       FT_UInt           len    = name->stringLength / 2;
-      FT_Error          error;
+      FT_Error          error  = SFNT_Err_Ok;
+
+      FT_UNUSED( error );
 
 
       if ( !FT_ALLOC( result, name->stringLength + 1 ) )
@@ -181,9 +219,6 @@
 
         FT_FRAME_EXIT();
       }
-
-      (void)error;	/* Muffle compiler */
-
       goto Exit;
     }
 
@@ -192,7 +227,9 @@
       FT_Memory         memory = face->root.memory;
       TT_NameEntryRec*  name   = face->name_table.names + found_apple;
       FT_UInt           len    = name->stringLength;
-      FT_Error          error;
+      FT_Error          error  = SFNT_Err_Ok;
+
+      FT_UNUSED( error );
 
 
       if ( !FT_ALLOC( result, len + 1 ) )
@@ -211,17 +248,35 @@
         }
         ((char*)result)[len] = '\0';
       }
-
-      (void)error;	/* Muffle compiler */
     }
 
   Exit:
-    face->root.internal->postscript_name = result;
+    face->postscript_name = result;
     return result;
   }
 
+  static const FT_Service_PsFontNameRec  sfnt_service_ps_name =
+  {
+    (FT_PsName_GetFunc)sfnt_get_ps_name
+  };
 
-#endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
+
+
+ /*
+  *  SERVICE LIST
+  *
+  */
+
+  static const FT_ServiceDescRec  sfnt_services[] =
+  {
+    { FT_SERVICE_ID_SFNT_TABLE,           &sfnt_service_sfnt_table },
+    { FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &sfnt_service_ps_name },
+#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
+    { FT_SERVICE_ID_GLYPH_DICT,           &sfnt_service_glyph_dict },
+#endif
+
+    { NULL, NULL }
+  };
 
 
   FT_CALLBACK_DEF( FT_Module_Interface )
@@ -236,15 +291,7 @@
     if ( ft_strcmp( module_interface, "load_sfnt" ) == 0 )
       return (FT_Module_Interface)tt_face_load_any;
 
-#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
-    if ( ft_strcmp( module_interface, "glyph_name" ) == 0 )
-      return (FT_Module_Interface)get_sfnt_glyph_name;
-#endif
-
-    if ( ft_strcmp( module_interface, "postscript_name" ) == 0 )
-      return (FT_Module_Interface)get_sfnt_postscript_name;
-
-    return 0;
+    return ft_service_list_lookup( sfnt_services, module_interface );
   }
 
 

Index: sfobjs.c
===================================================================
RCS file: /cvs/xorg/xc/extras/freetype2/src/sfnt/sfobjs.c,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/sfobjs.c	26 Nov 2003 22:48:28 -0000	1.1.4.1
+++ b/sfobjs.c	23 Feb 2004 21:33:05 -0000	1.1.4.2
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    SFNT object management (base).                                       */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002 by                                           */
+/*  Copyright 1996-2001, 2002, 2003 by                                     */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -14,17 +14,16 @@
 /*  understand and accept it fully.                                        */
 /*                                                                         */
 /***************************************************************************/
-/* $XFree86: xc/extras/freetype2/src/sfnt/sfobjs.c,v 1.3 2003/05/29 02:13:05 dawes Exp $ */
+
 
 #include <ft2build.h>
 #include "sfobjs.h"
 #include "ttload.h"
 #include "ttcmap0.h"
 #include FT_INTERNAL_SFNT_H
-#include FT_INTERNAL_POSTSCRIPT_NAMES_H
 #include FT_TRUETYPE_IDS_H
 #include FT_TRUETYPE_TAGS_H
-
+#include FT_SERVICE_POSTSCRIPT_CMAPS_H
 #include "sferrors.h"
 
 
@@ -258,9 +257,11 @@
     {
       if ( rec->string == NULL )
       {
-        FT_Error   error;
+        FT_Error   error  = SFNT_Err_Ok;
         FT_Stream  stream = face->name_table.stream;
 
+        FT_UNUSED( error );
+
 
         if ( FT_NEW_ARRAY  ( rec->string, rec->stringLength ) ||
              FT_STREAM_SEEK( rec->stringOffset )              ||
@@ -271,8 +272,6 @@
           result            = NULL;
           goto Exit;
         }
-
-	(void)error;	/* Muffle compiler */
       }
 
       result = convert( rec, memory );
@@ -307,11 +306,11 @@
       { TT_PLATFORM_MICROSOFT,     TT_MS_ID_SYMBOL_CS,  FT_ENCODING_MS_SYMBOL },
       { TT_PLATFORM_MICROSOFT,     TT_MS_ID_UCS_4,      FT_ENCODING_UNICODE },
       { TT_PLATFORM_MICROSOFT,     TT_MS_ID_UNICODE_CS, FT_ENCODING_UNICODE },
-      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_SJIS,       FT_ENCODING_MS_SJIS },
-      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_GB2312,     FT_ENCODING_MS_GB2312 },
-      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_BIG_5,      FT_ENCODING_MS_BIG5 },
-      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_WANSUNG,    FT_ENCODING_MS_WANSUNG },
-      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_JOHAB,      FT_ENCODING_MS_JOHAB }
+      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_SJIS,       FT_ENCODING_SJIS },
+      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_GB2312,     FT_ENCODING_GB2312 },
+      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_BIG_5,      FT_ENCODING_BIG5 },
+      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_WANSUNG,    FT_ENCODING_WANSUNG },
+      { TT_PLATFORM_MICROSOFT,     TT_MS_ID_JOHAB,      FT_ENCODING_JOHAB }
     };
 
     const TEncoding  *cur, *limit;
@@ -365,11 +364,7 @@
       face->goto_table = sfnt->goto_table;
     }
 
-    if ( !face->psnames )
-    {
-      face->psnames = (PSNames_Service)
-                        FT_Get_Module_Interface( library, "psnames" );
-    }
+    FT_FACE_FIND_GLOBAL_SERVICE( face, face->psnames, POSTSCRIPT_CMAPS );
 
     /* check that we have a valid TrueType file */
     error = sfnt->load_sfnt_header( face, stream, face_index, &sfnt_header );
@@ -558,7 +553,7 @@
       /* Compute style flags.                                              */
       /*                                                                   */
       flags = 0;
-      if ( has_outline == TRUE && face->os2.version != 0xFFFF )
+      if ( has_outline == TRUE && face->os2.version != 0xFFFFU )
       {
         /* we have an OS/2 table; use the `fsSelection' field */
         if ( face->os2.fsSelection & 1 )
@@ -633,18 +628,30 @@
           root->face_flags |= FT_FACE_FLAG_VERTICAL;
         }
 #endif
-        root->num_fixed_sizes = face->num_sbit_strikes;
+        root->num_fixed_sizes = (FT_Int)face->num_sbit_strikes;
 
         if ( FT_NEW_ARRAY( root->available_sizes, face->num_sbit_strikes ) )
           goto Exit;
 
         for ( n = 0 ; n < face->num_sbit_strikes ; n++ )
         {
-          root->available_sizes[n].width =
-            face->sbit_strikes[n].x_ppem;
+          FT_Bitmap_Size*  bsize  = root->available_sizes + n;
+          TT_SBit_Strike   strike = face->sbit_strikes + n;
+          FT_UShort        fupem  = face->header.Units_Per_EM;
+          FT_Short         height = (FT_Short)( face->horizontal.Ascender -
+                                                face->horizontal.Descender +
+                                                face->horizontal.Line_Gap );
+          FT_Short         avg    = face->os2.xAvgCharWidth;
 
-          root->available_sizes[n].height =
-            face->sbit_strikes[n].y_ppem;
+
+          /* assume 72dpi */
+          bsize->height =
+            (FT_Short)( ( height * strike->y_ppem + fupem/2 ) / fupem );
+          bsize->width  =
+            (FT_Short)( ( avg * strike->y_ppem + fupem/2 ) / fupem );
+          bsize->size   = strike->y_ppem << 6;
+          bsize->x_ppem = strike->x_ppem << 6;
+          bsize->y_ppem = strike->y_ppem << 6;
         }
       }
       else
@@ -663,7 +670,7 @@
       if ( has_outline == TRUE )
       {
         /* XXX What about if outline header is missing */
-        /*     (e.g. sfnt wrapped outline)?            */
+        /*     (e.g. sfnt wrapped bitmap)?             */
         root->bbox.xMin    = face->header.xMin;
         root->bbox.yMin    = face->header.yMin;
         root->bbox.xMax    = face->header.xMax;
@@ -708,16 +715,18 @@
         root->height    = (FT_Short)( root->ascender - root->descender +
                                       face->horizontal.Line_Gap );
 
+#if 0
         /* if the line_gap is 0, we add an extra 15% to the text height --  */
         /* this computation is based on various versions of Times New Roman */
         if ( face->horizontal.Line_Gap == 0 )
           root->height = (FT_Short)( ( root->height * 115 + 50 ) / 100 );
+#endif
 
 #if 0
 
         /* some fonts have the OS/2 "sTypoAscender", "sTypoDescender" & */
         /* "sTypoLineGap" fields set to 0, like ARIALNB.TTF             */
-        if ( face->os2.version != 0xFFFF && root->ascender )
+        if ( face->os2.version != 0xFFFFU && root->ascender )
         {
           FT_Int  height;
 

Index: ttcmap0.c
===================================================================
RCS file: /cvs/xorg/xc/extras/freetype2/src/sfnt/ttcmap0.c,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/ttcmap0.c	26 Nov 2003 22:48:28 -0000	1.1.4.1
+++ b/ttcmap0.c	23 Feb 2004 21:33:05 -0000	1.1.4.2
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    TrueType new character mapping table (cmap) support (body).          */
 /*                                                                         */
-/*  Copyright 2002 by                                                      */
+/*  Copyright 2002, 2003 by                                                */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -14,7 +14,7 @@
 /*  understand and accept it fully.                                        */
 /*                                                                         */
 /***************************************************************************/
-/* $XFree86: xc/extras/freetype2/src/sfnt/ttcmap0.c,v 1.4 2003/05/29 02:13:05 dawes Exp $ */
+
 
 #include <ft2build.h>
 #include FT_INTERNAL_DEBUG_H
@@ -701,9 +701,18 @@
           p += offset;  /* start of glyph id array */
 
           /* check that we point within the glyph ids table only */
-          if ( p < glyph_ids                                ||
-               p + ( end - start + 1 ) * 2 > table + length )
-            FT_INVALID_DATA;
+          if ( valid->level >= FT_VALIDATE_TIGHT )
+          {
+            if ( p < glyph_ids                                ||
+                 p + ( end - start + 1 ) * 2 > table + length )
+              FT_INVALID_DATA;
+          }
+          else
+          {
+            if ( p < glyph_ids                              ||
+                 p + ( end - start + 1 ) * 2 > valid->limit )
+              FT_INVALID_DATA;
+          }
 
           /* check glyph indices within the segment range */
           if ( valid->level >= FT_VALIDATE_TIGHT )
@@ -780,10 +789,8 @@
 
           if ( code < start )
             max = mid;
-
           else if ( code > end )
             min = mid + 1;
-
           else
           {
             /* we found the segment */
@@ -872,24 +879,117 @@
   {
     FT_Byte*   table     = cmap->data;
     FT_UInt32  result    = 0;
-    FT_UInt32  char_code = *pchar_code + 1;
     FT_UInt    gindex    = 0;
+    FT_UInt32  char_code = *pchar_code;
     FT_Byte*   p;
-    FT_Byte*   q;
     FT_UInt    code, num_segs2;
 
 
-    if ( char_code >= 0x10000UL )
+    if ( char_code >= 0xFFFFUL )
       goto Exit;
 
-    code      = (FT_UInt)char_code;
+    code      = (FT_UInt)char_code + 1;
     p         = table + 6;
     num_segs2 = TT_PEEK_USHORT(p) & -2;  /* ensure even-ness */
 
+#if 1
+
     for (;;)
     {
-      FT_UInt  offset, n;
+      /* Some fonts have more than 170 segments in their charmaps! */
+      /* We changed this function to use a more efficient binary   */
+      /* search                                                    */
+      FT_UInt  offset;
       FT_Int   delta;
+      FT_UInt  min = 0;
+      FT_UInt  max = num_segs2 >> 1;
+      FT_UInt  mid, start, end;
+      FT_UInt  hi;
+
+
+      /* we begin by finding the segment which end is
+         closer to our code point */
+      hi = max + 1;
+      while ( min < max )
+      {
+        mid = ( min + max ) >> 1;
+        p   = table + 14 + mid * 2;
+        end = TT_PEEK_USHORT( p );
+
+        if ( end < code )
+          min = mid + 1;
+        else
+        {
+          hi  = mid;
+          max = mid;
+        }
+      }
+
+      if ( hi > max )
+      {
+        /* the point is behind the last segment;
+           we will exit right now */
+        goto Exit;
+      }
+
+      p   = table + 14 + hi * 2;
+      end = TT_PEEK_USHORT( p );
+
+      p    += 2 + num_segs2;
+      start = TT_PEEK_USHORT( p );
+
+      if ( code < start )
+        code = start;
+
+      p    += num_segs2;
+      delta = TT_PEEK_USHORT( p );
+
+      p     += num_segs2;
+      offset = TT_PEEK_USHORT( p );
+
+      if ( offset != 0 && offset != 0xFFFFU )
+      {
+        /* parse the glyph ids array for non-zero index */
+        p += offset + ( code - start ) * 2;
+        while ( code <= end )
+        {
+          gindex = TT_NEXT_USHORT( p );
+          if ( gindex != 0 )
+          {
+            gindex = (FT_UInt)( gindex + delta ) & 0xFFFFU;
+            if ( gindex != 0 )
+            {
+              result = code;
+              goto Exit;
+            }
+          }
+          code++;
+        }
+      }
+      else if ( offset == 0xFFFFU )
+      {
+        /* an offset of 0xFFFF means an empty glyph in certain fonts! */
+        code = end + 1;
+      }
+      else  /* offset == 0 */
+      {
+        gindex = (FT_UInt)( code + delta ) & 0xFFFFU;
+        if ( gindex != 0 )
+        {
+          result = code;
+          goto Exit;
+        }
+        code++;
+      }
+    }
+
+#else   /* old code -- kept for reference */
+
+    for ( ;; )
+    {
+      FT_UInt   offset, n;
+      FT_Int    delta;
+      FT_Byte*  q;
 
 
       p = table + 14;              /* ends table  */
@@ -943,14 +1043,14 @@
           goto Exit;
         }
       }
-
       /* loop to next trial charcode */
       if ( code >= 0xFFFFU )
         break;
 
       code++;
     }
-    return (FT_UInt)result;
+
+#endif /* !1 */
 
   Exit:
     *pchar_code = result;
@@ -1018,8 +1118,7 @@
     p      = table + 2;
     length = TT_NEXT_USHORT( p );
 
-    p      = table + 6;             /* skip language */
-    (void)   TT_NEXT_USHORT( p );
+    p      = table + 8;             /* skip language and start index */
     count  = TT_NEXT_USHORT( p );
 
     if ( table + length > valid->limit || length < 10 + count * 2 )
@@ -1397,8 +1496,7 @@
       FT_INVALID_TOO_SHORT;
 
     length = TT_NEXT_ULONG( p );
-    p      = table + 12;
-    (void)   TT_NEXT_ULONG( p );
+    p      = table + 16;
     count  = TT_NEXT_ULONG( p );
 
     if ( table + length > valid->limit || length < 20 + count * 2 )
@@ -1464,9 +1562,7 @@
     {
       gindex = TT_NEXT_USHORT( p );
       if ( gindex != 0 )
-      {
         break;
-      }
       char_code++;
     }
 
@@ -1711,7 +1807,7 @@
 
 
     if ( p + 4 > limit )
-      return FT_Err_Invalid_Table;
+      return SFNT_Err_Invalid_Table;
 
     /* only recognize format 0 */
     if ( TT_NEXT_USHORT( p ) != 0 )
@@ -1719,7 +1815,7 @@
       p -= 2;
       FT_ERROR(( "tt_face_build_cmaps: unsupported `cmap' table format = %d\n",
                  TT_PEEK_USHORT( p ) ));
-      return FT_Err_Invalid_Table;
+      return SFNT_Err_Invalid_Table;
     }
 
     num_cmaps = TT_NEXT_USHORT( p );
@@ -1739,7 +1835,7 @@
       if ( offset && table + offset + 2 < limit )
       {
         FT_Byte*                       cmap   = table + offset;
-        FT_UInt                        format = TT_PEEK_USHORT( cmap );
+        volatile FT_UInt               format = TT_PEEK_USHORT( cmap );
         const TT_CMap_Class* volatile  pclazz = tt_cmap_classes;
         TT_CMap_Class                  clazz;
 

Index: ttload.c
===================================================================
RCS file: /cvs/xorg/xc/extras/freetype2/src/sfnt/ttload.c,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/ttload.c	26 Nov 2003 22:48:28 -0000	1.1.4.1
+++ b/ttload.c	23 Feb 2004 21:33:05 -0000	1.1.4.2
@@ -5,7 +5,7 @@
 /*    Load the basic TrueType tables, i.e., tables that can be either in   */
 /*    TTF or OTF fonts (body).                                             */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002 by                                           */
+/*  Copyright 1996-2001, 2002, 2003 by                                     */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -15,7 +15,7 @@
 /*  understand and accept it fully.                                        */
 /*                                                                         */
 /***************************************************************************/
-/* $XFree86: xc/extras/freetype2/src/sfnt/ttload.c,v 1.2 2003/10/22 17:26:30 tsi Exp $ */
+
 
 #include <ft2build.h>
 #include FT_INTERNAL_DEBUG_H
@@ -179,16 +179,12 @@
     /* if 'num_tables' is 0, read the table count from the file */
     if ( num_tables == 0 )
     {
-      FT_ULong  format_tag;
-
       if ( FT_STREAM_SEEK( offset )     ||
-           FT_READ_ULONG ( format_tag ) ||
+           FT_STREAM_SKIP( 4 )          ||
            FT_READ_USHORT( num_tables ) ||
            FT_STREAM_SKIP( 6 )          )
         goto Bad_Format;
 
-      (void) format_tag;
-
       if ( offset + 12 + num_tables*16 > stream->size )
         goto Bad_Format;
     }
@@ -214,13 +210,13 @@
 
         has_head = 1;
 
-       /* the table length should be 0x36, but certain font tools
-        * make it 0x38, so we will just check that it is greater.
-        *
-        * note that according to the specification,
-        * the table must be padded to 32-bit lengths, but this doesn't
-        * apply to the value of its "Length" field !!
-        */
+        /* The table length should be 0x36, but certain font tools
+         * make it 0x38, so we will just check that it is greater.
+         *
+         * Note that according to the specification,
+         * the table must be padded to 32-bit lengths, but this doesn't
+         * apply to the value of its "Length" field!
+         */
         if ( table.Length < 0x36                 ||
              FT_STREAM_SEEK( table.Offset + 12 ) ||
              FT_READ_ULONG( magic )              ||
@@ -239,7 +235,7 @@
     return  error;
 
   Bad_Format:
-    error = FT_Err_Unknown_File_Format;
+    error = SFNT_Err_Unknown_File_Format;
     goto Exit;
   }
 
@@ -841,16 +837,16 @@
       {
 
 #ifdef FT_CONFIG_OPTION_INCREMENTAL
-      /* If this is an incrementally loaded font and there are    */
-      /* overriding metrics tolerate a missing 'hmtx' table.      */
+        /* If this is an incrementally loaded font and there are */
+        /* overriding metrics tolerate a missing 'hmtx' table.   */
         if ( face->root.internal->incremental_interface &&
              face->root.internal->incremental_interface->funcs->
-                 get_glyph_metrics )
+               get_glyph_metrics )
         {
           face->horizontal.number_Of_HMetrics = 0;
           error = SFNT_Err_Ok;
           goto Exit;
-	    }
+        }
 #endif
 
         FT_ERROR(( " no horizontal metrics in file!\n" ));
@@ -1780,6 +1776,7 @@
     FT_Memory  memory = stream->memory;
 
     TT_Hdmx    hdmx = &face->hdmx;
+    FT_Short   num_records;
     FT_Long    num_glyphs;
     FT_Long    record_size;
 
@@ -1797,7 +1794,7 @@
       goto Exit;
 
     hdmx->version     = FT_GET_USHORT();
-    hdmx->num_records = FT_GET_SHORT();
+    num_records       = FT_GET_SHORT();
     record_size       = FT_GET_LONG();
 
     FT_FRAME_EXIT();
@@ -1806,9 +1803,10 @@
     if ( hdmx->version != 0 )
       goto Exit;
 
-    if ( FT_NEW_ARRAY( hdmx->records, hdmx->num_records ) )
+    if ( FT_NEW_ARRAY( hdmx->records, num_records ) )
       goto Exit;
 
+    hdmx->num_records = num_records;
     num_glyphs   = face->root.num_glyphs;
     record_size -= num_glyphs + 2;
 

Index: ttpost.c
===================================================================
RCS file: /cvs/xorg/xc/extras/freetype2/src/sfnt/ttpost.c,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/ttpost.c	26 Nov 2003 22:48:28 -0000	1.1.4.1
+++ b/ttpost.c	23 Feb 2004 21:33:05 -0000	1.1.4.2
@@ -5,7 +5,7 @@
 /*    Postcript name table processing for TrueType and OpenType fonts      */
 /*    (body).                                                              */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002 by                                           */
+/*  Copyright 1996-2001, 2002, 2003 by                                     */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -50,7 +50,7 @@
 #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
 
 
-#include FT_INTERNAL_POSTSCRIPT_NAMES_H
+#include FT_SERVICE_POSTSCRIPT_CMAPS_H
 
 #define MAC_NAME( x )  ( (FT_String*)psnames->macintosh_name( x ) )
 
@@ -441,7 +441,7 @@
     FT_Fixed         format;
 
 #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
-    PSNames_Service  psnames;
+    FT_Service_PsCMaps  psnames;
 #endif
 
 
@@ -452,7 +452,7 @@
       return SFNT_Err_Invalid_Glyph_Index;
 
 #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
-    psnames = (PSNames_Service)face->psnames;
+    psnames = (FT_Service_PsCMaps)face->psnames;
     if ( !psnames )
       return SFNT_Err_Unimplemented_Feature;
 #endif
@@ -510,7 +510,7 @@
         *PSname = MAC_NAME( idx );
       }
     }
-    
+
     /* nothing to do for format == 0x00030000L */
 
   End:

Index: ttsbit.c
===================================================================
RCS file: /cvs/xorg/xc/extras/freetype2/src/sfnt/ttsbit.c,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -u -d -r1.1.4.1 -r1.1.4.2
--- a/ttsbit.c	26 Nov 2003 22:48:28 -0000	1.1.4.1
+++ b/ttsbit.c	23 Feb 2004 21:33:05 -0000	1.1.4.2
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    TrueType and OpenType embedded bitmap support (body).                */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002 by                                           */
+/*  Copyright 1996-2001, 2002, 2003 by                                     */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -635,7 +635,7 @@
 
     for ( i = 0; i < face->num_sbit_strikes; i++ )
     {
-      if ( ( face->sbit_strikes[i].y_ppem  == y_ppem )    &&
+      if ( ( face->sbit_strikes[i].y_ppem == y_ppem )     &&
            ( ( x_ppem == 0 )                            ||
              ( face->sbit_strikes[i].x_ppem == x_ppem ) ) )
       {
@@ -1232,9 +1232,9 @@
     if ( error )
       goto Exit;
 
-    /* this function is recursive.  At the top-level call, we  */
+    /* This function is recursive.  At the top-level call, we  */
     /* compute the dimensions of the higher-level glyph to     */
-    /* allocate the final pixmap buffer                        */
+    /* allocate the final pixmap buffer.                       */
     if ( depth == 0 )
     {
       FT_Long  size;
@@ -1355,7 +1355,7 @@
                                  y_offset + comp->y_offset,
                                  stream,
                                  &elem_metrics,
-                                 depth+1 );
+                                 depth + 1 );
         if ( error )
           goto Fail_Memory;
       }





More information about the xorg-commit mailing list