[ 
https://issues.apache.org/jira/browse/FOP-2897?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Simon Steiner reassigned FOP-2897:
----------------------------------

    Assignee: Simon Steiner

> 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
>            Assignee: Simon Steiner
>            Priority: Major
>
> 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 
> (IOException does not break the entire processing, just skips the current 
> font loading, 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.20.7#820007)

Reply via email to