Package org.apache.pdfbox.pdmodel.font
Class PDSimpleFont
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.font.PDFont
-
- org.apache.pdfbox.pdmodel.font.PDSimpleFont
-
- All Implemented Interfaces:
COSObjectable,PDFontLike
- Direct Known Subclasses:
PDTrueTypeFont,PDType1CFont,PDType1Font,PDType3Font
public abstract class PDSimpleFont extends PDFont
A simple font. Simple fonts use a PostScript encoding vector.
-
-
Field Summary
Fields Modifier and Type Field Description protected Encodingencodingprotected GlyphListglyphListprivate java.lang.BooleanisSymbolicprivate static org.apache.commons.logging.LogLOGprivate java.util.Set<java.lang.Integer>noUnicode-
Fields inherited from class org.apache.pdfbox.pdmodel.font.PDFont
DEFAULT_FONT_MATRIX, dict
-
-
Constructor Summary
Constructors Constructor Description PDSimpleFont()Constructor for embedding.PDSimpleFont(COSDictionary fontDictionary)Constructor.PDSimpleFont(Standard14Fonts.FontName baseFont)Constructor for Standard 14.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddToSubset(int codePoint)Adds the given Unicode point to the subset.private voidassignGlyphList(Standard14Fonts.FontName fontName)EncodinggetEncoding()Returns the Encoding.abstract FontBoxFontgetFontBoxFont()Returns the embedded or system font used for rendering.GlyphListgetGlyphList()Returns the glyphlist.abstract java.awt.geom.GeneralPathgetPath(java.lang.String name)Returns the path for the character with the given name.protected floatgetStandard14Width(int code)Returns the glyph width from the AFM if this is a Standard 14 font.protected java.lang.BooleangetSymbolicFlag()Returns the value of the symbolic flag, allowing for the fact that the result may be indeterminate.booleanhasExplicitWidth(int code)Returns true if the Font dictionary specifies an explicit width for the given glyph.abstract booleanhasGlyph(java.lang.String name)Returns true if the font contains the character with the given name.protected java.lang.BooleanisFontSymbolic()Internal implementation of isSymbolic, allowing for the fact that the result may be indeterminate.protected booleanisNonZeroBoundingBox(PDRectangle bbox)booleanisStandard14()Returns true if this font is one of the "Standard 14" fonts and receives special handling.booleanisSymbolic()Returns true if the font is a symbolic (that is, it does not use the Adobe Standard Roman character set).booleanisVertical()Returns true if the font uses vertical writing mode.protected voidreadEncoding()Reads the Encoding from the Font dictionary or the embedded or substituted font file.protected abstract EncodingreadEncodingFromFont()Called by readEncoding() if the encoding needs to be extracted from the font file.voidsubset()Replaces this font with a subset containing only the given Unicode characters.java.lang.StringtoUnicode(int code)Returns the Unicode character sequence which corresponds to the given character code.java.lang.StringtoUnicode(int code, GlyphList customGlyphList)Returns the Unicode character sequence which corresponds to the given character code.booleanwillBeSubset()Returns true if this font will be subset when embedded.-
Methods inherited from class org.apache.pdfbox.pdmodel.font.PDFont
encode, encode, equals, getAverageFontWidth, getCOSObject, getDisplacement, getFontDescriptor, getFontMatrix, getPositionVector, getSpaceWidth, getStandard14AFM, getStringWidth, getSubType, getToUnicodeCMap, getType, getWidth, getWidths, hashCode, readCMap, readCode, setFontDescriptor, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.pdfbox.pdmodel.font.PDFontLike
getBoundingBox, getHeight, getName, getWidthFromFont, isDamaged, isEmbedded
-
-
-
-
Constructor Detail
-
PDSimpleFont
PDSimpleFont()
Constructor for embedding.
-
PDSimpleFont
PDSimpleFont(Standard14Fonts.FontName baseFont)
Constructor for Standard 14.
-
PDSimpleFont
PDSimpleFont(COSDictionary fontDictionary)
Constructor.- Parameters:
fontDictionary- Font dictionary.
-
-
Method Detail
-
readEncoding
protected void readEncoding() throws java.io.IOExceptionReads the Encoding from the Font dictionary or the embedded or substituted font file. Must be called at the end of any subclass constructors.- Throws:
java.io.IOException- if the font file could not be read
-
readEncodingFromFont
protected abstract Encoding readEncodingFromFont() throws java.io.IOException
Called by readEncoding() if the encoding needs to be extracted from the font file.- Returns:
- encoding of the font
- Throws:
java.io.IOException- if the font file could not be read.
-
getEncoding
public Encoding getEncoding()
Returns the Encoding.- Returns:
- encoding
-
getGlyphList
public GlyphList getGlyphList()
Returns the glyphlist.- Returns:
- the glyphlist
-
isSymbolic
public final boolean isSymbolic()
Returns true if the font is a symbolic (that is, it does not use the Adobe Standard Roman character set).- Returns:
- true if the font is a symbolic
-
isFontSymbolic
protected java.lang.Boolean isFontSymbolic()
Internal implementation of isSymbolic, allowing for the fact that the result may be indeterminate.- Returns:
- true if isSymbolic
-
getSymbolicFlag
protected final java.lang.Boolean getSymbolicFlag()
Returns the value of the symbolic flag, allowing for the fact that the result may be indeterminate.- Returns:
- the value of the isSymbolic flag form the font descriptor
-
toUnicode
public java.lang.String toUnicode(int code)
Description copied from class:PDFontReturns the Unicode character sequence which corresponds to the given character code.
-
toUnicode
public java.lang.String toUnicode(int code, GlyphList customGlyphList)Description copied from class:PDFontReturns the Unicode character sequence which corresponds to the given character code.
-
isVertical
public boolean isVertical()
Description copied from class:PDFontReturns true if the font uses vertical writing mode.- Specified by:
isVerticalin classPDFont- Returns:
- true if the font uses vertical writing mode
-
getStandard14Width
protected final float getStandard14Width(int code)
Description copied from class:PDFontReturns the glyph width from the AFM if this is a Standard 14 font.- Specified by:
getStandard14Widthin classPDFont- Parameters:
code- character code- Returns:
- width in 1/1000 text space
-
isStandard14
public boolean isStandard14()
Description copied from class:PDFontReturns true if this font is one of the "Standard 14" fonts and receives special handling.- Overrides:
isStandard14in classPDFont- Returns:
- true if this font is one of the "Standard 14" fonts
-
isNonZeroBoundingBox
protected boolean isNonZeroBoundingBox(PDRectangle bbox)
-
getPath
public abstract java.awt.geom.GeneralPath getPath(java.lang.String name) throws java.io.IOExceptionReturns the path for the character with the given name. For some fonts, GIDs may be used instead of names when calling this method. *- Parameters:
name- glyph name- Returns:
- glyph path of the character with the given name
- Throws:
java.io.IOException- if the path could not be read
-
hasGlyph
public abstract boolean hasGlyph(java.lang.String name) throws java.io.IOExceptionReturns true if the font contains the character with the given name.- Parameters:
name- glyph name- Returns:
- true if the font contains the character with the given name
- Throws:
java.io.IOException- if the path could not be read
-
getFontBoxFont
public abstract FontBoxFont getFontBoxFont()
Returns the embedded or system font used for rendering. This is never null.- Returns:
- the embedded or system font used for rendering
-
addToSubset
public void addToSubset(int codePoint)
Description copied from class:PDFontAdds the given Unicode point to the subset.- Specified by:
addToSubsetin classPDFont- Parameters:
codePoint- Unicode code point
-
subset
public void subset() throws java.io.IOExceptionDescription copied from class:PDFontReplaces this font with a subset containing only the given Unicode characters.
-
willBeSubset
public boolean willBeSubset()
Description copied from class:PDFontReturns true if this font will be subset when embedded.- Specified by:
willBeSubsetin classPDFont- Returns:
- true if this font will be subset when embedded
-
hasExplicitWidth
public boolean hasExplicitWidth(int code) throws java.io.IOExceptionDescription copied from interface:PDFontLikeReturns true if the Font dictionary specifies an explicit width for the given glyph. This includes Width, W but not default widths entries.- Parameters:
code- character code- Returns:
- true if the Font dictionary specifies an explicit width for the given glyph
- Throws:
java.io.IOException- if the font could not be read
-
assignGlyphList
private void assignGlyphList(Standard14Fonts.FontName fontName)
-
-