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 Object
implements Type1CharStringReader, EncodedFont, FontBoxFont
Represents an Adobe Type 1 (.pfb) font. Thread safe.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) int
(package private) float
(package private) int
private final Map<String,
Type1CharString> (package private) Encoding
(package private) String
(package private) String
(package private) String
(package private) int
(package private) boolean
(package private) String
(package private) boolean
(package private) float
(package private) int
(package private) String
(package private) int
private final byte[]
private final byte[]
(package private) float
(package private) final List<byte[]>
(package private) float
(package private) float
(package private) int
(package private) String
(package private) String
-
Constructor Summary
ConstructorsConstructorDescriptionType1Font
(byte[] segment1, byte[] segment2) Constructs a new Type1Font, called by Type1Parser. -
Method Summary
Modifier and TypeMethodDescriptionstatic Type1Font
createWithPFB
(byte[] pfbBytes) Constructs a new Type1Font object from a .pfb stream.static Type1Font
createWithPFB
(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[]
Returns the ASCII segment.byte[]
Returns the binary segment.int
Returns the blue fuzz.float
Returns the blue scale.int
Returns the blue shift.Returns the blues values.Returns the /CharStrings dictionary as raw bytes.Returns the Encoding, if present.Returns the family blues values.Returns the family name.Returns the other family blues values.Returns the font bounding box.Returns the font ID.Returns the font matrix.Returns the font name.int
Returns the font type.Returns the full name.float
Returns the italic angle.int
Returns the language group.getName()
The PostScript name of the font.Returns the notice.Returns the other blues values.int
Returns the paint type.Returns the path for the character with the given name.getStdHW()
Returns the StdHW value.getStdVW()
Returns the StdVW value.Returns the StemSnapH value.Returns the StemSnapV value.float
Returns the stroke width.List<byte[]>
Returns the /Subrs array as raw bytes.getType1CharString
(String name) Returns the Type 1 CharString for the character with the given name.float
Returns the underline positionfloat
Returns the underline thickness.int
Returns unique ID.Returns the version.Returns the weight.float
Returns the advance width for the character with the given name.boolean
Returns true if the font contains the given glyph.boolean
Determines if the font has a fixed pitch.boolean
Determines if the font is bold.toString()
-
Field Details
-
fontName
String fontName -
encoding
Encoding encoding -
paintType
int paintType -
fontType
int fontType -
fontMatrix
-
fontBBox
-
uniqueID
int uniqueID -
strokeWidth
float strokeWidth -
fontID
String fontID -
version
String version -
notice
String notice -
fullName
String fullName -
familyName
String familyName -
weight
String weight -
italicAngle
float italicAngle -
isFixedPitch
boolean isFixedPitch -
underlinePosition
float underlinePosition -
underlineThickness
float underlineThickness -
blueValues
-
otherBlues
-
familyBlues
-
familyOtherBlues
-
blueScale
float blueScale -
blueShift
int blueShift -
blueFuzz
int blueFuzz -
stdHW
-
stdVW
-
stemSnapH
-
stemSnapV
-
forceBold
boolean forceBold -
languageGroup
int languageGroup -
subrs
-
charstrings
-
charStringCache
-
segment1
private final byte[] segment1 -
segment2
private final byte[] segment2
-
-
Constructor Details
-
Type1Font
Type1Font(byte[] segment1, byte[] segment2) Constructs a new Type1Font, called by Type1Parser.
-
-
Method Details
-
createWithPFB
Constructs a new Type1Font object from a .pfb stream.- Parameters:
pfbStream
- .pfb input stream, including headers- Returns:
- a type1 font
- Throws:
IOException
- if something went wrong
-
createWithPFB
Constructs a new Type1Font object from a .pfb stream.- Parameters:
pfbBytes
- .pfb data, including headers- Returns:
- a type1 font
- Throws:
IOException
- if something went wrong
-
createWithSegments
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:
IOException
- if something went wrong
-
getSubrsArray
Returns the /Subrs array as raw bytes.- Returns:
- Type 1 char string bytes
-
getCharStringsDict
Returns the /CharStrings dictionary as raw bytes.- Returns:
- Type 1 char string bytes
-
getName
Description copied from interface:FontBoxFont
The PostScript name of the font.- Specified by:
getName
in interfaceFontBoxFont
-
getPath
Description copied from interface:FontBoxFont
Returns the path for the character with the given name.- Specified by:
getPath
in interfaceFontBoxFont
- Returns:
- glyph path
- Throws:
IOException
- if the path could not be read
-
getWidth
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:
IOException
- if the path could not be read
-
hasGlyph
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
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:
IOException
- if something went wrong
-
getFontName
Returns the font name.- Returns:
- the font name
-
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
Returns the font matrix.- Specified by:
getFontMatrix
in interfaceFontBoxFont
- Returns:
- the font matrix
-
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
Returns the font ID.- Returns:
- the font ID
-
getVersion
Returns the version.- Returns:
- the version
-
getNotice
Returns the notice.- Returns:
- the notice
-
getFullName
Returns the full name.- Returns:
- the full name
-
getFamilyName
Returns the family name.- Returns:
- the family name
-
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
Returns the blues values.- Returns:
- the blues values
-
getOtherBlues
Returns the other blues values.- Returns:
- the other blues values
-
getFamilyBlues
Returns the family blues values.- Returns:
- the family blues values
-
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
Returns the StdHW value.- Returns:
- the StdHW value
-
getStdVW
Returns the StdVW value.- Returns:
- the StdVW value
-
getStemSnapH
Returns the StemSnapH value.- Returns:
- the StemSnapH value
-
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
-