@@ -235,7 +235,7 @@ private void writeTableBody(OutputStream os, byte[] bytes) throws IOException
235235
236236 private byte [] buildHeadTable () throws IOException
237237 {
238- ByteArrayOutputStream bos = new ByteArrayOutputStream ();
238+ ByteArrayOutputStream bos = new ByteArrayOutputStream (54 );
239239 DataOutputStream out = new DataOutputStream (bos );
240240
241241 HeaderTable h = ttf .getHeader ();
@@ -264,7 +264,7 @@ private byte[] buildHeadTable() throws IOException
264264
265265 private byte [] buildHheaTable () throws IOException
266266 {
267- ByteArrayOutputStream bos = new ByteArrayOutputStream ();
267+ ByteArrayOutputStream bos = new ByteArrayOutputStream (36 );
268268 DataOutputStream out = new DataOutputStream (bos );
269269
270270 HorizontalHeaderTable h = ttf .getHorizontalHeader ();
@@ -308,7 +308,7 @@ private boolean shouldCopyNameRecord(NameRecord nr)
308308
309309 private byte [] buildNameTable () throws IOException
310310 {
311- ByteArrayOutputStream bos = new ByteArrayOutputStream ();
311+ ByteArrayOutputStream bos = new ByteArrayOutputStream (512 );
312312 DataOutputStream out = new DataOutputStream (bos );
313313
314314 NamingTable name = ttf .getNaming ();
@@ -393,7 +393,7 @@ else if (encoding == 1) // ISO 10646=
393393
394394 private byte [] buildMaxpTable () throws IOException
395395 {
396- ByteArrayOutputStream bos = new ByteArrayOutputStream ();
396+ ByteArrayOutputStream bos = new ByteArrayOutputStream (32 );
397397 DataOutputStream out = new DataOutputStream (bos );
398398
399399 MaximumProfileTable p = ttf .getMaximumProfile ();
@@ -428,7 +428,7 @@ private byte[] buildOS2Table() throws IOException
428428 return null ;
429429 }
430430
431- ByteArrayOutputStream bos = new ByteArrayOutputStream ();
431+ ByteArrayOutputStream bos = new ByteArrayOutputStream (78 );
432432 DataOutputStream out = new DataOutputStream (bos );
433433
434434 writeUint16 (out , os2 .getVersion ());
@@ -476,7 +476,7 @@ private byte[] buildOS2Table() throws IOException
476476 // never returns null
477477 private byte [] buildLocaTable (long [] newOffsets ) throws IOException
478478 {
479- ByteArrayOutputStream bos = new ByteArrayOutputStream ();
479+ ByteArrayOutputStream bos = new ByteArrayOutputStream (newOffsets . length * 4 );
480480 DataOutputStream out = new DataOutputStream (bos );
481481
482482 for (long offset : newOffsets )
@@ -598,7 +598,7 @@ else if ((flags & 1 << 3) != 0)
598598 // never returns null
599599 private byte [] buildGlyfTable (long [] newOffsets ) throws IOException
600600 {
601- ByteArrayOutputStream bos = new ByteArrayOutputStream ();
601+ ByteArrayOutputStream bos = new ByteArrayOutputStream (512 );
602602
603603 GlyphTable g = ttf .getGlyph ();
604604 long [] offsets = ttf .getIndexToLocation ().getOffsets ();
@@ -749,7 +749,7 @@ private byte[] buildCmapTable() throws IOException
749749 return null ;
750750 }
751751
752- ByteArrayOutputStream bos = new ByteArrayOutputStream ();
752+ ByteArrayOutputStream bos = new ByteArrayOutputStream (64 );
753753 DataOutputStream out = new DataOutputStream (bos );
754754
755755 // cmap header
@@ -869,7 +869,7 @@ private byte[] buildPostTable() throws IOException
869869 return null ;
870870 }
871871
872- ByteArrayOutputStream bos = new ByteArrayOutputStream ();
872+ ByteArrayOutputStream bos = new ByteArrayOutputStream (64 );
873873 DataOutputStream out = new DataOutputStream (bos );
874874
875875 writeFixed (out , 2.0 ); // version
0 commit comments