Class GlyphSubstitutionTable


  • public class GlyphSubstitutionTable
    extends TTFTable
    A glyph substitution 'GSUB' table in a TrueType or OpenType font.
    • Constructor Detail

      • GlyphSubstitutionTable

        GlyphSubstitutionTable​(TrueTypeFont font)
    • Method Detail

      • read

        void read​(TrueTypeFont ttf,
                  TTFDataStream data)
           throws java.io.IOException
        Description copied from class: TTFTable
        This will read the required data from the stream.
        Overrides:
        read in class TTFTable
        Parameters:
        ttf - The font that is being read.
        data - The stream to read the data from.
        Throws:
        java.io.IOException - If there is an error reading the data.
      • selectScriptTag

        private java.lang.String selectScriptTag​(java.lang.String[] tags)
        Choose from one of the supplied OpenType script tags, depending on what the font supports and potentially on context.
        Parameters:
        tags -
        Returns:
        The best OpenType script tag
      • getFeatureRecords

        private java.util.List<GlyphSubstitutionTable.FeatureRecord> getFeatureRecords​(java.util.Collection<GlyphSubstitutionTable.LangSysTable> langSysTables,
                                                                                       java.util.List<java.lang.String> enabledFeatures)
        Get a list of FeatureRecords from a collection of LangSysTables. Optionally filter the returned features by supplying a list of allowed feature tags in enabledFeatures. Note that features listed as required (LangSysTable#requiredFeatureIndex) will be included even if not explicitly enabled.
        Parameters:
        langSysTables - The LangSysTables indicating FeatureRecords to search for
        enabledFeatures - An optional whitelist of feature tags (null to allow all)
        Returns:
        The indicated FeatureRecords
      • getSubstitution

        public int getSubstitution​(int gid,
                                   java.lang.String[] scriptTags,
                                   java.util.List<java.lang.String> enabledFeatures)
        Apply glyph substitutions to the supplied gid. The applicable substitutions are determined by the scriptTags which indicate the language of the gid, and by the enabledFeatures which acts as a whitelist. To ensure that a single gid isn't mapped to multiple substitutions, subsequent invocations with the same gid will return the same result as the first, regardless of script or enabled features.
        Parameters:
        gid - GID
        scriptTags - Script tags applicable to the gid (see OpenTypeScript)
        enabledFeatures - Whitelist of features to apply
      • getUnsubstitution

        public int getUnsubstitution​(int sgid)
        For a substitute-gid (obtained from getSubstitution(int, String[], List)), retrieve the original gid. Only gids previously substituted by this instance can be un-substituted. If you are trying to unsubstitute before you substitute, something is wrong.
        Parameters:
        sgid - Substitute GID