[jira] [Commented] (FOP-2514) [PATCH] Empty hyphenation-character leads to "String index out of range: 0"

2019-03-27 Thread Chris Bowditch (JIRA)


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

Chris Bowditch commented on FOP-2514:
-

I still can't commit your change. Looks like it breaks a unit test:

[junit] Testcase: runTest[6](org.apache.fop.intermediate.IFTestCase):
FAILED
 [junit] Expected XPath expression to evaluate to 'true', but got '' (XPath:
/descendant::if:text[1]/@hyphenated)
 [junit] junit.framework.AssertionFailedError: Expected XPath expression to e
valuate to 'true', but got '' (XPath: /descendant::if:text[1]/@hyphenated)
 [junit] at org.apache.fop.layoutengine.EvalCheck.doCheck(EvalCheck.java:
86)
 [junit] at org.apache.fop.layoutengine.EvalCheck.check(EvalCheck.java:65
)

> [PATCH] Empty hyphenation-character leads to "String index out of range: 0"
> ---
>
> Key: FOP-2514
> URL: https://issues.apache.org/jira/browse/FOP-2514
> Project: FOP
>  Issue Type: Bug
>Affects Versions: 2.0
>Reporter: Björn Kautler
>Assignee: Chris Bowditch
>Priority: Major
> Attachments: hyphen.fo, issue-2514.patch
>
>
> If you set hyphenation-character to the empty value, then you get the error 
> message "String index out of range: 0".
> If there is no hyphenation-character set, there should simply nothing be used.
> This is useful in cases where you want hyphenation but no hyphenation 
> character like in program listings or similar



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (FOP-2514) [PATCH] Empty hyphenation-character leads to "String index out of range: 0"

2019-03-27 Thread Chris Bowditch (JIRA)


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

Chris Bowditch commented on FOP-2514:
-

On second thought, I had a go at inheriting CharacterProperty from 
OptionalCharacterProperty. It only saves 2 member variable declarations and the 
definition of getObject() and causes a number of problems. So I'm happy to 
accept the patch as-is

> [PATCH] Empty hyphenation-character leads to "String index out of range: 0"
> ---
>
> Key: FOP-2514
> URL: https://issues.apache.org/jira/browse/FOP-2514
> Project: FOP
>  Issue Type: Bug
>Affects Versions: 2.0
>Reporter: Björn Kautler
>Assignee: Chris Bowditch
>Priority: Major
> Attachments: hyphen.fo, issue-2514.patch
>
>
> If you set hyphenation-character to the empty value, then you get the error 
> message "String index out of range: 0".
> If there is no hyphenation-character set, there should simply nothing be used.
> This is useful in cases where you want hyphenation but no hyphenation 
> character like in program listings or similar



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Resolved] (FOP-2847) [PATCH] Support palette-based transparency via tRNS chunk of PNG images in PDF export

2019-03-27 Thread simon steiner (JIRA)


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

simon steiner resolved FOP-2847.

Resolution: Fixed
  Assignee: simon steiner

http://svn.apache.org/viewvc?view=revision=1856423

> [PATCH] Support palette-based transparency via tRNS chunk of PNG images in 
> PDF export
> -
>
> Key: FOP-2847
> URL: https://issues.apache.org/jira/browse/FOP-2847
> Project: FOP
>  Issue Type: Bug
>  Components: renderer/pdf
>Affects Versions: 2.3
>Reporter: Tobias Hain
>Assignee: simon steiner
>Priority: Major
> Attachments: acrobat_reader_error_message.PNG, 
> broken_generated_pdf.pdf, pal_bk.png, pdf_trans_broken.png, 
> sample_image_palette_tRNS.png
>
>
> h4. TL;NR
> When using palette-based transparency via tRNS chunk in PNG images, the 
> generated PDFs are broken.
> h4. palette-based with transparency.
> {quote}*8.5.2. Palette-Based with Transparency*
> "The PNG spec forbids the use of a full alpha channel with palette-based 
> images, but it does allow `cheap alpha` via the transparency chunk, tRNS 
> [...] In effect, it transforms the palette from an RGB lookup table to an 
> RGBA table [...] a single PNG transparency entry should come first"
> {quote}
> [http://www.libpng.org/pub/png/book/chapter08.html#png.ch08.div.5.2]
> h4. general PDF encoding strategy
> Option 1:
> {quote}most libraries just undo the palettization and use a full color image 
> + mask.
> {quote}
> [https://forums.adobe.com/message/6148131#6148131]
> Option 2:
> {quote}SMask would be simpler since you could leave the palette in place
> {quote}
> [https://forums.adobe.com/message/6148557#6148557]
> h4. what does FOP do
> It creates a chroma-key mask:
> {code:java}
>  /Type /XObject
>   /ColorSpace [/Indexed /DeviceRGB 255 ]
>   /Mask [182 182 151 151 158 158]
> {code}
> Acrobat Reader even fails to read those files while PDF viewers embedded into 
> Chrome/Firefox read the file, but show visual glitches:
> !acrobat_reader_error_message.PNG!
> https://github.com/apache/fop/pull/49 fixes the Acrobat Reader error.
> FOP doesn't implement Option 1 yet. None of the ImageLoaders is prepared to 
> do that:
>  [https://wiki.apache.org/xmlgraphics-fop/HowTo/ImageLoaderRawPNG]
>  In fact the following results in missing Option 2:
> {code:java}
> public void setup(PDFDocument doc) {
>   RenderedImage ri = getImage().getRenderedImage();
>   // code deleted
>   Raster raster = GraphicsUtil.getAlphaRaster(ri);
>   if (raster != null) {
> AlphaRasterImage alphaImage = new AlphaRasterImage("Mask:" + getKey(), 
> raster);
> this.softMask = doc.addImage(null, alphaImage).makeReference();
>   }
> {code}
> [https://github.com/apache/fop/blob/ff452f3685a02715aee791d651b58dd1797ddfd4/fop-core/src/main/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java]
> In the above code raster will be null and therefore FOP fails to initialize a 
> softMask. {{GraphicsUtil.getAlphaRaster()}} calls internally 
> {{ColorModel.getAlphaRaster()}}, which returns null:
> {quote}If this is an IndexColorModel which has alpha in the lookup table, 
> this method will return null since there is no spatially discrete alpha 
> channel.
> {quote}
> [https://docs.oracle.com/javase/8/docs/api/index.html?java/awt/image/ColorModel.html]
> The softMask Issue is fixed by:
> https://github.com/apache/fop/pull/50
> As a result an image such as !pal_bk.png! is rendered with a transparency 
> gradient instead of !pdf_trans_broken.png!
> This code will then add the chroma key mask to the image:
> {code:java}
> protected void populateXObjectDictionaryForIndexColorModel(PDFDictionary 
> dict, IndexColorModel icm) {
>   // code deleted
>   Integer index = getIndexOfFirstTransparentColorInPalette(icm);
>   if (index != null) {
> PDFArray mask = new PDFArray(dict);
> mask.add(index);
> mask.add(index);
> dict.put("Mask", mask);
>   }
> }
> {code}
> [https://github.com/apache/fop/blob/ff452f3685a02715aee791d651b58dd1797ddfd4/fop-core/src/main/java/org/apache/fop/render/pdf/AbstractImageAdapter.java]
> h4. why care to support?
> Libraries such as pngquant optimize images for web usage and low footprint 
> and can not be used directly with Apache FOP as source images:
> {quote}"*pngquant*: Lossy PNG optimizer, reducing a PNG image down to an 8 
> bit color palette with dithering. It will build indexed-color PNG's with 
> alpha transparency colors conveyed in the tRNS chunk."
> {quote}
> [https://imagemagick.org/Usage/formats/#png_non-im]
> h4. sample data
> {code}
> $ identify -verbose sample_image_palette_tRNS.png
>   Format: PNG (Portable Network Graphics)
>   Type: PaletteAlpha
>   png:IHDR.color_type  : 3 (Indexed)
>   png:tRNS : chunk was found
> {code}




[jira] [Work started] (FOP-2514) [PATCH] Empty hyphenation-character leads to "String index out of range: 0"

2019-03-27 Thread Chris Bowditch (JIRA)


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

Work on FOP-2514 started by Chris Bowditch.
---
> [PATCH] Empty hyphenation-character leads to "String index out of range: 0"
> ---
>
> Key: FOP-2514
> URL: https://issues.apache.org/jira/browse/FOP-2514
> Project: FOP
>  Issue Type: Bug
>Affects Versions: 2.0
>Reporter: Björn Kautler
>Assignee: Chris Bowditch
>Priority: Major
> Attachments: hyphen.fo, issue-2514.patch
>
>
> If you set hyphenation-character to the empty value, then you get the error 
> message "String index out of range: 0".
> If there is no hyphenation-character set, there should simply nothing be used.
> This is useful in cases where you want hyphenation but no hyphenation 
> character like in program listings or similar



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Assigned] (FOP-2514) [PATCH] Empty hyphenation-character leads to "String index out of range: 0"

2019-03-27 Thread Chris Bowditch (JIRA)


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

Chris Bowditch reassigned FOP-2514:
---

Assignee: Chris Bowditch

> [PATCH] Empty hyphenation-character leads to "String index out of range: 0"
> ---
>
> Key: FOP-2514
> URL: https://issues.apache.org/jira/browse/FOP-2514
> Project: FOP
>  Issue Type: Bug
>Affects Versions: 2.0
>Reporter: Björn Kautler
>Assignee: Chris Bowditch
>Priority: Major
> Attachments: hyphen.fo, issue-2514.patch
>
>
> If you set hyphenation-character to the empty value, then you get the error 
> message "String index out of range: 0".
> If there is no hyphenation-character set, there should simply nothing be used.
> This is useful in cases where you want hyphenation but no hyphenation 
> character like in program listings or similar



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Work stopped] (FOP-2514) [PATCH] Empty hyphenation-character leads to "String index out of range: 0"

2019-03-27 Thread Chris Bowditch (JIRA)


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

Work on FOP-2514 stopped by Chris Bowditch.
---
> [PATCH] Empty hyphenation-character leads to "String index out of range: 0"
> ---
>
> Key: FOP-2514
> URL: https://issues.apache.org/jira/browse/FOP-2514
> Project: FOP
>  Issue Type: Bug
>Affects Versions: 2.0
>Reporter: Björn Kautler
>Assignee: Chris Bowditch
>Priority: Major
> Attachments: hyphen.fo, issue-2514.patch
>
>
> If you set hyphenation-character to the empty value, then you get the error 
> message "String index out of range: 0".
> If there is no hyphenation-character set, there should simply nothing be used.
> This is useful in cases where you want hyphenation but no hyphenation 
> character like in program listings or similar



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Assigned] (FOP-2514) [PATCH] Empty hyphenation-character leads to "String index out of range: 0"

2019-03-27 Thread Chris Bowditch (JIRA)


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

Chris Bowditch reassigned FOP-2514:
---

Assignee: (was: Chris Bowditch)

> [PATCH] Empty hyphenation-character leads to "String index out of range: 0"
> ---
>
> Key: FOP-2514
> URL: https://issues.apache.org/jira/browse/FOP-2514
> Project: FOP
>  Issue Type: Bug
>Affects Versions: 2.0
>Reporter: Björn Kautler
>Priority: Major
> Attachments: hyphen.fo, issue-2514.patch
>
>
> If you set hyphenation-character to the empty value, then you get the error 
> message "String index out of range: 0".
> If there is no hyphenation-character set, there should simply nothing be used.
> This is useful in cases where you want hyphenation but no hyphenation 
> character like in program listings or similar



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (FOP-2514) [PATCH] Empty hyphenation-character leads to "String index out of range: 0"

2019-03-27 Thread Chris Bowditch (JIRA)


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

Chris Bowditch commented on FOP-2514:
-

I've confirmed the fix works. However, I don't like the fact a lot of the code 
in CharacterProperty has been copied into the new class 
OptionalCharacterProperty. I'd prefer it if OptionalCharacterProperty extended 
CharacterProperty to reduce code duplication

Ideally the patch should include a unit test as well, but I can overlook that 
if you can fix the inheritance of OptionalCharacterProperty

> [PATCH] Empty hyphenation-character leads to "String index out of range: 0"
> ---
>
> Key: FOP-2514
> URL: https://issues.apache.org/jira/browse/FOP-2514
> Project: FOP
>  Issue Type: Bug
>Affects Versions: 2.0
>Reporter: Björn Kautler
>Assignee: Chris Bowditch
>Priority: Major
> Attachments: hyphen.fo, issue-2514.patch
>
>
> If you set hyphenation-character to the empty value, then you get the error 
> message "String index out of range: 0".
> If there is no hyphenation-character set, there should simply nothing be used.
> This is useful in cases where you want hyphenation but no hyphenation 
> character like in program listings or similar



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (FOP-2514) [PATCH] Empty hyphenation-character leads to "String index out of range: 0"

2019-03-27 Thread Chris Bowditch (JIRA)


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

Chris Bowditch updated FOP-2514:

Attachment: hyphen.fo

> [PATCH] Empty hyphenation-character leads to "String index out of range: 0"
> ---
>
> Key: FOP-2514
> URL: https://issues.apache.org/jira/browse/FOP-2514
> Project: FOP
>  Issue Type: Bug
>Affects Versions: 2.0
>Reporter: Björn Kautler
>Priority: Major
> Attachments: hyphen.fo, issue-2514.patch
>
>
> If you set hyphenation-character to the empty value, then you get the error 
> message "String index out of range: 0".
> If there is no hyphenation-character set, there should simply nothing be used.
> This is useful in cases where you want hyphenation but no hyphenation 
> character like in program listings or similar



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Work started] (FOP-2514) [PATCH] Empty hyphenation-character leads to "String index out of range: 0"

2019-03-27 Thread Chris Bowditch (JIRA)


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

Work on FOP-2514 started by Chris Bowditch.
---
> [PATCH] Empty hyphenation-character leads to "String index out of range: 0"
> ---
>
> Key: FOP-2514
> URL: https://issues.apache.org/jira/browse/FOP-2514
> Project: FOP
>  Issue Type: Bug
>Affects Versions: 2.0
>Reporter: Björn Kautler
>Assignee: Chris Bowditch
>Priority: Major
> Attachments: hyphen.fo, issue-2514.patch
>
>
> If you set hyphenation-character to the empty value, then you get the error 
> message "String index out of range: 0".
> If there is no hyphenation-character set, there should simply nothing be used.
> This is useful in cases where you want hyphenation but no hyphenation 
> character like in program listings or similar



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Assigned] (FOP-2514) [PATCH] Empty hyphenation-character leads to "String index out of range: 0"

2019-03-27 Thread Chris Bowditch (JIRA)


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

Chris Bowditch reassigned FOP-2514:
---

Assignee: Chris Bowditch

> [PATCH] Empty hyphenation-character leads to "String index out of range: 0"
> ---
>
> Key: FOP-2514
> URL: https://issues.apache.org/jira/browse/FOP-2514
> Project: FOP
>  Issue Type: Bug
>Affects Versions: 2.0
>Reporter: Björn Kautler
>Assignee: Chris Bowditch
>Priority: Major
> Attachments: hyphen.fo, issue-2514.patch
>
>
> If you set hyphenation-character to the empty value, then you get the error 
> message "String index out of range: 0".
> If there is no hyphenation-character set, there should simply nothing be used.
> This is useful in cases where you want hyphenation but no hyphenation 
> character like in program listings or similar



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (FOP-2847) [PATCH] Support palette-based transparency via tRNS chunk of PNG images in PDF export

2019-03-27 Thread Tobias Hain (JIRA)


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

Tobias Hain commented on FOP-2847:
--

[~ssteiner1] here you go:
https://github.com/apache/fop/pull/55
All other three removed from open pull request list.

> [PATCH] Support palette-based transparency via tRNS chunk of PNG images in 
> PDF export
> -
>
> Key: FOP-2847
> URL: https://issues.apache.org/jira/browse/FOP-2847
> Project: FOP
>  Issue Type: Bug
>  Components: renderer/pdf
>Affects Versions: 2.3
>Reporter: Tobias Hain
>Priority: Major
> Attachments: acrobat_reader_error_message.PNG, 
> broken_generated_pdf.pdf, pal_bk.png, pdf_trans_broken.png, 
> sample_image_palette_tRNS.png
>
>
> h4. TL;NR
> When using palette-based transparency via tRNS chunk in PNG images, the 
> generated PDFs are broken.
> h4. palette-based with transparency.
> {quote}*8.5.2. Palette-Based with Transparency*
> "The PNG spec forbids the use of a full alpha channel with palette-based 
> images, but it does allow `cheap alpha` via the transparency chunk, tRNS 
> [...] In effect, it transforms the palette from an RGB lookup table to an 
> RGBA table [...] a single PNG transparency entry should come first"
> {quote}
> [http://www.libpng.org/pub/png/book/chapter08.html#png.ch08.div.5.2]
> h4. general PDF encoding strategy
> Option 1:
> {quote}most libraries just undo the palettization and use a full color image 
> + mask.
> {quote}
> [https://forums.adobe.com/message/6148131#6148131]
> Option 2:
> {quote}SMask would be simpler since you could leave the palette in place
> {quote}
> [https://forums.adobe.com/message/6148557#6148557]
> h4. what does FOP do
> It creates a chroma-key mask:
> {code:java}
>  /Type /XObject
>   /ColorSpace [/Indexed /DeviceRGB 255 ]
>   /Mask [182 182 151 151 158 158]
> {code}
> Acrobat Reader even fails to read those files while PDF viewers embedded into 
> Chrome/Firefox read the file, but show visual glitches:
> !acrobat_reader_error_message.PNG!
> https://github.com/apache/fop/pull/49 fixes the Acrobat Reader error.
> FOP doesn't implement Option 1 yet. None of the ImageLoaders is prepared to 
> do that:
>  [https://wiki.apache.org/xmlgraphics-fop/HowTo/ImageLoaderRawPNG]
>  In fact the following results in missing Option 2:
> {code:java}
> public void setup(PDFDocument doc) {
>   RenderedImage ri = getImage().getRenderedImage();
>   // code deleted
>   Raster raster = GraphicsUtil.getAlphaRaster(ri);
>   if (raster != null) {
> AlphaRasterImage alphaImage = new AlphaRasterImage("Mask:" + getKey(), 
> raster);
> this.softMask = doc.addImage(null, alphaImage).makeReference();
>   }
> {code}
> [https://github.com/apache/fop/blob/ff452f3685a02715aee791d651b58dd1797ddfd4/fop-core/src/main/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java]
> In the above code raster will be null and therefore FOP fails to initialize a 
> softMask. {{GraphicsUtil.getAlphaRaster()}} calls internally 
> {{ColorModel.getAlphaRaster()}}, which returns null:
> {quote}If this is an IndexColorModel which has alpha in the lookup table, 
> this method will return null since there is no spatially discrete alpha 
> channel.
> {quote}
> [https://docs.oracle.com/javase/8/docs/api/index.html?java/awt/image/ColorModel.html]
> The softMask Issue is fixed by:
> https://github.com/apache/fop/pull/50
> As a result an image such as !pal_bk.png! is rendered with a transparency 
> gradient instead of !pdf_trans_broken.png!
> This code will then add the chroma key mask to the image:
> {code:java}
> protected void populateXObjectDictionaryForIndexColorModel(PDFDictionary 
> dict, IndexColorModel icm) {
>   // code deleted
>   Integer index = getIndexOfFirstTransparentColorInPalette(icm);
>   if (index != null) {
> PDFArray mask = new PDFArray(dict);
> mask.add(index);
> mask.add(index);
> dict.put("Mask", mask);
>   }
> }
> {code}
> [https://github.com/apache/fop/blob/ff452f3685a02715aee791d651b58dd1797ddfd4/fop-core/src/main/java/org/apache/fop/render/pdf/AbstractImageAdapter.java]
> h4. why care to support?
> Libraries such as pngquant optimize images for web usage and low footprint 
> and can not be used directly with Apache FOP as source images:
> {quote}"*pngquant*: Lossy PNG optimizer, reducing a PNG image down to an 8 
> bit color palette with dithering. It will build indexed-color PNG's with 
> alpha transparency colors conveyed in the tRNS chunk."
> {quote}
> [https://imagemagick.org/Usage/formats/#png_non-im]
> h4. sample data
> {code}
> $ identify -verbose sample_image_palette_tRNS.png
>   Format: PNG (Portable Network Graphics)
>   Type: PaletteAlpha
>   png:IHDR.color_type  : 3 (Indexed)
>   png:tRNS : chunk was found
> 

[jira] [Resolved] (FOP-2853) Error for SVG using TTF fallback to AFP

2019-03-27 Thread simon steiner (JIRA)


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

simon steiner resolved FOP-2853.

Resolution: Fixed

http://svn.apache.org/viewvc?view=revision=1856399

> Error for SVG using TTF fallback to AFP
> ---
>
> Key: FOP-2853
> URL: https://issues.apache.org/jira/browse/FOP-2853
> Project: FOP
>  Issue Type: Bug
>Reporter: simon steiner
>Assignee: simon steiner
>Priority: Major
> Attachments: fop.xconf, test.fo
>
>
> fop test.fo -c fop.xconf -afp out.afp
> java.lang.ArrayIndexOutOfBoundsException: -1
>     at 
> org.apache.fop.fonts.MultiByteFont.getBoundingBox(MultiByteFont.java:211)



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (FOP-2853) Error for SVG using TTF fallback to AFP

2019-03-27 Thread simon steiner (JIRA)


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

simon steiner updated FOP-2853:
---
Attachment: test.fo

> Error for SVG using TTF fallback to AFP
> ---
>
> Key: FOP-2853
> URL: https://issues.apache.org/jira/browse/FOP-2853
> Project: FOP
>  Issue Type: Bug
>Reporter: simon steiner
>Assignee: simon steiner
>Priority: Major
> Attachments: fop.xconf, test.fo
>
>
> fop test.fo -c fop.xconf -afp out.afp
> java.lang.ArrayIndexOutOfBoundsException: -1
>     at 
> org.apache.fop.fonts.MultiByteFont.getBoundingBox(MultiByteFont.java:211)



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (FOP-2853) Error for SVG using TTF fallback to AFP

2019-03-27 Thread simon steiner (JIRA)


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

simon steiner updated FOP-2853:
---
Description: 
fop test.fo -c fop.xconf -afp out.afp

java.lang.ArrayIndexOutOfBoundsException: -1
    at org.apache.fop.fonts.MultiByteFont.getBoundingBox(MultiByteFont.java:211)

> Error for SVG using TTF fallback to AFP
> ---
>
> Key: FOP-2853
> URL: https://issues.apache.org/jira/browse/FOP-2853
> Project: FOP
>  Issue Type: Bug
>Reporter: simon steiner
>Assignee: simon steiner
>Priority: Major
> Attachments: fop.xconf, test.fo
>
>
> fop test.fo -c fop.xconf -afp out.afp
> java.lang.ArrayIndexOutOfBoundsException: -1
>     at 
> org.apache.fop.fonts.MultiByteFont.getBoundingBox(MultiByteFont.java:211)



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (FOP-2853) Error for SVG using TTF fallback to AFP

2019-03-27 Thread simon steiner (JIRA)


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

simon steiner updated FOP-2853:
---
Attachment: fop.xconf

> Error for SVG using TTF fallback to AFP
> ---
>
> Key: FOP-2853
> URL: https://issues.apache.org/jira/browse/FOP-2853
> Project: FOP
>  Issue Type: Bug
>Reporter: simon steiner
>Assignee: simon steiner
>Priority: Major
> Attachments: fop.xconf, test.fo
>
>
> fop test.fo -c fop.xconf -afp out.afp
> java.lang.ArrayIndexOutOfBoundsException: -1
>     at 
> org.apache.fop.fonts.MultiByteFont.getBoundingBox(MultiByteFont.java:211)



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (FOP-2853) Error for SVG using TTF fallback to AFP

2019-03-27 Thread simon steiner (JIRA)
simon steiner created FOP-2853:
--

 Summary: Error for SVG using TTF fallback to AFP
 Key: FOP-2853
 URL: https://issues.apache.org/jira/browse/FOP-2853
 Project: FOP
  Issue Type: Bug
Reporter: simon steiner
Assignee: simon steiner






--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Comment Edited] (FOP-2847) [PATCH] Support palette-based transparency via tRNS chunk of PNG images in PDF export

2019-03-27 Thread simon steiner (JIRA)


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

simon steiner edited comment on FOP-2847 at 3/27/19 1:09 PM:
-

Can you submit 1 patch or 1 PR with 1 commit


was (Author: ssteiner1):
Next time submit 1 patch or 1 PR with 1 commit

> [PATCH] Support palette-based transparency via tRNS chunk of PNG images in 
> PDF export
> -
>
> Key: FOP-2847
> URL: https://issues.apache.org/jira/browse/FOP-2847
> Project: FOP
>  Issue Type: Bug
>  Components: renderer/pdf
>Affects Versions: 2.3
>Reporter: Tobias Hain
>Priority: Major
> Attachments: acrobat_reader_error_message.PNG, 
> broken_generated_pdf.pdf, pal_bk.png, pdf_trans_broken.png, 
> sample_image_palette_tRNS.png
>
>
> h4. TL;NR
> When using palette-based transparency via tRNS chunk in PNG images, the 
> generated PDFs are broken.
> h4. palette-based with transparency.
> {quote}*8.5.2. Palette-Based with Transparency*
> "The PNG spec forbids the use of a full alpha channel with palette-based 
> images, but it does allow `cheap alpha` via the transparency chunk, tRNS 
> [...] In effect, it transforms the palette from an RGB lookup table to an 
> RGBA table [...] a single PNG transparency entry should come first"
> {quote}
> [http://www.libpng.org/pub/png/book/chapter08.html#png.ch08.div.5.2]
> h4. general PDF encoding strategy
> Option 1:
> {quote}most libraries just undo the palettization and use a full color image 
> + mask.
> {quote}
> [https://forums.adobe.com/message/6148131#6148131]
> Option 2:
> {quote}SMask would be simpler since you could leave the palette in place
> {quote}
> [https://forums.adobe.com/message/6148557#6148557]
> h4. what does FOP do
> It creates a chroma-key mask:
> {code:java}
>  /Type /XObject
>   /ColorSpace [/Indexed /DeviceRGB 255 ]
>   /Mask [182 182 151 151 158 158]
> {code}
> Acrobat Reader even fails to read those files while PDF viewers embedded into 
> Chrome/Firefox read the file, but show visual glitches:
> !acrobat_reader_error_message.PNG!
> https://github.com/apache/fop/pull/49 fixes the Acrobat Reader error.
> FOP doesn't implement Option 1 yet. None of the ImageLoaders is prepared to 
> do that:
>  [https://wiki.apache.org/xmlgraphics-fop/HowTo/ImageLoaderRawPNG]
>  In fact the following results in missing Option 2:
> {code:java}
> public void setup(PDFDocument doc) {
>   RenderedImage ri = getImage().getRenderedImage();
>   // code deleted
>   Raster raster = GraphicsUtil.getAlphaRaster(ri);
>   if (raster != null) {
> AlphaRasterImage alphaImage = new AlphaRasterImage("Mask:" + getKey(), 
> raster);
> this.softMask = doc.addImage(null, alphaImage).makeReference();
>   }
> {code}
> [https://github.com/apache/fop/blob/ff452f3685a02715aee791d651b58dd1797ddfd4/fop-core/src/main/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java]
> In the above code raster will be null and therefore FOP fails to initialize a 
> softMask. {{GraphicsUtil.getAlphaRaster()}} calls internally 
> {{ColorModel.getAlphaRaster()}}, which returns null:
> {quote}If this is an IndexColorModel which has alpha in the lookup table, 
> this method will return null since there is no spatially discrete alpha 
> channel.
> {quote}
> [https://docs.oracle.com/javase/8/docs/api/index.html?java/awt/image/ColorModel.html]
> The softMask Issue is fixed by:
> https://github.com/apache/fop/pull/50
> As a result an image such as !pal_bk.png! is rendered with a transparency 
> gradient instead of !pdf_trans_broken.png!
> This code will then add the chroma key mask to the image:
> {code:java}
> protected void populateXObjectDictionaryForIndexColorModel(PDFDictionary 
> dict, IndexColorModel icm) {
>   // code deleted
>   Integer index = getIndexOfFirstTransparentColorInPalette(icm);
>   if (index != null) {
> PDFArray mask = new PDFArray(dict);
> mask.add(index);
> mask.add(index);
> dict.put("Mask", mask);
>   }
> }
> {code}
> [https://github.com/apache/fop/blob/ff452f3685a02715aee791d651b58dd1797ddfd4/fop-core/src/main/java/org/apache/fop/render/pdf/AbstractImageAdapter.java]
> h4. why care to support?
> Libraries such as pngquant optimize images for web usage and low footprint 
> and can not be used directly with Apache FOP as source images:
> {quote}"*pngquant*: Lossy PNG optimizer, reducing a PNG image down to an 8 
> bit color palette with dithering. It will build indexed-color PNG's with 
> alpha transparency colors conveyed in the tRNS chunk."
> {quote}
> [https://imagemagick.org/Usage/formats/#png_non-im]
> h4. sample data
> {code}
> $ identify -verbose sample_image_palette_tRNS.png
>   Format: PNG (Portable Network Graphics)
>   Type: PaletteAlpha
>   png:IHDR.color_type  : 3 

[jira] [Commented] (FOP-2847) [PATCH] Support palette-based transparency via tRNS chunk of PNG images in PDF export

2019-03-27 Thread simon steiner (JIRA)


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

simon steiner commented on FOP-2847:


Next time submit 1 patch or 1 PR with 1 commit

> [PATCH] Support palette-based transparency via tRNS chunk of PNG images in 
> PDF export
> -
>
> Key: FOP-2847
> URL: https://issues.apache.org/jira/browse/FOP-2847
> Project: FOP
>  Issue Type: Bug
>  Components: renderer/pdf
>Affects Versions: 2.3
>Reporter: Tobias Hain
>Priority: Major
> Attachments: acrobat_reader_error_message.PNG, 
> broken_generated_pdf.pdf, pal_bk.png, pdf_trans_broken.png, 
> sample_image_palette_tRNS.png
>
>
> h4. TL;NR
> When using palette-based transparency via tRNS chunk in PNG images, the 
> generated PDFs are broken.
> h4. palette-based with transparency.
> {quote}*8.5.2. Palette-Based with Transparency*
> "The PNG spec forbids the use of a full alpha channel with palette-based 
> images, but it does allow `cheap alpha` via the transparency chunk, tRNS 
> [...] In effect, it transforms the palette from an RGB lookup table to an 
> RGBA table [...] a single PNG transparency entry should come first"
> {quote}
> [http://www.libpng.org/pub/png/book/chapter08.html#png.ch08.div.5.2]
> h4. general PDF encoding strategy
> Option 1:
> {quote}most libraries just undo the palettization and use a full color image 
> + mask.
> {quote}
> [https://forums.adobe.com/message/6148131#6148131]
> Option 2:
> {quote}SMask would be simpler since you could leave the palette in place
> {quote}
> [https://forums.adobe.com/message/6148557#6148557]
> h4. what does FOP do
> It creates a chroma-key mask:
> {code:java}
>  /Type /XObject
>   /ColorSpace [/Indexed /DeviceRGB 255 ]
>   /Mask [182 182 151 151 158 158]
> {code}
> Acrobat Reader even fails to read those files while PDF viewers embedded into 
> Chrome/Firefox read the file, but show visual glitches:
> !acrobat_reader_error_message.PNG!
> https://github.com/apache/fop/pull/49 fixes the Acrobat Reader error.
> FOP doesn't implement Option 1 yet. None of the ImageLoaders is prepared to 
> do that:
>  [https://wiki.apache.org/xmlgraphics-fop/HowTo/ImageLoaderRawPNG]
>  In fact the following results in missing Option 2:
> {code:java}
> public void setup(PDFDocument doc) {
>   RenderedImage ri = getImage().getRenderedImage();
>   // code deleted
>   Raster raster = GraphicsUtil.getAlphaRaster(ri);
>   if (raster != null) {
> AlphaRasterImage alphaImage = new AlphaRasterImage("Mask:" + getKey(), 
> raster);
> this.softMask = doc.addImage(null, alphaImage).makeReference();
>   }
> {code}
> [https://github.com/apache/fop/blob/ff452f3685a02715aee791d651b58dd1797ddfd4/fop-core/src/main/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java]
> In the above code raster will be null and therefore FOP fails to initialize a 
> softMask. {{GraphicsUtil.getAlphaRaster()}} calls internally 
> {{ColorModel.getAlphaRaster()}}, which returns null:
> {quote}If this is an IndexColorModel which has alpha in the lookup table, 
> this method will return null since there is no spatially discrete alpha 
> channel.
> {quote}
> [https://docs.oracle.com/javase/8/docs/api/index.html?java/awt/image/ColorModel.html]
> The softMask Issue is fixed by:
> https://github.com/apache/fop/pull/50
> As a result an image such as !pal_bk.png! is rendered with a transparency 
> gradient instead of !pdf_trans_broken.png!
> This code will then add the chroma key mask to the image:
> {code:java}
> protected void populateXObjectDictionaryForIndexColorModel(PDFDictionary 
> dict, IndexColorModel icm) {
>   // code deleted
>   Integer index = getIndexOfFirstTransparentColorInPalette(icm);
>   if (index != null) {
> PDFArray mask = new PDFArray(dict);
> mask.add(index);
> mask.add(index);
> dict.put("Mask", mask);
>   }
> }
> {code}
> [https://github.com/apache/fop/blob/ff452f3685a02715aee791d651b58dd1797ddfd4/fop-core/src/main/java/org/apache/fop/render/pdf/AbstractImageAdapter.java]
> h4. why care to support?
> Libraries such as pngquant optimize images for web usage and low footprint 
> and can not be used directly with Apache FOP as source images:
> {quote}"*pngquant*: Lossy PNG optimizer, reducing a PNG image down to an 8 
> bit color palette with dithering. It will build indexed-color PNG's with 
> alpha transparency colors conveyed in the tRNS chunk."
> {quote}
> [https://imagemagick.org/Usage/formats/#png_non-im]
> h4. sample data
> {code}
> $ identify -verbose sample_image_palette_tRNS.png
>   Format: PNG (Portable Network Graphics)
>   Type: PaletteAlpha
>   png:IHDR.color_type  : 3 (Indexed)
>   png:tRNS : chunk was found
> {code}



--
This message was sent by Atlassian JIRA