freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft-devel] [bdf] Unused bitfields


From: Alexei Podtelezhnikov
Subject: Re: [ft-devel] [bdf] Unused bitfields
Date: Wed, 15 Aug 2018 10:14:21 -0400

On Tue, Aug 14, 2018 at 4:23 AM Werner LEMBERG <address@hidden> wrote:
> ... only the `have' array.  This greatly reduces the size of the bdf driver.

Removing the `have' array would not break anything either. The
duplicate encoding will still be sorted. The cmap functions will still
find correct encodings. There is some ambiguity in which duplicate
encoding will be chosen, but who cares if a broken font behaves
somewhat unpredictably. Here is a patch.

diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c
index 8133bc6..4fe756c 100644
--- a/src/bdf/bdflib.c
+++ b/src/bdf/bdflib.c
@@ -270,8 +270,6 @@
     bdf_font_t*     font;
     bdf_options_t*  opts;

-    unsigned long   have[34816];
-
     _bdf_list_t     list;

     FT_Memory       memory;
@@ -1458,39 +1456,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 */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]