{
    "mode": "perldoc",
    "parameter": "Font::TTF::Glyph",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Font%3A%3ATTF%3A%3AGlyph/json",
    "generated": "2026-06-15T16:05:18Z",
    "sections": {
        "NAME": {
            "content": "Font::TTF::Glyph - Holds a information for a single glyph\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This is a single glyph description as held in a TT font. On creation only its header is read.\nThus you can get the bounding box of each glyph without having to read all the other\ninformation.\n",
            "subsections": []
        },
        "INSTANCE VARIABLES": {
            "content": "In addition to the named variables in a glyph header (\"xMin\" etc.), there are also all capital\ninstance variables for holding working information, mostly from the location table.\n",
            "subsections": [
                {
                    "name": "Variables for all glyphs:",
                    "content": "The standard attributes each glyph has are:\n\nnumberOfContours\nFor simple glyphs this will be the count of contours. For compound glyphs this will be -1.\n\nxMin\nyMin\nxMax\nyMax\nThese identify the bounding box of the glyph.\n\nThere are also other, derived, instance variables for each glyph which are read when the whole\nglyph is read (via \"readdat\"):\n\ninstLen\nNumber of bytes in the hinting instructions (Warning this variable is deprecated, use\n\"length($g-\"{'hints'})> instead).\n\nhints\nThe string containing the hinting code for the glyph\n\nVariables for simple glyphs (numberOfContours >= 0):\nendPoints\nAn array of endpoints for each contour in the glyph. There are \"numberOfContours\" contours\nin a glyph. The number of points in a glyph is equal to the highest endpoint of a contour.\n\nnumPoints\nThis is a generated value which contains the total number of points for this simple glyph.\n\nThere are also a number of arrays indexed by point number:\n\nflags\nThe flags associated with reading this point. The flags for a point are recalculated for a\npoint when it is \"update\"d. Thus the flags are not very useful. The only important bit is\nbit 0 which indicates whether the point is an 'on' curve point, or an 'off' curve point.\n\nx   The absolute x co-ordinate of the point.\n\ny   The absolute y co-ordinate of the point\n\nVariables for compound glyphs (numberOfContours == -1):\nmetric\nThis holds the component number (not its glyph number) of the component from which the\nmetrics for this glyph should be taken.\n\ncomps\nThis is an array of hashes for each component. Each hash has a number of elements:\n\nglyph\nThe glyph number of the glyph which comprises this component of the composite. NOTE: In\nsome badly generated fonts, \"glyph\" may contain a numerical value but that glyph might\nnot actually exist in the font file. This could occur in any glyph, but is particularly\nlikely for glyphs that have no strokes, such as SPACE, U+00A0 NO-BREAK SPACE, or U+200B\nZERO WIDTH SPACE.\n\nargs\nAn array of two arguments which may be an x, y co-ordinate or two attachment points (one\non the base glyph the other on the component). See flags for details.\n\nflag\nThe flag for this component\n\nscale\nA 4 number array for component scaling. This allows stretching, rotating, etc. Note that\nscaling applies to placement co-ordinates (rather than attachment points) before\nlocating rather than after.\n\nnumPoints\nThis is a generated value which contains the number of components read in for this compound\nglyph.\n"
                },
                {
                    "name": "Private instance variables:",
                    "content": "INFILE (P)\nThe input file form which to read any information\n\nLOC (P)\nLocation relative to the start of the glyf table in the read file\n\nBASE (P)\nThe location of the glyf table in the read file\n\nLEN (P)\nThis is the number of bytes required by the glyph. It should be kept up to date by calling\nthe \"update\" method whenever any of the glyph content changes.\n\nOUTLOC (P)\nLocation relative to the start of the glyf table. This variable is only active whilst the\noutput process is going on. It is used to inform the location table where the glyph is\nlocated, since the glyf table is output before the loca table due to alphabetical ordering.\n\nOUTLEN (P)\nThis indicates the length of the glyph data when it is output. This more accurately reflects\nthe internal memory form than the \"LEN\" variable which only reflects the read file length.\nThe \"OUTLEN\" variable is only set after calling \"out\" or \"outdat\".\n"
                },
                {
                    "name": "Editing",
                    "content": "If you want to edit a glyph in some way, then you should readdat the glyph, then make your\nchanges and then update the glyph or set the $g->{' isDirty'} variable. The application must\nensure that the following instance variables are correct, from which update will calculate the\nrest, including the bounding box information.\n\nnumPoints\nnumberOfContours\nendPoints\nx, y, flags         (only flags bit 0)\ninstLen\nhints\n\nFor components, the numPoints, x, y, endPoints & flags are not required but the following\ninformation is required for each component.\n\nflag                (bits 2, 10, 11, 12)\nglyph\nargs\nscale\nmetric              (glyph instance variable)\n"
                }
            ]
        },
        "METHODS": {
            "content": "Font::TTF::Glyph->new(%parms)\nCreates a new glyph setting various instance variables\n\n$g->read\nReads the header component of the glyph (numberOfContours and bounding box) and also the glyph\ncontent, but into a data field rather than breaking it down into its constituent structures. Use\nreaddat for this.\n\n$g->readdat\nReads the contents of the glyph (components and curves, etc.) from the memory store \"DAT\" into\nstructures within the object.\n\n$g->out($fh)\nWrites the glyph data to outfile\n\n$g->outxml($context, $depth)\nOutputs an XML description of the glyph\n\n$g->dirty($val)\nThis sets the dirty flag to the given value or 1 if no given value. It returns the value of the\nflag\n\n$g->update\nGenerates a \"$self-\"{'DAT'}> from the internal structures, if the data has been read into\nstructures in the first place. If you are building a glyph from scratch you will need to set the\ninstance variable ' isDirty'.\n\n$g->updatebbox\nUpdates the bounding box for this glyph according to the points in the glyph\n\n$g->maxInfo\nReturns lots of information about a glyph so that the \"maxp\" table can update itself. Returns\narray containing contributions of this glyph to maxPoints, maxContours, maxCompositePoints,\nmaxCompositeContours, maxSizeOfInstructions, maxComponentElements, and maxComponentDepth.\n\n$g->empty\nEmpties the glyph of all information to the level of not having been read. Useful for saving\nmemory in apps with many glyphs being read\n\n$g->getpoints\nThis method creates point information for a compound glyph. The information is stored in the\nsame place as if the glyph was not a compound, but since numberOfContours is negative, the glyph\nis still marked as being a compound\n\n$g->getrefs\nReturns an array of all the glyph ids that are used to make up this glyph. That is all the\ncompounds and their references and so on. If this glyph is not a compound, then returns an empty\narray.\n\nPlease note the warning about bad fonts that reference nonexistent glyphs under INSTANCE\nVARIABLES above. This function will not attempt to filter out nonexistent glyph numbers.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "*   The instance variables used here are somewhat clunky and inconsistent with the other tables.\n\n*   \"update\" doesn't re-calculate the bounding box or \"numberOfContours\".\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::Glyph - Holds a information for a single glyph",
    "flags": [],
    "examples": [],
    "see_also": []
}