Package com.aowagie.text.pdf
Class TrueTypeFontSubSet
java.lang.Object
com.aowagie.text.pdf.TrueTypeFontSubSet
Subsets a True Type font by removing the unneeded glyphs from
the font.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private final int
private static final int[]
private final String
The file name.private int
private int
private final ArrayList
private final HashMap
(package private) static final int
private final boolean
private final boolean
private boolean
private int[]
private int
private static final int
private byte[]
private int[]
private byte[]
private byte[]
private final RandomAccessFileOrArray
The file in use.private static final int
private static final int
private static final int
private HashMap
Contains the location of the several tables.private int
private static final String[]
private static final String[]
private static final String[]
private static final int
private static final int
private static final int
-
Constructor Summary
ConstructorsConstructorDescriptionTrueTypeFontSubSet
(String fileName, RandomAccessFileOrArray rf, HashMap glyphsUsed, int directoryOffset, boolean includeCmap, boolean includeExtras) Creates a new TrueTypeFontSubSet -
Method Summary
Modifier and TypeMethodDescriptionprivate void
private int
calculateChecksum
(byte[] b) private void
checkGlyphComposite
(int glyph) private void
private void
private void
private void
(package private) byte[]
process()
Does the actual work of subsetting the font.private void
readLoca()
private String
readStandardString
(int length) Reads aString
from the font file as bytes using the Cp1252 encoding.private void
writeFontInt
(int n) private void
writeFontShort
(int n) private void
-
Field Details
-
tableNamesSimple
-
tableNamesCmap
-
tableNamesExtra
-
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
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
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
private final boolean includeCmap -
includeExtras
private final boolean includeExtras -
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 final int directoryOffset
-
-
Constructor Details
-
TrueTypeFontSubSet
TrueTypeFontSubSet(String fileName, RandomAccessFileOrArray rf, HashMap 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
-true
if 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:
IOException
DocumentException
-
readLoca
- Throws:
IOException
DocumentException
-
createNewGlyphTables
- Throws:
IOException
-
locaTobytes
private void locaTobytes() -
flatGlyphs
- Throws:
IOException
DocumentException
-
checkGlyphComposite
- Throws:
IOException
-
readStandardString
Reads aString
from the font file as bytes using the Cp1252 encoding.- Parameters:
length
- the length of bytes to read- Returns:
- the
String
read - 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)
-