Interface Subset

  • All Known Implementing Classes:
    NameKeyedSubset, OTSubset, SubsetDefaultImpl, Type1Subset

    public interface Subset
    Represent a subset of a font.

    Implementations of this interface keeps track of the correspondance between gids in the original font and gids in the subsetted font, which can be accessed via getFullGID and getSubsetGID. The number of glyphs in the subset is accessed by getNumGlyphs. New glyphs are added to the subset as needed when getSubsetGID is called: if the glyph that is passed in is not yet in the subset, it is added.

    Initially, the subset contains only the glyphs needed for the integrity of the subset font (e.g. it contains the .notdef glyph if that is required by the font format). For TrueType fonts, the subset always includes the glyphs with glyphID 0, 1, 2, 3; the purpose of this is to preserve the recommendation on the first four glyphs, if it has been followed by the original font (and the cost is typically very small, even if the recommendation was not followed in the first place).

    Some fonts do not allow subsetting. The subset behaves as if it had been built with all the glyphs of the original font.

    Some font technologies have the notion of building glyphs using other glyphs. For example, a TrueType glyph outline can invoke other glyph outlines. Implementations of this inteface maintain the subset so that it is closed, i.e. if such a composite glyph is in the subset, then the component glyphs are also in the subset.

    There is no guarantee that the glyph ID in a subset be equal to the glyph ID in the full font, even that is possible. In particular, adding all the glyphs in a font to a subset may result in an arbitrary permutation of the glyph ids (except for glyphs with well-known gids, such as .notdef, if any).

    Synchronization

    A Subset object implements enough synchronization to be called safely from multiple threads.

    As methods are called, glyphs are only added to the subset. In particular, getNumGlyphs never decreases over time; if getSubsetGid returns some value at some point it always returns that value afterward; if getFullGid returns some value at some point for a glyph in the subset, then it always returns that value afterwards. Thus, code of the form:

     if (k < getNumGlyphs ()) {
       getFullGid (k);
     }
     
    does not need to be synchronized; the precondition on getFullGid is guaranteed by the earlier test (since getNumGlyph cannot decrease).
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      int getExistingSubsetGid​(int fullGid)
      Return the currently esisting subset gid corresponding to a full gid, if there is one, without generating a new one.
      int getFullGid​(int subsetGid)
      Return the full gid corresponding to a subset gid.
      int getNumGlyphs()
      Return the number of glyphs in the subset.
      int getSubsetGid​(int fullGid)
      Return the subset gid corresponding to a full gid.
    • Method Detail

      • getNumGlyphs

        int getNumGlyphs()
        Return the number of glyphs in the subset.
      • getFullGid

        int getFullGid​(int subsetGid)
        Return the full gid corresponding to a subset gid.
        Parameters:
        subsetGid - the subset gid, must be in the range [0..getNumGlyphs () [