From a8b8e454d569a83c2d4fbb415b6f2c26e57e3df3 Mon Sep 17 00:00:00 2001 From: Alberto Fernandez Date: Mon, 20 Nov 2017 21:27:11 +0100 Subject: [PATCH 1/3] Modifications made by TIBCO Software for JasperReports >= 6.2 # 1 Fix for transparency issue with setClip method in PdfGraphics2D # 2 Fix for transparency bleeding for Batik gradients # 3 Fix for stroke opacity state in the create() method of PdfGraphics2D # 4 Method to directly write AWT GlyphVectors to PDF for Indic scripts support # 5 No character spacing in justified lines with a single word Origin: https://sources.debian.net/patches/libitext-java/2.1.7-11/04_tibco-changes.patch/ http://jaspersoft.artifactoryonline.com/jaspersoft/third-party-ce-artifacts/com/lowagie/itext/2.1.7.js5/itext-2.1.7.js5-sources.jar --- .../com/lowagie/text/pdf/FontDetails.java | 37 ++++++++++ .../com/lowagie/text/pdf/PdfContentByte.java | 32 ++++++++- .../com/lowagie/text/pdf/PdfDocument.java | 8 ++- .../com/lowagie/text/pdf/PdfGraphics2D.java | 35 ++++++++-- .../com/lowagie/text/pdf/TrueTypeFont.java | 4 +- .../lowagie/text/pdf/TrueTypeFontUnicode.java | 67 ++++++++++++++++++- 6 files changed, 174 insertions(+), 9 deletions(-) diff --git a/openpdf/src/main/java/com/lowagie/text/pdf/FontDetails.java b/openpdf/src/main/java/com/lowagie/text/pdf/FontDetails.java index 773d31839..b6e48f1ed 100755 --- a/openpdf/src/main/java/com/lowagie/text/pdf/FontDetails.java +++ b/openpdf/src/main/java/com/lowagie/text/pdf/FontDetails.java @@ -49,6 +49,7 @@ package com.lowagie.text.pdf; +import java.awt.font.GlyphVector; import java.io.UnsupportedEncodingException; import java.util.HashMap; @@ -244,6 +245,42 @@ byte[] convertToBytes(String text) { return b; } + byte[] convertToBytes(GlyphVector glyphVector) { + if (fontType != BaseFont.FONT_TYPE_TTUNI || symbolic) { + throw new UnsupportedOperationException("Only supported for True Type Unicode fonts"); + } + + char[] glyphs = new char[glyphVector.getNumGlyphs()]; + int glyphCount = 0; + for (int i = 0; i < glyphs.length; i++) { + int code = glyphVector.getGlyphCode(i); + if (code == 0xFFFE || code == 0xFFFF) {// considered non-glyphs by + // AWT + continue; + } + + glyphs[glyphCount++] = (char) code;// FIXME supplementary plane? + + Integer codeKey = Integer.valueOf(code); + if (!longTag.containsKey(codeKey)) { + int glyphWidth = ttu.getGlyphWidth(code); + Integer charCode = ttu.getCharacterCode(code); + int[] metrics = charCode != null ? new int[] { code, glyphWidth, charCode.intValue() } : new int[] { + code, glyphWidth }; + longTag.put(codeKey, metrics); + } + } + + String s = new String(glyphs, 0, glyphCount); + try { + byte[] b = s.getBytes(CJKFont.CJK_ENCODING); + return b; + } catch (UnsupportedEncodingException e) { + throw new ExceptionConverter(e); + } + } + + /** * Writes the font definition to the document. * @param writer the PdfWriter of this document diff --git a/openpdf/src/main/java/com/lowagie/text/pdf/PdfContentByte.java b/openpdf/src/main/java/com/lowagie/text/pdf/PdfContentByte.java index eae055197..fc889e51e 100644 --- a/openpdf/src/main/java/com/lowagie/text/pdf/PdfContentByte.java +++ b/openpdf/src/main/java/com/lowagie/text/pdf/PdfContentByte.java @@ -50,8 +50,10 @@ package com.lowagie.text.pdf; import java.awt.Color; +import java.awt.font.GlyphVector; import java.awt.geom.AffineTransform; import java.awt.print.PrinterJob; +import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -1435,7 +1437,15 @@ public void showText(String text) { showText2(text); content.append("Tj").append_i(separator); } - + + // TIBCO Software #4 : Part 1 - START + public void showText(GlyphVector glyphVector) { + byte[] b = state.fontDetails.convertToBytes(glyphVector); + escapeString(b, content); + content.append("Tj").append_i(separator); + } + // TIBCO Software #4 : Part 1 - END + /** * Constructs a kern array for a text in a certain font * @param text the text @@ -3015,6 +3025,13 @@ public void setDefaultColorspace(PdfName name, PdfObject obj) { * @param struc the tagging structure */ public void beginMarkedContentSequence(PdfStructureElement struc) { + // TIBCO Software #4 : Part 1 - START + PdfDictionary dict = new PdfDictionary(); + beginMarkedContentSequence(struc, dict); + } + + public void beginMarkedContentSequence(PdfStructureElement struc, PdfDictionary dict) { + // TIBCO Software #4 : Part 1 - END PdfObject obj = struc.get(PdfName.K); int mark = pdf.getMarkPoint(); if (obj != null) { @@ -3043,7 +3060,18 @@ else if (obj.isArray()) { } pdf.incMarkPoint(); mcDepth++; - content.append(struc.get(PdfName.S).getBytes()).append(" <> BDC").append_i(separator); + // TIBCO Software #4 : Part 1 - START + //content.append(struc.get(PdfName.S).getBytes()).append(" <> BDC").append_i(separator); + dict.put(PdfName.MCID, new PdfNumber(mark)); + content.append(struc.get(PdfName.S).getBytes()).append(" "); + try { + dict.toPdf(writer, content); + } + catch (IOException e) { + throw new ExceptionConverter(e); + } + content.append(" BDC").append_i(separator); + // TIBCO Software #4 : Part 1 - END } /** diff --git a/openpdf/src/main/java/com/lowagie/text/pdf/PdfDocument.java b/openpdf/src/main/java/com/lowagie/text/pdf/PdfDocument.java index 0f5c26d56..600c68714 100644 --- a/openpdf/src/main/java/com/lowagie/text/pdf/PdfDocument.java +++ b/openpdf/src/main/java/com/lowagie/text/pdf/PdfDocument.java @@ -1399,7 +1399,13 @@ else if (isJustified) { hangingCorrection = width - oldWidth; } } - float baseFactor = width / (ratio * numberOfSpaces + lineLen - 1); + // TIBCO Software #5 : Part 1 - START +// float baseFactor = width / (ratio * numberOfSpaces + lineLen - 1); + // if there's a single word on the line and we are using NO_SPACE_CHAR_RATIO, + // we don't want any character spacing + float baseFactor = (numberOfSpaces == 0 && ratio == PdfWriter.NO_SPACE_CHAR_RATIO) + ? 0f : width / (ratio * numberOfSpaces + lineLen - 1); + // TIBCO Software #5 : Part 1 - END baseWordSpacing = ratio * baseFactor; baseCharacterSpacing = baseFactor; lastBaseFactor = baseFactor; diff --git a/openpdf/src/main/java/com/lowagie/text/pdf/PdfGraphics2D.java b/openpdf/src/main/java/com/lowagie/text/pdf/PdfGraphics2D.java index 0e9d3b365..d58edb520 100755 --- a/openpdf/src/main/java/com/lowagie/text/pdf/PdfGraphics2D.java +++ b/openpdf/src/main/java/com/lowagie/text/pdf/PdfGraphics2D.java @@ -909,6 +909,9 @@ public Graphics create() { g2.paint = this.paint; g2.fillGState = this.fillGState; g2.currentFillGState = this.currentFillGState; + // TIBCO Software #3 : Part 1 - START + g2.currentStrokeGState = this.currentStrokeGState; + // TIBCO Software #3 : Part 1 - END g2.strokeGState = this.strokeGState; g2.background = this.background; g2.mediaTracker = this.mediaTracker; @@ -1086,7 +1089,10 @@ public void setClip(Shape s) { followPath(s, CLIP); } paintFill = paintStroke = null; - currentFillGState = currentStrokeGState = 255; + // TIBCO Software #1 : Part 1 - START + //currentFillGState = currentStrokeGState = 255; + currentFillGState = currentStrokeGState = -1; // 255; + // TIBCO Software #1 : Part 1 - END oldStroke = strokeOne; } @@ -1487,7 +1493,10 @@ private boolean drawImage(Image img, Image mask, AffineTransform xform, Color bg } catch (Exception ex) { throw new IllegalArgumentException(); } - if (currentFillGState != 255) { + // TIBCO Software #1 : Part 2 - START + //if (currentFillGState != 255) { + if (currentFillGState != 255 && currentFillGState != -1) { + // TIBCO Software #1 : Part 2 - END PdfGState gs = fillGState[currentFillGState]; cb.setGState(gs); } @@ -1613,10 +1622,28 @@ else if (paint instanceof TexturePaint) { PdfPatternPainter pattern = cb.createPattern(width, height); image.setAbsolutePosition(0,0); pattern.addImage(image); - if (fill) + // TIBCO Software #2 : Part 1 - START + //if (fill) + // cb.setPatternFill(pattern); + //else + // cb.setPatternStroke(pattern); + if (fill) { + if (currentFillGState != 255){ + currentFillGState = 255; + PdfGState gs = fillGState[255]; + if (gs == null) { + gs = new PdfGState(); + gs.setFillOpacity(1); + fillGState[255] = gs; + } + cb.setGState(gs); + } cb.setPatternFill(pattern); - else + } + else { cb.setPatternStroke(pattern); + } + // TIBCO Software #2 : Part 1 - END } catch (Exception ex) { if (fill) cb.setColorFill(Color.gray); diff --git a/openpdf/src/main/java/com/lowagie/text/pdf/TrueTypeFont.java b/openpdf/src/main/java/com/lowagie/text/pdf/TrueTypeFont.java index 1befc3d4d..69c926f1e 100644 --- a/openpdf/src/main/java/com/lowagie/text/pdf/TrueTypeFont.java +++ b/openpdf/src/main/java/com/lowagie/text/pdf/TrueTypeFont.java @@ -672,7 +672,9 @@ void process(byte ttfAfm[], boolean preload) throws DocumentException, IOExcepti readCMaps(); readKerning(); readBbox(); - GlyphWidths = null; + // TIBCO Software #4 : Part 1 - START + // GlyphWidths = null; + // TIBCO Software #4 : Part 1 - END } } finally { diff --git a/openpdf/src/main/java/com/lowagie/text/pdf/TrueTypeFontUnicode.java b/openpdf/src/main/java/com/lowagie/text/pdf/TrueTypeFontUnicode.java index c5743bfec..ab7087afd 100755 --- a/openpdf/src/main/java/com/lowagie/text/pdf/TrueTypeFontUnicode.java +++ b/openpdf/src/main/java/com/lowagie/text/pdf/TrueTypeFontUnicode.java @@ -50,13 +50,17 @@ package com.lowagie.text.pdf; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; -import com.lowagie.text.error_messages.MessageLocalization; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import com.lowagie.text.DocumentException; import com.lowagie.text.Utilities; +import com.lowagie.text.error_messages.MessageLocalization; /** Represents a True Type font with Unicode encoding. All the character * in the font can be used directly by using the encoding Identity-H or @@ -71,6 +75,10 @@ class TrueTypeFontUnicode extends TrueTypeFont implements Comparator{ */ boolean vertical = false; + // TIBCO Software #4 : Part 1 - START + Map inverseCmap; + // TIBCO Software #4 : Part 1 - END + /** * Creates a new TrueType font addressed by Unicode characters. The font * will always be embedded. @@ -117,6 +125,34 @@ class TrueTypeFontUnicode extends TrueTypeFont implements Comparator{ vertical = enc.endsWith("V"); } + // TIBCO Software #4 : Part 1 - START + void readCMaps() throws DocumentException, IOException { + super.readCMaps(); + + Map cmap = null; + if (cmapExt != null) { + cmap = cmapExt; + } else if (cmap31 != null) { + cmap = cmap31; + } + + if (cmap != null) { + inverseCmap = new HashMap(); + for (Iterator iterator = cmap.entrySet().iterator(); iterator.hasNext();) { + Map.Entry entry = (Map.Entry) iterator.next(); + Integer code = (Integer) entry.getKey(); + int[] metrics = (int[]) entry.getValue(); + inverseCmap.put(Integer.valueOf(metrics[0]), code); + } + } + } + + protected Integer getCharacterCode(int code) { + return inverseCmap == null ? null : (Integer) inverseCmap.get(Integer.valueOf(code)); + } + + // TIBCO Software #4 : Part 1 - END + /** * Gets the width of a char in normalized 1000 units. * @param char1 the unicode char to get the width of @@ -174,6 +210,9 @@ public int getWidth(String text) { * @return the stream representing this CMap or null */ private PdfStream getToUnicode(Object metrics[]) { + // TIBCO Software #4 : Part 1 - START + metrics = filterCmapMetrics(metrics); + // TIBCO Software #4 : Part 1 - END if (metrics.length == 0) return null; StringBuffer buf = new StringBuffer( @@ -215,6 +254,32 @@ private PdfStream getToUnicode(Object metrics[]) { return stream; } + // TIBCO Software #4 : Part 1 - START + private Object[] filterCmapMetrics(Object[] metrics) { + if (metrics.length == 0) { + return metrics; + } + + List cmapMetrics = new ArrayList(metrics.length); + for (int i = 0; i < metrics.length; i++) { + int metric[] = (int[]) metrics[i]; + // PdfContentByte.showText(GlyphVector) uses glyphs that might not + // map to a character. + // the glyphs are included in the metrics array, but we need to + // exclude them from the cmap. + if (metric.length >= 3) { + cmapMetrics.add(metric); + } + } + + if (cmapMetrics.size() == metrics.length) { + return metrics; + } + + return cmapMetrics.toArray(); + } + // TIBCO Software #4 : Part 1 - END + private static String toHex4(int n) { String s = "0000" + Integer.toHexString(n); return s.substring(s.length() - 4); From 7516779bd3db01047e017aa4a7561ffb837c60e1 Mon Sep 17 00:00:00 2001 From: Alberto Fernandez Date: Tue, 28 Nov 2017 17:26:49 +0100 Subject: [PATCH 2/3] Comments cleanup --- .../com/lowagie/text/pdf/PdfContentByte.java | 7 ------- .../java/com/lowagie/text/pdf/PdfDocument.java | 3 --- .../com/lowagie/text/pdf/PdfGraphics2D.java | 17 ++--------------- .../java/com/lowagie/text/pdf/TrueTypeFont.java | 3 --- .../lowagie/text/pdf/TrueTypeFontUnicode.java | 8 -------- 5 files changed, 2 insertions(+), 36 deletions(-) diff --git a/openpdf/src/main/java/com/lowagie/text/pdf/PdfContentByte.java b/openpdf/src/main/java/com/lowagie/text/pdf/PdfContentByte.java index fc889e51e..2a81da2ab 100644 --- a/openpdf/src/main/java/com/lowagie/text/pdf/PdfContentByte.java +++ b/openpdf/src/main/java/com/lowagie/text/pdf/PdfContentByte.java @@ -1438,13 +1438,11 @@ public void showText(String text) { content.append("Tj").append_i(separator); } - // TIBCO Software #4 : Part 1 - START public void showText(GlyphVector glyphVector) { byte[] b = state.fontDetails.convertToBytes(glyphVector); escapeString(b, content); content.append("Tj").append_i(separator); } - // TIBCO Software #4 : Part 1 - END /** * Constructs a kern array for a text in a certain font @@ -3025,13 +3023,11 @@ public void setDefaultColorspace(PdfName name, PdfObject obj) { * @param struc the tagging structure */ public void beginMarkedContentSequence(PdfStructureElement struc) { - // TIBCO Software #4 : Part 1 - START PdfDictionary dict = new PdfDictionary(); beginMarkedContentSequence(struc, dict); } public void beginMarkedContentSequence(PdfStructureElement struc, PdfDictionary dict) { - // TIBCO Software #4 : Part 1 - END PdfObject obj = struc.get(PdfName.K); int mark = pdf.getMarkPoint(); if (obj != null) { @@ -3060,8 +3056,6 @@ else if (obj.isArray()) { } pdf.incMarkPoint(); mcDepth++; - // TIBCO Software #4 : Part 1 - START - //content.append(struc.get(PdfName.S).getBytes()).append(" <> BDC").append_i(separator); dict.put(PdfName.MCID, new PdfNumber(mark)); content.append(struc.get(PdfName.S).getBytes()).append(" "); try { @@ -3071,7 +3065,6 @@ else if (obj.isArray()) { throw new ExceptionConverter(e); } content.append(" BDC").append_i(separator); - // TIBCO Software #4 : Part 1 - END } /** diff --git a/openpdf/src/main/java/com/lowagie/text/pdf/PdfDocument.java b/openpdf/src/main/java/com/lowagie/text/pdf/PdfDocument.java index 600c68714..aea1aaf88 100644 --- a/openpdf/src/main/java/com/lowagie/text/pdf/PdfDocument.java +++ b/openpdf/src/main/java/com/lowagie/text/pdf/PdfDocument.java @@ -1399,13 +1399,10 @@ else if (isJustified) { hangingCorrection = width - oldWidth; } } - // TIBCO Software #5 : Part 1 - START -// float baseFactor = width / (ratio * numberOfSpaces + lineLen - 1); // if there's a single word on the line and we are using NO_SPACE_CHAR_RATIO, // we don't want any character spacing float baseFactor = (numberOfSpaces == 0 && ratio == PdfWriter.NO_SPACE_CHAR_RATIO) ? 0f : width / (ratio * numberOfSpaces + lineLen - 1); - // TIBCO Software #5 : Part 1 - END baseWordSpacing = ratio * baseFactor; baseCharacterSpacing = baseFactor; lastBaseFactor = baseFactor; diff --git a/openpdf/src/main/java/com/lowagie/text/pdf/PdfGraphics2D.java b/openpdf/src/main/java/com/lowagie/text/pdf/PdfGraphics2D.java index d58edb520..95eb0afa6 100755 --- a/openpdf/src/main/java/com/lowagie/text/pdf/PdfGraphics2D.java +++ b/openpdf/src/main/java/com/lowagie/text/pdf/PdfGraphics2D.java @@ -909,9 +909,7 @@ public Graphics create() { g2.paint = this.paint; g2.fillGState = this.fillGState; g2.currentFillGState = this.currentFillGState; - // TIBCO Software #3 : Part 1 - START g2.currentStrokeGState = this.currentStrokeGState; - // TIBCO Software #3 : Part 1 - END g2.strokeGState = this.strokeGState; g2.background = this.background; g2.mediaTracker = this.mediaTracker; @@ -1089,10 +1087,7 @@ public void setClip(Shape s) { followPath(s, CLIP); } paintFill = paintStroke = null; - // TIBCO Software #1 : Part 1 - START - //currentFillGState = currentStrokeGState = 255; - currentFillGState = currentStrokeGState = -1; // 255; - // TIBCO Software #1 : Part 1 - END + currentFillGState = currentStrokeGState = -1; oldStroke = strokeOne; } @@ -1493,10 +1488,7 @@ private boolean drawImage(Image img, Image mask, AffineTransform xform, Color bg } catch (Exception ex) { throw new IllegalArgumentException(); } - // TIBCO Software #1 : Part 2 - START - //if (currentFillGState != 255) { if (currentFillGState != 255 && currentFillGState != -1) { - // TIBCO Software #1 : Part 2 - END PdfGState gs = fillGState[currentFillGState]; cb.setGState(gs); } @@ -1622,11 +1614,7 @@ else if (paint instanceof TexturePaint) { PdfPatternPainter pattern = cb.createPattern(width, height); image.setAbsolutePosition(0,0); pattern.addImage(image); - // TIBCO Software #2 : Part 1 - START - //if (fill) - // cb.setPatternFill(pattern); - //else - // cb.setPatternStroke(pattern); + if (fill) { if (currentFillGState != 255){ currentFillGState = 255; @@ -1643,7 +1631,6 @@ else if (paint instanceof TexturePaint) { else { cb.setPatternStroke(pattern); } - // TIBCO Software #2 : Part 1 - END } catch (Exception ex) { if (fill) cb.setColorFill(Color.gray); diff --git a/openpdf/src/main/java/com/lowagie/text/pdf/TrueTypeFont.java b/openpdf/src/main/java/com/lowagie/text/pdf/TrueTypeFont.java index 69c926f1e..ca8ab25e0 100644 --- a/openpdf/src/main/java/com/lowagie/text/pdf/TrueTypeFont.java +++ b/openpdf/src/main/java/com/lowagie/text/pdf/TrueTypeFont.java @@ -672,9 +672,6 @@ void process(byte ttfAfm[], boolean preload) throws DocumentException, IOExcepti readCMaps(); readKerning(); readBbox(); - // TIBCO Software #4 : Part 1 - START - // GlyphWidths = null; - // TIBCO Software #4 : Part 1 - END } } finally { diff --git a/openpdf/src/main/java/com/lowagie/text/pdf/TrueTypeFontUnicode.java b/openpdf/src/main/java/com/lowagie/text/pdf/TrueTypeFontUnicode.java index ab7087afd..26ae5ad42 100755 --- a/openpdf/src/main/java/com/lowagie/text/pdf/TrueTypeFontUnicode.java +++ b/openpdf/src/main/java/com/lowagie/text/pdf/TrueTypeFontUnicode.java @@ -75,9 +75,7 @@ class TrueTypeFontUnicode extends TrueTypeFont implements Comparator{ */ boolean vertical = false; - // TIBCO Software #4 : Part 1 - START Map inverseCmap; - // TIBCO Software #4 : Part 1 - END /** * Creates a new TrueType font addressed by Unicode characters. The font @@ -125,7 +123,6 @@ class TrueTypeFontUnicode extends TrueTypeFont implements Comparator{ vertical = enc.endsWith("V"); } - // TIBCO Software #4 : Part 1 - START void readCMaps() throws DocumentException, IOException { super.readCMaps(); @@ -151,7 +148,6 @@ protected Integer getCharacterCode(int code) { return inverseCmap == null ? null : (Integer) inverseCmap.get(Integer.valueOf(code)); } - // TIBCO Software #4 : Part 1 - END /** * Gets the width of a char in normalized 1000 units. @@ -210,9 +206,7 @@ public int getWidth(String text) { * @return the stream representing this CMap or null */ private PdfStream getToUnicode(Object metrics[]) { - // TIBCO Software #4 : Part 1 - START metrics = filterCmapMetrics(metrics); - // TIBCO Software #4 : Part 1 - END if (metrics.length == 0) return null; StringBuffer buf = new StringBuffer( @@ -254,7 +248,6 @@ private PdfStream getToUnicode(Object metrics[]) { return stream; } - // TIBCO Software #4 : Part 1 - START private Object[] filterCmapMetrics(Object[] metrics) { if (metrics.length == 0) { return metrics; @@ -278,7 +271,6 @@ private Object[] filterCmapMetrics(Object[] metrics) { return cmapMetrics.toArray(); } - // TIBCO Software #4 : Part 1 - END private static String toHex4(int n) { String s = "0000" + Integer.toHexString(n); From 2d34473b14e8feecf6f5995916e272d269aa7a98 Mon Sep 17 00:00:00 2001 From: Alberto Fernandez Date: Tue, 28 Nov 2017 17:30:54 +0100 Subject: [PATCH 3/3] Added generics --- .../main/java/com/lowagie/text/pdf/TrueTypeFontUnicode.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openpdf/src/main/java/com/lowagie/text/pdf/TrueTypeFontUnicode.java b/openpdf/src/main/java/com/lowagie/text/pdf/TrueTypeFontUnicode.java index 26ae5ad42..aacd82f86 100755 --- a/openpdf/src/main/java/com/lowagie/text/pdf/TrueTypeFontUnicode.java +++ b/openpdf/src/main/java/com/lowagie/text/pdf/TrueTypeFontUnicode.java @@ -75,7 +75,7 @@ class TrueTypeFontUnicode extends TrueTypeFont implements Comparator{ */ boolean vertical = false; - Map inverseCmap; + Map inverseCmap; /** * Creates a new TrueType font addressed by Unicode characters. The font @@ -139,13 +139,13 @@ void readCMaps() throws DocumentException, IOException { Map.Entry entry = (Map.Entry) iterator.next(); Integer code = (Integer) entry.getKey(); int[] metrics = (int[]) entry.getValue(); - inverseCmap.put(Integer.valueOf(metrics[0]), code); + inverseCmap.put(metrics[0], code); } } } protected Integer getCharacterCode(int code) { - return inverseCmap == null ? null : (Integer) inverseCmap.get(Integer.valueOf(code)); + return inverseCmap == null ? null : inverseCmap.get(code); }