Class GlyfTable


  • public class GlyfTable
    extends java.lang.Object
    This "glyf" table in a TrueType font file contains information that describes the glyphs. This class is responsible for creating a subset of the "glyf" table given a set of glyph indices.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  GlyfTable.GlyfFlags  
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Set<java.lang.Integer> composedGlyphs
      All the glyphs that are composed, but do not appear in the subset.
      protected java.util.Set<java.lang.Integer> compositeGlyphs
      All the composite glyphs that appear in the subset.
      private FontFileReader in  
      private OFMtxEntry[] mtxTab  
      private java.util.Set<java.lang.Long> remappedComposites  
      protected java.util.Map<java.lang.Integer,​java.lang.Integer> subset  
      private long tableOffset  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addAllComposedGlyphsToSubset()
      Adds to the subset, all the glyphs that are composed by a glyph, but do not appear themselves in the subset.
      boolean isComposite​(int indexInOriginal)  
      protected void populateGlyphsWithComposites()
      Populates the map of subset glyphs with all the glyphs that compose the glyphs in the subset.
      private void remapComposite​(long glyphOffset)
      Re-maps the index of composed glyphs in the original font to the index of the same glyph in the subset font.
      java.util.Set<java.lang.Integer> retrieveComposedGlyphs​(int indexInOriginal)
      Reads a composite glyph at a given index and retrieves all the glyph indices of contingent composed glyphs.
      private void scanGlyphsRecursively​(int indexInOriginal)
      Scans each glyph for any composed glyphs.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • tableOffset

        private final long tableOffset
      • remappedComposites

        private final java.util.Set<java.lang.Long> remappedComposites
      • subset

        protected final java.util.Map<java.lang.Integer,​java.lang.Integer> subset
      • compositeGlyphs

        protected java.util.Set<java.lang.Integer> compositeGlyphs
        All the composite glyphs that appear in the subset.
      • composedGlyphs

        protected java.util.Set<java.lang.Integer> composedGlyphs
        All the glyphs that are composed, but do not appear in the subset.
    • Constructor Detail

      • GlyfTable

        public GlyfTable​(FontFileReader in,
                         OFMtxEntry[] metrics,
                         OFDirTabEntry dirTableEntry,
                         java.util.Map<java.lang.Integer,​java.lang.Integer> glyphs)
                  throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • populateGlyphsWithComposites

        protected void populateGlyphsWithComposites()
                                             throws java.io.IOException
        Populates the map of subset glyphs with all the glyphs that compose the glyphs in the subset. This also re-maps the indices of composed glyphs to their new index in the subset font.
        Throws:
        java.io.IOException - an I/O error
      • scanGlyphsRecursively

        private void scanGlyphsRecursively​(int indexInOriginal)
                                    throws java.io.IOException
        Scans each glyph for any composed glyphs. This populates compositeGlyphs with all the composite glyphs being used in the subset. This also populates newGlyphs with any new glyphs that are composed and do not appear in the subset of glyphs. For example the double quote mark (") is often composed of two apostrophes ('), if an apostrophe doesn't appear in the glyphs in the subset, it will be included and will be added to newGlyphs.
        Parameters:
        indexInOriginal - the index of the glyph to test from the original font
        Throws:
        java.io.IOException - an I/O error
      • addAllComposedGlyphsToSubset

        protected void addAllComposedGlyphsToSubset()
        Adds to the subset, all the glyphs that are composed by a glyph, but do not appear themselves in the subset.
      • remapComposite

        private void remapComposite​(long glyphOffset)
                             throws java.io.IOException
        Re-maps the index of composed glyphs in the original font to the index of the same glyph in the subset font.
        Parameters:
        glyphOffset - the offset of the composite glyph
        Throws:
        java.io.IOException - an I/O error
      • isComposite

        public boolean isComposite​(int indexInOriginal)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • retrieveComposedGlyphs

        public java.util.Set<java.lang.Integer> retrieveComposedGlyphs​(int indexInOriginal)
                                                                throws java.io.IOException
        Reads a composite glyph at a given index and retrieves all the glyph indices of contingent composed glyphs.
        Parameters:
        indexInOriginal - the glyph index of the composite glyph
        Returns:
        the set of glyph indices this glyph composes
        Throws:
        java.io.IOException - an I/O error