Class OTFSubSetFile
java.lang.Object
org.docx4j.fonts.fop.fonts.truetype.OpenFont
org.docx4j.fonts.fop.fonts.truetype.OTFFile
org.docx4j.fonts.fop.fonts.truetype.OTFSubSetWriter
org.docx4j.fonts.fop.fonts.truetype.OTFSubSetFile
public class OTFSubSetFile extends OTFSubSetWriter
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 classes/interfaces inherited from class org.docx4j.fonts.fop.fonts.truetype.OpenFont
OpenFont.PostScriptVersion -
Field Summary
Fields Modifier and Type Field Description protected CFFDataReadercffReaderThe CFF reader object used to read data and offsets from the original font fileprotected java.lang.StringembeddedNameThe embedded name to change in the name tableprotected java.util.List<java.util.List<byte[]>>fdSubrsFor 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 subsetLocalIndexSubrprotected java.util.Map<java.lang.Integer,java.lang.Integer>gidToSIDA map of the new GID to SID used to construct the charset tableprotected CFFDataReader.CFFIndexDataglobalIndexSubrprotected java.util.List<java.lang.Integer>globalUniquesprotected CFFDataReader.CFFIndexDatalocalIndexSubrprotected java.util.List<java.lang.Integer>localUniquesA list of unique subroutines from the global / local subroutine indexesstatic intNUM_STANDARD_STRINGSThe number of standard strings in CFFprotected java.util.List<byte[]>stringIndexDataAn array used to hold the string index data for the subset fontprotected java.util.List<byte[]>subsetCharStringsIndexA list of char string data for each glyph to be stored in the subset fontprotected java.util.List<byte[]>subsetGlobalIndexSubrprotected intsubsetGlobalSubrCountprotected java.util.Map<java.lang.Integer,java.lang.Integer>subsetGlyphsA map containing each glyph to be included in the subset with their existing and new GID'sprotected java.util.List<byte[]>subsetLocalIndexSubrList of subroutines to write to the local / global indexes in the subset fontprotected intsubsetLocalSubrCountA store of the number of subroutines each global / local subroutine will storeFields inherited from class org.docx4j.fonts.fop.fonts.truetype.OTFSubSetWriter
currentPos, outputFields inherited from class org.docx4j.fonts.fop.fonts.truetype.OpenFont
advancedTableReader, cid, dirTabs, embedFontName, familyNames, fontFile, fullName, lastLoca, locaFormat, log, mtxTab, nhmtx, notice, numberOfGlyphs, postScriptName, subFamilyName, TRACE_ENABLED, unicodeMappings, useAdvanced, useKerning -
Constructor Summary
Constructors Constructor Description OTFSubSetFile() -
Method Summary
Modifier and Type Method Description protected voidcreateCFF()protected voidcreateCharStringDataCID()static byte[]createNewRef(int newRef, int[] operatorCode, int forceLength, boolean isDict)CFFDataReadergetCFFReader()Returns the parsed CFF data for the original font.protected java.util.List<java.lang.Integer>getUsedFDFonts()voidreadFont(FontFileReader in, java.lang.String embeddedName, MultiByteFont mbFont)Reads a font.protected java.util.List<java.lang.Integer>storeFDStrings(java.util.List<java.lang.Integer> uniqueNewRefs)protected voidupdateCIDOffsets(org.docx4j.fonts.fop.fonts.truetype.OTFSubSetFile.Offsets offsets)protected voidupdateFixedOffsets(java.util.Map<java.lang.String,CFFDataReader.DICTEntry> topDICT, org.docx4j.fonts.fop.fonts.truetype.OTFSubSetFile.Offsets offsets)protected voidupdateOffsets(org.docx4j.fonts.fop.fonts.truetype.OTFSubSetFile.Offsets offsets)protected byte[]writeCIDCount(CFFDataReader.DICTEntry dictEntry)protected java.util.List<java.lang.Integer>writeCIDDictsAndSubrs(java.util.List<java.lang.Integer> uniqueNewRefs)protected intwriteFDArray(java.util.List<java.lang.Integer> uniqueNewRefs, java.util.List<java.lang.Integer> privateDictOffsets, java.util.List<java.lang.Integer> fontNameSIDs)protected voidwriteFDSelect()protected intwriteIndex(java.util.List<byte[]> dataArray)protected intwriteIndex(java.util.List<byte[]> dataArray, int offSize)protected voidwritePrivateDict()protected intwriteTopDICT()Methods inherited from class org.docx4j.fonts.fop.fonts.truetype.OTFSubSetWriter
concatArray, getFontSubset, writeByte, writeBytes, writeCard16, writeThreeByteNumber, writeULongMethods inherited from class org.docx4j.fonts.fop.fonts.truetype.OTFFile
getCFFData, initializeFont, isType1, readName, updateBBoxAndOffsetMethods inherited from class org.docx4j.fonts.fop.fonts.truetype.OpenFont
checkTTC, convertTTFUnit2PDFUnit, createCMaps, determineAscDesc, getAnsiKerning, getBBox, getBBoxRaw, getBoundingBoxes, getCapHeight, getCharSetName, getCharWidth, getCharWidthRaw, getCMaps, getCopyrightNotice, getDirectoryEntry, getEmbedFontName, getFamilyNames, getFirstChar, getFlags, getFontBBox, getFullName, getGDEF, getGPOS, getGSUB, getItalicAngle, getKerning, getLastChar, getLowerCaseAscent, getLowerCaseDescent, getMtx, getNumGlyphs, getPadSize, getPanose, getPostScriptName, 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, streamMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
subsetGlyphs
protected java.util.Map<java.lang.Integer,java.lang.Integer> subsetGlyphsA map containing each glyph to be included in the subset with their existing and new GID's -
gidToSID
protected java.util.Map<java.lang.Integer,java.lang.Integer> gidToSIDA map of the new GID to SID used to construct the charset table -
localIndexSubr
-
globalIndexSubr
-
subsetLocalIndexSubr
protected java.util.List<byte[]> subsetLocalIndexSubrList of subroutines to write to the local / global indexes in the subset font -
subsetGlobalIndexSubr
protected java.util.List<byte[]> subsetGlobalIndexSubr -
fdSubrs
protected java.util.List<java.util.List<byte[]>> fdSubrsFor 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 subsetLocalIndexSubr -
localUniques
protected java.util.List<java.lang.Integer> localUniquesA list of unique subroutines from the global / local subroutine indexes -
globalUniques
protected java.util.List<java.lang.Integer> globalUniques -
subsetLocalSubrCount
protected int subsetLocalSubrCountA store of the number of subroutines each global / local subroutine will store -
subsetGlobalSubrCount
protected int subsetGlobalSubrCount -
subsetCharStringsIndex
protected java.util.List<byte[]> subsetCharStringsIndexA list of char string data for each glyph to be stored in the subset font -
embeddedName
protected java.lang.String embeddedNameThe embedded name to change in the name table -
stringIndexData
protected java.util.List<byte[]> stringIndexDataAn 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 -
NUM_STANDARD_STRINGS
public static final int NUM_STANDARD_STRINGSThe number of standard strings in CFF- See Also:
- Constant Field Values
-
-
Constructor Details
-
OTFSubSetFile
public OTFSubSetFile() throws java.io.IOException- Throws:
java.io.IOException
-
-
Method Details
-
readFont
public void readFont(FontFileReader in, java.lang.String embeddedName, MultiByteFont mbFont) throws java.io.IOExceptionDescription copied from class:OpenFontReads a font. -
createCFF
protected void createCFF() throws java.io.IOException- Throws:
java.io.IOException
-
storeFDStrings
protected java.util.List<java.lang.Integer> storeFDStrings(java.util.List<java.lang.Integer> uniqueNewRefs) throws java.io.IOException- Throws:
java.io.IOException
-
writeTopDICT
protected int writeTopDICT() throws java.io.IOException- Throws:
java.io.IOException
-
writeCIDCount
- Throws:
java.io.IOException
-
createCharStringDataCID
protected void createCharStringDataCID() throws java.io.IOException- Throws:
java.io.IOException
-
writeFDSelect
protected void writeFDSelect() -
getUsedFDFonts
protected java.util.List<java.lang.Integer> getUsedFDFonts() -
writeCIDDictsAndSubrs
protected java.util.List<java.lang.Integer> writeCIDDictsAndSubrs(java.util.List<java.lang.Integer> uniqueNewRefs) throws java.io.IOException- Throws:
java.io.IOException
-
writeFDArray
protected int writeFDArray(java.util.List<java.lang.Integer> uniqueNewRefs, java.util.List<java.lang.Integer> privateDictOffsets, java.util.List<java.lang.Integer> fontNameSIDs) throws java.io.IOException- Throws:
java.io.IOException
-
createNewRef
public static byte[] createNewRef(int newRef, int[] operatorCode, int forceLength, boolean isDict) -
writeIndex
protected int writeIndex(java.util.List<byte[]> dataArray) -
writeIndex
protected int writeIndex(java.util.List<byte[]> dataArray, int offSize) -
writePrivateDict
protected void writePrivateDict() throws java.io.IOException- Throws:
java.io.IOException
-
updateOffsets
protected void updateOffsets(org.docx4j.fonts.fop.fonts.truetype.OTFSubSetFile.Offsets offsets) throws java.io.IOException- Throws:
java.io.IOException
-
updateFixedOffsets
protected void updateFixedOffsets(java.util.Map<java.lang.String,CFFDataReader.DICTEntry> topDICT, org.docx4j.fonts.fop.fonts.truetype.OTFSubSetFile.Offsets offsets) throws java.io.IOException- Throws:
java.io.IOException
-
updateCIDOffsets
protected void updateCIDOffsets(org.docx4j.fonts.fop.fonts.truetype.OTFSubSetFile.Offsets offsets) throws java.io.IOException- Throws:
java.io.IOException
-
getCFFReader
Returns the parsed CFF data for the original font.- Returns:
- The CFFDataReader contaiing the parsed data
-