shithub: freetype+ttf2subf

Download patch

ref: e1ca18d4492d819e2deeb4302a9d3ed037f64ebb
parent: 0af21dcf13ce44b1624feb3186f0609599355288
author: Werner Lemberg <[email protected]>
date: Sat Oct 17 07:51:27 EDT 2015

[bdf] Use stream size to adjust number of glyphs.

* src/bdf/bdflib.c (ACMSG17): New message macro.
(_bdf_parse_t): Add member `size'.
(bdf_load_font): Set `size'.
(_bdf_parse_glyphs): Adjust `cnt' if necessary.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2015-10-17  Werner Lemberg  <[email protected]>
 
+	[bdf] Use stream size to adjust number of glyphs.
+
+	* src/bdf/bdflib.c (ACMSG17): New message macro.
+	(_bdf_parse_t): Add member `size'.
+	(bdf_load_font): Set `size'.
+	(_bdf_parse_glyphs): Adjust `cnt' if necessary.
+
+2015-10-17  Werner Lemberg  <[email protected]>
+
 	* src/cid/cidload.c (cid_parse_dict): Check `[FG]DBytes' size.
 
 2015-10-17  Werner Lemberg  <[email protected]>
--- a/src/bdf/bdflib.c
+++ b/src/bdf/bdflib.c
@@ -201,6 +201,7 @@
 #define ACMSG14  "Glyph %ld extra columns removed.\n"
 #define ACMSG15  "Incorrect glyph count: %ld indicated but %ld found.\n"
 #define ACMSG16  "Glyph %ld missing columns padded with zero bits.\n"
+#define ACMSG17  "Adjusting number of glyphs to %ld.\n"
 
   /* Error messages. */
 #define ERRMSG1  "[line %ld] Missing `%s' line.\n"
@@ -432,6 +433,7 @@
     _bdf_list_t     list;
 
     FT_Memory       memory;
+    unsigned long   size;        /* the stream size */
 
   } _bdf_parse_t;
 
@@ -1579,6 +1581,13 @@
         goto Exit;
       p->cnt = font->glyphs_size = _bdf_atoul( p->list.field[1], 0, 10 );
 
+      /* We need at least 20 bytes per glyph. */
+      if ( p->cnt > p->size / 20 )
+      {
+        p->cnt = p->size / 20;
+        FT_TRACE2(( "_bdf_parse_glyphs: " ACMSG17, p->cnt ));
+      }
+
       /* Make sure the number of glyphs is non-zero. */
       if ( p->cnt == 0 )
         font->glyphs_size = 64;
@@ -2447,6 +2456,7 @@
     memory    = NULL;
     p->opts   = (bdf_options_t*)( ( opts != 0 ) ? opts : &_bdf_opts );
     p->minlb  = 32767;
+    p->size   = stream->size;
     p->memory = extmemory;  /* only during font creation */
 
     _bdf_list_init( &p->list, extmemory );