Commit 923fcbcdd8393dbf12b0f2b3616e71fc106bc6da

Alexei Podtelezhnikov 2018-08-15T22:50:06

[bdf] Don't track duplicate encodings. There is no harm except some umbiguity in broken fonts with duplicate encodings. * src/bdf/bdflib.c (_bdf_parse_glyphs): Remove duplicate tracking. (_bdf_parse_t): Remove large `have' bitfield.

diff --git a/ChangeLog b/ChangeLog
index 33ab977..c8b4819 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2018-08-15  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+	[bdf] Don't track duplicate encodings.
+
+	There is no harm except some umbiguity in broken fonts with duplicate
+	encodings.
+
+	* src/bdf/bdflib.c (_bdf_parse_glyphs): Remove duplicate tracking.
+	(_bdf_parse_t): Remove large `have' bitfield.
+
 2018-08-15  Werner Lemberg  <wl@gnu.org>
 
 	Don't use `trace_' prefix for FT_COMPONENT arguments.
diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c
index e6a4682..95ab171 100644
--- a/src/bdf/bdflib.c
+++ b/src/bdf/bdflib.c
@@ -196,7 +196,6 @@
 #define ACMSG9   "SWIDTH field missing at line %ld.  Set automatically.\n"
 #define ACMSG10  "DWIDTH field missing at line %ld.  Set to glyph width.\n"
 #define ACMSG11  "SIZE bits per pixel field adjusted to %hd.\n"
-#define ACMSG12  "Duplicate encoding %ld (%s) changed to unencoded.\n"
 #define ACMSG13  "Glyph %lu extra rows removed.\n"
 #define ACMSG14  "Glyph %lu extra columns removed.\n"
 #define ACMSG15  "Incorrect glyph count: %ld indicated but %ld found.\n"
@@ -208,7 +207,6 @@
 #define ERRMSG2  "[line %ld] Font header corrupted or missing fields.\n"
 #define ERRMSG3  "[line %ld] Font glyphs corrupted or missing fields.\n"
 #define ERRMSG4  "[line %ld] BBX too big.\n"
-#define ERRMSG5  "[line %ld] `%s' value too big.\n"
 #define ERRMSG6  "[line %ld] Input line too long.\n"
 #define ERRMSG7  "[line %ld] Font name too long.\n"
 #define ERRMSG8  "[line %ld] Invalid `%s' value.\n"
@@ -270,8 +268,6 @@
     bdf_font_t*     font;
     bdf_options_t*  opts;
 
-    unsigned long   have[34816];
-
     _bdf_list_t     list;
 
     FT_Memory       memory;
@@ -1458,39 +1454,11 @@
       if ( p->glyph_enc == -1 && p->list.used > 2 )
         p->glyph_enc = _bdf_atol( p->list.field[2] );
 
-      if ( p->glyph_enc < -1 )
+      if ( p->glyph_enc < -1 || p->glyph_enc >= 0x110000L )
         p->glyph_enc = -1;
 
       FT_TRACE4(( DBGMSG2, p->glyph_enc ));
 
-      /* Check that the encoding is in the Unicode range because  */
-      /* otherwise p->have (a bitmap with static size) overflows. */
-      if ( p->glyph_enc > 0                                      &&
-           (size_t)p->glyph_enc >= sizeof ( p->have ) /
-                                   sizeof ( unsigned long ) * 32 )
-      {
-        FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG5, lineno, "ENCODING" ));
-        error = FT_THROW( Invalid_File_Format );
-        goto Exit;
-      }
-
-      /* Check whether this encoding has already been encountered. */
-      /* If it has then change it to unencoded so it gets added if */
-      /* indicated.                                                */
-      if ( p->glyph_enc >= 0 )
-      {
-        if ( _bdf_glyph_modified( p->have, p->glyph_enc ) )
-        {
-          /* Emit a message saying a glyph has been moved to the */
-          /* unencoded area.                                     */
-          FT_TRACE2(( "_bdf_parse_glyphs: " ACMSG12,
-                      p->glyph_enc, p->glyph_name ));
-          p->glyph_enc = -1;
-        }
-        else
-          _bdf_set_glyph_modified( p->have, p->glyph_enc );
-      }
-
       if ( p->glyph_enc >= 0 )
       {
         /* Make sure there are enough glyphs allocated in case the */