FontData and slicing

61 views
Skip to first unread message

tinn...@yahoo.com

unread,
Dec 26, 2012, 4:51:01 AM12/26/12
to sfntly...@googlegroups.com
I'm not sure how well I can describe this, but anyway,

When you take a slice of a WritableFontData (context: Creating a Glyph object), where the length of the slice is zero, should this not throw an exception for any attempt to read data from this slice? I ask because I found inconsistent behaviour between loading from a font from a byte array and directly from a file input stream. When loading from a byte array and calling the xMin() method of the created glyph (where data length=0), it goes fine, but if I do this from the same font loaded directly from an input stream, I get an IndexOutOfBoundsException. I should also note that for the glyph in question, if the length of the Glyph table is x, then the Glyph was at offset x, length 0.

I think with the byte array case, it was overrunning into whatever followed the glyph table, which I'm guessing is incorrect? Should there be a check against boundLength too for the read_ methods in ReadableFontData?

Thanks

Brian Stell

unread,
Dec 27, 2012, 6:26:19 PM12/27/12
to sfntly...@googlegroups.com
FYI: Stuart is on vacation till January

Happy Holidays

:-)


Stuart Gill

unread,
Jan 25, 2013, 8:49:31 PM1/25/13
to sfntly...@googlegroups.com, tinn...@yahoo.com


On Wednesday, 26 December 2012 01:51:01 UTC-8, tinn...@yahoo.com wrote:
I'm not sure how well I can describe this, but anyway,

When you take a slice of a WritableFontData (context: Creating a Glyph object), where the length of the slice is zero, should this not throw an exception for any attempt to read data from this slice?

Yes, I think that sounds correct.
 
I ask because I found inconsistent behaviour between loading from a font from a byte array and directly from a file input stream. When loading from a byte array and calling the xMin() method of the created glyph (where data length=0), it goes fine, but if I do this from the same font loaded directly from an input stream, I get an IndexOutOfBoundsException. I should also note that for the glyph in question, if the length of the Glyph table is x, then the Glyph was at offset x, length 0.

If you have some sample code for this issue that would be very helpful. Could you create an issue for this with the sample code? http://code.google.com/p/sfntly/issues/list 

I think with the byte array case, it was overrunning into whatever followed the glyph table, which I'm guessing is incorrect? Should there be a check against boundLength too for the read_ methods in ReadableFontData?

Yes, though the RFD and WFD are just wrappers around other objects below that do the bounds checking. See for example the ByteArray.get() methods.

Stuart
 

Thanks
Reply all
Reply to author
Forward
0 new messages