| Method from org.apache.fop.fonts.type1.PFMFile Detail: |
public int getCapHeight() {
return etmCapHeight;
}
Returns the CapHeight parameter for the font (height of uppercase H). |
public short getCharSet() {
return dfCharSet;
}
Returns the charset used for the font. |
public String getCharSetName() {
//TODO Had to remove the detection for Expert(Subset) encoding. The PFM is not suitable
//for detecting these character sets. We have to parse the AFM for that.
switch (dfCharSet) {
case 0:
return "WinAnsi"; // AKA ISOAdobe
case 2:
if ("Symbol".equals(getPostscriptName())) {
return "Symbol";
}
break;
case 128:
return "Shift-JIS (Japanese)";
default:
log.warn("Unknown charset detected (" + dfCharSet
+ ", 0x" + Integer.toHexString(dfCharSet)
+ "). Trying fallback to WinAnsi.");
}
return "WinAnsi";
}
Returns the charset of the font as a string. |
public int getCharWidth(short which) {
return extentTable[which - dfFirstChar];
}
Returns the width of a character |
public short getFirstChar() {
return dfFirstChar;
}
Returns the number of the character that defines
the first entry in the widths list. |
public int getFlags() {
int flags = 0;
if (!getIsProportional()) {
flags |= 1; //bit 1: FixedPitch
}
if (isNonSymbolic()) {
flags |= 32; //bit 6: Nonsymbolic
} else {
flags |= 4; //bit 3: Symbolic
}
//int serif = dfPitchAndFamily & 0xFFFE;
if ((dfPitchAndFamily & 16) != 0) {
flags |= 2; //bit 2: Serif
}
if ((dfPitchAndFamily & 64) != 0) {
flags |= 8; //bit 4: Script
}
if (dfItalic != 0) {
flags |= 64; //bit 7: Italic
}
return flags;
}
Returns the characteristics flags for the font as
needed for a PDF font descriptor (See PDF specs). |
public int[] getFontBBox() {
int[] bbox = new int[4];
// Just guessing....
if (!getIsProportional() && (dfAvgWidth == dfMaxWidth)) {
bbox[0] = -20;
} else {
bbox[0] = -100;
}
bbox[1] = getLowerCaseDescent() - 5;
bbox[2] = dfMaxWidth + 10;
bbox[3] = getLowerCaseAscent() + 5;
return bbox;
}
Returns the bounding box for the font.
Note: this value is just an approximation,
it does not really exist in the PFM file. |
public boolean getIsProportional() {
return ((dfPitchAndFamily & 1) == 1);
}
Tells whether the font has proportional character spacing. |
public int getItalicAngle() {
if (dfItalic != 0) {
return -16; // Just guessing....
} else {
return 0;
}
}
Returns the italic angle of the font.
Note: this value is just an approximation,
it does not really exist in the PFM file. |
public Map getKerning() {
return kerningTab;
}
Return the kerning table. The kerning table is a Map with
strings with glyphnames as keys, containing Maps as value.
The value map contains a glyph name string key and an Integer value |
public short getLastChar() {
return dfLastChar;
}
Returns the number of the character that defines
the last entry in the widths list. |
public int getLowerCaseAscent() {
return etmLowerCaseAscent;
}
Returns the LowerCaseAscent parameter for the font (height of lowercase d). |
public int getLowerCaseDescent() {
return etmLowerCaseDescent;
}
Returns the LowerCaseDescent parameter for the font (height of lowercase p). |
public String getPostscriptName() {
return postscriptName;
}
Returns the Postscript name of the font. |
public int getStemV() {
// Just guessing....
if (dfItalic != 0) {
return (int)Math.round(dfMinWidth * 0.25);
} else {
return (int)Math.round(dfMinWidth * 0.6);
}
}
Returns the width of the dominant vertical stems of the font.
Note: this value is just an approximation,
it does not really exist in the PFM file. |
public String getWindowsName() {
return windowsName;
}
Returns the Windows name of the font. |
public int getXHeight() {
return etmXHeight;
}
Returns the XHeight parameter for the font (height of lowercase x). |
public boolean isNonSymbolic() {
return (dfCharSet != 2); //!= Symbol fonts
}
Indicates whether the font is non-symbolic (Font uses the Adobe standard Latin character
set or a subset of it). |
public void load(InputStream inStream) throws IOException {
byte[] pfmBytes = IOUtils.toByteArray(inStream);
InputStream bufin = inStream;
bufin = new ByteArrayInputStream(pfmBytes);
PFMInputStream in = new PFMInputStream(bufin);
bufin.mark(512);
short sh1 = in.readByte();
short sh2 = in.readByte();
if (sh1 == 128 && sh2 == 1) {
//Found the first section header of a PFB file!
throw new IOException("Cannot parse PFM file. You probably specified the PFB file"
+ " of a Type 1 font as parameter instead of the PFM.");
}
bufin.reset();
byte[] b = new byte[16];
bufin.read(b);
if (new String(b, "US-ASCII").equalsIgnoreCase("StartFontMetrics")) {
//Found the header of a AFM file!
throw new IOException("Cannot parse PFM file. You probably specified the AFM file"
+ " of a Type 1 font as parameter instead of the PFM.");
}
bufin.reset();
final int version = in.readShort();
if (version != 256) {
log.warn("PFM version expected to be '256' but got '" + version + "'."
+ " Please make sure you specify the PFM as parameter"
+ " and not the PFB or the AFM.");
}
//final long filesize = in.readInt();
bufin.reset();
loadHeader(in);
loadExtension(in);
}
|