[jira] [Commented] (FOP-2897) Out of memory when loading fonts on Mac - instead it should report font too large and continue

2022-06-20 Thread Dan Caprioara (Jira)


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

Dan Caprioara commented on FOP-2897:


Sure, but in our case FOP is part of an application and it runs on somebody 
else machine, so it is not an option to delegate this to the end user.

> 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
>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)


[jira] [Commented] (FOP-2897) Out of memory when loading fonts on Mac - instead it should report font too large and continue

2022-06-17 Thread Simon Steiner (Jira)


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

Simon Steiner commented on FOP-2897:


Can you increase the Xmx to fop?

> 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
>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)