Skip to content

Commit

Permalink
PDFBOX-3187: avoid NPE
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1724102 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
lehmi committed Jan 11, 2016
1 parent a135973 commit 3ae08cc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
10 changes: 10 additions & 0 deletions fontbox/src/main/java/org/apache/fontbox/cff/CFFCharset.java
Expand Up @@ -47,6 +47,16 @@ public abstract class CFFCharset
this.isCIDFont = isCIDFont;
}

/**
* Indicates if the charset belongs to a CID font.
*
* @return true for CID fonts
*/
public boolean isCIDFont()
{
return isCIDFont;
}

/**
* Adds a new GID/SID/name combination to the charset.
*
Expand Down
18 changes: 12 additions & 6 deletions fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java
Expand Up @@ -1323,11 +1323,14 @@ protected Format1Charset(boolean isCIDFont)
@Override
public int getCIDForGID(int gid)
{
for (RangeMapping mapping : rangesCID2GID)
if (isCIDFont())
{
if (mapping.isInRange(gid))
for (RangeMapping mapping : rangesCID2GID)
{
return mapping.mapValue(gid);
if (mapping.isInRange(gid))
{
return mapping.mapValue(gid);
}
}
}
return super.getCIDForGID(gid);
Expand All @@ -1336,11 +1339,14 @@ public int getCIDForGID(int gid)
@Override
public int getGIDForCID(int cid)
{
for (RangeMapping mapping : rangesCID2GID)
if (isCIDFont())
{
if (mapping.isInReverseRange(cid))
for (RangeMapping mapping : rangesCID2GID)
{
return mapping.mapReverseValue(cid);
if (mapping.isInReverseRange(cid))
{
return mapping.mapReverseValue(cid);
}
}
}
return super.getGIDForCID(cid);
Expand Down

0 comments on commit 3ae08cc

Please sign in to comment.