huhuang03 / sfntly

Automatically exported from code.google.com/p/sfntly
0 stars 0 forks source link

Index OO Bounds when adding/changing the last written name in the name table to a zero length name #27

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add a name to the fonts name table that will sort at the end of the list.
2. Save the font.

What is the expected output? What do you see instead?

Font should save but instead an Index Out of Bounds exception is thrown.

Code snippet:

    FontFactory fontFactory = FontFactory.getInstance();
    File fontFile = TestFont.TestFontNames.OPENSANS.getFile();
    Font.Builder fontBuilder = fontFactory.loadFontsForBuilding(new FileInputStream(fontFile))[0];
    NameTable.Builder nameTableBuilder = (NameTable.Builder) fontBuilder.getTableBuilder(Tag.name);
    nameTableBuilder.nameBuilder(Font.PlatformId.Windows.value(),
        Font.WindowsEncodingId.UnicodeUCS4.value(), 
        NameTable.WindowsLanguageId.Spanish_UnitedStates.value(),
        NameTable.NameId.WWSSubfamilyName.value()).setName("");
    Font font = fontBuilder.build(); // exception occurs here.

Original issue reported on code.google.com by stua...@google.com on 15 Jan 2013 at 11:26

GoogleCodeExporter commented 9 years ago
Fixed in r148.

Original comment by stua...@google.com on 16 Jan 2013 at 12:14