shithub: freetype+ttf2subf

Download patch

ref: 01caf4a7a9dc4946bc704f9e10a4ad99f8492054
parent: 6e3fee0b541e39511cc36d3ac4811d21222d5331
author: Werner Lemberg <[email protected]>
date: Wed Mar 23 01:19:59 EDT 2011

* src/truetype/ttpload.c(tt_face_load_loca): Fix mismatch warning.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-03-23  Werner Lemberg  <[email protected]>
+
+	* src/truetype/ttpload.c(tt_face_load_loca): Fix mismatch warning.
+
 2011-03-20  Werner Lemberg  <[email protected]>
 
 	* src/sfnt/sfobjs.c (sfnt_open_font): Check number of TTC subfonts.
--- a/src/truetype/ttpload.c
+++ b/src/truetype/ttpload.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    TrueType-specific tables loader (body).                              */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by */
+/*  Copyright 1996-2002, 2004-2011 by                                      */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -110,15 +110,16 @@
       face->num_locations = table_len >> shift;
     }
 
-    if ( face->num_locations != (FT_ULong)face->root.num_glyphs )
+    if ( face->num_locations != (FT_ULong)face->root.num_glyphs + 1 )
     {
       FT_TRACE2(( "glyph count mismatch!  loca: %d, maxp: %d\n",
-                  face->num_locations, face->root.num_glyphs ));
+                  face->num_locations - 1, face->root.num_glyphs ));
 
       /* we only handle the case where `maxp' gives a larger value */
-      if ( face->num_locations < (FT_ULong)face->root.num_glyphs )
+      if ( face->num_locations <= (FT_ULong)face->root.num_glyphs )
       {
-        FT_Long   new_loca_len = (FT_Long)face->root.num_glyphs << shift;
+        FT_Long   new_loca_len =
+                    ( (FT_Long)( face->root.num_glyphs ) + 1 ) << shift;
 
         TT_Table  entry = face->dir_tables;
         TT_Table  limit = entry + face->num_tables;
@@ -145,7 +146,7 @@
 
         if ( new_loca_len <= dist )
         {
-          face->num_locations = face->root.num_glyphs;
+          face->num_locations = face->root.num_glyphs + 1;
           table_len           = new_loca_len;
 
           FT_TRACE2(( "adjusting num_locations to %d\n",