org.foray.font
Class Subset

java.lang.Object
  extended by org.foray.font.Subset

public class Subset
extends Object

Keeps track of which glyphs are included in a subset, and provides methods to convert indexes back and forth between the original complete font and the subset font.

Design Note: Although the internals of this class will only handle 16-bit font indexes, the API deliberately uses ints (31 unsigned bits) instead of chars. This way the internals can be expanded in the future if necessary, without changing the API.


Constructor Summary
Subset(ConsumerFont4a consumerFont)
          Constructor.
 
Method Summary
 int decodeSubsetIndex(int subsetGlyphIndex)
          Get the full font glyph index (not subsetted) that corresponds to subsetGlyphIndex.
 int encodeSubsetIndex(int fontGlyphIndex)
          Get the subsetted font glyph index that corresponds to fontGlyphIndex, creating a subset glyph index if necessary.
 org.apache.commons.logging.Log getLogger()
          Returns the logger.
 boolean glyphUsed(int originalGlyphIndex)
          Indicates whether a given glyph is in this subset.
 int numGlyphsUsed()
          Returns the number of glyphs in this subset.
 void sortUsedGlyphs()
          Sorts the subset by underlying Unicode codepoint.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Subset

public Subset(ConsumerFont4a consumerFont)
Constructor.

Parameters:
consumerFont - The parent ConsumerFont instance.
Method Detail

encodeSubsetIndex

public int encodeSubsetIndex(int fontGlyphIndex)
Get the subsetted font glyph index that corresponds to fontGlyphIndex, creating a subset glyph index if necessary.

Parameters:
fontGlyphIndex - The index into the full font (not subsetted) glyphs.
Returns:
The index into the subsetted glyphs.

decodeSubsetIndex

public int decodeSubsetIndex(int subsetGlyphIndex)
Get the full font glyph index (not subsetted) that corresponds to subsetGlyphIndex.

Parameters:
subsetGlyphIndex - The index into the subset font glyphs.
Returns:
The index into the full font (not subsetted) glyphs, or Character.MAX_VALUE if the input is not valid.

sortUsedGlyphs

public void sortUsedGlyphs()
Sorts the subset by underlying Unicode codepoint. This may make some output formats more compact. For example, the PDF ToUnicodeCMap can be written more compactly if glyph indexes are in Unicode order. Since this changes the subset indexes, it is only useful if no output has been written (or any other permanent meaning assigned) using the pre-sorted indices.


numGlyphsUsed

public int numGlyphsUsed()
Returns the number of glyphs in this subset.

Returns:
The number of glyphs in this subset.

glyphUsed

public boolean glyphUsed(int originalGlyphIndex)
Indicates whether a given glyph is in this subset.

Parameters:
originalGlyphIndex - The original (full font) glyph index that is being checked.
Returns:
True iff originalGlyphIndex exists in this subset.

getLogger

public org.apache.commons.logging.Log getLogger()
Returns the logger.

Returns:
The logger.


Copyright © 2017. All rights reserved.