Package org.apache.fontbox.type1
Class Type1Font
- java.lang.Object
-
- org.apache.fontbox.type1.Type1Font
-
- All Implemented Interfaces:
EncodedFont
,FontBoxFont
,Type1CharStringReader
public final class Type1Font extends java.lang.Object implements Type1CharStringReader, EncodedFont, FontBoxFont
Represents an Adobe Type 1 (.pfb) font. Thread safe.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) int
blueFuzz
(package private) float
blueScale
(package private) int
blueShift
(package private) java.util.List<java.lang.Number>
blueValues
private java.util.Map<java.lang.String,Type1CharString>
charStringCache
(package private) java.util.Map<java.lang.String,byte[]>
charstrings
(package private) Encoding
encoding
(package private) java.util.List<java.lang.Number>
familyBlues
(package private) java.lang.String
familyName
(package private) java.util.List<java.lang.Number>
familyOtherBlues
(package private) java.util.List<java.lang.Number>
fontBBox
(package private) java.lang.String
fontID
(package private) java.util.List<java.lang.Number>
fontMatrix
(package private) java.lang.String
fontName
(package private) int
fontType
(package private) boolean
forceBold
(package private) java.lang.String
fullName
(package private) boolean
isFixedPitch
(package private) float
italicAngle
(package private) int
languageGroup
(package private) java.lang.String
notice
(package private) java.util.List<java.lang.Number>
otherBlues
(package private) int
paintType
private byte[]
segment1
private byte[]
segment2
(package private) java.util.List<java.lang.Number>
stdHW
(package private) java.util.List<java.lang.Number>
stdVW
(package private) java.util.List<java.lang.Number>
stemSnapH
(package private) java.util.List<java.lang.Number>
stemSnapV
(package private) float
strokeWidth
(package private) java.util.List<byte[]>
subrs
(package private) float
underlinePosition
(package private) float
underlineThickness
(package private) int
uniqueID
(package private) java.lang.String
version
(package private) java.lang.String
weight
-
Constructor Summary
Constructors Constructor Description Type1Font(byte[] segment1, byte[] segment2)
Constructs a new Type1Font, called by Type1Parser.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Type1Font
createWithPFB(byte[] pfbBytes)
Constructs a new Type1Font object from a .pfb stream.static Type1Font
createWithPFB(java.io.InputStream pfbStream)
Constructs a new Type1Font object from a .pfb stream.static Type1Font
createWithSegments(byte[] segment1, byte[] segment2)
Constructs a new Type1Font object from two header-less .pfb segments.byte[]
getASCIISegment()
Returns the ASCII segment.byte[]
getBinarySegment()
Returns the binary segment.int
getBlueFuzz()
Returns the blue fuzz.float
getBlueScale()
Returns the blue scale.int
getBlueShift()
Returns the blue shift.java.util.List<java.lang.Number>
getBlueValues()
Returns the blues values.java.util.Map<java.lang.String,byte[]>
getCharStringsDict()
Returns the /CharStrings dictionary as raw bytes.Encoding
getEncoding()
Returns the Encoding, if present.java.util.List<java.lang.Number>
getFamilyBlues()
Returns the family blues values.java.lang.String
getFamilyName()
Returns the family name.java.util.List<java.lang.Number>
getFamilyOtherBlues()
Returns the other family blues values.BoundingBox
getFontBBox()
Returns the font bounding box.java.lang.String
getFontID()
Returns the font ID.java.util.List<java.lang.Number>
getFontMatrix()
Returns the font matrix.java.lang.String
getFontName()
Returns the font name.int
getFontType()
Returns the font type.java.lang.String
getFullName()
Returns the full name.float
getItalicAngle()
Returns the italic angle.int
getLanguageGroup()
Returns the language group.java.lang.String
getName()
The PostScript name of the font.java.lang.String
getNotice()
Returns the notice.java.util.List<java.lang.Number>
getOtherBlues()
Returns the other blues values.int
getPaintType()
Returns the paint type.java.awt.geom.GeneralPath
getPath(java.lang.String name)
Returns the path for the character with the given name.java.util.List<java.lang.Number>
getStdHW()
Returns the StdHW value.java.util.List<java.lang.Number>
getStdVW()
Returns the StdVW value.java.util.List<java.lang.Number>
getStemSnapH()
Returns the StemSnapH value.java.util.List<java.lang.Number>
getStemSnapV()
Returns the StemSnapV value.float
getStrokeWidth()
Returns the stroke width.java.util.List<byte[]>
getSubrsArray()
Returns the /Subrs array as raw bytes.Type1CharString
getType1CharString(java.lang.String name)
Returns the Type 1 CharString for the character with the given name.float
getUnderlinePosition()
Returns the underline positionfloat
getUnderlineThickness()
Returns the underline thickness.int
getUniqueID()
Returns unique ID.java.lang.String
getVersion()
Returns the version.java.lang.String
getWeight()
Returns the weight.float
getWidth(java.lang.String name)
Returns the advance width for the character with the given name.boolean
hasGlyph(java.lang.String name)
Returns true if the font contains the given glyph.boolean
isFixedPitch()
Determines if the font has a fixed pitch.boolean
isForceBold()
Determines if the font is bold.java.lang.String
toString()
-
-
-
Field Detail
-
fontName
java.lang.String fontName
-
encoding
Encoding encoding
-
paintType
int paintType
-
fontType
int fontType
-
fontMatrix
java.util.List<java.lang.Number> fontMatrix
-
fontBBox
java.util.List<java.lang.Number> fontBBox
-
uniqueID
int uniqueID
-
strokeWidth
float strokeWidth
-
fontID
java.lang.String fontID
-
version
java.lang.String version
-
notice
java.lang.String notice
-
fullName
java.lang.String fullName
-
familyName
java.lang.String familyName
-
weight
java.lang.String weight
-
italicAngle
float italicAngle
-
isFixedPitch
boolean isFixedPitch
-
underlinePosition
float underlinePosition
-
underlineThickness
float underlineThickness
-
blueValues
java.util.List<java.lang.Number> blueValues
-
otherBlues
java.util.List<java.lang.Number> otherBlues
-
familyBlues
java.util.List<java.lang.Number> familyBlues
-
familyOtherBlues
java.util.List<java.lang.Number> familyOtherBlues
-
blueScale
float blueScale
-
blueShift
int blueShift
-
blueFuzz
int blueFuzz
-
stdHW
java.util.List<java.lang.Number> stdHW
-
stdVW
java.util.List<java.lang.Number> stdVW
-
stemSnapH
java.util.List<java.lang.Number> stemSnapH
-
stemSnapV
java.util.List<java.lang.Number> stemSnapV
-
forceBold
boolean forceBold
-
languageGroup
int languageGroup
-
subrs
final java.util.List<byte[]> subrs
-
charstrings
final java.util.Map<java.lang.String,byte[]> charstrings
-
charStringCache
private final java.util.Map<java.lang.String,Type1CharString> charStringCache
-
segment1
private final byte[] segment1
-
segment2
private final byte[] segment2
-
-
Method Detail
-
createWithPFB
public static Type1Font createWithPFB(java.io.InputStream pfbStream) throws java.io.IOException
Constructs a new Type1Font object from a .pfb stream.- Parameters:
pfbStream
- .pfb input stream, including headers- Returns:
- a type1 font
- Throws:
java.io.IOException
- if something went wrong
-
createWithPFB
public static Type1Font createWithPFB(byte[] pfbBytes) throws java.io.IOException
Constructs a new Type1Font object from a .pfb stream.- Parameters:
pfbBytes
- .pfb data, including headers- Returns:
- a type1 font
- Throws:
java.io.IOException
- if something went wrong
-
createWithSegments
public static Type1Font createWithSegments(byte[] segment1, byte[] segment2) throws java.io.IOException
Constructs a new Type1Font object from two header-less .pfb segments.- Parameters:
segment1
- The first segment, without headersegment2
- The second segment, without header- Returns:
- A new Type1Font instance
- Throws:
java.io.IOException
- if something went wrong
-
getSubrsArray
public java.util.List<byte[]> getSubrsArray()
Returns the /Subrs array as raw bytes.- Returns:
- Type 1 char string bytes
-
getCharStringsDict
public java.util.Map<java.lang.String,byte[]> getCharStringsDict()
Returns the /CharStrings dictionary as raw bytes.- Returns:
- Type 1 char string bytes
-
getName
public java.lang.String getName()
Description copied from interface:FontBoxFont
The PostScript name of the font.- Specified by:
getName
in interfaceFontBoxFont
-
getPath
public java.awt.geom.GeneralPath getPath(java.lang.String name) throws java.io.IOException
Description copied from interface:FontBoxFont
Returns the path for the character with the given name.- Specified by:
getPath
in interfaceFontBoxFont
- Returns:
- glyph path
- Throws:
java.io.IOException
- if the path could not be read
-
getWidth
public float getWidth(java.lang.String name) throws java.io.IOException
Description copied from interface:FontBoxFont
Returns the advance width for the character with the given name.- Specified by:
getWidth
in interfaceFontBoxFont
- Returns:
- glyph advance width
- Throws:
java.io.IOException
- if the path could not be read
-
hasGlyph
public boolean hasGlyph(java.lang.String name)
Description copied from interface:FontBoxFont
Returns true if the font contains the given glyph.- Specified by:
hasGlyph
in interfaceFontBoxFont
- Parameters:
name
- PostScript glyph name
-
getType1CharString
public Type1CharString getType1CharString(java.lang.String name) throws java.io.IOException
Description copied from interface:Type1CharStringReader
Returns the Type 1 CharString for the character with the given name.- Specified by:
getType1CharString
in interfaceType1CharStringReader
- Returns:
- Type 1 CharString
- Throws:
java.io.IOException
- if something went wrong
-
getFontName
public java.lang.String getFontName()
Returns the font name.- Returns:
- the font name
-
getEncoding
public Encoding getEncoding()
Returns the Encoding, if present.- Specified by:
getEncoding
in interfaceEncodedFont
- Returns:
- the encoding or null
-
getPaintType
public int getPaintType()
Returns the paint type.- Returns:
- the paint type
-
getFontType
public int getFontType()
Returns the font type.- Returns:
- the font type
-
getFontMatrix
public java.util.List<java.lang.Number> getFontMatrix()
Returns the font matrix.- Specified by:
getFontMatrix
in interfaceFontBoxFont
- Returns:
- the font matrix
-
getFontBBox
public BoundingBox getFontBBox()
Returns the font bounding box.- Specified by:
getFontBBox
in interfaceFontBoxFont
- Returns:
- the font bounding box
-
getUniqueID
public int getUniqueID()
Returns unique ID.- Returns:
- the unique ID
-
getStrokeWidth
public float getStrokeWidth()
Returns the stroke width.- Returns:
- the stroke width
-
getFontID
public java.lang.String getFontID()
Returns the font ID.- Returns:
- the font ID
-
getVersion
public java.lang.String getVersion()
Returns the version.- Returns:
- the version
-
getNotice
public java.lang.String getNotice()
Returns the notice.- Returns:
- the notice
-
getFullName
public java.lang.String getFullName()
Returns the full name.- Returns:
- the full name
-
getFamilyName
public java.lang.String getFamilyName()
Returns the family name.- Returns:
- the family name
-
getWeight
public java.lang.String getWeight()
Returns the weight.- Returns:
- the weight
-
getItalicAngle
public float getItalicAngle()
Returns the italic angle.- Returns:
- the italic angle
-
isFixedPitch
public boolean isFixedPitch()
Determines if the font has a fixed pitch.- Returns:
- true if the font has a fixed pitch
-
getUnderlinePosition
public float getUnderlinePosition()
Returns the underline position- Returns:
- the underline position
-
getUnderlineThickness
public float getUnderlineThickness()
Returns the underline thickness.- Returns:
- the underline thickness
-
getBlueValues
public java.util.List<java.lang.Number> getBlueValues()
Returns the blues values.- Returns:
- the blues values
-
getOtherBlues
public java.util.List<java.lang.Number> getOtherBlues()
Returns the other blues values.- Returns:
- the other blues values
-
getFamilyBlues
public java.util.List<java.lang.Number> getFamilyBlues()
Returns the family blues values.- Returns:
- the family blues values
-
getFamilyOtherBlues
public java.util.List<java.lang.Number> getFamilyOtherBlues()
Returns the other family blues values.- Returns:
- the other family blues values
-
getBlueScale
public float getBlueScale()
Returns the blue scale.- Returns:
- the blue scale
-
getBlueShift
public int getBlueShift()
Returns the blue shift.- Returns:
- the blue shift
-
getBlueFuzz
public int getBlueFuzz()
Returns the blue fuzz.- Returns:
- the blue fuzz
-
getStdHW
public java.util.List<java.lang.Number> getStdHW()
Returns the StdHW value.- Returns:
- the StdHW value
-
getStdVW
public java.util.List<java.lang.Number> getStdVW()
Returns the StdVW value.- Returns:
- the StdVW value
-
getStemSnapH
public java.util.List<java.lang.Number> getStemSnapH()
Returns the StemSnapH value.- Returns:
- the StemSnapH value
-
getStemSnapV
public java.util.List<java.lang.Number> getStemSnapV()
Returns the StemSnapV value.- Returns:
- the StemSnapV value
-
isForceBold
public boolean isForceBold()
Determines if the font is bold.- Returns:
- true if the font is bold
-
getLanguageGroup
public int getLanguageGroup()
Returns the language group.- Returns:
- the language group
-
getASCIISegment
public byte[] getASCIISegment()
Returns the ASCII segment.- Returns:
- the ASCII segment.
-
getBinarySegment
public byte[] getBinarySegment()
Returns the binary segment.- Returns:
- the binary segment.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-