|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.faceless.pdf2.PDFObject
org.faceless.pdf2.PDFMap
org.faceless.pdf2.PDFFont
org.faceless.pdf2.Type1Font
Create a new PostScript Type 1 font. This class of font is commonly used on UNIX systems. The standard 14 fonts are a special class of Type 1 font.
Type 1 fonts give each character shape, or "glyph", a name, in the same way the PDF documents refer to glyphs by name (hardly surprising really, seeing as both Type 1 fonts and PDF documents are defined by Adobe). Because text written to the PDF via this library is specified in Unicode, Type 1 fonts need a "mapping" from Unicode character to Glyph name.
For many fonts this isn't a problem. Font's based on the latin character set (more specifically, fonts implementing a subset of the Adobe Standard Glyph List) already have their mapping defined. Adobe have a naming standard for glyphs outside that list (specifically each character not on the list should be named "uniXXXX" where XXXX is the position of that character in the Unicode mapping in hex). If this standard is followed then no further thought needs to be given to this issue.
If the standard is not followed, it is necessary for the developer to
supply a mapping from Unicode character to Glyph name. This takes the
form of a Map
, with a Character
representing a Unicode
character as the key, and a corresponding String
representing
the name of the glyph as the value.
OpenTypeFont
,
StandardFont
Field Summary | |
static Map |
AGL
This Map is a list of the Adobe Standard Glyphs. |
Constructor Summary | |
Type1Font(InputStream afm,
InputStream pfb)
Create a new Type 1 font, using the standard Adobe mapping from unicode to glyph name. |
|
Type1Font(InputStream afm,
InputStream pfb,
Map mapping)
Create a new Type 1 font, using a user defined mapping from unicode to glyph name. |
Method Summary | |
float |
getAscender()
Get the Ascender for the font (the maximum height above the baseline the font extends), as a proportion of the point size. |
float |
getDefaultLeading()
Get the default leading for this font - the preferred distance between two successive baselines of text. |
float |
getDescender()
Get the Descender for the font (the maximum height below the baseline the font extends), as a proportion of the point size. |
int |
getKerning(int c1,
int c2)
Get the horizontal character-to-character (or "pair-wise") kerning in this font for the specified characters, in millipoints. |
float |
getStrikeoutPosition()
Get the strikeout position, as a proportion of the font size. |
float |
getStrikeoutThickness()
Get the strikeout thickness, as a proportion of the font size. |
float |
getSubscriptPosition()
Get the recommended position of a sub-script version of this font, as a proportion of the sub-scripted font size. |
float |
getSubscriptSize()
Get the recommended size of a super/sub script version of this font, as a proportion of the normal font size. |
float |
getSuperscriptPosition()
Get the recommended position of a super-script version of this font, as a proportion of the sub-scripted font size. |
float |
getUnderlinePosition()
Get the underline position, as a proportion of the font size. |
float |
getUnderlineThickness()
Get the underline thickness, as a proportion of the font size. |
boolean |
isMonospace()
Return true if every character has the same width (like Courier), false if every character is potentially a different width (like Times-Roman) |
Methods inherited from class org.faceless.pdf2.PDFFont |
equals, getBaseName, getBottom, getCharWidth, getCharWidth, getKerning, getLeft, getRight, getTop, isDefined, isDefined, isHorizontal, ligaturize, ligaturize, requote, requote, toString |
Methods inherited from class java.lang.Object |
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final Map AGL
Map
is a list of the Adobe Standard Glyphs. Some fonts
which claim to be encoded using the Adobe Standard Glyph mapping deviate
from the list slightly. Using this Map you can easily create a slight
variation on the standard mapping to pass into the Type 1 constructor.
For example, lets say your font has a glyph called "hyphenminus" instead
of the standard name "hyphen". You could create the font like so:
Map mymap = new HashMap(Type1Font.AGL); mymap.put(new Character('-'), "hyphenminus"): PDFFont myfont = new Type1Font(afmfile, pfbfile, mymap);
Constructor Detail |
public Type1Font(InputStream afm, InputStream pfb) throws IOException
afm
- The .afm
(Adobe Font Metrics) file specifying
the metrics for this fontpfb
- The .pfb
or .pfa
file containing
the glyph shapes to be embedded in the PDF. If the font is not to be
embedded, this should be null.
IOException
- If the .afm
or .pfb
InputStream can't be read or parsedpublic Type1Font(InputStream afm, InputStream pfb, Map mapping) throws IOException
Create a new Type 1 font, using a user defined mapping from unicode to glyph name. The font can be embedded, which ensures that your viewers will see exactly the font you specified, at the cost of increasing the file size. If a font is not embedded and the viewer does not have the same font installed, the viewing software will substitute an "appropriate" font.
afm
- The .afm
(Adobe Font Metrics) file specifying the
metrics for this fontpfb
- The .pfb
or .pfa
file containing the glyph
shapes to be embedded in the PDF. If the font is not to be embedded, this should be null.mapping
- The mapping from unicode->glyph, as described in the class header above.
IOException
- If the .afm
or .pfb file can't be read or parsedMethod Detail |
public int getKerning(int c1, int c2)
PDFFont
PDFFont.getKerning(char,char)
but takes ints, to handle the new Unicode 4.0
characters defined in Java 1.5
getKerning
in class PDFFont
c1
- a Unicode codepoint between U+0000 and U+10FFFDc2
- a Unicode codepoint between U+0000 and U+10FFFDpublic float getDefaultLeading()
PDFFont
Get the default leading for this font - the preferred distance between two successive baselines of text. Values are a ratio of the font size, and are typically between 1 and 1.3
Note that the values of the different spacing-between-lines methods have
changed - in versions 1.0.4 and earlier this routine normally returned 1
and the spacing was set by the PDFStyle.setTextLineSpacing(float)
method.
Since 1.1, the values for these two methods are effectively reversed. See
the relevant method comments in the PDFStyle
class for more
information.
getDefaultLeading
in class PDFFont
public float getSubscriptPosition()
PDFFont
Get the recommended position of a sub-script version of this font, as a proportion of the sub-scripted font size. Value is almost always zero or negative.
For some fonts (like CJK or barcode fonts) where there is no concept of super or subscript, this value is entirely arbitrary.
getSubscriptPosition
in class PDFFont
public float getSuperscriptPosition()
PDFFont
Get the recommended position of a super-script version of this font, as a proportion of the sub-scripted font size. Value is always positive.
For some fonts (like CJK or barcode fonts) where there is no concept of super or subscript, this value is entirely arbitrary.
getSuperscriptPosition
in class PDFFont
public float getSubscriptSize()
PDFFont
Get the recommended size of a super/sub script version of this font, as a proportion of the normal font size. Typical value is around 0.6.
For some fonts (like CJK or barcode fonts) where there is no concept of super or subscript, this value is entirely arbitrary.
getSubscriptSize
in class PDFFont
public float getStrikeoutThickness()
PDFFont
getStrikeoutThickness
in class PDFFont
public float getStrikeoutPosition()
PDFFont
getStrikeoutPosition
in class PDFFont
public float getUnderlineThickness()
PDFFont
getUnderlineThickness
in class PDFFont
public float getUnderlinePosition()
PDFFont
getDescender()
method, the returned value is almost
always negative, indicating below the baseline.
getUnderlinePosition
in class PDFFont
public float getAscender()
PDFFont
getAscender
in class PDFFont
public float getDescender()
PDFFont
getDescender
in class PDFFont
public boolean isMonospace()
PDFFont
isMonospace
in class PDFFont
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |