[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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
diff --git a/ChangeLog b/ChangeLog
index 0971afc..2374771 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2015-10-17 Werner Lemberg <wl@gnu.org>
+ [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 <wl@gnu.org>
+
* src/cid/cidload.c (cid_parse_dict): Check `[FG]DBytes' size.
2015-10-17 Werner Lemberg <wl@gnu.org>
diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c
index 5b1beef..4f3b4fd 100644
--- 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 );