Package com.itextpdf.io.font
Class Type1Font
- java.lang.Object
-
- com.itextpdf.io.font.FontProgram
-
- com.itextpdf.io.font.Type1Font
-
- Direct Known Subclasses:
DocType1Font
public class Type1Font extends FontProgram
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
characterSet
private Type1Parser
fontParser
private byte[]
fontStreamBytes
private int[]
fontStreamLengths
private java.util.Map<java.lang.Long,java.lang.Integer>
kernPairs
Represents the section KernPairs in the AFM file.private static int[]
PFB_TYPES
Types of records in a PFB file.-
Fields inherited from class com.itextpdf.io.font.FontProgram
avgWidth, codeToGlyph, DEFAULT_WIDTH, encodingScheme, fontIdentification, fontMetrics, fontNames, HORIZONTAL_SCALING_FACTOR, isFontSpecific, registry, unicodeToGlyph, UNITS_NORMALIZATION
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static Type1Font
createStandardFont(java.lang.String name)
java.lang.String
getCharacterSet()
byte[]
getFontStreamBytes()
int[]
getFontStreamLengths()
Glyph
getGlyph(java.lang.String name)
Find glyph by glyph name.int
getKerning(Glyph first, Glyph second)
Gets the kerning between two glyphs.int
getPdfFontFlags()
boolean
hasKernPairs()
Checks if the font has any kerning pairs.void
initializeGlyphs(FontEncoding fontEncoding)
Fills missing character codes incodeToGlyph
map.boolean
isBuiltInFont()
boolean
isBuiltWith(java.lang.String fontProgram)
Checks whether theFontProgram
was built with corresponding fontName.protected void
process()
boolean
setKerning(int first, int second, int kern)
Sets the kerning between two Unicode chars.-
Methods inherited from class com.itextpdf.io.font.FontProgram
convertGlyphSpaceToTextSpace, convertGlyphSpaceToTextSpace, convertGlyphSpaceToTextSpace, convertTextSpaceToGlyphSpace, countOfGlyphs, fixSpaceIssue, getAvgWidth, getCharBBox, getFontIdentification, getFontMetrics, getFontNames, getGlyph, getGlyphByCode, getKerning, getRegistry, getWidth, isFontSpecific, setBbox, setBold, setCapHeight, setFixedPitch, setFontFamily, setFontName, setFontStretch, setFontWeight, setItalicAngle, setRegistry, setStemH, setStemV, setTypoAscender, setTypoDescender, setXHeight, toString, trimFontStyle
-
-
-
-
Field Detail
-
fontParser
private Type1Parser fontParser
-
characterSet
private java.lang.String characterSet
-
kernPairs
private java.util.Map<java.lang.Long,java.lang.Integer> kernPairs
Represents the section KernPairs in the AFM file. Key is uni1 << 32 + uni2. Value is kerning value.
-
PFB_TYPES
private static final int[] PFB_TYPES
Types of records in a PFB file. ASCII is 1 and BINARY is 2. They have to appear in the PFB file in this sequence.
-
fontStreamBytes
private byte[] fontStreamBytes
-
fontStreamLengths
private int[] fontStreamLengths
-
-
Method Detail
-
createStandardFont
protected static Type1Font createStandardFont(java.lang.String name) throws java.io.IOException
- Throws:
java.io.IOException
-
initializeGlyphs
public void initializeGlyphs(FontEncoding fontEncoding)
Fills missing character codes incodeToGlyph
map.- Parameters:
fontEncoding
- to be used to map unicode values to character codes.
-
isBuiltInFont
public boolean isBuiltInFont()
-
getPdfFontFlags
public int getPdfFontFlags()
- Specified by:
getPdfFontFlags
in classFontProgram
-
getCharacterSet
public java.lang.String getCharacterSet()
-
hasKernPairs
public boolean hasKernPairs()
Checks if the font has any kerning pairs.- Overrides:
hasKernPairs
in classFontProgram
- Returns:
true
if the font has any kerning pairs.
-
getKerning
public int getKerning(Glyph first, Glyph second)
Description copied from class:FontProgram
Gets the kerning between two glyphs.- Specified by:
getKerning
in classFontProgram
- Parameters:
first
- the first glyphsecond
- the second glyph- Returns:
- the kerning to be applied
-
setKerning
public boolean setKerning(int first, int second, int kern)
Sets the kerning between two Unicode chars.- Parameters:
first
- the first unicode char.second
- the second unicode char.kern
- the kerning to apply in normalized 1000 units.- Returns:
true
if the kerning was applied,false
otherwise.
-
getGlyph
public Glyph getGlyph(java.lang.String name)
Find glyph by glyph name.- Parameters:
name
- Glyph name- Returns:
- Glyph instance if found, otherwise null.
-
getFontStreamBytes
public byte[] getFontStreamBytes()
-
getFontStreamLengths
public int[] getFontStreamLengths()
-
isBuiltWith
public boolean isBuiltWith(java.lang.String fontProgram)
Description copied from class:FontProgram
Checks whether theFontProgram
was built with corresponding fontName. Default value is false unless overridden.- Overrides:
isBuiltWith
in classFontProgram
- Parameters:
fontProgram
- a font name or path to a font program- Returns:
- true, if the FontProgram was built with the fontProgram. Otherwise false.
-
process
protected void process() throws java.io.IOException
- Throws:
java.io.IOException
-
-