Dan Caprioara created FOP-2897: ---------------------------------- Summary: Out of memory when loading fonts on Mac - instead it should report font too large and continue Key: FOP-2897 URL: https://issues.apache.org/jira/browse/FOP-2897 Project: FOP Issue Type: Bug Reporter: Dan Caprioara Fix For: 2.4
The FontInfoFinder class collects all the fonts from the system. On Mac there are huge font files containing icons. This makes FOP break with OutOfMemoryError. Probably it should show an warning and throw an IOException instead of OOM. In this way next fonts can be loaded. There are two places in the FontInfoFinder class where the OOM should be catched: {code:java} try { TTFFile ttf = new TTFFile(false, false); FontFileReader reader = new FontFileReader(in); ttcNames = ttf.getTTCnames(reader); } catch (OutOfMemoryError oom) { handleOOM(fontURI); } {code} {code:java} try { OFFontLoader ttfLoader = new OFFontLoader(fontURI, fontName, true, EmbeddingMode.AUTO, EncodingMode.AUTO, useKerning, useAdvanced, resourceResolver, false, false); customFont = ttfLoader.getFont(); if (this.eventListener != null) { customFont.setEventListener(this.eventListener); } } catch(OutOfMemoryError e) { handleOOM(fontURI); } {code} And the handling: {code:java} private void handleOOM(URI fontURI) throws IOException { String sizeMsg = ""; if ("file".equals(fontURI.getScheme())) { sizeMsg = "The font file size was: " + new File(fontURI).length() + " bytes"; } throw new IOException( "Font is too large. " + sizeMsg); } {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)