Package com.itextpdf.text.pdf
Class TrueTypeFontSubSet
java.lang.Object
com.itextpdf.text.pdf.TrueTypeFontSubSet
Subsets a True Type font by removing the unneeded glyphs from
the font.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final intprotected int(package private) static final int[]protected StringThe file name.protected intprotected int(package private) static final intprotected booleanprotected booleanprotected booleanprotected int[]protected int(package private) static final intprotected byte[]protected int[]protected byte[]protected byte[]protected RandomAccessFileOrArrayThe file in use.(package private) static final int(package private) static final int(package private) static final intContains the location of the several tables.protected int(package private) static final String[](package private) static final String[](package private) static final String[](package private) static final int(package private) static final int(package private) static final int -
Constructor Summary
ConstructorsConstructorDescriptionTrueTypeFontSubSet(String fileName, RandomAccessFileOrArray rf, HashSet<Integer> glyphsUsed, int directoryOffset, boolean includeCmap, boolean includeExtras) Creates a new TrueTypeFontSubSet -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected intcalculateChecksum(byte[] b) protected voidcheckGlyphComposite(int glyph) protected voidprotected voidprotected voidprotected void(package private) byte[]process()Does the actual work of subsetting the font.protected voidreadLoca()protected StringreadStandardString(int length) Reads aStringfrom the font file as bytes using the Cp1252 encoding.protected voidwriteFontInt(int n) protected voidwriteFontShort(int n) protected void
-
Field Details
-
tableNamesSimple
-
tableNamesCmap
-
tableNamesExtra
-
entrySelectors
static final int[] entrySelectors -
TABLE_CHECKSUM
static final int TABLE_CHECKSUM- See Also:
-
TABLE_OFFSET
static final int TABLE_OFFSET- See Also:
-
TABLE_LENGTH
static final int TABLE_LENGTH- See Also:
-
HEAD_LOCA_FORMAT_OFFSET
static final int HEAD_LOCA_FORMAT_OFFSET- See Also:
-
ARG_1_AND_2_ARE_WORDS
static final int ARG_1_AND_2_ARE_WORDS- See Also:
-
WE_HAVE_A_SCALE
static final int WE_HAVE_A_SCALE- See Also:
-
MORE_COMPONENTS
static final int MORE_COMPONENTS- See Also:
-
WE_HAVE_AN_X_AND_Y_SCALE
static final int WE_HAVE_AN_X_AND_Y_SCALE- See Also:
-
WE_HAVE_A_TWO_BY_TWO
static final int WE_HAVE_A_TWO_BY_TWO- See Also:
-
tableDirectory
Contains the location of the several tables. The key is the name of the table and the value is anint[3]where position 0 is the checksum, position 1 is the offset from the start of the file and position 2 is the length of the table. -
rf
The file in use. -
fileName
The file name. -
includeCmap
protected boolean includeCmap -
includeExtras
protected boolean includeExtras -
locaShortTable
protected boolean locaShortTable -
locaTable
protected int[] locaTable -
glyphsUsed
-
glyphsInList
-
tableGlyphOffset
protected int tableGlyphOffset -
newLocaTable
protected int[] newLocaTable -
newLocaTableOut
protected byte[] newLocaTableOut -
newGlyfTable
protected byte[] newGlyfTable -
glyfTableRealSize
protected int glyfTableRealSize -
locaTableRealSize
protected int locaTableRealSize -
outFont
protected byte[] outFont -
fontPtr
protected int fontPtr -
directoryOffset
protected int directoryOffset
-
-
Constructor Details
-
TrueTypeFontSubSet
TrueTypeFontSubSet(String fileName, RandomAccessFileOrArray rf, HashSet<Integer> glyphsUsed, int directoryOffset, boolean includeCmap, boolean includeExtras) Creates a new TrueTypeFontSubSet- Parameters:
fileName- the file name of the fontglyphsUsed- the glyphs useddirectoryOffset- The offset from the start of the file to the table directoryincludeCmap-trueif the table cmap is to be included in the generated font
-
-
Method Details
-
process
Does the actual work of subsetting the font.- Returns:
- the subset font
- Throws:
IOException- on errorDocumentException- on error
-
assembleFont
- Throws:
IOException
-
createTableDirectory
- Throws:
IOExceptionDocumentException
-
readLoca
- Throws:
IOExceptionDocumentException
-
createNewGlyphTables
- Throws:
IOException
-
locaTobytes
protected void locaTobytes() -
flatGlyphs
- Throws:
IOExceptionDocumentException
-
checkGlyphComposite
- Throws:
IOException
-
readStandardString
Reads aStringfrom the font file as bytes using the Cp1252 encoding.- Parameters:
length- the length of bytes to read- Returns:
- the
Stringread - Throws:
IOException- the font file could not be read
-
writeFontShort
protected void writeFontShort(int n) -
writeFontInt
protected void writeFontInt(int n) -
writeFontString
-
calculateChecksum
protected int calculateChecksum(byte[] b)
-