You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Philip Helger (JIRA)" <ji...@apache.org> on 2014/04/02 20:20:16 UTC
[jira] [Created] (PDFBOX-2012) Extend CMAPEncodingEntry API
Philip Helger created PDFBOX-2012:
-------------------------------------
Summary: Extend CMAPEncodingEntry API
Key: PDFBOX-2012
URL: https://issues.apache.org/jira/browse/PDFBOX-2012
Project: PDFBox
Issue Type: Bug
Components: FontBox
Affects Versions: 1.8.4, 2.0.0
Reporter: Philip Helger
Please extend the API with the following 2 methods (incl. a minor performance improvement):
### Eclipse Workspace Patch 1.0
#P fontbox
Index: src/main/java/org/apache/fontbox/ttf/CMAPEncodingEntry.java
===================================================================
--- src/main/java/org/apache/fontbox/ttf/CMAPEncodingEntry.java (revision 1583927)
+++ src/main/java/org/apache/fontbox/ttf/CMAPEncodingEntry.java (working copy)
@@ -436,7 +436,7 @@
for (int i = 0; i < 256; i++)
{
subHeaderKeys[i] = data.readUnsignedShort();
- maxSubHeaderIndex = Math.max(maxSubHeaderIndex, (int) (subHeaderKeys[i] / 8));
+ maxSubHeaderIndex = Math.max(maxSubHeaderIndex, subHeaderKeys[i] / 8);
}
// ---- Read all SubHeaders to avoid useless seek on DataSource
@@ -556,18 +556,32 @@
*/
public int getGlyphId(int characterCode)
{
- if (characterCodeToGlyphId.containsKey(characterCode))
- {
- return characterCodeToGlyphId.get(characterCode);
- }
- else
- {
- return 0;
- }
+ Integer glyphId = characterCodeToGlyphId.get(characterCode);
+ return glyphId == null ? 0 : glyphId.intValue ();
}
+
+ /**
+ * Get the minimum character code for which a glyph id is present
+ *
+ * @return The minimum character code for which a glyph id is present or -1 if no character code is present.
+ */
+ public int getMinimumCharacterCode()
+ {
+ return characterCodeToGlyphId.isEmpty () ? -1 : Collections.min (characterCodeToGlyphId.keySet ()).intValue ();
+ }
/**
+ * Get the maximum character code for which a glyph id is present
*
+ * @return The maximum character code for which a glyph id is present or -1 if no character code is present.
+ */
+ public int getMaximumCharacterCode()
+ {
+ return characterCodeToGlyphId.isEmpty () ? -1 : Collections.max (characterCodeToGlyphId.keySet ()).intValue ();
+ }
+
+ /**
+ *
* Class used to manage CMap - Format 2.
*
*/
--
This message was sent by Atlassian JIRA
(v6.2#6252)