Class TrueTypeFontSubset
java.lang.Object
com.itextpdf.io.font.TrueTypeFontSubset
Subsets a True Type font by removing the unneeded glyphs from the font.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate intprivate static final int[]private StringThe file name.private intprivate intprivate static final intprivate booleanprivate int[]private intprivate static final intprivate byte[]private int[]private byte[]private byte[]protected RandomAccessFileOrArrayThe file in use.private static final intprivate static final intprivate static final String[]private static final String[]private static final intContains the location of the several tables.private intprivate final String[]private static final intprivate static final intprivate static final int -
Constructor Summary
ConstructorsConstructorDescriptionTrueTypeFontSubset(String fileName, RandomAccessFileOrArray rf, Set<Integer> glyphsUsed, int directoryOffset, boolean subset) Creates a new TrueTypeFontSubSet -
Method Summary
Modifier and TypeMethodDescriptionprivate voidprivate intcalculateChecksum(byte[] b) private voidcheckGlyphComposite(int glyph) private voidprivate voidprivate voidprivate void(package private) byte[]process()Does the actual work of subsetting the font.private voidreadLoca()private StringreadStandardString(int length) Reads aStringfrom the font file as bytes using the Cp1252 encoding.private voidwriteFontInt(int n) private voidwriteFontShort(int n) private void
-
Field Details
-
TABLE_NAMES_SUBSET
-
TABLE_NAMES
-
entrySelectors
private static final int[] entrySelectors -
TABLE_CHECKSUM
private static final int TABLE_CHECKSUM- See Also:
-
TABLE_OFFSET
private static final int TABLE_OFFSET- See Also:
-
TABLE_LENGTH
private static final int TABLE_LENGTH- See Also:
-
HEAD_LOCA_FORMAT_OFFSET
private static final int HEAD_LOCA_FORMAT_OFFSET- See Also:
-
ARG_1_AND_2_ARE_WORDS
private static final int ARG_1_AND_2_ARE_WORDS- See Also:
-
WE_HAVE_A_SCALE
private static final int WE_HAVE_A_SCALE- See Also:
-
MORE_COMPONENTS
private static final int MORE_COMPONENTS- See Also:
-
WE_HAVE_AN_X_AND_Y_SCALE
private static final int WE_HAVE_AN_X_AND_Y_SCALE- See Also:
-
WE_HAVE_A_TWO_BY_TWO
private static final int WE_HAVE_A_TWO_BY_TWO- See Also:
-
tableDirectory
-
rf
The file in use. -
fileName
The file name. -
locaShortTable
private boolean locaShortTable -
locaTable
private int[] locaTable -
glyphsUsed
-
glyphsInList
-
tableGlyphOffset
private int tableGlyphOffset -
newLocaTable
private int[] newLocaTable -
newLocaTableOut
private byte[] newLocaTableOut -
newGlyfTable
private byte[] newGlyfTable -
glyfTableRealSize
private int glyfTableRealSize -
locaTableRealSize
private int locaTableRealSize -
outFont
private byte[] outFont -
fontPtr
private int fontPtr -
directoryOffset
private int directoryOffset -
tableNames
-
-
Constructor Details
-
TrueTypeFontSubset
TrueTypeFontSubset(String fileName, RandomAccessFileOrArray rf, Set<Integer> glyphsUsed, int directoryOffset, boolean subset) 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 directory
-
-
Method Details
-
process
Does the actual work of subsetting the font.- Returns:
- the subset font
- Throws:
IOException- on error
-
assembleFont
- Throws:
IOException
-
createTableDirectory
- Throws:
IOException
-
readLoca
- Throws:
IOException
-
createNewGlyphTables
- Throws:
IOException
-
locaToBytes
private void locaToBytes() -
flatGlyphs
- Throws:
IOException
-
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
private void writeFontShort(int n) -
writeFontInt
private void writeFontInt(int n) -
writeFontString
-
calculateChecksum
private int calculateChecksum(byte[] b)
-