TestFontCollectionpublic class TestFontCollection extends TestCase Tests FontCollection and FontEntityAtom records |
Fields Summary |
---|
private byte[] | data |
Methods Summary |
---|
public void | testAddFont()
FontCollection fonts = new FontCollection(data, 0, data.length);
int idx = fonts.addFont("Times New Roman");
assertEquals(idx, 0);
idx = fonts.addFont("Helvetica");
assertEquals(idx, 1);
idx = fonts.addFont("Arial");
assertEquals(idx, 2);
idx = fonts.addFont("Arial"); //the font being added twice
assertEquals(idx, 2);
// Font collection should contain 3 fonts
Record[] child = fonts.getChildRecords();
assertEquals(child.length, 3);
// Check we get the right font name for the indicies
assertEquals("Times New Roman", fonts.getFontWithId(0));
assertEquals("Helvetica", fonts.getFontWithId(1));
assertEquals("Arial", fonts.getFontWithId(2));
assertNull(fonts.getFontWithId(3));
| public void | testFonts()
FontCollection fonts = new FontCollection(data, 0, data.length);
Record[] child = fonts.getChildRecords();
assertEquals(child.length, 1);
FontEntityAtom fnt = (FontEntityAtom)child[0];
assertEquals(fnt.getFontName(), "Times New Roman");
| public void | testWrite()
FontCollection fonts = new FontCollection(data, 0, data.length);
ByteArrayOutputStream out = new ByteArrayOutputStream();
fonts.writeOut(out);
byte[] recdata = out.toByteArray();
assertTrue(Arrays.equals(recdata, data));
|
|