org.apache.fop.fonts.truetype

## Class OTFSubSetFile

- java.lang.Object
- - org.apache.fop.fonts.truetype.OpenFont
  - - org.apache.fop.fonts.truetype.OTFFile
    - - org.apache.fop.fonts.truetype.OTFSubSetFile

-     public class OTFSubSetFile
      extends OTFFile

  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.apache.fop.fonts.truetype.OpenFont

      `OpenFont.PostScriptVersion`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected CFFDataReader` | `cffReader` The CFF reader object used to read data and offsets from the original font file
    `protected int` | `currentPos`
    `protected java.lang.String` | `embeddedName` The embedded name to change in the name table
    `protected java.util.LinkedHashMap<java.lang.Integer,java.lang.Integer>` | `gidToSID` A map of the new GID to SID used to construct the charset table
    `protected CFFDataReader.CFFIndexData` | `globalIndexSubr`
    `protected java.util.List<java.lang.Integer>` | `globalUniques`
    `protected CFFDataReader.CFFIndexData` | `localIndexSubr`
    `protected java.util.List<java.lang.Integer>` | `localUniques` A list of unique subroutines from the global / local subroutine indexes
    `static int` | `NUM_STANDARD_STRINGS` The number of standard strings in CFF
    `protected byte[]` | `output`
    `protected java.util.List<byte[]>` | `stringIndexData` An array used to hold the string index data for the subset font
    `protected java.util.List<byte[]>` | `subsetCharStringsIndex` A list of char string data for each glyph to be stored in the subset font
    `protected java.util.List<byte[]>` | `subsetGlobalIndexSubr`
    `protected int` | `subsetGlobalSubrCount`
    `protected java.util.LinkedHashMap<java.lang.Integer,java.lang.Integer>` | `subsetGlyphs` A map containing each glyph to be included in the subset with their existing and new GID's
    `protected java.util.List<byte[]>` | `subsetLocalIndexSubr` List of subroutines to write to the local / global indexes in the subset font
    `protected int` | `subsetLocalSubrCount` A store of the number of subroutines each global / local subroutine will store

    - ### Fields inherited from class org.apache.fop.fonts.truetype.OTFFile

      `fileFont`

    - ### Fields inherited from class org.apache.fop.fonts.truetype.OpenFont

      `advancedTableReader, cid, dirTabs, familyNames, fontFile, fullName, lastLoca, locaFormat, log, mtxTab, nhmtx, notice, numberOfGlyphs, postScriptName, subFamilyName, TRACE_ENABLED, unicodeMappings, useAdvanced, useKerning`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `OTFSubSetFile()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static byte[]` | `concatArray(byte[] a, byte[] b)`
    `protected void` | `createCFF()`
    `protected void` | `createCharStringDataCID()`
    `static byte[]` | `createNewRef(int newRef, int[] operatorCode, int forceLength)`
    `CFFDataReader` | `getCFFReader()` Returns the parsed CFF data for the original font.
    `byte[]` | `getFontSubset()` Returns a subset of the fonts (readFont() MUST be called first in order to create the subset).
    `protected java.util.List<java.lang.Integer>` | `getUsedFDFonts()`
    `void` | `readFont(FontFileReader in, java.lang.String embeddedName, java.lang.String header, MultiByteFont mbFont)`
    `protected java.util.List<java.lang.Integer>` | `storeFDStrings(java.util.List<java.lang.Integer> uniqueNewRefs)`
    `protected void` | `updateCIDOffsets(int topDictDataOffset, int fdArrayOffset, int fdSelectOffset, int charsetOffset, int charStringOffset, int encodingOffset)`
    `protected void` | `updateFixedOffsets(java.util.Map<java.lang.String,CFFDataReader.DICTEntry> topDICT, int dataTopDictOffset, int charsetOffset, int charStringOffset, int encodingOffset)`
    `protected byte[]` | `updateOffset(byte[] out, int position, int length, int replacement)`
    `protected void` | `updateOffsets(int topDictOffset, int charsetOffset, int charStringOffset, int privateDictOffset, int localIndexOffset, int encodingOffset)`
    `protected void` | `writeByte(int b)` Appends a byte to the output array, updates currentPost but not realSize
    `protected void` | `writeBytes(byte[] out)`
    `protected void` | `writeBytes(byte[] out, int offset, int length)`
    `protected void` | `writeCard16(int s)` Appends a USHORT to the output array, updates currentPost but not realSize
    `protected void` | `writeCIDCount(CFFDataReader.DICTEntry dictEntry)`
    `protected java.util.List<java.lang.Integer>` | `writeCIDDictsAndSubrs(java.util.List<java.lang.Integer> uniqueNewRefs)`
    `protected int` | `writeFDArray(java.util.List<java.lang.Integer> uniqueNewRefs, java.util.List<java.lang.Integer> privateDictOffsets, java.util.List<java.lang.Integer> fontNameSIDs)`
    `protected void` | `writeFDSelect()`
    `protected int` | `writeIndex(java.util.List<byte[]> dataArray)`
    `protected void` | `writePrivateDict()`
    `protected void` | `writeTopDICT()`

    - ### Methods inherited from class org.apache.fop.fonts.truetype.OTFFile

      `getCFFData, initializeFont, readName, updateBBoxAndOffset`

    - ### Methods inherited from class org.apache.fop.fonts.truetype.OpenFont

      `checkTTC, convertTTFUnit2PDFUnit, createCMaps, determineAscDesc, getAnsiKerning, getBBox, getBoundingBoxes, getCapHeight, getCharSetName, getCharWidth, getCMaps, getDirectoryEntry, getFamilyNames, getFirstChar, getFlags, getFontBBox, getFullName, getGDEF, getGPOS, getGSUB, getItalicAngle, getKerning, getLastChar, getLowerCaseAscent, getLowerCaseDescent, getMtx, getNumGlyphs, getPadSize, getPostScriptName, getStemV, getStrikeoutPosition, getStrikeoutThickness, getSubFamilyName, getTTCnames, getUnderlinePosition, getUnderlineThickness, getWeightClass, getWidths, getXHeight, guessVerticalMetricsFromGlyphBBox, handleCharacterSpacing, hasAdvancedTable, initAnsiWidths, isCFF, isEmbeddable, main, printStuff, readCMAP, readDirTabs, readFont, readFont, readFont, readFontHeader, readHorizontalHeader, readHorizontalMetrics, readKerning, readOS2, readPCLT, readPostScript, seekTab, stream`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### output

          protected byte[] output

    - #### currentPos

          protected int currentPos

    - #### subsetGlyphs

          protected java.util.LinkedHashMap<java.lang.Integer,java.lang.Integer> subsetGlyphs

      A map containing each glyph to be included in the subset with their existing and new GID's

    - #### gidToSID

          protected java.util.LinkedHashMap<java.lang.Integer,java.lang.Integer> gidToSID

      A map of the new GID to SID used to construct the charset table

    - #### localIndexSubr

          protected CFFDataReader.CFFIndexData localIndexSubr

    - #### globalIndexSubr

          protected CFFDataReader.CFFIndexData globalIndexSubr

    - #### subsetLocalIndexSubr

          protected java.util.List<byte[]> subsetLocalIndexSubr

      List of subroutines to write to the local / global indexes in the subset font

    - #### subsetGlobalIndexSubr

          protected java.util.List<byte[]> subsetGlobalIndexSubr

    - #### localUniques

          protected java.util.List<java.lang.Integer> localUniques

      A list of unique subroutines from the global / local subroutine indexes

    - #### globalUniques

          protected java.util.List<java.lang.Integer> globalUniques

    - #### subsetLocalSubrCount

          protected int subsetLocalSubrCount

      A store of the number of subroutines each global / local subroutine will store

    - #### subsetGlobalSubrCount

          protected int subsetGlobalSubrCount

    - #### subsetCharStringsIndex

          protected java.util.List<byte[]> subsetCharStringsIndex

      A list of char string data for each glyph to be stored in the subset font

    - #### embeddedName

          protected java.lang.String embeddedName

      The embedded name to change in the name table

    - #### stringIndexData

          protected java.util.List<byte[]> stringIndexData

      An array used to hold the string index data for the subset font

    - #### cffReader

          protected CFFDataReader 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_STRINGS

      The number of standard strings in CFF
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### OTFSubSetFile

          public OTFSubSetFile()
                        throws java.io.IOException

      Throws:
        `java.io.IOException`

  - ### Method Detail

    - #### readFont

          public void readFont(FontFileReader in,
                               java.lang.String embeddedName,
                               java.lang.String header,
                               MultiByteFont mbFont)
                        throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### 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`

    - #### writeBytes

          protected void writeBytes(byte[] out)

    - #### writeBytes

          protected void writeBytes(byte[] out,
                                    int offset,
                                    int length)

    - #### writeTopDICT

          protected void writeTopDICT()
                               throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### writeCIDCount

          protected void writeCIDCount(CFFDataReader.DICTEntry dictEntry)
                                throws java.io.IOException

      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)

    - #### concatArray

          public static byte[] concatArray(byte[] a,
                                           byte[] b)

    - #### writeIndex

          protected int writeIndex(java.util.List<byte[]> dataArray)

    - #### writePrivateDict

          protected void writePrivateDict()
                                   throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### updateOffsets

          protected void updateOffsets(int topDictOffset,
                                       int charsetOffset,
                                       int charStringOffset,
                                       int privateDictOffset,
                                       int localIndexOffset,
                                       int encodingOffset)
                                throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### updateFixedOffsets

          protected void updateFixedOffsets(java.util.Map<java.lang.String,CFFDataReader.DICTEntry> topDICT,
                                            int dataTopDictOffset,
                                            int charsetOffset,
                                            int charStringOffset,
                                            int encodingOffset)

    - #### updateCIDOffsets

          protected void updateCIDOffsets(int topDictDataOffset,
                                          int fdArrayOffset,
                                          int fdSelectOffset,
                                          int charsetOffset,
                                          int charStringOffset,
                                          int encodingOffset)

    - #### updateOffset

          protected byte[] updateOffset(byte[] out,
                                        int position,
                                        int length,
                                        int replacement)

    - #### writeByte

          protected void writeByte(int b)

      Appends a byte to the output array, updates currentPost but not realSize

    - #### writeCard16

          protected void writeCard16(int s)

      Appends a USHORT to the output array, updates currentPost but not realSize

    - #### getFontSubset

          public byte[] getFontSubset()

      Returns a subset of the fonts (readFont() MUST be called first in order to create the subset).
      Returns:
        byte array

    - #### getCFFReader

          public CFFDataReader getCFFReader()

      Returns the parsed CFF data for the original font.
      Returns:
        The CFFDataReader contaiing the parsed data

Copyright 1999-2015 The Apache Software Foundation. All Rights Reserved.