Class OTFSubSetFile
java.lang.Object
org.apache.fop.fonts.truetype.OpenFont
org.apache.fop.fonts.truetype.OTFFile
org.apache.fop.fonts.truetype.OTFSubSetWriter
org.apache.fop.fonts.truetype.OTFSubSetFile
Reads an OpenType CFF file and generates a subset
The OpenType specification can be found at the Microsoft
Typography site: http://www.microsoft.com/typography/otspec/
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classA class used to store the last number operand and also it's size in bytesprivate static class(package private) static class(package private) static classNested classes/interfaces inherited from class OpenFont
OpenFont.PostScriptVersion, OpenFont.UnicodeMapping -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprotected CFFDataReaderThe CFF reader object used to read data and offsets from the original font fileprotected StringThe embedded name to change in the name tableFor fonts which have an FDSelect or ROS flag in Top Dict, this is used to store the local subroutine indexes for each group as opposed to the above subsetLocalIndexSubrA map of the new GID to SID used to construct the charset tableprivate static final intThe operator used to identify a global subroutine referenceprotected CFFDataReader.CFFIndexDataprivate static final intThe operator used to identify a local subroutine referenceprotected CFFDataReader.CFFIndexDataA list of unique subroutines from the global / local subroutine indexesprivate MultiByteFontThe class used to represent this fontstatic final intThe number of standard strings in CFFprotected List<byte[]> An array used to hold the string index data for the subset fontprotected List<byte[]> A list of char string data for each glyph to be stored in the subset fontprivate Map<Integer, OTFSubSetFile.FDIndexReference> The subset FD Select table used to store the mappings between glyphs and their associated FDFont object which point to a private dict and local subroutines.protected List<byte[]> protected intA map containing each glyph to be included in the subset with their existing and new GID'sprotected List<byte[]> List of subroutines to write to the local / global indexes in the subset fontprotected intA store of the number of subroutines each global / local subroutine will storeprivate OTFSubSetFile.Type2ParserThe parser used to parse type2 charstringFields inherited from class OTFSubSetWriter
currentPos, outputFields inherited from class OpenFont
advancedTableReader, cid, dirTabs, embedFontName, ENC_BUF_SIZE, familyNames, fontFile, fullName, lastLoca, locaFormat, log, MAX_CHAR_CODE, mtxTab, nhmtx, notice, NTABS, numberOfGlyphs, postScriptName, subFamilyName, svgs, TRACE_ENABLED, unicodeMappings, useAdvanced, useKerning -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate byte[]constructNewRefData(int curDataPos, byte[] currentData, OTFSubSetFile.BytesNumber operand, int fullSubsetIndexSize, int curSubsetIndexSize, int[] operatorCode) protected voidprivate voidprotected voidstatic byte[]createNewRef(int newRef, int[] operatorCode, int forceLength, boolean isDict) private intgetBias(int subrCount) Returns the parsed CFF data for the original font.private intgetNewRefForReference(int subrNumber, List<Integer> uniquesArray, CFFDataReader.CFFIndexData indexSubr, List<byte[]> subsetIndexSubr, int subrCount) private intgetOffSize(int totLength) private intgetSubrNumber(int numSubroutines, int operand) getType1Sequence(org.apache.fontbox.cff.Type1CharString type1CharString) private booleanprivate voidprivate voidpreScanForSubsetIndexSize(byte[] data) private voidpreScanForSubsetIndexSize(CFFDataReader.CFFIndexData indexSubr, List<Integer> uniques) private byte[]readCharStringData(byte[] data, int subsetLocalSubrCount) voidreadFont(FontFileReader in, String embeddedName, MultiByteFont mbFont) Reads a font.(package private) voidreadFont(FontFileReader in, String embeddedName, MultiByteFont mbFont, Map<Integer, Integer> usedGlyphs) Reads and creates a subset of the font.private byte[]resizeToFitOpLen(byte[] fdPrivateDictByteData, CFFDataReader.DICTEntry subrs) sortByValue(Map<Integer, Integer> map) storeFDStrings(List<Integer> uniqueNewRefs) protected voidupdateCIDOffsets(OTFSubSetFile.Offsets offsets) protected voidupdateFixedOffsets(Map<String, CFFDataReader.DICTEntry> topDICT, OTFSubSetFile.Offsets offsets) private voidupdateOffset(byte[] out, int position, int length, int replacement) private voidupdateOffset(int position, int length, int replacement) protected voidupdateOffsets(OTFSubSetFile.Offsets offsets) private voidwriteCharsetTable(boolean cidFont) protected byte[]writeCIDCount(CFFDataReader.DICTEntry dictEntry) writeCIDDictsAndSubrs(List<Integer> uniqueNewRefs) private intwriteFDArray(List<Integer> subsetFDFonts, List<Integer> fontNameSIDs) protected intwriteFDArray(List<Integer> uniqueNewRefs, List<Integer> privateDictOffsets, List<Integer> fontNameSIDs) protected voidprotected intwriteIndex(List<byte[]> dataArray) protected intwriteIndex(List<byte[]> dataArray, int offSize) protected voidprivate byte[]writeROSEntry(CFFDataReader.DICTEntry dictEntry) private voidprotected intprivate byte[]writeTopDictStringEntry(CFFDataReader.DICTEntry dictEntry) Methods inherited from class OTFSubSetWriter
concatArray, getFontSubset, writeByte, writeBytes, writeCard16, writeThreeByteNumber, writeULongMethods inherited from class OTFFile
getCFFData, initializeFont, isType1, readName, updateBBoxAndOffsetMethods inherited from class OpenFont
checkTTC, convertTTFUnit2PDFUnit, createCMaps, determineAscDesc, getAnsiKerning, getBBox, getBBoxRaw, getBoundingBoxes, getCapHeight, getCharSetName, getCharWidth, getCharWidthRaw, getCMaps, getCopyrightNotice, getDirectoryEntry, getEmbedFontName, getFamilyNames, getFirstChar, getFlags, getFontBBox, getFullName, getGDEF, getGlyphName, getGPOS, getGSUB, getItalicAngle, getKerning, getLastChar, getLowerCaseAscent, getLowerCaseDescent, getMtx, getNumGlyphs, getPadSize, getPostScriptName, getPostScriptVersion, getStemV, getStrikeoutPosition, getStrikeoutThickness, getSubFamilyName, getTTCnames, getUnderlinePosition, getUnderlineThickness, getWeightClass, getWidths, getXHeight, guessVerticalMetricsFromGlyphBBox, handleCharacterSpacing, hasAdvancedTable, initAnsiWidths, isCFF, isEmbeddable, main, printStuff, readCMAP, readDirTabs, readFont, readFont, readFontHeader, readHorizontalHeader, readHorizontalMetrics, readKerning, readOS2, readPCLT, readPostScript, seekTab, sortDirTabMap, stream
-
Field Details
-
subsetGlyphs
-
gidToSID
-
localIndexSubr
-
globalIndexSubr
-
subsetLocalIndexSubr
List of subroutines to write to the local / global indexes in the subset font -
subsetGlobalIndexSubr
-
fdSubrs
-
subsetFDSelect
The subset FD Select table used to store the mappings between glyphs and their associated FDFont object which point to a private dict and local subroutines. -
localUniques
-
globalUniques
-
subsetLocalSubrCount
protected int subsetLocalSubrCountA store of the number of subroutines each global / local subroutine will store -
subsetGlobalSubrCount
protected int subsetGlobalSubrCount -
subsetCharStringsIndex
A list of char string data for each glyph to be stored in the subset font -
embeddedName
The embedded name to change in the name table -
stringIndexData
An array used to hold the string index data for the subset font -
cffReader
The CFF reader object used to read data and offsets from the original font file -
mbFont
The class used to represent this font -
NUM_STANDARD_STRINGS
public static final int NUM_STANDARD_STRINGSThe number of standard strings in CFF- See Also:
-
LOCAL_SUBROUTINE
private static final int LOCAL_SUBROUTINEThe operator used to identify a local subroutine reference- See Also:
-
GLOBAL_SUBROUTINE
private static final int GLOBAL_SUBROUTINEThe operator used to identify a global subroutine reference- See Also:
-
ACCENT_CMD
- See Also:
-
type2Parser
The parser used to parse type2 charstring
-
-
Constructor Details
-
OTFSubSetFile
- Throws:
IOException
-
-
Method Details
-
readFont
public void readFont(FontFileReader in, String embeddedName, MultiByteFont mbFont) throws IOException Description copied from class:OpenFontReads a font.- Overrides:
readFontin classOpenFont- Parameters:
in- FontFileReader to read from- Throws:
IOException- in case of an I/O problem
-
readFont
void readFont(FontFileReader in, String embeddedName, MultiByteFont mbFont, Map<Integer, Integer> usedGlyphs) throws IOExceptionReads and creates a subset of the font.- Parameters:
in- FontFileReader to read fromembeddedName- Name to be checked for in the font fileusedGlyphs- Map of glyphs (glyphs has old index as (Integer) key and new index as (Integer) value)- Throws:
IOException- in case of an I/O problem
-
mapChars
- Throws:
IOException
-
getType1Sequence
-
sortByValue
-
createCFF
- Throws:
IOException
-
writeFDArray
private int writeFDArray(List<Integer> subsetFDFonts, List<Integer> fontNameSIDs) throws IOException - Throws:
IOException
-
isCharStringBeforeFD
private boolean isCharStringBeforeFD() -
storeFDStrings
- Throws:
IOException
-
writeTopDICT
- Throws:
IOException
-
writeROSEntry
- Throws:
IOException
-
writeCIDCount
- Throws:
IOException
-
writeTopDictStringEntry
- Throws:
IOException
-
writeStringIndex
- Throws:
IOException
-
createCharStringDataCID
- Throws:
IOException
-
writeFDSelect
protected void writeFDSelect() -
getFormat3Index
-
getUsedFDFonts
-
writeCIDDictsAndSubrs
- Throws:
IOException
-
resizeToFitOpLen
private byte[] resizeToFitOpLen(byte[] fdPrivateDictByteData, CFFDataReader.DICTEntry subrs) throws IOException - Throws:
IOException
-
writeFDArray
protected int writeFDArray(List<Integer> uniqueNewRefs, List<Integer> privateDictOffsets, List<Integer> fontNameSIDs) throws IOException - Throws:
IOException
-
createCharStringData
- Throws:
IOException
-
preScanForSubsetIndexSize
- Throws:
IOException
-
preScanForSubsetIndexSize
private void preScanForSubsetIndexSize(CFFDataReader.CFFIndexData indexSubr, List<Integer> uniques) throws IOException - Throws:
IOException
-
getSubrNumber
private int getSubrNumber(int numSubroutines, int operand) -
readCharStringData
- Throws:
IOException
-
getNewRefForReference
private int getNewRefForReference(int subrNumber, List<Integer> uniquesArray, CFFDataReader.CFFIndexData indexSubr, List<byte[]> subsetIndexSubr, int subrCount) throws IOException - Throws:
IOException
-
getBias
private int getBias(int subrCount) -
constructNewRefData
private byte[] constructNewRefData(int curDataPos, byte[] currentData, OTFSubSetFile.BytesNumber operand, int fullSubsetIndexSize, int curSubsetIndexSize, int[] operatorCode) throws IOException - Throws:
IOException
-
createNewRef
public static byte[] createNewRef(int newRef, int[] operatorCode, int forceLength, boolean isDict) -
writeIndex
-
writeIndex
-
getOffSize
private int getOffSize(int totLength) -
writeCharsetTable
- Throws:
IOException
-
writePrivateDict
- Throws:
IOException
-
updateOffsets
- Throws:
IOException
-
updateFixedOffsets
protected void updateFixedOffsets(Map<String, CFFDataReader.DICTEntry> topDICT, OTFSubSetFile.Offsets offsets) throws IOException - Throws:
IOException
-
updateCIDOffsets
- Throws:
IOException
-
updateOffset
- Throws:
IOException
-
updateOffset
private void updateOffset(byte[] out, int position, int length, int replacement) -
getCFFReader
Returns the parsed CFF data for the original font.- Returns:
- The CFFDataReader contaiing the parsed data
-