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.StringcharacterSetprivate Type1ParserfontParserprivate byte[]fontStreamBytesprivate int[]fontStreamLengthsprivate java.util.Map<java.lang.Long,java.lang.Integer>kernPairsRepresents the section KernPairs in the AFM file.private static int[]PFB_TYPESTypes 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 Type1FontcreateStandardFont(java.lang.String name)java.lang.StringgetCharacterSet()byte[]getFontStreamBytes()int[]getFontStreamLengths()GlyphgetGlyph(java.lang.String name)Find glyph by glyph name.intgetKerning(Glyph first, Glyph second)Gets the kerning between two glyphs.intgetPdfFontFlags()booleanhasKernPairs()Checks if the font has any kerning pairs.voidinitializeGlyphs(FontEncoding fontEncoding)Fills missing character codes incodeToGlyphmap.booleanisBuiltInFont()booleanisBuiltWith(java.lang.String fontProgram)Checks whether theFontProgramwas built with corresponding fontName.protected voidprocess()booleansetKerning(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 incodeToGlyphmap.- Parameters:
fontEncoding- to be used to map unicode values to character codes.
-
isBuiltInFont
public boolean isBuiltInFont()
-
getPdfFontFlags
public int getPdfFontFlags()
- Specified by:
getPdfFontFlagsin classFontProgram
-
getCharacterSet
public java.lang.String getCharacterSet()
-
hasKernPairs
public boolean hasKernPairs()
Checks if the font has any kerning pairs.- Overrides:
hasKernPairsin classFontProgram- Returns:
trueif the font has any kerning pairs.
-
getKerning
public int getKerning(Glyph first, Glyph second)
Description copied from class:FontProgramGets the kerning between two glyphs.- Specified by:
getKerningin 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:
trueif the kerning was applied,falseotherwise.
-
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:FontProgramChecks whether theFontProgramwas built with corresponding fontName. Default value is false unless overridden.- Overrides:
isBuiltWithin 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
-
-