Class StandardFont
- java.lang.Object
-
- org.faceless.pdf2.PDFFont
-
- org.faceless.pdf2.StandardFont
-
- All Implemented Interfaces:
Cloneable
public final class StandardFont extends PDFFont
A concrete subclass of
PDFFontrepresenting the standard 14 fonts guaranteed to exist in all PDF readers.The Times, Helvetica and Courier fonts can represent the characters from all of ISO-8859-1, ISO-8859-2, ISO-8859-6 and ISO-8859-15 as well as a few other characters, which we believe is enough to render the following languages: English, French, German, Portuguese, Italian, Spanish, Dutch, Danish, Swedish, Norwegian, Icelandic, Finnish, Polish, Croatian, Czech, Hungarian, Romanian, Slovak, Solvenian, Latvian, Lithuanian, Estonian, Turkish, Catalan, Basque, Albanian, Rhaeto-Romanic, Sorbian, Faroese, Irish, Scottish, Afrikaans, Swahili, Frisian, Galician, Indonesian/Malay and Tagalog. (This list is based on an old IETF draft here and Roman Czyborras Alphabet Soup pages, and is not definitive or even necessarily accurate). Note the Dutch IJ ligatures (U+0132 and U+0133) and the Catalan "L with dot" (U+0140) characters are missing.
Maps showing all the characters available in these fonts are included in the "docs" directory, or you can view them here for the main fonts, the Symbol font and ZapfDingbats.
- Since:
- 1.0, with additional characters added in 2.7.3
-
-
Field Summary
Fields Modifier and Type Field Description static intCOURIERRepresents the "Courier" fontstatic intCOURIERBOLDRepresents the "Courier-Bold" fontstatic intCOURIERBOLDOBLIQUERepresents the "Courier-BoldOblique" fontstatic intCOURIEROBLIQUERepresents the "Courier-Oblique" fontstatic intHELVETICARepresents the "Helvetica" fontstatic intHELVETICABOLDRepresents the "Helvetica-Bold" fontstatic intHELVETICABOLDOBLIQUERepresents the "Helvetica-BoldOblique" fontstatic intHELVETICAOBLIQUERepresents the "Helvetica-Oblique" fontstatic intSYMBOLRepresents the "Symbol" fontstatic intTIMESRepresents the "Times-Roman" fontstatic intTIMESBOLDRepresents the "Times-Bold" fontstatic intTIMESBOLDITALICRepresents the "Times-BoldItalic" fontstatic intTIMESITALICRepresents the "Times-Italic" fontstatic intZAPFDINGBATSRepresents the "ZapfDingbats" font.
-
Constructor Summary
Constructors Constructor Description StandardFont(int fonttype)Create a new font of the specified type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description floatgetAscender()Get the Ascender for the font (the maximum height above the baseline the font extends), as a proportion of the point size.StringgetBaseName()Return the Base Font Name for this font.floatgetCapHeight()Get the Cap-Height of the font - normally the height of an upper-case 'O' characterfloatgetDefaultLeading()Get the default leading for this font - the preferred distance between two successive baselines of text.BitSetgetDefinedCodepoints()Return read-only BitSet containing all the Unicode codepoints defined in this fontfloatgetDescender()Get the Descender for the font (the maximum height below the baseline the font extends), as a proportion of the point size.floatgetStrikeoutPosition()Get the strikeout position, as a proportion of the font size.floatgetStrikeoutThickness()Get the strikeout thickness, as a proportion of the font size.floatgetSubscriptPosition()Get the recommended position of a sub-script version of this font, as a proportion of the sub-scripted font size.floatgetSubscriptSize()Get the recommended size of a super/sub script version of this font, as a proportion of the normal font size.floatgetSuperscriptPosition()Get the recommended position of a super-script version of this font, as a proportion of the sub-scripted font size.intgetType()Return the type of font, as supplied to the StandardFont constructorfloatgetUnderlinePosition()Get the underline position, as a proportion of the font size.floatgetUnderlineThickness()Get the underline thickness, as a proportion of the font size.floatgetXHeight()Get the X-Height of the font - normally the height of a lower-case 'x' character.booleanisBold()Return true if the font is boldbooleanisItalic()Return true if the font is italicbooleanisMonospace()Return true if every character has the same width (like Courier), false if every character is potentially a different width (like Times-Roman)booleanisSerif()Return true if the font is serifStringtoString()PDFFontversionBold()Return a bold version of the current font, if available.PDFFontversionItalic()Return an italic version of the current font, if available.PDFFontversionNonBold()Return a non-bold version of the current font, if available.PDFFontversionNonItalic()Return a non-italic version of the current font, if available.PDFFontversionRegular()Return a non-bold, non-italic version of the current font, if available.-
Methods inherited from class org.faceless.pdf2.PDFFont
clone, getAvailableFeatures, getBottom, getCharWidth, getCharWidth, getFeature, getKerning, getKerning, getLeft, getMetaData, getRight, getTop, getXMP, hasFeature, isDefined, isDefined, isEmbedded, isHorizontal, isSubset, setFeature, setFeature, setMetaData
-
-
-
-
Field Detail
-
TIMES
public static final int TIMES
Represents the "Times-Roman" font- See Also:
- Constant Field Values
-
TIMESBOLD
public static final int TIMESBOLD
Represents the "Times-Bold" font- See Also:
- Constant Field Values
-
TIMESITALIC
public static final int TIMESITALIC
Represents the "Times-Italic" font- See Also:
- Constant Field Values
-
TIMESBOLDITALIC
public static final int TIMESBOLDITALIC
Represents the "Times-BoldItalic" font- See Also:
- Constant Field Values
-
HELVETICA
public static final int HELVETICA
Represents the "Helvetica" font- See Also:
- Constant Field Values
-
HELVETICABOLD
public static final int HELVETICABOLD
Represents the "Helvetica-Bold" font- See Also:
- Constant Field Values
-
HELVETICAOBLIQUE
public static final int HELVETICAOBLIQUE
Represents the "Helvetica-Oblique" font- See Also:
- Constant Field Values
-
HELVETICABOLDOBLIQUE
public static final int HELVETICABOLDOBLIQUE
Represents the "Helvetica-BoldOblique" font- See Also:
- Constant Field Values
-
COURIER
public static final int COURIER
Represents the "Courier" font- See Also:
- Constant Field Values
-
COURIERBOLD
public static final int COURIERBOLD
Represents the "Courier-Bold" font- See Also:
- Constant Field Values
-
COURIEROBLIQUE
public static final int COURIEROBLIQUE
Represents the "Courier-Oblique" font- See Also:
- Constant Field Values
-
COURIERBOLDOBLIQUE
public static final int COURIERBOLDOBLIQUE
Represents the "Courier-BoldOblique" font- See Also:
- Constant Field Values
-
SYMBOL
public static final int SYMBOL
Represents the "Symbol" font- See Also:
- Constant Field Values
-
ZAPFDINGBATS
public static final int ZAPFDINGBATS
Represents the "ZapfDingbats" font. Note that the characters in the font are defined by the correct Unicode codepoints, rather than just numbers 1 to 255. See the filedocs/map-zapf.pdfthat came with the distribution to see what these codepoints are.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
StandardFont
public StandardFont(int fonttype)
Create a new font of the specified type.- Parameters:
fonttype- which font to create - one ofTIMES,COURIERBOLDetc.
-
-
Method Detail
-
getType
public int getType()
Return the type of font, as supplied to the StandardFont constructor- Since:
- 2.14.1
-
getBaseName
public String getBaseName()
Description copied from class:PDFFontReturn the Base Font Name for this font.- Overrides:
getBaseNamein classPDFFont
-
getDefaultLeading
public float getDefaultLeading()
Description copied from class:PDFFontGet 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 thePDFStyleclass for more information.- Specified by:
getDefaultLeadingin classPDFFont
-
getStrikeoutThickness
public float getStrikeoutThickness()
Description copied from class:PDFFontGet the strikeout thickness, as a proportion of the font size.- Specified by:
getStrikeoutThicknessin classPDFFont
-
getStrikeoutPosition
public float getStrikeoutPosition()
Description copied from class:PDFFontGet the strikeout position, as a proportion of the font size. The value is the distance from the baseline to the center of the strikeout, and shuold be positive.- Specified by:
getStrikeoutPositionin classPDFFont
-
getSubscriptSize
public float getSubscriptSize()
Description copied from class:PDFFontGet 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.
- Specified by:
getSubscriptSizein classPDFFont
-
getSuperscriptPosition
public float getSuperscriptPosition()
Description copied from class:PDFFontGet 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.
- Specified by:
getSuperscriptPositionin classPDFFont
-
getSubscriptPosition
public float getSubscriptPosition()
Description copied from class:PDFFontGet 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.
- Specified by:
getSubscriptPositionin classPDFFont
-
getUnderlineThickness
public float getUnderlineThickness()
Description copied from class:PDFFontGet the underline thickness, as a proportion of the font size.- Specified by:
getUnderlineThicknessin classPDFFont
-
getUnderlinePosition
public float getUnderlinePosition()
Description copied from class:PDFFontGet the underline position, as a proportion of the font size. Like thegetDescender()method, the returned value is almost always negative, indicating below the baseline. The distance is from the baseline to the center of the underline.- Specified by:
getUnderlinePositionin classPDFFont
-
getAscender
public float getAscender()
Description copied from class:PDFFontGet the Ascender for the font (the maximum height above the baseline the font extends), as a proportion of the point size. The exact source of of this value is undefined except for OpenTypeFonts, where it comes from the "hhea.ascender" value normally, or the from "OS2.sTypoAscender" flag if the USE_TYPO_METRICS flag is set.- Specified by:
getAscenderin classPDFFont
-
getDescender
public float getDescender()
Description copied from class:PDFFontGet the Descender for the font (the maximum height below the baseline the font extends), as a proportion of the point size. The returned value is usually negative. The exact source of this value is undefined except for OpenTypeFonts, where it comes from the "hhea.descender" value normally, or the from "OS2.sTypoDescender" flag if the USE_TYPO_METRICS flag is set.- Specified by:
getDescenderin classPDFFont
-
getXHeight
public float getXHeight()
Description copied from class:PDFFontGet the X-Height of the font - normally the height of a lower-case 'x' character.- Specified by:
getXHeightin classPDFFont
-
getCapHeight
public float getCapHeight()
Description copied from class:PDFFontGet the Cap-Height of the font - normally the height of an upper-case 'O' character- Specified by:
getCapHeightin classPDFFont
-
isItalic
public boolean isItalic()
Description copied from class:PDFFontReturn true if the font is italic
-
isBold
public boolean isBold()
Description copied from class:PDFFontReturn true if the font is bold
-
isSerif
public boolean isSerif()
Description copied from class:PDFFontReturn true if the font is serif
-
isMonospace
public boolean isMonospace()
Description copied from class:PDFFontReturn true if every character has the same width (like Courier), false if every character is potentially a different width (like Times-Roman)- Specified by:
isMonospacein classPDFFont
-
versionItalic
public PDFFont versionItalic()
Description copied from class:PDFFontReturn an italic version of the current font, if available. By default this just returns this font.- Overrides:
versionItalicin classPDFFont
-
versionBold
public PDFFont versionBold()
Description copied from class:PDFFontReturn a bold version of the current font, if available. By default this just returns this font.- Overrides:
versionBoldin classPDFFont
-
versionNonItalic
public PDFFont versionNonItalic()
Description copied from class:PDFFontReturn a non-italic version of the current font, if available. By default this just returns this font.- Overrides:
versionNonItalicin classPDFFont
-
versionNonBold
public PDFFont versionNonBold()
Description copied from class:PDFFontReturn a non-bold version of the current font, if available. By default this just returns this font.- Overrides:
versionNonBoldin classPDFFont
-
versionRegular
public PDFFont versionRegular()
Description copied from class:PDFFontReturn a non-bold, non-italic version of the current font, if available. By default this just returns this font.- Overrides:
versionRegularin classPDFFont
-
getDefinedCodepoints
public BitSet getDefinedCodepoints()
Description copied from class:PDFFontReturn read-only BitSet containing all the Unicode codepoints defined in this font- Specified by:
getDefinedCodepointsin classPDFFont
-
toString
public String toString()
-
-