Class CIDSubset

java.lang.Object
org.docx4j.fonts.fop.fonts.CIDSubset

public class CIDSubset
extends java.lang.Object
Keeps track of the glyphs used in a document. This information is later used to build a subset of a font.
  • Constructor Summary

    Constructors 
    Constructor Description
    CIDSubset()  
  • Method Summary

    Modifier and Type Method Description
    java.util.BitSet getGlyphIndexBitSet()
    Returns a BitSet with bits set for each available glyph index.
    int getGlyphIndexForSubsetIndex​(int subsetIndex)
    Returns the original index of the glyph inside the (non-subset) font's glyph list.
    char[] getSubsetChars()
    Returns a char array containing all Unicode characters that are in the subset.
    java.util.Map getSubsetGlyphs()
    Returns an unmodifiable Map of the font subset.
    int getSubsetSize()
    Returns the number of glyphs in the subset.
    char getUnicodeForSubsetIndex​(int subsetIndex)
    Returns the Unicode value for a subset index (character selector).
    int mapSubsetChar​(int glyphIndex, char unicode)
    Maps a character to a character selector for a font subset.
    void setupFirstThreeGlyphs()
    Adds the initial 3 glyphs which are the same for all CID subsets.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • setupFirstThreeGlyphs

      public void setupFirstThreeGlyphs()
      Adds the initial 3 glyphs which are the same for all CID subsets.
    • getGlyphIndexForSubsetIndex

      public int getGlyphIndexForSubsetIndex​(int subsetIndex)
      Returns the original index of the glyph inside the (non-subset) font's glyph list. This index can be used to access the character width information, for example.
      Parameters:
      subsetIndex - the subset index (character selector) to access the glyph
      Returns:
      the original index (or -1 if no glyph index is available for the subset index)
    • getUnicodeForSubsetIndex

      public char getUnicodeForSubsetIndex​(int subsetIndex)
      Returns the Unicode value for a subset index (character selector). If there's no such Unicode value, the "NOT A CHARACTER" (0xFFFF) is returned.
      Parameters:
      subsetIndex - the subset index (character selector)
      Returns:
      the Unicode value or "NOT A CHARACTER" (0xFFFF)
    • mapSubsetChar

      public int mapSubsetChar​(int glyphIndex, char unicode)
      Maps a character to a character selector for a font subset. If the character isn't in the subset, yet, it is added and a new character selector returned. Otherwise, the already allocated character selector is returned from the existing map/subset.
      Parameters:
      glyphIndex - the glyph index of the character
      unicode - the Unicode index of the character
      Returns:
      the subset index
    • getSubsetGlyphs

      public java.util.Map getSubsetGlyphs()
      Returns an unmodifiable Map of the font subset. It maps from glyph index to character selector (i.e. the subset index in this case).
      Returns:
      Map Map<Integer, Integer> of the font subset
    • getSubsetChars

      public char[] getSubsetChars()
      Returns a char array containing all Unicode characters that are in the subset.
      Returns:
      a char array with all used Unicode characters
    • getSubsetSize

      public int getSubsetSize()
      Returns the number of glyphs in the subset.
      Returns:
      the number of glyphs in the subset
    • getGlyphIndexBitSet

      public java.util.BitSet getGlyphIndexBitSet()
      Returns a BitSet with bits set for each available glyph index.
      Returns:
      a BitSet indicating available glyph indices