{
    "mode": "perldoc",
    "parameter": "Font::TTF::Ttopen",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Font%3A%3ATTF%3A%3ATtopen/json",
    "generated": "2026-06-15T14:55:15Z",
    "sections": {
        "NAME": {
            "content": "Font::TTF::Ttopen - Opentype superclass for standard Opentype lookup based tables (GSUB and\nGPOS)\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Handles all the script, lang, feature, lookup stuff for a Font::TTF::Gsub/Font::TTF::Gpos table\nleaving the class specifics to the subclass\n",
            "subsections": []
        },
        "INSTANCE VARIABLES": {
            "content": "The instance variables of an opentype table form a complex sub-module hierarchy.\n\nVersion\nThis contains the version of the table as a floating point number\n\nSCRIPTS\nThe scripts list is a hash of script tags. Each script tag (of the form\n$t->{'SCRIPTS'}{$tag}) has information below it.\n\nOFFSET  This variable is preceded by a space and gives the offset from the start of the\ntable (not the table section) to the script table for this script\n\nREFTAG  This variable is preceded by a space and gives a corresponding script tag to this\none such that the offsets in the file are the same. When writing, it is up to the\ncaller to ensure that the REFTAGs are set correctly, since these will be used to\nassume that the scripts are identical. Note that REFTAG must refer to a script which\nhas no REFTAG of its own.\n\nDEFAULT This corresponds to the default language for this script, if there is one, and\ncontains the same information as an itemised language\n\nLANGTAGS\nThis contains an array of language tag strings (each 4 bytes) corresponding to the\nlanguages listed by this script\n\n$lang   Each language is a hash containing its information:\n\nOFFSET      This variable is preceded by a a space and gives the offset from the\nstart of the whole table to the language table for this language\n\nREFTAG      This variable is preceded by a space and has the same function as for\nthe script REFTAG, only for the languages within a script.\n\nRE-ORDER    This indicates re-ordering information, and has not been set. The value\nshould always be 0.\n\nDEFAULT     This holds the index of the default feature, if there is one, or -1\notherwise.\n\nFEATURES    This is an array of feature tags for all the features enabled for this\nlanguage\n\nFEATURES\nThe features section of instance variables corresponds to the feature table in the opentype\ntable.\n\nFEATTAGS\nThis array gives the ordered list of feature tags for this table. It is used during\nreading and writing for converting between feature index and feature tag.\n\nThe rest of the FEATURES variable is itself a hash based on the feature tag for each\nfeature. Each feature has the following structure:\n\nOFFSET  This attribute is preceded by a space and gives the offset relative to the start of\nthe whole table of this particular feature.\n\nPARMS   If FeatureParams are defined for this feature, this contains a reference to the\ncorresponding FeatureParams object. Otherwise set to null.\n\nLOOKUPS This is an array containing indices to lookups in the LOOKUP instance variable of\nthe table\n\nINDEX   This gives the feature index for this feature and is used during reading and writing\nfor converting between feature tag and feature index.\n\nLOOKUP\nThis variable is an array of lookups in order and is indexed via the features of a language\nof a script. Each lookup contains subtables and other information:\n\nOFFSET  This name is preceded by a space and contains the offset from the start of the table\nto this particular lookup\n\nTYPE    This is a subclass specific type for a lookup. It stipulates the type of lookup and\nhence subtables within the lookup\n\nFLAG    Holds the lookup flag bits\n\nFILTER  Holds the MarkFilteringSet (that is, the index into GDEF->MARKSETS) for the lookup.\n\nSUB     This holds an array of subtables which are subclass specific. Each subtable must\nhave an OFFSET. The other variables described here are an abstraction used in both\nthe GSUB and GPOS tables which are the target subclasses of this class.\n\nOFFSET      This is preceded by a space and gives the offset relative to the start\nof the table for this subtable\n\nFORMAT      Gives the sub-table sub format for this GSUB subtable. It is assumed\nthat this value is correct when it comes time to write the subtable.\n\nCOVERAGE    Most lookups consist of a coverage table corresponding to the first\nglyph to match. The offset of this coverage table is stored here and the\ncoverage table looked up against the GSUB table proper. There are two\nlookups without this initial coverage table which is used to index into\nthe RULES array. These lookups have one element in the RULES array which\nis used for the whole match.\n\nRULES       The rules are a complex array. In most cases, each element of the array\ncorresponds to an element in the coverage table (governed by the\ncoverage index). In a few caess, such as when there is no coverage\ntable, then there is considered to be only one element in the rules\narray. Each element of the array is itself an array corresponding to the\npossibly multiple string matches which may follow the initial glyph.\nEach element of this array is a hash with fixed keys corresponding to\ninformation needed to match a glyph string or act upon it. Thus the\nRULES element is an array of arrays of hashes which contain the\nfollowing keys:\n\nMATCH           This contains a sequence of elements held as an array.\nThe elements may be glyph ids (gid), class ids (cids),\nor offsets to coverage tables. Each element corresponds\nto one glyph in the glyph string. See MATCHTYPE for\ndetails of how the different element types are marked.\n\nPRE             This array holds the sequence of elements preceding the\nfirst match element and has the same form as the MATCH\narray.\n\nPOST            This array holds the sequence of elements to be tested\nfor following the match string and is of the same form\nas the MATCH array.\n\nACTION          This array holds information regarding what should be\ndone if a match is found. The array may either hold\nglyph ids (which are used to replace or insert or\nwhatever glyphs in the glyph string) or 2 element arrays\nconsisting of:\n\nOFFSET              Offset from the start of the matched\nstring that the lookup should start\nat when processing the substring.\n\nLOOKUPINDEX        The index to a lookup to be acted\nupon on the match string.\n\nCLASS       For those lookups which use class categories rather than glyph ids for\nmatching this is the offset to the class definition used to categories\nglyphs in the match string.\n\nPRECLASS   This is the offset to the class definition for the before match glyphs\n\nPOSTCLASS  This is the offset to the class definition for the after match glyphs.\n\nACTIONTYPE This string holds the type of information held in the ACTION variable of\na RULE. It is subclass specific.\n\nMATCHTYPE  This holds the type of information in the MATCH array of a RULE. This is\nsubclass specific.\n\nADJUST      This corresponds to a single action for all items in a coverage table.\nThe meaning is subclass specific.\n\nCACHE       This key starts with a space\n\nA hash of other tables (such as coverage tables, classes, anchors,\ndevice tables) based on the offset given in the subtable to that other\ninformation. Note that the documentation is particularly unhelpful here\nin that such tables are given as offsets relative to the beginning of\nthe subtable not the whole GSUB table. This includes those items which\nare stored relative to another base within the subtable.\n",
            "subsections": []
        },
        "METHODS": {
            "content": "$t->read\nReads the table passing control to the subclass to handle the subtable specifics\n\n$t->readsub($fh, $lookup, $index)\nThis stub is to allow subclasses to read subtables of lookups in a table specific manner. A\nreference to the lookup is passed in along with the subtable index. The file is located at the\nstart of the subtable to be read\n\n$t->extension()\nReturns the lookup number for the extension table that allows access to 32-bit offsets.\n\n$t->out($fh)\nWrites this Opentype table to the output calling $t->outsub for each sub table at the\nappropriate point in the output. The assumption is that on entry the number of scripts,\nlanguages, features, lookups, etc. are all resolved and the relationships fixed. This includes a\nLANGTAGS list for a script, and that all scripts and languages in their respective dictionaries\neither have a REFTAG or contain real data.\n\n$t->numsub($lookup)\nAsks the subclass to count the number of subtables for a particular lookup and to return that\nvalue. Used in out().\n\n$t->outsub($fh, $lookup, $index)\nThis stub is to allow subclasses to output subtables of lookups in a table specific manner. A\nreference to the lookup is passed in along with the subtable index. The file is located at the\nstart of the subtable to be output\n\n$t->dirty\nSetting GPOS or GSUB dirty means that OS/2 may need updating, so set it dirty.\n\n$t->maxContext\nReturns the length of the longest opentype rule in this table.\n\n$t->update\nPerform various housekeeping items:\n\nFor all lookups, set/clear 0x0010 bit of flag words based on 'FILTER' value.\n\nSort COVERAGE table and RULES for all lookups.\n\nUnless $t->{' PARENT'}{' noharmony'} is true, update will make sure that GPOS and GSUB include\nthe same scripts and languages. Any added scripts and languages will have empty feature sets.\n\nInternal Functions & Methods\nMost of these methods are used by subclasses for handling such things as coverage tables.\n\ncopy($ref)\nInternal function to copy the top level of a dictionary to create a new dictionary. Only the top\nlevel is copied.\n\n$t->readcover($coveroffset, $lookuploc, $lookup, $fh, $iscover)\nReads a coverage table and stores the results in $lookup->{' CACHE'}, that is, if it has not\nbeen read already.\n\nrefcache($obj, $cache, $offset [, $template])\nInternal function to keep track of the local positioning of subobjects such as coverage and\nclass definition tables, and their offsets. What happens is that the cache is a hash of sub\nobjects indexed by the reference (using a string mashing of the reference name which is valid\nfor the duration of the reference) and holds a list of locations in the output string which\nshould be filled in with the offset to the sub object when the final string is output in\noutfinal.\n\nUses tricks for Tie::Refhash\n\noutfinal($fh, $out, $cachelist, $state)\nInternal function to actually output everything to the file handle given that now we know the\noffset to the first sub object to be output and which sub objects are to be output and what\nlocations need to be updated, we can now generate everything. $cachelist is an array of two\nelement arrays. The first element is a cache object, the second is an offset to be subtracted\nfrom each reference to that object made in the cache.\n\nIf $state is 1, then the output is not sent to the filehandle and the return value is the string\nto be output. If $state is absent or 0 then output is not limited by storing in a string first\nand the return value is \"\";\n\n$self->readcontext($lookup, $fh, $type, $fmt, $cover, $count, $loc)\nInternal method to read context (simple and chaining context) lookup subtables for the GSUB and\nGPOS table types. The assumed values for $type correspond to those for GSUB, so GPOS should\nadjust the values upon calling.\n\n$self->outcontext($lookup, $fh, $type, $fmt, $ctables, $out, $num)\nProvides shared behaviour between GSUB and GPOS tables during output for context (chained and\nsimple) rules. In addition, support is provided here for type 4 GSUB tables, which are not used\nin GPOS. The value for $type corresponds to the type in a GSUB table so calling from GPOS should\nadjust the value accordingly.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "*   No way to share cachable items (coverage tables, classes, anchors, device tables) across\ndifferent lookups. The items are always output after the lookup and repeated if necessary.\nWithin lookup sharing is possible.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Martin Hosken <http://scripts.sil.org/FontUtils>.\n",
            "subsections": []
        },
        "LICENSING": {
            "content": "Copyright (c) 1998-2016, SIL International (http://www.sil.org)\n\nThis module is released under the terms of the Artistic License 2.0. For details, see the full\ntext of the license in the file LICENSE.\n",
            "subsections": []
        }
    },
    "summary": "Font::TTF::Ttopen - Opentype superclass for standard Opentype lookup based tables (GSUB and GPOS)",
    "flags": [],
    "examples": [],
    "see_also": []
}