The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Increase maximum number of points in a TTF glyph

These changes was commited to the Birdfont repository Thu, 08 Dec 2016 11:30:14 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Thu, 08 Dec 2016 11:30:14 +0000]

Updated Files

libbirdfont/OpenFontFormat/GlyfData.vala
libbirdfont/OpenFontFormat/GlyfTable.vala
--- a/libbirdfont/OpenFontFormat/GlyfData.vala +++ b/libbirdfont/OpenFontFormat/GlyfData.vala @@ -43,7 +43,7 @@ public Gee.ArrayList<int16> coordinate_y = new Gee.ArrayList<int16> (); uint16 end_point = 0; - int16 nflags = 0; + uint16 nflags = 0; Glyph glyph; @@ -127,7 +127,7 @@ return (int16) paths.size; } - public int16 get_nflags () { + public uint16 get_nflags () { return nflags; } @@ -150,15 +150,21 @@ } foreach (EditPoint e in quadratic.points) { + if (unlikely (nflags == uint16.MAX - 1) { + warning (@"Too many end points in $(glyph.get_name ())"); + break; + } + end_point++; type = e.get_right_handle ().type; // off curve - end_point++; - - if (end_point >= 0xFFFF) { - warning ("Too many points"); + if (unlikely (nflags == uint16.MAX - 1) { + warning (@"Too many end points in $(glyph.get_name ())"); + break; } + + end_point++; } end_points.add (end_point - 1); @@ -189,7 +195,13 @@ // off curve flags.add (CoordinateFlags.NONE); - nflags++; + + if (unlikely (nflags == uint16.MAX) { + warning (@"Too many flags in $(glyph.get_name ())"); + return; + } + + nflags++; } } }
--- a/libbirdfont/OpenFontFormat/GlyfTable.vala +++ b/libbirdfont/OpenFontFormat/GlyfTable.vala @@ -209,7 +209,7 @@ uint16 end_point; uint16 npoints; int16 ncontours; - int16 nflags; + uint16 nflags; int glyph_offset; uint len; uint coordinate_length;