Skip to content

Commit

Permalink
GH-80 fix rendering regressions with some type1 fonts.
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Corless committed Apr 27, 2021
1 parent 880560c commit 5d54336
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ public Point2D getAdvance(char ech) {
return super.getAdvance(ech);
}

@Override
protected String codeToName(String estr) {
return codeToName(estr.charAt(0));
}

protected String codeToName(int code) {
if (encoding != null &&
org.icepdf.core.pobjects.fonts.zfont.Encoding.STANDARD_ENCODING_NAME.equals(encoding.getName())) {
return type1Font.getEncoding().getName(code);
} else {
return String.valueOf((char) code);
}
}

@Override
public void paint(Graphics2D g, String estr, float x, float y, long layout, int mode, Color strokeColor) {
super.paint(g, estr, x, y, layout, mode, strokeColor);
Expand Down Expand Up @@ -134,7 +148,7 @@ public FontFile deriveFont(Map<Integer, Float> widths, int firstCh, float missin

@Override
public boolean canDisplay(char ech) {
return type1Font.hasGlyph(String.valueOf(ech));
return type1Font.hasGlyph(codeToName(ech));
}

@Override
Expand Down

0 comments on commit 5d54336

Please sign in to comment.