Skip to content

Commit

Permalink
CODE REVIEW: Support for all cases where character is not found
Browse files Browse the repository at this point in the history
Changes after review to cover all NPE cases.  This will return space
character for all


Signed-off-by: sguan <sguan@actuate.com>
  • Loading branch information
sguan-actuate committed Oct 4, 2016
1 parent 6d3b63f commit aee4734
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -176,7 +176,6 @@ public class TrueTypeFont
static final int WE_HAVE_AN_X_AND_Y_SCALE = 64;
static final int WE_HAVE_A_TWO_BY_TWO = 128;

static private final int NBSP = 160;
static private final int SPACE = 32;
/**
* The components of table 'head'.
Expand Down Expand Up @@ -1213,10 +1212,16 @@ private String toPSString( String data )
return "(" + data + ")";
}

/**
* find the glyph index of a character
*
* @param c character to search
* @return if found the character return the index, if not return space
*/
public int getGlyphIndex( char c )
{
int[] glyphIndexs = (int[]) getCMap( ).get( (int) c );
if( glyphIndexs == null && c == NBSP )
if( glyphIndexs == null )
{
glyphIndexs = getCMap( ).get( SPACE );
}
Expand Down

0 comments on commit aee4734

Please sign in to comment.