return bbox;
}
+ /**
+ * Indicates whether the font is non-symbolic (Font uses the Adobe standard Latin character
+ * set or a subset of it).
+ * @return true if the font is non-symbolic
+ */
+ public boolean isNonSymbolic() {
+ return (dfCharSet != 2); //!= Symbol fonts
+ }
+
/**
* Returns the characteristics flags for the font as
* needed for a PDF font descriptor (See PDF specs).
public int getFlags() {
int flags = 0;
if (!getIsProportional()) {
- flags |= 1;
+ flags |= 1; //bit 1: FixedPitch
}
- if ((dfPitchAndFamily & 16) == 16) {
- flags |= 2;
+ if (isNonSymbolic()) {
+ flags |= 32; //bit 6: Nonsymbolic
+ } else {
+ flags |= 4; //bit 3: Symbolic
}
- if ((dfPitchAndFamily & 64) == 64) {
- flags |= 4;
+ //int serif = dfPitchAndFamily & 0xFFFE;
+ if ((dfPitchAndFamily & 16) != 0) {
+ flags |= 2; //bit 2: Serif
}
- if (dfCharSet == 0) {
- flags |= 6;
+ if ((dfPitchAndFamily & 64) != 0) {
+ flags |= 8; //bit 4: Script
}
if (dfItalic != 0) {
- flags |= 7;
+ flags |= 64; //bit 7: Italic
}
return flags;
}
pfm.load(in);\r
singleFont = new SingleByteFont();\r
singleFont.setFontType(FontType.TYPE1);\r
- singleFont.setEncoding(pfm.getCharSetName() + "Encoding");\r
+ if (pfm.getCharSet() >= 0 && pfm.getCharSet() <= 2) {\r
+ singleFont.setEncoding(pfm.getCharSetName() + "Encoding");\r
+ } else {\r
+ log.warn("The PFM reports an unsupported encoding (" \r
+ + pfm.getCharSetName() + "). The font may not work as expected.");\r
+ singleFont.setEncoding("WinAnsiEncoding"); //Try fallback, no guarantees!\r
+ }\r
singleFont.setResolver(this.resolver);\r
returnFont = singleFont;\r
returnFont.setFontName(pfm.getPostscriptName());\r
returnFont.setDescender(pfm.getLowerCaseDescent());\r
returnFont.setFontBBox(pfm.getFontBBox());\r
returnFont.setFirstChar(pfm.getFirstChar());\r
- returnFont.setLastChar(pfm.getFirstChar());\r
+ returnFont.setLastChar(pfm.getLastChar());\r
returnFont.setFlags(pfm.getFlags());\r
returnFont.setStemV(pfm.getStemV());\r
returnFont.setItalicAngle(pfm.getItalicAngle());\r