shithub: freetype+ttf2subf

Download patch

ref: cecd9127478e4e2c26105d5df71b3ed9b5dc4018
parent: d87389e9d38e69e132b2885a8332b45cef4750aa
author: Werner Lemberg <[email protected]>
date: Wed Mar 9 01:18:28 EST 2011

Make FT_Sfnt_Table_Info return the number of SFNT tables.

* src/sfnt/sfdriver.c (sfnt_table_info): Implement it.
* include/freetype/tttables.h: Update documentation.
* docs/CHANGES: Updated.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,12 @@
-2011-03-27  Bram Tassyns  <[email protected]>
+2011-03-09  Werner Lemberg  <[email protected]>
+
+	Make FT_Sfnt_Table_Info return the number of SFNT tables.
+
+	* src/sfnt/sfdriver.c (sfnt_table_info): Implement it.
+	* include/freetype/tttables.h: Update documentation.
+	* docs/CHANGES: Updated.
+
+2011-03-07  Bram Tassyns  <[email protected]>
 
 	Fix Savannah bug #27988.
 
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -15,6 +15,9 @@
 
   III. MISCELLANEOUS
 
+    - `FT_Sfnt_Table_Info' can now return the number of SFNT tables of
+      a font.
+
     - Support for PCF files compressed with bzip2 has been contributed
       by Joel  Klinghed.  To  make this  work, the  OS must  provide a
       bzip2 library.
--- a/include/freetype/tttables.h
+++ b/include/freetype/tttables.h
@@ -5,7 +5,7 @@
 /*    Basic SFNT/TrueType tables definitions and interface                 */
 /*    (specification only).                                                */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2008, 2009, 2010 by       */
+/*  Copyright 1996-2005, 2008-2011 by                                      */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -687,12 +687,16 @@
   *     The index of an SFNT table.  The function returns
   *     FT_Err_Table_Missing for an invalid value.
   *
-  * @output:
+  * @inout:
   *   tag ::
-  *     The name tag of the SFNT table.
+  *     The name tag of the SFNT table.  If the value is NULL, `table_index'
+  *     is ignored, and `length' returns the number of SFNT tables in the
+  *     font.
   *
+  * @output:
   *   length ::
-  *     The length of the SFNT table.
+  *     The length of the SFNT table (or the number of SFNT tables, depending
+  *     on `tag').
   *
   * @return:
   *   FreeType error code.  0~means success.
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    High-level SFNT driver interface (body).                             */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */
+/*  Copyright 1996-2007, 2009-2011 by                                      */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -117,15 +117,20 @@
                    FT_ULong  *offset,
                    FT_ULong  *length )
   {
-    if ( !tag || !offset || !length )
+    if ( !offset || !length )
       return SFNT_Err_Invalid_Argument;
 
-    if ( idx >= face->num_tables )
-      return SFNT_Err_Table_Missing;
+    if ( !tag )
+      *length = face->num_tables;
+    else
+    {
+      if ( idx >= face->num_tables )
+        return SFNT_Err_Table_Missing;
 
-    *tag    = face->dir_tables[idx].Tag;
-    *offset = face->dir_tables[idx].Offset;
-    *length = face->dir_tables[idx].Length;
+      *tag    = face->dir_tables[idx].Tag;
+      *offset = face->dir_tables[idx].Offset;
+      *length = face->dir_tables[idx].Length;
+    }
 
     return SFNT_Err_Ok;
   }