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.OTFSubSetWriter
      - - org.apache.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.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 String` | `embeddedName` The embedded name to change in the name table
    `protected List<List<byte[]>>` | `fdSubrs` For 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
    `protected Map<Integer,Integer>` | `gidToSID` A map of the new GID to SID used to construct the charset table
    `protected CFFDataReader.CFFIndexData` | `globalIndexSubr`
    `protected List<Integer>` | `globalUniques`
    `protected CFFDataReader.CFFIndexData` | `localIndexSubr`
    `protected List<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 List<byte[]>` | `stringIndexData` An array used to hold the string index data for the subset font
    `protected List<byte[]>` | `subsetCharStringsIndex` A list of char string data for each glyph to be stored in the subset font
    `protected List<byte[]>` | `subsetGlobalIndexSubr`
    `protected int` | `subsetGlobalSubrCount`
    `protected Map<Integer,Integer>` | `subsetGlyphs` A map containing each glyph to be included in the subset with their existing and new GID's
    `protected 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.OTFSubSetWriter

      `currentPos, output`

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

      `fileFont`

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

      `advancedTableReader, cid, dirTabs, embedFontName, familyNames, fontFile, fullName, lastLoca, locaFormat, log, mtxTab, nhmtx, notice, numberOfGlyphs, postScriptName, subFamilyName, svgs, 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
    --- | ---
    `protected void` | `createCFF()`
    `protected void` | `createCharStringDataCID()`
    `static byte[]` | `createNewRef(int newRef, int[] operatorCode, int forceLength, boolean isDict)`
    `CFFDataReader` | `getCFFReader()` Returns the parsed CFF data for the original font.
    `protected List<Integer>` | `getUsedFDFonts()`
    `void` | `readFont(FontFileReader in, String embeddedName, MultiByteFont mbFont)` Reads a font.
    `protected List<Integer>` | `storeFDStrings(List<Integer> uniqueNewRefs)`
    `protected void` | `updateCIDOffsets(org.apache.fop.fonts.truetype.OTFSubSetFile.Offsets offsets)`
    `protected void` | `updateFixedOffsets(Map<String,CFFDataReader.DICTEntry> topDICT, org.apache.fop.fonts.truetype.OTFSubSetFile.Offsets offsets)`
    `protected void` | `updateOffsets(org.apache.fop.fonts.truetype.OTFSubSetFile.Offsets offsets)`
    `protected byte[]` | `writeCIDCount(CFFDataReader.DICTEntry dictEntry)`
    `protected List<Integer>` | `writeCIDDictsAndSubrs(List<Integer> uniqueNewRefs)`
    `protected int` | `writeFDArray(List<Integer> uniqueNewRefs, List<Integer> privateDictOffsets, List<Integer> fontNameSIDs)`
    `protected void` | `writeFDSelect()`
    `protected int` | `writeIndex(List<byte[]> dataArray)`
    `protected int` | `writeIndex(List<byte[]> dataArray, int offSize)`
    `protected void` | `writePrivateDict()`
    `protected int` | `writeTopDICT()`

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

      `concatArray, getFontSubset, writeByte, writeBytes, writeCard16, writeThreeByteNumber, writeULong`

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

      `getCFFData, initializeFont, isType1, readName, updateBBoxAndOffset`

    - ### Methods inherited from class org.apache.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, 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, stream`

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

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

- - ### Field Detail

    - #### subsetGlyphs

          protected Map<Integer,Integer> subsetGlyphs

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

    - #### gidToSID

          protected Map<Integer,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 List<byte[]> subsetLocalIndexSubr

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

    - #### subsetGlobalIndexSubr

          protected List<byte[]> subsetGlobalIndexSubr

    - #### fdSubrs

          protected List<List<byte[]>> fdSubrs

      For 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 List<Integer> localUniques

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

    - #### globalUniques

          protected List<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 List<byte[]> subsetCharStringsIndex

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

    - #### embeddedName

          protected String embeddedName

      The embedded name to change in the name table

    - #### stringIndexData

          protected 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 IOException

      Throws:
        `IOException`

  - ### Method Detail

    - #### readFont

          public void readFont(FontFileReader in,
                               String embeddedName,
                               MultiByteFont mbFont)
                        throws IOException

      Description copied from class: `OpenFont`
      Reads a font.
      Overrides:
        `readFont` in class `OpenFont`
      Parameters:
        `in` - FontFileReader to read from
      Throws:
        `IOException` - in case of an I/O problem

    - #### createCFF

          protected void createCFF()
                            throws IOException

      Throws:
        `IOException`

    - #### storeFDStrings

          protected List<Integer> storeFDStrings(List<Integer> uniqueNewRefs)
                                          throws IOException

      Throws:
        `IOException`

    - #### writeTopDICT

          protected int writeTopDICT()
                              throws IOException

      Throws:
        `IOException`

    - #### writeCIDCount

          protected byte[] writeCIDCount(CFFDataReader.DICTEntry dictEntry)
                                  throws IOException

      Throws:
        `IOException`

    - #### createCharStringDataCID

          protected void createCharStringDataCID()
                                          throws IOException

      Throws:
        `IOException`

    - #### writeFDSelect

          protected void writeFDSelect()

    - #### getUsedFDFonts

          protected List<Integer> getUsedFDFonts()

    - #### writeCIDDictsAndSubrs

          protected List<Integer> writeCIDDictsAndSubrs(List<Integer> uniqueNewRefs)
                                                 throws IOException

      Throws:
        `IOException`

    - #### writeFDArray

          protected int writeFDArray(List<Integer> uniqueNewRefs,
                                     List<Integer> privateDictOffsets,
                                     List<Integer> fontNameSIDs)
                              throws IOException

      Throws:
        `IOException`

    - #### createNewRef

          public static byte[] createNewRef(int newRef,
                                            int[] operatorCode,
                                            int forceLength,
                                            boolean isDict)

    - #### writeIndex

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

    - #### writeIndex

          protected int writeIndex(List<byte[]> dataArray,
                                   int offSize)

    - #### writePrivateDict

          protected void writePrivateDict()
                                   throws IOException

      Throws:
        `IOException`

    - #### updateOffsets

          protected void updateOffsets(org.apache.fop.fonts.truetype.OTFSubSetFile.Offsets offsets)
                                throws IOException

      Throws:
        `IOException`

    - #### updateFixedOffsets

          protected void updateFixedOffsets(Map<String,CFFDataReader.DICTEntry> topDICT,
                                            org.apache.fop.fonts.truetype.OTFSubSetFile.Offsets offsets)
                                     throws IOException

      Throws:
        `IOException`

    - #### updateCIDOffsets

          protected void updateCIDOffsets(org.apache.fop.fonts.truetype.OTFSubSetFile.Offsets offsets)
                                   throws IOException

      Throws:
        `IOException`

    - #### getCFFReader

          public CFFDataReader getCFFReader()

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

Copyright © 2025 Apache Software Foundation. All rights reserved.