
    <`                    $   d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlT d dlZd dlZd dlZd dlZd d	lmZmZ d d
lmZ d dlmZ dZdez   dz   Z ej        d          ZddZ eee          e_         e ej        d                    Zd Zd Z d Z!d Z" eej#                  d             Z$ eej#                  d             Z% eej#                  d             Z& eej#                  d             Z' eej(                  d             Z$ eej(                  d             Z) eej(                  dd            Z& eej(                  d              Z' eej*                  d!             Z+ eej*                  d"             Z, eej-                  d#             Z+ eej-                  d$             Z, eej.                  d%             Z+ eej.                  d&             Z, eej/                  d'             Z+ eej/                  d(             Z, eej0                  d)             Z+ eej0                  d*             Z, eej1                  d+             Z2 eej3                  d,             Z4 eej5                  d-             Z, eej5                  d.             Z6 eej7                  d/             Z, eej7                  d0             Z6 eej8                  d1             Z, eej9                  d2             Z4 eej8                  d3             Z6 eej:                  d4             Z, eej:                  d5             Z6 eej;                  d6             Z, eej;                  d7             Z6 eej<                  d8             Z, eej<                  d9             Z6 eej*        ej-        ej.        ej/        ej0        ej5        ej7        ej8        ej:        ej;        ej<                  d:             Z= eej*        ej-        ej.        ej/        ej0        ej5        ej7        ej8        ej:        ej;        ej<                  d;             Z> eej*        ej-        ej.        ej/        ej0        ej?        ej@        ejA        ejB        	  	        d<             Z6 eej*        ej.        ej0                  d=             ZC eej-        ej/        ej?        ej@                  d>             ZC eej?        ej@        ejA        ejB                  d?             ZD eej?        ej@                  d@             Z+ eej?        ejA        ej@        ejB                  dA             Z, eej?        ej@        ejA        ejB                  dB             Z= eej?        ej@        ejA        ejB                  dC             Z> eejE                  dD             Z+ eejE                  dE             ZC eejE        ejF                  dF             Z, eejE        ejF                  dG             Z6 eejE        ejF                  dH             Z= eejE        ejF                  dI             Z> eejG                  ddJ            Z+ eejG                  dK             Z, eejG                  dL             Z6 eejG                  dM             Z= eejG                  dN             Z> eejG                  dO             ZC eejH                  dP             Z, eejH                  dQ             Z6 eejH                  dR             Z= eejH                  dS             ZI eejH                  dT             ZJ eejK                  dU             Z= eejL                  dV             Z= eejL                  dW             Z> eejL                  dX             ZM eejN                  dY             Z= eejO                  dZ             Z= eejO                  d[             Z> eejN                  d\             ZM eejO                  d]             ZM eejP        ejQ                  d^             ZM eejP        ejQ                  d_             ZR eejS                  dd`            ZM eejS                  da             ZR eejT                  db             ZM eejT                  dc             ZR e ejU        dd                    de             Z, e ejU        df                    dg             Z, e ejU        dh                    di             Z, e ejU        dj                    dk             Z+ e ejU        dj           ejU        dl                    dm             Z, e ejU        dj           ejU        dl                    dn             ZV e ejU        dj           ejU        dl                    do             Z= e ejU        dj           ejU        dl                    dp             ZI e ejU        dj           ejU        dl                    ddq            ZW e ejU        dj           ejU        dl                    dr             ZX e ejU        dj           ejU        dl                    ds             ZY e ejU        dj           ejU        dl                    dt             ZZ e ejU        dj           ejU        dl                    du             Z[ e ejU        dj           ejU        dl                    dv             Z\ e ejU        dj           ejU        dl                    dw             Z6 e ejU        dx                    dy             Z,dz Z] e ejU        dx                    d{             Z6 e ejU        d|                    d}             Z[ e ejU        d|                    d~             Z, e ejU        d                    d             Z, e ejU        d                    d             Z, e ejU        d                    d             Z, e ejU        d                    d             Z, e ejU        d                    d             Z+ e ejU        d                    d             Z, e ejU        d                    d             Z, e ejU        d                    d             Z[ e ejU        d                    d             Z,d Z^ e ejU        d                    d             Z, e ejU        d                    d             Z, e ejU        d                    d             Z, e ejU        d                    d             Z, e ejU        d                    d             Z[ e ejU        d                    d             Z, e ejU        d                    d             Z,d Z_ e ejU        d                    d             Z+ e ejU        d                    d             Z, e ejU        d                    d             Z6 eej`                  d             Z+ eeja                  d             Z+ e ejU        d                    d             Z+ eejb                  d             Z, eejc                  d             Z, eejd                  d             Z, eeje                  d             Z, eeja                  d             Z, e ejU        d                    d             Z, e ejf        d          jg                  d             Zh e ejU        d                    d             Z+ e ejU        d                    d             Z[ e ejU        d                    d             Z, e ejU        d                    d             Z6 e ejU        d                    d             Z+ e ejU        d                    d             Z[ e ejU        d                    d             Z, e ejU        d                    d             Z[ e ejU        d                    d             Z[ e ejU        d                    d             Z[ e ejU        d                    d             Z6 G d dei          Zj G d dei          Zk edæ          	 	 	 	 ddĄ            Zl edŦ          dƄ             ZmdǄ ZndȄ ZodɄ Zpdʄ Zq ed˦          dd̄            Zrg d͢Zsetdk    r eju         er                       dS dS )    )otRound)ttLib)otTables)
maxCtxFont)NullPen)Timer)*N)Counterdefaultdict)reduce)
MethodTypez3pyftsubset font-file [glyph...] [--option=value]...a(  pyftsubset -- OpenType font subsetter and optimizer

  pyftsubset is an OpenType font subsetter and optimizer, based on fontTools.
  It accepts any TT- or CFF-flavored OpenType (.otf or .ttf) or WOFF (.woff)
  font file. The subsetted glyph set is based on the specified glyphs
  or characters, and specified OpenType layout features.

  The tool also performs some size-reducing optimizations, aimed for using
  subset fonts as webfonts.  Individual optimizations can be enabled or
  disabled, and are enabled by default when they are safe.

Usage:
  a9  

  At least one glyph or one of --gids, --gids-file, --glyphs, --glyphs-file,
  --text, --text-file, --unicodes, or --unicodes-file, must be specified.

Arguments:
  font-file
    The input font file.
  glyph
    Specify one or more glyph identifiers to include in the subset. Must be
    PS glyph names, or the special string '*' to keep the entire glyph set.

Initial glyph set specification:
  These options populate the initial glyph set. Same option can appear
  multiple times, and the results are accummulated.
  --gids=<NNN>[,<NNN>...]
      Specify comma/whitespace-separated list of glyph IDs or ranges as
      decimal numbers.  For example, --gids=10-12,14 adds glyphs with
      numbers 10, 11, 12, and 14.
  --gids-file=<path>
      Like --gids but reads from a file. Anything after a '#' on any line
      is ignored as comments.
  --glyphs=<glyphname>[,<glyphname>...]
      Specify comma/whitespace-separated PS glyph names to add to the subset.
      Note that only PS glyph names are accepted, not gidNNN, U+XXXX, etc
      that are accepted on the command line.  The special string '*' will keep
      the entire glyph set.
  --glyphs-file=<path>
      Like --glyphs but reads from a file. Anything after a '#' on any line
      is ignored as comments.
  --text=<text>
      Specify characters to include in the subset, as UTF-8 string.
  --text-file=<path>
      Like --text but reads from a file. Newline character are not added to
      the subset.
  --unicodes=<XXXX>[,<XXXX>...]
      Specify comma/whitespace-separated list of Unicode codepoints or
      ranges as hex numbers, optionally prefixed with 'U+', 'u', etc.
      For example, --unicodes=41-5a,61-7a adds ASCII letters, so does
      the more verbose --unicodes=U+0041-005A,U+0061-007A.
      The special strings '*' will choose all Unicode characters mapped
      by the font.
  --unicodes-file=<path>
      Like --unicodes, but reads from a file. Anything after a '#' on any
      line in the file is ignored as comments.
  --ignore-missing-glyphs
      Do not fail if some requested glyphs or gids are not available in
      the font.
  --no-ignore-missing-glyphs
      Stop and fail if some requested glyphs or gids are not available
      in the font. [default]
  --ignore-missing-unicodes [default]
      Do not fail if some requested Unicode characters (including those
      indirectly specified using --text or --text-file) are not available
      in the font.
  --no-ignore-missing-unicodes
      Stop and fail if some requested Unicode characters are not available
      in the font.
      Note the default discrepancy between ignoring missing glyphs versus
      unicodes.  This is for historical reasons and in the future
      --no-ignore-missing-unicodes might become default.

Other options:
  For the other options listed below, to see the current value of the option,
  pass a value of '?' to it, with or without a '='.
  Examples:
    $ pyftsubset --glyph-names?
    Current setting for 'glyph-names' is: False
    $ ./pyftsubset --name-IDs=?
    Current setting for 'name-IDs' is: [0, 1, 2, 3, 4, 5, 6]
    $ ./pyftsubset --hinting? --no-hinting --hinting?
    Current setting for 'hinting' is: True
    Current setting for 'hinting' is: False

Output options:
  --output-file=<path>
      The output font file. If not specified, the subsetted font
      will be saved in as font-file.subset.
  --flavor=<type>
      Specify flavor of output font file. May be 'woff' or 'woff2'.
      Note that WOFF2 requires the Brotli Python extension, available
      at https://github.com/google/brotli
  --with-zopfli
      Use the Google Zopfli algorithm to compress WOFF. The output is 3-8 %
      smaller than pure zlib, but the compression speed is much slower.
      The Zopfli Python bindings are available at:
      https://pypi.python.org/pypi/zopfli

Glyph set expansion:
  These options control how additional glyphs are added to the subset.
  --retain-gids
      Retain glyph indices; just empty glyphs not needed in-place.
  --notdef-glyph
      Add the '.notdef' glyph to the subset (ie, keep it). [default]
  --no-notdef-glyph
      Drop the '.notdef' glyph unless specified in the glyph set. This
      saves a few bytes, but is not possible for Postscript-flavored
      fonts, as those require '.notdef'. For TrueType-flavored fonts,
      this works fine as long as no unsupported glyphs are requested
      from the font.
  --notdef-outline
      Keep the outline of '.notdef' glyph. The '.notdef' glyph outline is
      used when glyphs not supported by the font are to be shown. It is not
      needed otherwise.
  --no-notdef-outline
      When including a '.notdef' glyph, remove its outline. This saves
      a few bytes. [default]
  --recommended-glyphs
      Add glyphs 0, 1, 2, and 3 to the subset, as recommended for
      TrueType-flavored fonts: '.notdef', 'NULL' or '.null', 'CR', 'space'.
      Some legacy software might require this, but no modern system does.
  --no-recommended-glyphs
      Do not add glyphs 0, 1, 2, and 3 to the subset, unless specified in
      glyph set. [default]
  --no-layout-closure
      Do not expand glyph set to add glyphs produced by OpenType layout
      features.  Instead, OpenType layout features will be subset to only
      rules that are relevant to the otherwise-specified glyph set.
  --layout-features[+|-]=<feature>[,<feature>...]
      Specify (=), add to (+=) or exclude from (-=) the comma-separated
      set of OpenType layout feature tags that will be preserved.
      Glyph variants used by the preserved features are added to the
      specified subset glyph set. By default, 'calt', 'ccmp', 'clig', 'curs',
      'dnom', 'frac', 'kern', 'liga', 'locl', 'mark', 'mkmk', 'numr', 'rclt',
      'rlig', 'rvrn', and all features required for script shaping are
      preserved. To see the full list, try '--layout-features=?'.
      Use '*' to keep all features.
      Multiple --layout-features options can be provided if necessary.
      Examples:
        --layout-features+=onum,pnum,ss01
            * Keep the default set of features and 'onum', 'pnum', 'ss01'.
        --layout-features-='mark','mkmk'
            * Keep the default set of features but drop 'mark' and 'mkmk'.
        --layout-features='kern'
            * Only keep the 'kern' feature, drop all others.
        --layout-features=''
            * Drop all features.
        --layout-features='*'
            * Keep all features.
        --layout-features+=aalt --layout-features-=vrt2
            * Keep default set of features plus 'aalt', but drop 'vrt2'.
  --layout-scripts[+|-]=<script>[,<script>...]
      Specify (=), add to (+=) or exclude from (-=) the comma-separated
      set of OpenType layout script tags that will be preserved. LangSys tags
      can be appended to script tag, separated by '.', for example:
      'arab.dflt,arab.URD,latn.TRK'. By default all scripts are retained ('*').

Hinting options:
  --hinting
      Keep hinting [default]
  --no-hinting
      Drop glyph-specific hinting and font-wide hinting tables, as well
      as remove hinting-related bits and pieces from other tables (eg. GPOS).
      See --hinting-tables for list of tables that are dropped by default.
      Instructions and hints are stripped from 'glyf' and 'CFF ' tables
      respectively. This produces (sometimes up to 30%) smaller fonts that
      are suitable for extremely high-resolution systems, like high-end
      mobile devices and retina displays.

Optimization options:
  --desubroutinize
      Remove CFF use of subroutinizes.  Subroutinization is a way to make CFF
      fonts smaller.  For small subsets however, desubroutinizing might make
      the font smaller.  It has even been reported that desubroutinized CFF
      fonts compress better (produce smaller output) WOFF and WOFF2 fonts.
      Also see note under --no-hinting.
  --no-desubroutinize [default]
      Leave CFF subroutinizes as is, only throw away unused subroutinizes.

Font table options:
  --drop-tables[+|-]=<table>[,<table>...]
      Specify (=), add to (+=) or exclude from (-=) the comma-separated
      set of tables that will be be dropped.
      By default, the following tables are dropped:
      'BASE', 'JSTF', 'DSIG', 'EBDT', 'EBLC', 'EBSC', 'SVG ', 'PCLT', 'LTSH'
      and Graphite tables: 'Feat', 'Glat', 'Gloc', 'Silf', 'Sill'.
      The tool will attempt to subset the remaining tables.
      Examples:
        --drop-tables-='SVG '
            * Drop the default set of tables but keep 'SVG '.
        --drop-tables+=GSUB
            * Drop the default set of tables and 'GSUB'.
        --drop-tables=DSIG
            * Only drop the 'DSIG' table, keep all others.
        --drop-tables=
            * Keep all tables.
  --no-subset-tables+=<table>[,<table>...]
      Add to the set of tables that will not be subsetted.
      By default, the following tables are included in this list, as
      they do not need subsetting (ignore the fact that 'loca' is listed
      here): 'gasp', 'head', 'hhea', 'maxp', 'vhea', 'OS/2', 'loca', 'name',
      'cvt ', 'fpgm', 'prep', 'VMDX', 'DSIG', 'CPAL', 'MVAR', 'cvar', 'STAT'.
      By default, tables that the tool does not know how to subset and are not
      specified here will be dropped from the font, unless --passthrough-tables
      option is passed.
      Example:
         --no-subset-tables+=FFTM
            * Keep 'FFTM' table in the font by preventing subsetting.
  --passthrough-tables
      Do not drop tables that the tool does not know how to subset.
  --no-passthrough-tables
      Tables that the tool does not know how to subset and are not specified
      in --no-subset-tables will be dropped from the font. [default]
  --hinting-tables[-]=<table>[,<table>...]
      Specify (=), add to (+=) or exclude from (-=) the list of font-wide
      hinting tables that will be dropped if --no-hinting is specified,
      Examples:
        --hinting-tables-='VDMX'
            * Drop font-wide hinting tables except 'VDMX'.
        --hinting-tables=''
            * Keep all font-wide hinting tables (but strip hints from glyphs).
  --legacy-kern
      Keep TrueType 'kern' table even when OpenType 'GPOS' is available.
  --no-legacy-kern
      Drop TrueType 'kern' table if OpenType 'GPOS' is available. [default]

Font naming options:
  These options control what is retained in the 'name' table. For numerical
  codes, see: http://www.microsoft.com/typography/otspec/name.htm
  --name-IDs[+|-]=<nameID>[,<nameID>...]
      Specify (=), add to (+=) or exclude from (-=) the set of 'name' table
      entry nameIDs that will be preserved. By default, only nameIDs between 0
      and 6 are preserved, the rest are dropped. Use '*' to keep all entries.
      Examples:
        --name-IDs+=7,8,9
            * Also keep Trademark, Manufacturer and Designer name entries.
        --name-IDs=''
            * Drop all 'name' table entries.
        --name-IDs='*'
            * keep all 'name' table entries
  --name-legacy
      Keep legacy (non-Unicode) 'name' table entries (0.x, 1.x etc.).
      XXX Note: This might be needed for some fonts that have no Unicode name
      entires for English. See: https://github.com/fonttools/fonttools/issues/146
  --no-name-legacy
      Drop legacy (non-Unicode) 'name' table entries [default]
  --name-languages[+|-]=<langID>[,<langID>]
      Specify (=), add to (+=) or exclude from (-=) the set of 'name' table
      langIDs that will be preserved. By default only records with langID
      0x0409 (English) are preserved. Use '*' to keep all langIDs.
  --obfuscate-names
      Make the font unusable as a system font by replacing name IDs 1, 2, 3, 4,
      and 6 with dummy strings (it is still fully functional as webfont).

Glyph naming and encoding options:
  --glyph-names
      Keep PS glyph names in TT-flavored fonts. In general glyph names are
      not needed for correct use of the font. However, some PDF generators
      and PDF viewers might rely on glyph names to extract Unicode text
      from PDF documents.
  --no-glyph-names
      Drop PS glyph names in TT-flavored fonts, by using 'post' table
      version 3.0. [default]
  --legacy-cmap
      Keep the legacy 'cmap' subtables (0.x, 1.x, 4.x etc.).
  --no-legacy-cmap
      Drop the legacy 'cmap' subtables. [default]
  --symbol-cmap
      Keep the 3.0 symbol 'cmap'.
  --no-symbol-cmap
      Drop the 3.0 symbol 'cmap'. [default]

Other font-specific options:
  --recalc-bounds
      Recalculate font bounding boxes.
  --no-recalc-bounds
      Keep original font bounding boxes. This is faster and still safe
      for all practical purposes. [default]
  --recalc-timestamp
      Set font 'modified' timestamp to current time.
  --no-recalc-timestamp
      Do not modify font 'modified' timestamp. [default]
  --canonical-order
      Order tables as recommended in the OpenType standard. This is not
      required by the standard, nor by any known implementation.
  --no-canonical-order
      Keep original order of font tables. This is faster. [default]
  --prune-unicode-ranges
      Update the 'OS/2 ulUnicodeRange*' bits after subsetting. The Unicode
      ranges defined in the OpenType specification v1.7 are intersected with
      the Unicode codepoints specified in the font's Unicode 'cmap' subtables:
      when no overlap is found, the bit will be switched off. However, it will
      *not* be switched on if an intersection is found.  [default]
  --no-prune-unicode-ranges
      Don't change the 'OS/2 ulUnicodeRange*' bits.
  --recalc-average-width
      Update the 'OS/2 xAvgCharWidth' field after subsetting.
  --no-recalc-average-width
      Don't change the 'OS/2 xAvgCharWidth' field. [default]
  --recalc-max-context
      Update the 'OS/2 usMaxContext' field after subsetting.
  --no-recalc-max-context
      Don't change the 'OS/2 usMaxContext' field. [default]
  --font-number=<number>
      Select font number for TrueType Collection (.ttc/.otc), starting from 0.

Application options:
  --verbose
      Display verbose information of the subsetting process.
  --timing
      Display detailed timing information of the subsetting process.
  --xml
      Display the TTX XML representation of subsetted font.

Example:
  Produce a subset containing the characters ' !"#$%' without performing
  size-reducing optimizations:

  $ pyftsubset font.ttf --unicodes="U+0020-0025" \
    --layout-features='*' --glyph-names --symbol-cmap --legacy-cmap \
    --notdef-glyph --notdef-outline --recommended-glyphs \
    --name-IDs='*' --name-legacy --name-languages='*'
zfontTools.subsetc                     |                      dt          |                     |rE|                                |                      dt          fd|D                                  d S d S )NzGlyph names: %szGlyph IDs:   %sc              3   (   K   | ]}|         V  d S N ).0greverseGlyphMaps     9lib/python3.11/site-packages/fontTools/subset/__init__.py	<genexpr>z_log_glyphs.<locals>.<genexpr>d  s(      %I%IQoa&8%I%I%I%I%I%I    )infosortedgetReverseGlyphMap)selfglyphsfontr   s      @r   _log_glyphsr   `  s|    fVnn--- K++--/))v%I%I%I%I&%I%I%IIIJJJJJK Kr   zfontTools.subset.timer)loggerc                        fd}|S )zLReturns a decorator function that adds a new method to one or
	more classes.c                     g }D ]w}||v r|                     |           |j        dk    s
J d            t          || j                  rJ d|j        d| j        d            t          || j        |            xd S )NDefaultTablezOops, table class not found.zOops, class 'z' has method 'z'.)append__name__hasattrsetattr)methoddoneclazzclazzess      r   wrapperz_add_method.<locals>.wrapperq  s    	$ + +etmmX;;u
.N
*
*
*# +
*
*eV_-- ! ! !,1NNN!! ! ! 5&/6****	r   r   )r*   r+   s   ` r   _add_methodr,   n  s#         	r   c                 :    t          t          |                     S r   )r   set)ls    r   
_uniq_sortr0     s    s1vvr   c                        fd|D             S )Nc                 "    i | ]}||         S r   r   )r   r   ds     r   
<dictcomp>z _dict_subset.<locals>.<dictcomp>  s       A1Q4   r   r   )r3   r   s   ` r   _dict_subsetr5     s            r   c                 B     t                      fd|D             S )Nc                 ,    g | ]}|k     |         S r   r   )r   icountr/   s     r   
<listcomp>z _list_subset.<locals>.<listcomp>  s"    ,,,!!e))1)))r   len)r/   indicesr9   s   ` @r   _list_subsetr>     s,    	Q,,,,,w,,,,r   c                 D    fdt          | j                  D             S )z3Returns ascending list of matching coverage values.c                 "    g | ]\  }}|v 	|S r   r   )r   r8   r   r   s      r   r:   zintersect.<locals>.<listcomp>  s"    <<<sqVr   )	enumerater   r   r   s    `r   	intersectrC     s)     	=<<<i,,<<<<r   c                 D    t          fd| j        D                       S )z#Returns set of intersecting glyphs.c              3   $   K   | ]
}|v |V  d S r   r   r   r   r   s     r   r   z#intersect_glyphs.<locals>.<genexpr>  s'      22!a6kkAkkkk22r   )r.   r   rB   s    `r   intersect_glyphsrG     s*     	2222t{222222r   c                 b    |                                }fd| j        D             | _        |S )z4Returns ascending list of remaining coverage values.c                     g | ]}|v |	S r   r   rF   s     r   r:   zsubset.<locals>.<listcomp>  s    666a!v+++++r   rC   r   )r   r   r=   s    ` r   subsetrK     s8     >>&!!66664;666r   c                 .      fd|D              _         dS )zRemaps coverage.c                 *    g | ]}j         |         S r   r   r   r8   r   s     r   r:   zremap.<locals>.<listcomp>  s    5551A555r   NrN   )r   coverage_maps   ` r   remaprQ     s$     6555555r   c                      t          t           fdD                       rdgng fd j                                        D             z             S )z0Returns ascending list of matching class values.c              3   *   K   | ]}|j         vV  d S r   	classDefsr   r   r   s     r   r   zintersect.<locals>.<genexpr>  s*      771q&777777r   r   c                 "    g | ]\  }}|v 	|S r   r   r   r   vr   s      r   r:   zintersect.<locals>.<listcomp>  s"    777#!A1;;A;;;r   )r0   anyrU   itemsrB   s   ``r   rC   rC     sm     	777777777?QCCR7777%%''7778	9 	9 9r   c                      dk    rt           fdD                       S t          fd j                                        D                       S )z%Returns set of glyphs matching class.r   c              3   .   K   | ]}|j         v|V  d S r   rT   rV   s     r   r   z"intersect_class.<locals>.<genexpr>  s/      ::1!4>"9"9Q"9"9"9"9::r   c              3   6   K   | ]\  }}|k    |v |V  d S r   r   )r   r   rY   r   klasss      r   r   z"intersect_class.<locals>.<genexpr>  s@       & &#!A
u**f $& &r   )r.   rU   r[   )r   r   r_   s   ```r   intersect_classr`     s}     
QJJ	:::::::	:	:: & & & & &--// & & & 	& 	& &r   FTc                 8    fd j                                         D              _         t          |rt           fdD                       rdgng t	           j                                                   z             }|r                     |           |S )z,Returns ascending list of remaining classes.c                 $    i | ]\  }}|v 	||S r   r   rX   s      r   r4   zsubset.<locals>.<dictcomp>  s$    HHH31QAKK1QKKKr   c              3   *   K   | ]}|j         vV  d S r   rT   rV   s     r   r   zsubset.<locals>.<genexpr>  s*      "K"Kq1DN#:"K"K"K"K"K"Kr   r   )rU   r[   r0   rZ   listvaluesrQ   )r   r   rQ   	useClass0r=   s   ``   r   rK   rK     s     IHHH$."6"6"8"8HHH Ts"K"K"K"KF"K"K"KKKTQCCRT  !" " 
 **Wr   c                 \    fd| j                                         D             | _         dS )zRemaps classes.c                 B    i | ]\  }}|                     |          S r   index)r   r   rY   	class_maps      r   r4   zremap.<locals>.<dictcomp>  s+    JJJCAa1Y__Q''JJJr   N)rU   r[   )r   rk   s    `r   rQ   rQ     s3     KJJJ4>3G3G3I3IJJJr   c                     |j                             fd| j                                        D                        d S )Nc              3   *   K   | ]\  }}|v 	|V  d S r   r   )r   r   rY   
cur_glyphss      r   r   z!closure_glyphs.<locals>.<genexpr>  s+      FFsqa:ooooooFFr   )r   updatemappingr[   r   srn   s     `r   closure_glyphsrs     s@    FFFFdl0022FFFFFFFFr   c                     fd| j                                         D             | _         t          | j                   S )Nc                 @    i | ]\  }}|j         v |j         v ||S r   rN   r   r   rY   rr   s      r   r4   z!subset_glyphs.<locals>.<dictcomp>  s;     ) ) )1	QX!qx-- 1'--r   rp   r[   boolr   rr   s    `r   subset_glyphsrz     sJ    ) ) ) ) 2 2 4 4 ) ) )T\r   c                     | j                                         D ]#\  }}||v r|j                            |           $d S r   )rp   r[   r   ro   )r   rr   rn   glyphsubsts        r   rs   rs     sM    \''))  \UE
j8??5 r   c                     fd| j                                         D             | _         t          | j                   S )Nc                 d    i | ],\  }}|j         v t          fd |D                       )||-S )c              3   *   K   | ]}|j         v V  d S r   rN   )r   subrr   s     r   r   z+subset_glyphs.<locals>.<dictcomp>.<genexpr>  s)      ;;#cQXo;;;;;;r   )r   allrv   s      r   r4   z!subset_glyphs.<locals>.<dictcomp>  sR     = = =1	QX#;;;;;;;;; 1r   rw   ry   s    `r   rz   rz     sJ    = = = = 2 2 4 4 = = =T\r   c                 l     |j         j        fd| j                                        D               d S )Nc              3   *   K   | ]\  }}|v 	|V  d S r   r   )r   r   vlistrn   s      r   r   z!closure_glyphs.<locals>.<genexpr>  s8        WQuJ  r   )r   ro   
alternatesr[   rq   s     `r   rs   rs     sS        (=(=(?(?       r   c                     fd| j                                         D             | _         t          | j                   S )Nc                 |    i | ]8\  }}|j         v t          fd |D                       )|fd|D             9S )c              3   *   K   | ]}|j         v V  d S r   rN   r   rY   rr   s     r   r   z+subset_glyphs.<locals>.<dictcomp>.<genexpr>  s)      ))aAM))))))r   c                 &    g | ]}|j         v |S r   rN   r   s     r   r:   z,subset_glyphs.<locals>.<dictcomp>.<listcomp>  s     999Q1==q===r   )r   rZ   )r   r   r   rr   s      r   r4   z!subset_glyphs.<locals>.<dictcomp>  sl     + + +Ae==))))5)))))  9999%999==r   )r   r[   rx   ry   s    `r   rz   rz     sM    + + + +,,..+ + + 	T_r   c                 p     j         j        fd| j                                        D               d S )Nc              3   B   K   | ]\  }}|v 	fd |D             V  dS )c                 ^    g | ])}t          fd |j        D                       "|j        *S )c              3   *   K   | ]}|j         v V  d S r   rN   r   crr   s     r   r   z6closure_glyphs.<locals>.<genexpr>.<listcomp>.<genexpr>  s)      11aAM111111r   )r   	ComponentLigGlyphr   seqrr   s     r   r:   z,closure_glyphs.<locals>.<genexpr>.<listcomp>  sN     3 3 3S11113=111113CL 3 3 3r   Nr   )r   r   seqsrn   rr   s      r   r   z!closure_glyphs.<locals>.<genexpr>  s[        	4	Z3 3 3 3D 3 3 3 	 r   )r   ro   	ligaturesr[   rq   s    ``r   rs   rs     sZ         >''))      r   c                 $   fd| j                                         D             | _         fd| j                                         D             | _         d | j                                         D             | _         t          | j                   S )Nc                 .    i | ]\  }}|j         v ||S r   rN   rv   s      r   r4   z!subset_glyphs.<locals>.<dictcomp>  s1       31Q
qx-- Q
--r   c                 4    i | ]\  }}|fd |D             S )c                 p    g | ]2}|j         j        v t          fd |j        D                       0|3S )c              3   *   K   | ]}|j         v V  d S r   rN   r   s     r   r   z6subset_glyphs.<locals>.<dictcomp>.<listcomp>.<genexpr>  s)      ..1ah......r   )r   r   r   r   r   s     r   r:   z,subset_glyphs.<locals>.<dictcomp>.<listcomp>  sX     0 0 0c  ......... 	!    r   r   )r   r   r   rr   s      r   r4   z!subset_glyphs.<locals>.<dictcomp>  sT     + + + 
4  0 0 0 0T 0 0 0 + + +r   c                     i | ]
\  }}|||S r   r   )r   r   rY   s      r   r4   z!subset_glyphs.<locals>.<dictcomp>  s#    >>>31QA>1Q>>>r   )r   r[   rx   ry   s    `r   rz   rz     s       $."6"6"8"8   + + + + >''))+ + + ?>$."6"6"8"8>>>T^r   c                      j         dk    rn j                            |          }|r(t          fd j         j        z   D                       sd S j                             fd|D                        d S J d j         z              )N   c              3   L   K   | ]}|                     j                  V  d S r   rJ   r   s     r   r   z!closure_glyphs.<locals>.<genexpr>  sM       A A [["" A A A A A Ar   c              3   2   K   | ]}j         |         V  d S r   )
SubstituterO   s     r   r   z!closure_glyphs.<locals>.<genexpr>  s*      66$/!$666666r   r   unknown format: %s)FormatCoveragerC   r   LookAheadCoverageBacktrackCoverager   ro   )r   rr   rn   r=   s   ``  r   rs   rs     s    K1M##J//'	 
	 A A A A&)??A A A 
A 
A
 
6(//6666g66666666. 4;....r   c                    | j         dk    r| j                            j                  }t	          | j        |          | _        fdt          | j                  D             }t	          | j        |          | _        | j                            |           t          | j                  | _	        t          | j	        o't          fd| j        | j        z   D                                 S J d| j         z              )Nr   c                 ,    g | ]\  }}|j         v |S r   rN   )r   r8   r   rr   s      r   r:   z!subset_glyphs.<locals>.<listcomp>  s/       51Sqx r   c              3   L   K   | ]}|                     j                  V  d S r   rK   r   r   s     r   r   z subset_glyphs.<locals>.<genexpr>  sE       < <	 88AH < < < < < <r   r   r   )r   r   rK   r   r>   r   rA   rQ   r<   
GlyphCountrx   r   r   r   r   rr   r=   s    ` r   rz   rz     s   K1M  **' '::$/   Ido66   ' '::$/-g(($/	do <
 < < < <#D$::< < < < <
= 
= = / 4;....r   c                     | j         dv S )Nr         )DeltaFormatr   s    r   
is_hintingr     s    G##r   c                 ~    dD ]9}t          | |d           }|$|                                rt          | |           :d S )N)
XPlaDevice
YPlaDevice
XAdvDevice
YAdvDevice)getattrr   delattrr   namerY   s      r   prune_hintsr     sN    E  TdD$!]q||~~]
4 r   c                    | j         dk    r,t          | j                            |j                            S | j         dk    rv| j                            |j                  }| j        t                    fd|D             | _        t          | j                  | _        t          | j                  S J d| j         z              )Nr   r   c                 ,    g | ]}|k     |         S r   r   )r   r8   r9   re   s     r   r:   z!subset_glyphs.<locals>.<listcomp>&  s"    888aa%iiq	iiir   r   r   )r   r<   r   rK   r   Value
ValueCountrx   )r   rr   r=   r9   re   s      @@r   rz   rz     s    K1	T]!!!(++	,	,,
kQM  **':&
f++%888887888$*
OO$/	do		. 4;....r   c                 ,     j          j        dk    sJ dS  j        dk    r?|j        s j                                           j                                          _        n_ j        dk    rT|j        s j         D ]}|                                 t          t          j        d  j         D             d           _         j        dk    rHt           fd j         D                       r(d _         j        dk    r j         d         nd  _          `
dS )Nr   Tr   r   c                 6    g | ]}|                                 S r   )getEffectiveFormatr   rY   s     r   r:   z%prune_post_subset.<locals>.<listcomp>;  s$    (T(T(TA)=)=)?)?(T(T(Tr   c              3   :   K   | ]}|j         d          k    V  dS r   N)r   )r   rY   r   s     r   r   z$prune_post_subset.<locals>.<genexpr>>  s.      DDAQ$*Q-/DDDDDDr   )r   ValueFormatr   hintingr   r   r   int__or__r   r   )r   r   optionsrY   s   `   r   prune_post_subsetr   ,  s+   J		Q					 	K1	 :Z2244$
kQ	 J  qMMOOOOCJ(T(T(T(T(TVWXX$ 	K1DDDDDDDDD$+ $ 0A 5 5tz!}}4$*
or   c                      j         dk    r j                            j                  } j        t                    fd|D              _         j        D ]3}fd|j        D             |_        t          |j                  |_        4d t           j                  D             } j        	                    |           t           j        |           _        t           j                   _        t           j                  S  j         dk    r fd j                            j                             j        j                  d          D             } fd	 j                            j        dd
          D             } fd|D              _         j        D ]fd|D             _        t          |           _        t          |           _        t           j        o) j        dk    o j                            j                            S J d j         z              )Nr   c                 ,    g | ]}|k     |         S r   r   )r   r8   r9   pairss     r   r:   z!subset_glyphs.<locals>.<listcomp>K  s"    999qq5yy%(yyyr   c                 0    g | ]}|j         j        v |S r   )SecondGlyphr   )r   rrr   s     r   r:   z!subset_glyphs.<locals>.<listcomp>M  s'    RRRa8Q8Q8Q8Q8Qr   c                 &    g | ]\  }}|j         |S r   )PairValueCount)r   r8   ps      r   r:   z!subset_glyphs.<locals>.<listcomp>P  s$    FFF31QQ5EFQFFFr   r   c                 *    g | ]}|j         k     |S r   )Class1Countr   r   r   s     r   r:   z!subset_glyphs.<locals>.<listcomp>V  sI      C  C  Camnqu  rB  nB  nB  nB  nB  nBr   TrQ   c                 *    g | ]}|j         k     |S r   )Class2Countr   s     r   r:   z!subset_glyphs.<locals>.<listcomp>W  s(    pppa[\_c_o[o[o[o[o[or   F)rQ   rf   c                 *    g | ]}j         |         S r   )Class1RecordrO   s     r   r:   z!subset_glyphs.<locals>.<listcomp>X  s!    @@@t(+@@@r   c                 *    g | ]}j         |         S r   )Class2Record)r   r8   r   s     r   r:   z!subset_glyphs.<locals>.<listcomp>Z  s     ;;;1Q^A&;;;r   r   r   )r   r   rK   r   PairSetr<   PairValueRecordr   rA   rQ   r>   PairSetCountrx   	ClassDef1intersection	ClassDef2r   r   r   r   )	r   rr   r=   r   
class1_map
class2_mapr   r9   r   s	   ``    @@@r   rz   rz   E  sc   K1M  **'
,%
e**%99999G999$,< - -aRRRR1#4RRR1!+,,1FF)DL11FFF'-gdlG44$,$,''$	d	 	  
kQ C  C  C  C4>001F1Ft}G[1\1\dh0ii  C  C  C*pppp4>00QV0WWppp*@@@@Z@@@$ < <a;;;;
;;;1>>__$__$	d $
$	]!(##
% 
% % / 4;....r   c                    |j         sddd| j                 \  }}dx| _        | _        t	          | |          D ]}t	          ||          D ]}|j        r@|j                                         | xj        |j                                        z  c_        |j        r@|j                                         | xj        |j                                        z  c_        t          | j        | j        z            S )N)r   r   )r   r   r   r   r   )
r   r   ValueFormat1ValueFormat2r   Value1r   r   Value2rx   )r   r   r   attr1attr2rowr   s          r   r   r   d  s    8$&  	K,%
 +,+$d'T5!! 8 8cC 8 8qx 8X	!(55777x 8X	!(557778 	T!22333r   c                 ,   | j         dk    rv| j                            |j                  }| j        t                    fd|D             | _        t          | j                  | _        t          | j                  S J d| j         z              )Nr   c                 ,    g | ]}|k     |         S r   r   )r   r8   r9   recordss     r   r:   z!subset_glyphs.<locals>.<listcomp>~  s"    CCCU'!*r   r   r   )r   r   rK   r   EntryExitRecordr<   EntryExitCountrx   )r   rr   r=   r9   r   s      @@r   rz   rz   x  s    K1M  **' '
g,,%CCCCCgCCC$D011$	d!	"	"". 4;....r   c                     | j         dk    r	d| _         d S | j         dk    rTdD ]:}t          | |d           }|%|                                rt          | |d            ;| j        | j        d| _         d S d S d S d S )Nr   r   r   )XDeviceTableYDeviceTable)r   r   r   r&   r   r   r   s      r   r   r     s    K1$+++
kQ.  dtT4  1mmD$	4#4#<4;;; 
 #<#<r   c                     |j         sJ| j        D ]B}|j        r|j                                         |j        r|j                                         CdS NT)r   r   EntryAnchorr   
ExitAnchor)r   r   r   recs       r   r   r     sZ     3! 3 3c	o4s22444	n2cn00222r   c                 J   | j         dk    r| j                            |j                  }t	          | j        j        |          | j        _        t          | j        j                  | j        _        | j	                            |j                  }t	          | j
        j        |          | j
        _        t          | j
        j                  | j
        _        t          d | j        j        D                       }t          |          | _        | j        j        D ]!}|                    |j                  |_        "| j
        j        D ]}t	          |j        |          |_        t%          | j        o| j        j        o| j
        j                  S J d| j         z              )Nr   c              3   $   K   | ]}|j         V  d S r   Classr   s     r   r   z subset_glyphs.<locals>.<genexpr>  $      HHQWHHHHHHr   r   r   )r   MarkCoveragerK   r   r>   	MarkArray
MarkRecordr<   	MarkCountBaseCoverage	BaseArray
BaseRecord	BaseCountr0   
ClassCountrj   r  
BaseAnchorrx   )r   rr   mark_indicesbase_indicesclass_indicesmbs          r   rz   rz     sm   K1"))!(33,*4>+DlSS$. !:;;$."))!(33,*4>+DlSS$. !:;;$.HHdn.GHHHHH-&&$/>$ * *a  ))177>$ < <aq|];;1<<	do  ~ ~
! 
! ! / 4;....r   c                     |j         s^| j        j        D ]"}|j        r|j                                         #| j        j        D ]"}|j        D ]}|r|                                 #dS r   )r   r  r  
MarkAnchorr   r
  r  r  )r   r   r   r  r  as         r   r   r     s    	 N%    q|  \N%  q\  	 mmooo 
r   c                 ^   | j         dk    r| j                            |j                  }t	          | j        j        |          | j        _        t          | j        j                  | j        _        | j	                            |j                  }t	          | j
        j        |          | j
        _        t          | j
        j                  | j
        _        t          d | j        j        D                       }t          |          | _        | j        j        D ]!}|                    |j                  |_        "| j
        j        D ]&}|j        D ]}t	          |j        |          |_        't'          | j        o| j        j        o| j
        j                  S J d| j         z              )Nr   c              3   $   K   | ]}|j         V  d S r   r  r   s     r   r   z subset_glyphs.<locals>.<genexpr>  r  r   r   r   )r   r  rK   r   r>   r  r  r<   r  LigatureCoverageLigatureArrayLigatureAttachLigatureCountr0   r  rj   r  ComponentRecordLigatureAnchorrx   )r   rr   r  ligature_indicesr  r  r/   r   s           r   rz   rz     s   K1"))!(33,*4>+DlSS$. !:;;$.*11!(;;&243E3TVf&g&g$#%();)J%K%K$"HHdn.GHHHHH-&&$/>$ * *a  ))177, E Ea E Eq#A$4mDDAE	do (~('
) 
) ) / 4;....r   c                     |j         sh| j        j        D ]"}|j        r|j                                         #| j        j        D ],}|j        D ]"}|j        D ]}|r|                                 #-dS r   )	r   r  r  r  r   r  r  r  r  )r   r   r   r  r/   r   r  s          r   r   r     s    	 N%    q|  \-  q    	
 }} 
r   c                 J   | j         dk    r| j                            |j                  }t	          | j        j        |          | j        _        t          | j        j                  | j        _        | j	                            |j                  }t	          | j
        j        |          | j
        _        t          | j
        j                  | j
        _        t          d | j        j        D                       }t          |          | _        | j        j        D ]!}|                    |j                  |_        "| j
        j        D ]}t	          |j        |          |_        t#          | j        o| j        j        o| j
        j                  S J d| j         z              )Nr   c              3   $   K   | ]}|j         V  d S r   r  r   s     r   r   z subset_glyphs.<locals>.<genexpr>  s$      IIQWIIIIIIr   r   r   )r   Mark1CoveragerK   r   r>   
Mark1Arrayr  r<   r  Mark2Coverage
Mark2ArrayMark2Recordr0   r  rj   r  Mark2Anchorrx   )r   rr   mark1_indicesmark2_indicesr  r  r  s          r   rz   rz     sm   K1$++AH55-+DO,FVV$/!$/"<==$/$++AH55- ,T_-H- X X$/!$/"=>>$/IIdo.HIIIII-&&$/?% * *a  ))177?& > >a}==1==	do ! ! 
" 
" " / 4;....r   c                     |j         s^| j        j        D ]"}|j        r|j                                         #| j        j        D ]"}|j        D ]}|r|                                 #dS r   )r   r$  r  r  r   r&  r'  r(  )r   r   r   r  r  s        r   r   r     s    	 O&    q|  \O'  q]  	 mmooo 
r   c                     d S r   r   r   lookup_indicess     r   subset_lookupsr/     s	     r   c                     g S r   r   r   s    r   collect_lookupsr1    s	     	r   c                     dS r   r   r   r   r   s      r   r   r     s	     	r   c                     dS )NFr   r   s    r   may_have_non_1to1r5  (  s	     	r   c                     dS r   r   r   s    r   r5  r5  .  s	    
 	r   c                 (    G d dt                     }| j        dvrd S t          | j        d          si | j        _        | j        | j        j        vr* || j        | j                  }|| j        j        | j        <   | j        j        | j                 S )Nc                       e Zd Zd ZdS )0__subset_classify_context.<locals>.ContextHelperc                    |j                             d          rd}d}nd}d}|j                             d          rd}d}d}nd}d}d}||z   }|| _        || _        || _        || _        || _        || _        |d	z   | _	        |dk    rd
 }	d }
d }d }d }d }d }d }d }d }nS|dk    rd }	d }
d }d }d }d }d }d }d }d }n.|dk    rd }	d }
d }d }d }d }d }d  }d! }d" }nJ d#|z              |r$|
| _
        || _        || _        || _        || _        n#|	| _
        || _        || _        || _        || _        |dk    r2|d$z   | _        |d%z   | _        |d&z   | _        |d'z   | _        d( | _        d S |dk    rS|d)z   | _        |d*z   | _        |d+z   | _        |d,z   | _        d- | _        |rd.nd/| _        |rdnd| _        |rd0nd1| _        d S |dk    r|rd2nd3| _        d S d S )4NSubstSubPosChainr   r    r   LookupRecordc                     | j         S r   r   r   s    r   <lambda>zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>W       r   c                     | j         S r   rB  rC  s    r   rD  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>X      aj r   c                     dS )Nr   r   rC  s    r   rD  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>Y  s    7 r   c                     dS )N)NNNr   rC  s    r   rD  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>Z  s     2 r   c                     | j         fS r   )InputrC  s    r   rD  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>]  
    
 r   c                 *    | j         | j        | j        fS r   	BacktrackrK  	LookAheadrC  s    r   rD  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>^      ak17AK@ r   c                 >    |\  | _         d |D             \  | _        d S )Nc              3   :   K   | ]}t          |          d z   V  dS r   Nr;   r   xs     r   r   za__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetRuleData.<locals>.<genexpr>a  ,      ,,QAq,,,,,,r   )rK  r   r   r3   s     r   SetRuleDatazN__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetRuleData_  &    Zag,,!,,,_alllr   c                     |\  | _         | _        | _        t          |d                   t          |d                   dz   t          |d                   c| _        | _        | _        d S Nr   r   r   rO  rK  rP  r<   BacktrackGlyphCountInputGlyphCountLookAheadGlyphCountrX  s     r   ChainSetRuleDatazS__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.ChainSetRuleDatab  c    +,(ak17AKILQqTSVWXYZW[S\S\]^S^_bcdefcg_h_hEaA-a.C.C.Cr   r   c                     | j         S r   rB  rC  s    r   rD  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>f  rE  r   c                     | j         S r   rB  rC  s    r   rD  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>g  rG  r   c                     | j         fS r   ClassDefrC  s    r   rD  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>h  s
    AJ= r   c                 *    | j         | j        | j        fS r   BacktrackClassDefInputClassDefLookAheadClassDefrC  s    r   rD  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>i  s    !4O!! r   c                     |\  | _         d S r   rf  rX  s     r   SetContextDatazQ__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetContextDatal  s    ]ajjjr   c                 0    |\  | _         | _        | _        d S r   ri  rX  s     r   SetChainContextDatazV__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetChainContextDatan  s"     aor   c                     | j         fS r   r  rC  s    r   rD  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>r  rL  r   c                 *    | j         | j        | j        fS r   rN  rC  s    r   rD  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>s  rQ  r   c                 >    |\  | _         d |D             \  | _        d S )Nc              3   :   K   | ]}t          |          d z   V  dS rT  r;   rU  s     r   r   za__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetRuleData.<locals>.<genexpr>v  rW  r   )r  r   rX  s     r   rY  zN__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetRuleDatat  rZ  r   c                     |\  | _         | _        | _        t          |d                   t          |d                   dz   t          |d                   c| _        | _        | _        d S r\  r]  rX  s     r   ra  zS__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.ChainSetRuleDataw  rb  r   c                     | j         d         S Nr   rB  rC  s    r   rD  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>{  s    A r   c                     | j         d         S rw  )InputCoveragerC  s    r   rD  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>|  s    aoa0 r   c                     | j         S r   rB  rC  s    r   rD  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>  rE  r   c                 0    | j         | j        z   | j        z   S r   )r   ry  r   rC  s    r   rD  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>  s    a1	
	
	 r   c                 >    |\  | _         d |D             \  | _        d S )Nc              3   4   K   | ]}t          |          V  d S r   r;   rU  s     r   r   za__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetRuleData.<locals>.<genexpr>  s(      **1A******r   )r   r   rX  s     r   rY  zN__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetRuleData  s&    ]aj*****_alllr   c                 n    |\  | _         | _        | _        d |D             \  | _        | _        | _        d S )Nc              3   4   K   | ]}t          |          V  d S r   r;   rU  s     r   r   zf__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.ChainSetRuleData.<locals>.<genexpr>  s)      H[H[TUQH[H[H[H[H[H[r   )r   ry  r   r^  r_  r`  rX  s     r   ra  zS__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.ChainSetRuleData  s@    CD@a1?A,?H[H[YZH[H[H[EaA-a.C.C.Cr   r   Rule	RuleCountRuleSetRuleSetCountc                     || v r|gng S r   r   r   r   r   s      r   rD  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>  s    f1##" r   	ClassRuleClassRuleCountClassSetClassSetCountc                 x    |r|                     | |          n"|dk    rt          |           nt                      S rw  )r`   r.   r  s      r   rD  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>  s<    1 ,71+<+<VQ+G+G+G$%FFS[[[ r   rk  rg  rK  r  ry  r   )r$   endswith
startswithTypTyper>  ChainTypInputIdxDataLenr@  r   ContextDatarn  RuleDatarY  r  r  r  r  	Intersectrg  ClassDefIndexrK  )r   r_   r   r  r  r>  r  r  r  r   ChainCoverager  ChainContextDatarn  rp  r  ChainRuleDatarY  ra  s                      r   __init__z9__subset_classify_context.<locals>.ContextHelper.__init__<  s_   ng&& 
CDD
CDn(( EHGGEHGCi848494:4=4=4<N*4kk##H((M""K22N""H@@M- - -j j j j 	!##H((M((K! !     #"H@@M- - -j j j j 	!&&H00MKN##H M+ + +\ \ \ \ ,"V++++ #!DM'D-D!DM'DDM"D(DDM"DkkDIk)DNI%DL /DDDDNNN!$DI..DNJ&DL 0D8 8DN (-<OO*DM#*D!.wDJJJ!$)9zDJJJ 	r   N)r$   
__module____qualname__r  r   r   r   ContextHelperr9  ;  s(        q: q: q: q: q:r   r  r   _subset__ContextHelpers)objectr   r%   	__class__r  )r   r  helpers      r   __subset_classify_contextr  5  s    r: r: r: r: r:V r: r: r:h 	Ky  	 9:: .+-$.(Kt~====55&8>$.(5.t{;;r   c                    |                                                      |                               |          }|sg S                     |                               |          }| j        dk    r։                    |           }t          | j                  }t          | j                  }|D ]}||k    s||         st          ||         j	                  D ]b}|st          fdt          |                    |                    D                       sDt                      }	t          |j                  D ]}
|
s|
j        }||	v rd }nS|dk    r/t!                              |           j        |         g          }nt!          |j        |dz
           g          }j        j        j        |
j                 }|	                    |           |                                r8|	                    t5          |t7          |j                  dz                        |                    |           dd S | j        dk    r+t          | j                  }|                    |          }                    |           }t          | j                  }t          | j                  }|D ]}||k    s||         st          ||         j	                  D ]}|st          fdt          |                    |                    D                       sDt                      }	t          |j                  D ]$}
|
s|
j        }||	v rd }nn|dk    r$t!          |                    ||                    }nDt!          |                    j        t          |j                  |dz
                               }j        j        j        |
j                 }|	                    |           |                                rF|	                    t5          |t7          t          |j                            dz                        |                    |           &d S | j        dk    rRt          fd                    |           D                       sg S | }t          |j                  }t                      }	t          |j                  D ]}
|
s|
j        }||	v rd }nC|dk    rt!          |          }n-t!          ||                             j                            }j        j        j        |
j                 }|	                    |           |                                r3|	                    t5          |t7          |          dz                        |                    |           d S J d	| j        z              )
Nr   c              3   Z   K   | ]$\  }t          fd |D                       V  %dS )c              3   P   K   | ] }                     j        |          V  !d S r   r  r   r   kr   cdrr   s     r   r   z+closure_glyphs.<locals>.<genexpr>.<genexpr>  5      ??A1;;qxQ//??????r   Nr   r   klistr  r   rr   s     @r   r   z!closure_glyphs.<locals>.<genexpr>  s_       9 9Bu ??????????? 9 9 9 9 9 9r   r   r   )rn   c              3   Z   K   | ]$\  }t          fd |D                       V  %dS )c              3   P   K   | ] }                     j        |          V  !d S r   r  r  s     r   r   z+closure_glyphs.<locals>.<genexpr>.<genexpr>  r  r   Nr  r  s     @r   r   z!closure_glyphs.<locals>.<genexpr>  s_       : :R ??????????? : : : : : :r   r   c              3   L   K   | ]}|                     j                  V  d S r   rJ   r   rV  rr   s     r   r   z!closure_glyphs.<locals>.<genexpr>  s1      ==qQ[[""======r   r   )r  r   rC   rG   r   r  r   r  r  r  r   zipr  r.   r@  SequenceIndex	frozensetr   rK  table
LookupListLookupLookupListIndexaddr5  ro   ranger<   rs   rg  r`   )r   rr   rn   r=   r  rssrssCountr8   r   chaosllseqi
pos_glyphslookuprg  input_coveragesr   s    `              @r   rs   rs     s    
##%%::d%%j11 	)jj//
;;K1d##+ai  #T1>**( 5 5a8mm3q6m8CFAF## 5 5qh 9 9 9 9 9KA779 9 9 9 9 EEEa(( 5 5Tjj	qzz$//6q9:;;zzqwtax0122zg '(:;V
YYt___  "" 0ll5s17||A~..///14444555 50 kQT1:&&(z**'d##+ai  #T1>**( 5 5a8mm3q6m8CFAF## 5 5qh : : : : :[!**Q--88: : : : : EEEa(( 5 5Tjj	h66z1EEFFzzh66qxAGATATUY\]U]A^__``zg '(:;V
YYt___  "" <ll5s71ag#6#6779::;;;14444555 50 kQ	====AJJt,<,<===	=	= 
9
!Aqw''/
%%%Aq~&& 3 3b
h

4
emmJJqyyJ''ZZOD1BB18LLMMZG%b&89699T???   6	LLtS11!344555	z22223 3" / 4;....r   c                 p  	
 |                                  | j        dk    rJ| j                            j                  t          | j                  	t          | j                  
	
fdD             		D ]b}|st          |j                  }fd|D             }t          |j        |           t          |j
        t          |                     cfdt          	          D             | j                                       t          	          	t          | j        	           t          | j        t          	                     t          	          S | j        dk    r| j                            j                  sdS                     |           }fd|D             j                 t          | j                  	t          | j                  
	
fdD             	
t          | j                                      | j        j                  fd	t          	          D             		D ]}|st          |j                  }fd
|D             }t          |j        |           t          |j
        t          |                     |D ]C}                    |d t+                              |                    D                        Dfd	D             		r	d         	d= 	r	d         t          | j        	           t          | j        t          	                     t          	          S | j        dk    r.t/          fd                    |           D                       S J d| j        z              )Nr   c                 ,    g | ]}|k     |         S r   r   r   r8   r  r  s     r   r:   z!subset_glyphs.<locals>.<listcomp>   "    111AALLQLLLr   c                 t    g | ]4}|t          fd                     |          D                       2|5S )c              3   N   K   | ]}t          fd |D                       V   dS )c              3   *   K   | ]}|j         v V  d S r   rN   r   r   rr   s     r   r   z5subset_glyphs.<locals>.<listcomp>.<genexpr>.<genexpr>%  s)      44qAH}444444r   Nr  )r   glistrr   s     r   r   z+subset_glyphs.<locals>.<listcomp>.<genexpr>%  sT       ( ( 4444e44444 ( ( ( ( ( (r   )r   r  )r   r   r   rr   s     r   r:   z!subset_glyphs.<locals>.<listcomp>$  so     	) 	) 	)q	
	) ( ( ( (A( ( ( ( (	) 	) 	) 	)r   c                 H    g | ]\  }}|t          |j                  |S r   r   r  )r   r8   rsr   s      r   r:   z!subset_glyphs.<locals>.<listcomp>*  s3    HHH41RRHGB4G4GHQHHHr   r   Fc                 P    g | ]"}|r|                     j        d           nd#S )Tr   Nr   r  s     r   r:   z!subset_glyphs.<locals>.<listcomp>4  s5    SSS!!=...SSSr   c                 ,    g | ]}|k     |         S r   r   r  s     r   r:   z!subset_glyphs.<locals>.<listcomp>:  r  r   c                 &    g | ]\  }}|v r|nd S r   r   )r   r8   r  r=   s      r   r:   z!subset_glyphs.<locals>.<listcomp>>  s)    CCC51SW$CCCr   c                     g | ]@}|t          d  t                              |                    D                       >|AS )c              3   T   K   | ]"\  }t          fd |D                       V  #dS )c              3       K   | ]}|v V  	d S r   r   r   r  	klass_maps     r   r   z5subset_glyphs.<locals>.<listcomp>.<genexpr>.<genexpr>D  s'      55!qI~555555r   Nr  r   r  r  s     @r   r   z+subset_glyphs.<locals>.<listcomp>.<genexpr>D  s`       C C	% 5555u55555 C C C C C Cr   )r   r  r  )r   r   r   
klass_mapss     r   r:   z!subset_glyphs.<locals>.<listcomp>C  s~     	D 	D 	Dq	
	D C C#&z1::a==#A#AC C C C C	D 	D 	D 	Dr   c                 2    g | ]\  }fd |D             S )c                 :    g | ]}                     |          S r   ri   r  s     r   r:   z,subset_glyphs.<locals>.<listcomp>.<listcomp>K  s%    999ayq))999r   r   r  s     @r   r:   z!subset_glyphs.<locals>.<listcomp>K  sA     ? ? ?Ie :9995999 ? ? ?r   c                 F    g | ]}|rt          |j                  r|nd S r   r  )r   r  r   s     r   r:   z!subset_glyphs.<locals>.<listcomp>O  s3    BBBr	3gb!&))	3tBBBr   r   c              3   L   K   | ]}|                     j                  V  d S r   r   r  s     r   r   z subset_glyphs.<locals>.<genexpr>\  s1      ::AQXXah::::::r   r   r   )r  r   r   rK   r   r   r  r  r  r&   r  r<   rA   rQ   r>   rx   r  r  rg  rC   rY  r  r  r   )r   rr   r  ssr  r   r   r=   r  r  r  s    `    @@@@@r   rz   rz     s5   
 
##%%K1M  **'ai  #T1>**(11111111# % %b
hAF2	) 	) 	) 	) 	)B 	) 	) 	)2 2qvr
2q{CGG$$$$HHHH9S>>HHH'-gS'""#	$	3	$C)))	c
kQ			ah	'	' 
%d##+SSSS{SSS* q''ai  #T1>**(11111111#D!*%%//0DEE'CCCCIcNNCCC# @ @b
hAF2	D 	D 	D 	D 	DB 	D 	D 	D2 2qvr
2q{CGG$$$  @ @qMM! ? ?":qzz!}}==? ? ? @ @ @ @@
 	CBBBcBBB# B
2w 	 B	$	3	$C))) 
c
kQ	::::D)9)9:::	:	::. 4;....r   c                    |                                  }| j        dv rt          | |j                  D ]}|st          ||j                  D ]t}|st          ||j        fdt          ||j                  D                        t          ||j                  D ]$}|s                    |j                  |_        %ud S | j        dk    rqt          | |j        fdt          | |j                  D                        t          | |j                  D ]$}|s                    |j                  |_        %d S J d| j        z              )Nr   c                 *    g | ]}|r|j         v |S r   r  r   r  r.  s     r   r:   z"subset_lookups.<locals>.<listcomp>m  s8     6 6 6R	6"n44 	444r   r   c                 *    g | ]}|r|j         v |S r   r  r  s     r   r:   z"subset_lookups.<locals>.<listcomp>t  s8     5 5 5B
5!^33 333r   r   r   )	r  r   r   r  r  r&   r@  rj   r  )r   r.  r   r  r   r  s    `    r   r/  r/  `  s   
 
##%%K6D!)$$ 	C 	Cb
hB C CqhAq~6 6 6 671an-- 6 6 67 7 7 a(( C C(..r/ABBRCC	C 	C kQ	$5 5 5 5'$// 5 5 56 6 6 D!.)) A Ab
h&,,R-?@@2A A / 4;....r   c                     |                                  | j        dv r!fdt          | j                  D             S | j        dk    rd t          | j                  D             S J d| j        z              )Nr   c                     g | ]?}|t          |j                  D ]%}|t          |j                  D ]}||j        &@S r   )r   r  r@  r  )r   r  r   r  r   s       r   r:   z#collect_lookups.<locals>.<listcomp>  s     
/ 
/ 
/	
/B
/ 
/1
/ Q''
/ 
/ 
2
/"
 
/ 
/ 
/ 
/ 
/r   r   c                      g | ]}||j         S r   r  )r   r  s     r   r:   z#collect_lookups.<locals>.<listcomp>  s/     
2 
2 
2	b
2"
 
2 
2 
2r   r   r   )r  r   r   r  r@  )r   r   s    @r   r1  r1  |  s    
 
##%%K6
/ 
/ 
/ 
/T19%%
/ 
/ 
/ / kQ
2 
2T1>**
2 
2 
2 2 / 4;....r   c                 v    | j         dk    r| j                            ||           d S J d| j         z              Nr   r   r   )r   ExtSubTablers   rq   s      r   rs   rs     sD    K1!!!Z00000. 4;....r   c                 n    | j         dk    r| j                                        S J d| j         z              r  )r   r  r5  r   s    r   r5  r5    s:    K1			+	+	-	--. 4;....r   c                 p    | j         dk    r| j                            |          S J d| j         z              r  )r   r  rz   ry   s     r   rz   rz     s>     	K1			'	'	*	**. 4;....r   c                 r    | j         dk    r| j                            ||          S J d| j         z              r  )r   r  r   r3  s      r   r   r     s@     	K1			+	+D'	:	::. 4;....r   c                 p    | j         dk    r| j                            |          S J d| j         z              r  )r   r  r/  r-  s     r   r/  r/    s>     	K1			(	(	8	88. 4;....r   c                 n    | j         dk    r| j                                        S J d| j         z              r  )r   r  r1  r   s    r   r1  r1    s<     	K1			)	)	+	++. 4;....r   c                    |t          |j                  }t          |           }|j        }|                    |d          \  }}|t          |j                  k    r*t          |j                  t                      fx\  }}||<   |                    |          rd S |                    |           | j	        D ]}|s|
                    ||           d S )Nr   )r  r   id_doneLookupsgetr<   r.   issubsetro   SubTablers   )r   rr   rn   keydoneLookupsr9   coveredsts           r   rs   rs     s    ""* 
$xx~i00w	S]]&)!(mmSUU%;;-%+c"   	&
= # #R	XAz""""# #r   c                     fd| j         D             | _         t          | j                   | _        t          | j                  S )Nc                 B    g | ]}||                               |S r   rz   )r   r  rr   s     r   r:   z!subset_glyphs.<locals>.<listcomp>  s1    KKKKr7G7G7J7JK"KKKr   )r  r<   SubTableCountrx   ry   s    `r   rz   rz     sC    KKKKt}KKK$-((T   r   c                 T    d}| j         D ]}|s|                    ||          rd}|S NFT)r  r   )r   r   r   retr  s        r   r   r     s@    = 5 5R	X$((4#r   c                 D    | j         D ]}|                    |           d S r   )r  r/  )r   r.  rr   s      r   r/  r/    s4    
- # #Q>""""# #r   c                 @    t          d | j        D             g           S )Nc              3   B   K   | ]}||                                 V  d S r   )r1  r   r  s     r   r   z"collect_lookups.<locals>.<genexpr>  s3      @@bR@R!!@@@@@@r   )sumr  r   s    r   r1  r1    s#    @@DM@@@"EEEr   c                 >    t          d | j        D                       S )Nc              3   B   K   | ]}||                                 V  d S r   )r5  r  s     r   r   z$may_have_non_1to1.<locals>.<genexpr>  s3      AArbAB  ""AAAAAAr   )rZ   r  r   s    r   r5  r5    s!    AAT]AAAAAAr   c                 D    fdt          | j                  D             S )z(Returns the indices of nonempty lookups.c                 H    g | ]\  }}||                               |S r   r  )r   r8   r/   rr   s      r   r:   z!subset_glyphs.<locals>.<listcomp>  s3    IIIsqIaooa6H6HIIIIr   )rA   r  ry   s    `r   rz   rz     s*     	JIIIi,,IIIIr   c                 T    d}| j         D ]}|s|                    ||          rd}|S r  )r  r   )r   r   r   r  r/   s        r   r   r     s@    
+ 4 4Q	
Hw''3tr   c                                                          fd|D              _        t           j                   _         j        D ]}|                    |           d S )Nc                 @    g | ]}|j         k     j        |         S r   )LookupCountr  rO   s     r   r:   z"subset_lookups.<locals>.<listcomp>  s6          1
d

 A


r   )ensureDecompiledr  r<   r  r/  )r   r.  r/   s   `  r   r/  r/    s                 $$
+ # #Q>""""# #r   c                 z    |                                   fdt          | j                  D             | _        dS )+Sets lookups not in lookup_indices to None.c                 &    g | ]\  }}|v r|nd S r   r   )r   r8   r/   r.  s      r   r:   z"neuter_lookups.<locals>.<listcomp>  s+    UUUsqQ.((dUUUr   N)r  rA   r  r-  s    `r   neuter_lookupsr     s@     UUUUi>T>TUUUr   c                      t                    }	 t           fd|D             g           } fd|D             }|st                    S t          |          }                    |           |}c)zBReturns sorted index of all lookups reachable from lookup_indices.Tc              3   l   K   | ].}|j         k     j        |                                         V  /d S r   )r  r  r1  rO   s     r   r   z"closure_lookups.<locals>.<genexpr>  sN       5 5q4#333 Q779933335 5r   c                 2    g | ]}|v|j         k     |S r   )r  )r   r/   r.  r   s     r   r:   z#closure_lookups.<locals>.<listcomp>  s:     > > >1^##D,<(<(< (<(<(<r   )r0   r  extend)r   r.  recurserecurse_lookupss   ``  r   closure_lookupsr    s     ^,,	 5 5 5 55 5 568: :/> > > > > > > >/	 %
^
$
$$///((('	r   c                     fd| j         D             | _         fd| j         D             | _         t          | j                   | _        | j        pt          | j        t
          j                  S )z1"Returns True if feature is non-empty afterwards.c                     g | ]}|v |	S r   r   r   r/   r.  s     r   r:   z"subset_lookups.<locals>.<listcomp>  s-       q	
n		 			r   c                 :    g | ]}                     |          S r   ri   r  s     r   r:   z"subset_lookups.<locals>.<listcomp>  s7     # # #	 (--a00 # # #r   )r  r<   r  
isinstanceFeatureParamsr   FeatureParamsSizer-  s    `r   r/  r/    s       D$8   # # # #!# # #,--
  >d ("<==r   c                 D    fdt          | j                  D             S ))Returns the indices of nonempty features.c                 d    g | ],\  }}|j                                       s|j        d k    *|-S )pref)Featurer/  
FeatureTag)r   r8   fr.  s      r   r:   z"subset_lookups.<locals>.<listcomp>.  sK     	 	 	sqy//	LF 
r   )rA   FeatureRecordr-  s    `r   r/  r/  '  s8    	 	 	 	i 233 	 	 	 r   c                 <     t           fd|D             g           S )Nc              3   \   K   | ]&}|j         k     j        |         j        j        V  'd S r   )FeatureCountr&  r#  r  rO   s     r   r   z"collect_lookups.<locals>.<genexpr>4  sK        	4 "*: r   )r  r   feature_indicess   ` r   r1  r1  2  s>          !	# 	# #r   c                     |                                   t          | j        |          | _        t          | j                  | _        t          | j                  S r   )r  r>   r&  r<   r)  rx   r*  s     r   subset_featuresr-  8  sM    "4#5GG+,,Tr   c                 *    fd| j         D             S )r   c                 R    g | ]#}|j                                       |j        $S r   )r#  r/  FeatureIndex)r   r   r.  s     r   r:   z"subset_lookups.<locals>.<listcomp>B  s?     	0 	0 	0Ai~..	0 	0 	0 	0r   )SubstitutionRecordr-  s    `r   r/  r/  ?  s0    	0 	0 	0 	0!8 	0 	0 	0 0r   c                 F    t          fd| j        D             g           S )r   c              3   L   K   | ]}|j                                       V  d S r   )FeatureTableSubstitutionr/  )r   r%  r.  s     r   r   z!subset_lookups.<locals>.<genexpr>H  sH       * *	 '66~FF * * * * * *r   r  FeatureVariationRecordr-  s    `r   r/  r/  E  sC     	 * * * *(* * *+-	/ 	/ /r   c                 F    t          fd| j        D             g           S )Nc              3   `   K   | ](}|j         j        D ]}|j        v |j        j        V  )d S r   )r4  r1  r0  r#  r  )r   vrr   r+  s      r   r   z"collect_lookups.<locals>.<genexpr>M  s\       * *
(;* *	~(( Y& )((((* *r   r5  r*  s    `r   r1  r1  K  sC     * * * *)* * * ,.	/ 	/ /r   c                    |                                   fd| j        D             | _        | j        D ]!}                    |j                  |_        "t	          | j                  | _        t          | j                  S )Nc                 &    g | ]}|j         v |S r   )r0  )r   r   r+  s     r   r:   z#subset_features.<locals>.<listcomp>U  s/     / / /!No-- ---r   )r  r1  rj   r0  r<   SubstitutionCountrx   r   r+  r   s    ` r   r-  r-  R  s    / / / /t'> / / / 
! 9 9Q"((88!..d566T#$$$r   c                 v   |                                   | j        D ]}|j                            |           | j        rN| j        d         j        j        s7| j                                         | j        r| j        d         j        j        7t          | j                  | _        t          | j                  S )Nr  )	r  r6  r4  r-  r<  popr<   FeatureVariationCountrx   r=  s      r   r-  r-  ]  s    

% > >Q,,_==== 	# $
!"%.$ !!### 	# $
!"%.$ "$"=>>T'(((r   c                 4   | j         v r                     | j                   | _         nd| _         fd| j        D             | _        fd| j        D             | _        t          | j                  | _        t          | j        p
| j         dk              S )N  c                     g | ]}|v |	S r   r   r   r%  r+  s     r   r:   z#subset_features.<locals>.<listcomp>r  s#    KKKAa?6J6Ja6J6J6Jr   c                 B    g | ]}|v                      |          S r   ri   rD  s     r   r:   z#subset_features.<locals>.<listcomp>t  s;     % % %1O## &++A..###r   )ReqFeatureIndexrj   r0  r<   r)  rx   r*  s    `r   r-  r-  k  s     	O++(..t/CDD$$KKKK!2KKK% % % %8I % % %*++T?$"6%"?@@@r   c                     | j         d d          }| j        dk    r|                    | j                   t          |          S NrB  )r0  rF  r#   r0   r*  s     r   collect_featuresrI  y  sH     $QQQ'E!!-...?###r   c                     | j         r#| j                                       s	|sd | _         fd| j        D             | _        t          | j                  | _        t          | j        p| j                   S )Nc                 H    g | ]}|j                                       |S r   )LangSysr-  )r   r/   r+  s     r   r:   z#subset_features.<locals>.<listcomp>  s=     3 3 3Qy  113q 3 3 3r   )DefaultLangSysr-  LangSysRecordr<   LangSysCountrx   )r   r+  keepEmptyDefaultLangSyss    ` r   r-  r-    s     ++O<< $3 3 3 3$"4 3 3 3+,,T5$"5666r   c                     d | j         D             }| j        r,|                    | j                                                   t	          t          |g                     S )Nc                 @    g | ]}|j                                         S r   )rL  rI  )r   r/   s     r   r:   z$collect_features.<locals>.<listcomp>  s&    MMMQAI..00MMMr   )rN  rM  r#   rI  r0   r  r*  s     r   rI  rI    s_    MM$:LMMM A,==??@@@3++,,,r   c                     fd| j         D             | _         t          | j                   | _        t          | j                  S )Nc                 `    g | ]*}|j                             |j        d k              s(|+S )DFLT)Scriptr-  	ScriptTag)r   rr   r+  retain_emptys     r   r:   z#subset_features.<locals>.<listcomp>  sN       AX%%oq{F7JKKa   r   )ScriptRecordr<   ScriptCountrx   )r   r+  rX  s    ``r   r-  r-    s\        !2    )**Tr   c                 Z    t          t          d | j        D             g                     S )Nc              3   H   K   | ]}|j                                         V  d S r   )rV  rI  r   rr   s     r   r   z#collect_features.<locals>.<genexpr>  sD       & & 1133 & & & & & &r   )r0   r  rY  r   s    r   rI  rI    sB    3 & &$& & &')+ + 	, 	, ,r   EBLCc                     | j         D ]:}|j        D ]}fd|j        D             |_        d |j        D             |_        ;d | j         D             | _         dS )Nc                 &    g | ]}|j         v |S r   rN   )r   nrr   s     r   r:   z!subset_glyphs.<locals>.<listcomp>  s     JJJAMM!MMMr   c                      g | ]}|j         	|S r   )names)r   r8   s     r   r:   z!subset_glyphs.<locals>.<listcomp>  s    GGGqwG1GGGr   c                      g | ]}|j         	|S r   )indexSubTablesr]  s     r   r:   z!subset_glyphs.<locals>.<listcomp>  s     ===qA,<====r   T)strikesre  rc  )r   rr   strikeindexSubTables    `  r   rz   rz     s    | H HV, K KmJJJJ]%8JJJ=GGf&;GGG&==DL===r   EBDTc                 P    fd| j         D             }d |D             | _         dS )Nc                 8    g | ]fd j         D             S )c                 *    i | ]}|v ||         S r   r   r   r   rg  s     r   r4   z,subset_glyphs.<locals>.<listcomp>.<dictcomp>  s$    111AQ&[[1fQi[[[r   rN   )r   rg  rr   s    @r   r:   z!subset_glyphs.<locals>.<listcomp>  s@        2111111  r   c                     g | ]}||S r   r   )r   rg  s     r   r:   z!subset_glyphs.<locals>.<listcomp>  s    >>>vv>F>>>r   T)
strikeData)r   rr   ro  s    ` r   rz   rz     sI          ?>>>>r   sbixc                 p    | j                                         D ]fd|j        D             _        dS )Nc                 >    i | ]}|j         v |j         |         S r   rN   rm  s     r   r4   z!subset_glyphs.<locals>.<dictcomp>  s.    OOO1A<N<N1fmA&<N<N<Nr   T)rf  re   r   )r   rr   rg  s     @r   rz   rz     sF    |""$$ P PVOOOOOOO&--r   GSUBc                    | j         |_         | j         j        r| j         j                                        }ng }| j         j        r | j         j                            |          }ng }t          | j         dd           r"|| j         j                            |          z  }t          |          }| j         j        ri |_	        	 t          |j                  }|D ]Z}|| j         j        j        k    r| j         j        j        |         s0| j         j        j        |                             |           [||j        k    rn~|`	|` d S )NFeatureVariations)r  
ScriptListrI  FeatureListr1  r   ru  r0   r  r  r  r   r  r  rs   )r   rr   r+  r.  orig_glyphsr8   s         r   rs   rs     sM   :J J)::<<///J :)99/JJ...DJ+T22 RDJ0@@QQQ.^,,J 
!.
18$$; 6 6qDJ!---x: '*4HJ #2215555QX	
 nWWWr   GPOSc                     |j         |_        | j        j        r | j        j                            |          }ng }|                     |           dS r   )glyphs_gsubedr   r  r  rz   r/  )r   rr   r.  s      r   rz   rz     sR     OJ :(66q99...^$$$r   c                 <    | j         t          j        d          k    S )Nrs  )r  r   getTableClassr   s    r   retain_empty_scriptsr~    s    
 	%-f5555r   c                    | j         j        r| j         j                            |           | j         j        r | j         j                            |          }ng }t	          | j         dd          r"|| j         j                            |          z  }t          |          }| j         j        r| j         j                            |           t	          | j         dd          r| j         j                            |           | j         j        r4| j         j                            || 	                                           dS dS )zWRetains specified lookups, then removes empty features, language
	systems, and scripts.ru  N)
r  r  r/  rw  r   ru  r0   r-  rv  r~  )r   r.  r+  s      r   r/  r/    s6   
 	J 7*&&~666J J*99.II///DJ+T22 QTZ1@@PPP/o..J :*((999DJ+T22 @*..???J V*''9R9R9T9TUUUUUV Vr   c                 `    | j         j        r!| j         j                            |           dS dS )r  N)r  r  r  r-  s     r   r  r    s:     	J 7*&&~666667 7r   c                    | j         j        r| j         j                                        }ng }| j         j        r | j         j                            |          }ng }t          | j         dd          r"|| j         j                            |          z  }t          |          }| j         j        r | j         j        	                    |          }ng }|r| 
                    |           dS |                     |           dS )z/Remove (default) or neuter unreferenced lookupsru  N)r  rv  rI  rw  r1  r   ru  r0   r  r  r/  r  )r   rQ   r+  r.  s       r   prune_lookupsr    s    	J J)::<<///J :)99/JJ...DJ+T22 RDJ0@@QQQ.^,,J :(88HH...	 &n%%%%%n%%%%%r   c                    | j         j        rfdt          | j         j        j                  D             }| j         j                            |           t          | j         dd           r| j         j                            |           ng }| j         j        r4| j         j                            ||                                            d S d S )Nc                 ,    g | ]\  }}|j         v |S r   )r$  )r   r8   r%  feature_tagss      r   r:   z'subset_feature_tags.<locals>.<listcomp>%  s3     % % %#!A||## ###r   ru  )	r  rw  rA   r&  r-  r   ru  rv  r~  )r   r  r+  s    ` r   subset_feature_tagsr     s     	J % % % %4:1?@@ % % %  *((999TZ,d33 A://@@@/J V*''9R9R9T9TUUUUUV Vr   c                 >   i t                      |D ]}d|v r|                    d          n|df\  }}                    |                    d                                         |t                                                    |                    d                     | j        j        rfd| j        j        j        D             | j        j        _        t          | j        j        j                  | j        j        _	        | j        j        j        D ]}j
        v rpdj
                 vrafdj        j        D             j        _        t          j        j                  j        _        dj
                 vrd j        _        |d S d S )N.r	      c                 &    g | ]}|j         v |S r   )rW  )r   rr   script_tagss     r   r:   z&subset_script_tags.<locals>.<listcomp>;  s/     # # #!{k!! !!!r   z*   c                 <    g | ]}|j         j                 v |S r   )
LangSysTagrW  )r   r/   langsysrecords     r   r:   z&subset_script_tags.<locals>.<listcomp>B  s7     4 4 4A	
!12	2	2 	2	2	2r   dflt)r.   splitr  ljust
setdefaultr  rv  rY  r<   rZ  rW  rV  rN  rO  rM  )r   tagstag
script_taglang_tagr  r  r  s        @@@r   subset_script_tagsr  /  s    uu ? ?S+.#::3C:*h//*""1%%&&&	Z''++HNN1,=,=>>>>J )# # # #tz$1 # # # *$ '*$**?*L&M&M$*#
%2 ) )f'!!fGF<L4M&M&M4 4 4 4 4, 4 4 4 M "%V]%@!A!AFMWV-...$(V]!) )) )r   c                    | j         j        r| j         j                                        }ng }| j         j        r| j         j                            |           t          | j         dd          r| j         j                            |           | j         j        r4| j         j                            ||                                            dS dS )zRemove unreferenced featuresru  N)r  rv  rI  rw  r-  r   ru  r~  r*  s     r   prune_featuresr  H  s     	J J)::<<///J :*((999DJ+T22 @*..???J V*''9R9R9T9TUUUUUV Vr   c                     d|j         vr|                     |j                    d|j        vr|                     |j                   |                     d           dS )Nr	   Fr   T)layout_scriptsr  layout_featuresr  r  r3  s      r   prune_pre_subsetr  W  sj     w%%%'0111w&&&72333%   r   c                 z   | j         }|j        r|j        sd S |j        j        }|j        j        D ]	}|j        j        }|s|j        j        d d          D ]}|j        }t          |j
                  t          |j
                  k    r4|j        dk    |j        dk    k    rM|j        dk    r||j                 ||j                 k    rut          t          |j
                            D ],}||j
        |                  ||j
        |                  k    r n -|j        j                            |           d S rH  )r  rv  rw  r&  rY  rV  rM  rN  rL  r<   r0  rF  r  remove)r   r  featuresrr   r3   lrr/   r8   s           r   remove_redundant_langsysr  c  sd    
 	 1 	&+


' & &Qh!	
 H"111% & &b	z1	!.S0000E!q'8E'ABB5  !"hq/@&AAA#an%%&& & &qq!"hq~a/@&AAA
U B H!!"%%%#&	& &r   c                    | j         }|                                  |j        r|j                            ||           |j        sd |_        |j        r(|                                  |                                  t          |d          r:|j        r|j        r|j        j	        sd |_        |j        s|j
        dk    rd|_
        dS )Nru  i     T)r  r  r  r   rw  r  r  r%   ru  r6  Versionr   r   r   r  s       r   r   r     s     
	 4$$T7333 	 % 
 !!! E&'' 	
 ""0G" "5 
	  U]j%@%@5=r   GDEFc                 D   |j         | j        j        rfj        j                                      }t          j        j        |          j        _        t          j        j                  j        _        j	        r4fdj	        j
                                        D             j	        _
        j        r4fdj        j
                                        D             j        _
        j        rgj        j                                      }j        j        fd|D             j        _        t          j        j                  j        _        t!          d          r-j        r&j        j        D ]}|r|                               dS )Nc                 $    i | ]\  }}|v 	||S r   r   rX   s      r   r4   z!subset_glyphs.<locals>.<dictcomp>  /       CAaF{{ a{{r   c                 $    i | ]\  }}|v 	||S r   r   rX   s      r   r4   z!subset_glyphs.<locals>.<dictcomp>  r  r   c                 @    g | ]}|k     j         j        |         S r   )
AttachListAttachPoint)r   r8   r   r  s     r   r:   z!subset_glyphs.<locals>.<listcomp>  s4     "* "* "*
!j.. #("2">q"A(..r   MarkGlyphSetsDefT)r{  r  LigCaretListr   rK   r>   r   r<   LigGlyphCountMarkAttachClassDefrU   r[   GlyphClassDefr  r   r  r%   r  )r   rr   r=   coverager   r   r  s       @@@r   rz   rz     s   
/		 F'..v66' ,U-?-H' R R%%();)D%E%E%"	    5+5;;==    $ 
    5&06688     
 B%,,V44'**"* "* "* "* "*"* "* "*% #E$4$@ A A%E%&& 5+A (1  h OOF 	r   c                    d| vrd S | d         }|j         }t          |d          sd S |j        }t                      }|                    |           d| v r | d         j                             |           |                    |          }|                    |           d| v r"| d         j                             |           d S d S )Nr  VarStorery  )r  r%   r  r.   collect_device_varidxessubset_varidxesremap_device_varidxes)r   gdefr  storeusedVarIdxes
varidx_maps         r   
_pruneGDEFr    s    
$V	z""*FF	 |,,,
dNNv,,,\::: ##L11 Z(((
dNNv,**:66666 Nr   c                 t   | j         }|j        r|j        j        sd |_        |j        r|j        j        sd |_        |j        r|j        j        sd |_        |j        r|j        j        sd |_        t          |d          r1t          |           |j
        j        dk    r|j        dk    rd|_        t          |d          r|j        r|j        j        sd |_        |j        dk    rd|_        t          |j        p8|j        p1|j        p*|j        p#|j        dk    o|j        p|j        dk    o|j
                  S )Nr  r   i  i  r  r  )r  r  r  r  rU   r  r  r   r%   r  r  VarDataCountr  r  r   rx   r  s       r   r   r     s   		 u1? %	 "U%=%G "!%	  3 = %	 U-8 %E: T
^ A%%mz!!EM	*	+	+ %  %
]j  5=U 777 7 }
"=u'=	7
 }
"5u~	8 	8 8r   kernc                 V    d | j         D             | _         t          | j                   S )Nc                 2    g | ]}t          |d           |S 	kernTable)r%   r   ts     r   r:   z$prune_pre_subset.<locals>.<listcomp>  s'    JJJ!'![2I2IJAJJJr   )
kernTablesrx   r3  s      r   r  r    s,     KJtJJJT_r   c                     |j         | j        D ],}fd|j                                        D             |_        -d | j        D             | _        t	          | j                  S )Nc                 6    i | ]\  \  }}}|v |v ||f|S r   r   )r   r  r  rY   r   s       r   r4   z!subset_glyphs.<locals>.<dictcomp>  s?     + + +WUa16kka6kk Aq)kkr   c                      g | ]}|j         	|S r   r  r  s     r   r:   z!subset_glyphs.<locals>.<listcomp>  s    >>>!!+>A>>>r   )r{  r  r  r[   rx   )r   rr   r  r   s      @r   rz   rz     s{    
/
/ + +Q+ + + +(9(9(;(; + + +!++>>t>>>T_r   vmtxc                     t          | j        |j                  | _        |j        D ]}d| j        |<   t	          | j                  S )Nr   r   )r5   metricsr   glyphs_emptiedrx   r   rr   r   s      r   rz   rz     sF    T\1844

  Q$,q//T\r   hmtxc                 l    t          | j        |j                  | _        |j        D ]}d| j        |<   dS )Nr  T)r5   r  r   r  r  s      r   rz   rz   #  s;    T\1844

  Q$,q//r   hdmxc                     fd| j                                         D             | _         | j         D ]}j        D ]}d| j         |         |<   t          | j                   S )Nc                 B    i | ]\  }}|t          |j                  S r   )r5   r   )r   szr/   rr   s      r   r4   z!subset_glyphs.<locals>.<dictcomp>,  s+    IIItr!ba**IIIr   r   )r  r[   r  rx   )r   rr   r  r   s    `  r   rz   rz   *  ss    IIIIty7H7HIII9  R  a49R=TYr   ankrc                     | j         j        j        dk    sJ dj        z              fd|j        D             _        t          j                  dk    S )Nr   zunknown 'ankr' format %sc                 >    i | ]}|j         v |j         |         S r   )Anchorsr   r|   r  s     r   r4   z!subset_glyphs.<locals>.<dictcomp>6  s8     ! ! !%	%-		 u-			r   )r  AnchorPointsr   r   r  r<   r   rr   r  s     @r   rz   rz   2  sp    		 5D! ! ! !18 ! ! !EMQr   bslnc                 r    | j         j        }|j        dv r!|j                            |j                   d S d S )N)r   r   )r  Baseliner   r   r  StandardGlyphr  s      r   rs   rs   :  s>    			LF(,,u"##### r   c                    | j         j        j        dv rfd|j        D             }t	          |          dk    rdt          |                                                              d          d         \  }_        fd|	                                D             }t	          |          dk    r|_
        ndddj                 _        `
dS )N)r   r   c                 R    i | ]#}|j                             |j                  $S r   )BaselineValuesr  DefaultBaseliner  s     r   r4   z!subset_glyphs.<locals>.<dictcomp>D  sA       
 e*..ue6KLL   r   r   r   c                 (    i | ]\  }}|k    ||S r   r   )r   r|   r  
mostCommons      r   r4   z!subset_glyphs.<locals>.<dictcomp>I  s/       XUA:oo qoor   r   T)r  r  r   r   r<   r
   re   most_commonr  r[   r  )r   rr   	baselines_cntr  r  s       @@r   rz   rz   @  s    			LF   8  )^^ai..0011==a@@C:t%5   ):):   9^^a#5A,,u|,5<r   lcarc                     | j         j        j        dv r0fd|j        D             _        t          j                  dk    S J dj        z              )N)r   r   c                 >    i | ]}|j         v |j         |         S r   )Caretsr  s     r   r4   z!subset_glyphs.<locals>.<dictcomp>V  s8     $ $ $el"" e,"""r   r   Fzunknown 'lcar' format %s)r  LigatureCaretsr   r   r  r<   r  s     @r   rz   rz   R  sp    		"	LF$ $ $ $!( $ $ $%,	U\		Q	9*U\9999r   gvarc                 L    |j         r|j        sg | j        |j        d         <   dS Nr   T)notdef_glyphnotdef_outline
variations
glyphOrderr3  s      r   r  r  \  s/     +!7 +(*$/$/!$%r   c                     t          | j        |j                  | _        t          | j                  | _        t          | j                  S r   )r5   r  r   r<   
glyphCountrx   ry   s     r   rz   rz   b  s8    ::t''T_r   c                     fd|j                                         D             }|j         | j                          }| j                                        D ]\  }}|| j        k    r|nd||<   |S )Nc                 (    i | ]\  }}||         S r   r   )r   r  rY   r  s      r   r4   z$_remap_index_map.<locals>.<dictcomp>i  s#    >>>SQq:a=>>>r   r   )rp   r[   last_retained_glyphreverseEmptiedGlyphMaplast_retained_order)rr   r  	table_mapmap_last_idxr   r8   s    `     r   _remap_index_mapr  h  s    >>>>I$5$;$;$=$=>>> y()>?@$**,, 9 9SQqA111HHq$q''r   HVARc                 T   | j         }t                      }t                      }d}|j        r[t          |j        j        |j                  |j        _        |                    |j        j                                                   nL|                    |j                                                   |	                                }|j
        j        }|j        rZt          |j        j        |j                  |j        _        |                    |j        j                                                   |j        rZt          |j        j        |j                  |j        _        |                    |j        j                                                   |j                            |||          }|j        r t!          |||j                  |j        _        |j        r t!          |||j                  |j        _        |j        r t!          |||j                  |j        _        dS NF)retainFirstMapadvIdxesT)r  r.   AdvWidthMapr5   rp   r   ro   re   reverseOrigGlyphMapcopyr   retain_gidsLsbMapRsbMapr  r  r  r   rr   r  used	advIdxes_retainAdvMapr  s          r   rz   rz   r  s   	UU	 '*5+<+DahOO%++e'..001111++a#**,,---iikk)&,	L -%el&:AHEE%,++el"))++,,,	L -%el&:AHEE%,++el"))++,,,n,,T,Yb,cc	 Q.q*e>OPP%	L G)!ZFF%,	L G)!ZFF%, 	r   VVARc                 d   | j         }t                      }t                      }d}|j        r[t          |j        j        |j                  |j        _        |                    |j        j                                                   nL|                    |j                                                   |	                                }|j
        j        }|j        rZt          |j        j        |j                  |j        _        |                    |j        j                                                   |j        rZt          |j        j        |j                  |j        _        |                    |j        j                                                   |j        rZt          |j        j        |j                  |j        _        |                    |j        j                                                   |j                            |||          }|j        r t#          |||j                  |j        _        |j        r t#          |||j                  |j        _        |j        r t#          |||j                  |j        _        |j        r t#          |||j                  |j        _        dS r  )r  r.   AdvHeightMapr5   rp   r   ro   re   r
  r  r   r  TsbMapBsbMapVOrgMapr  r  r  r  s          r   rz   rz     s2   	UU	 '+E,>,FQQ%++e (//112222++a#**,,---iikk)&,	L -%el&:AHEE%,++el"))++,,,	L -%el&:AHEE%,++el"))++,,,	M .&u}'<ahGG%-++em#**,,---n,,T,Yb,cc	 S/:u?QRR%	L G)!ZFF%,	L G)!ZFF%,	M I*1j%-HH%- 	r   VORGc                     fd| j                                         D             | _         t          | j                   | _        dS )Nc                 .    i | ]\  }}|j         v ||S r   rN   rv   s      r   r4   z!subset_glyphs.<locals>.<dictcomp>  s1       !
qx-- !
--r   T)VOriginRecordsr[   r<   numVertOriginYMetricsry   s    `r   rz   rz     sT       t':'@'@'B'B   !$"566r   opbdc                 ,   | j         j        j        dk    r0fd|j        D             _        t          j                  dk    S j        dk    r0fd|j        D             _        t          j                  dk    S J dj        z              )Nr   c                 >    i | ]}|j         v |j         |         S r   )OpticalBoundsDeltasr  s     r   r4   z!subset_glyphs.<locals>.<dictcomp>  ;     1 1 1e///  %e&?&F///r   r   c                 >    i | ]}|j         v |j         |         S r   )OpticalBoundsPointsr  s     r   r4   z!subset_glyphs.<locals>.<dictcomp>  r"  r   Fzunknown 'opbd' format %s)r  OpticalBoundsr   r   r!  r<   r$  r  s     @r   rz   rz     s    		!	LA1 1 1 1x1 1 1% 
U&	'	'!	++la1 1 1 1x1 1 1% 
U&	'	'!	++9*U\9999r   postc                 "    |j         sd| _        dS )N      @T)glyph_names
formatTyper3  s      r   r  r    s     $/r   c                     g | _         dS r   )
extraNamesry   s     r   rz   rz     s    r   propc                    | j         j        j        dk    rj        dk    S j        dk    rfd|j        D             _        t          j                                                                      d          d         \  }_        fdj        	                                D             _        t          j                  dk    r`d_        j        dk    S dS J dj        z              )Nr   r   c                 R    i | ]#}|j                             |j                  $S r   )
Propertiesr  DefaultProperties)r   r   r-  s     r   r4   z!subset_glyphs.<locals>.<dictcomp>  s@        ++At/EFF   r   c                 (    i | ]\  }}|k    ||S r   r   )r   r   r-  r  s      r   r4   z!subset_glyphs.<locals>.<dictcomp>  s3       D
*

 


r   TFzunknown 'prop' format %s)r  GlyphPropertiesr   r1  r   r0  r
   re   r  r[   r<   )r   rr   r  r  r-  s      @@r   rz   rz     s   
"K1		1	$$
kQ     $/T_335566BB1EEaH*d%$   DO,A,A,C,C   $/Q4;

 A
%%	8*T[8888r   c                 Z    t                      fd}|                     ||           S )Nc                     | j         t          j        j        t          j        j        hv r                    | j                   d S d S r   )r   r   PaintFormat
PaintGlyphPaintColrGlyphr  Glyph)paintresults    r   callbackz$_paint_glyph_names.<locals>.callback  sO    
\"&   
::ek	 r   )r.   traverse)r:  colrr<  r;  s      @r   _paint_glyph_namesr?    s@    
%%     hr   COLRc                 4   | j         dk    r?|                     | j                  | _        d | j        j        j        D             | _        |j        }|rt                      }|D ]}| j        	                    |g           D ]}|
                    |j                   | j         dk    rD| j        	                    |          }|(|                    t          || j                             ||j        z  }|j                            |           |}|d S d S )Nr   c                 (    i | ]}|j         |j        S r   )	BaseGlyphPaint)r   r   s     r   r4   z"closure_glyphs.<locals>.<dictcomp>  s.       
 =#)  r   )version_decompileColorLayersV0r  ColorLayersBaseGlyphListBaseGlyphPaintRecordColorLayersV1r   r.   r  r  r   ro   r?  )r   rr   	decomposelayersr   layerr:  s          r   rs   rs      s@   L1
 11$*==$ j&;  $
 X 55& : :a $$Q++  u
JJuz
lQ""1%%E]]%eTZ88999AH&(//&)      r   c                     ddl m} ddlm}m}  fdj        D              _         j        dk    rt           j                  S  | j	        j
         j	        j                   |fdD                       \   j	        _
         j	        _         ` j         j	        j        j        sd _         `	t                    S  | j	        fdD                         `dS )Nr   )unbuildColrV1)buildColrV1populateCOLRv0c                 >    i | ]}|j         v |j         |         S r   )rG  rV   s     r   r4   z!subset_glyphs.<locals>.<dictcomp>"  s0    WWWdFVAVAVQ(+AVAVAVr   c                 4    i | ]}|j         v ||         S r   rN   )r   r   colorGlyphsV1rr   s     r   r4   z!subset_glyphs.<locals>.<dictcomp>(  s'    ???1ah1mAr   c                 6    i | ]}|d  |         D             S )c                 *    g | ]}|j         |j        fS r   )r   colorID)r   rM  s     r   r:   z,subset_glyphs.<locals>.<dictcomp>.<listcomp>6  s!    <<<u
EM"<<<r   r   )r   r   layersV0s     r   r4   z!subset_glyphs.<locals>.<dictcomp>5  s>        <<<<<  r   T)fontTools.colorLib.unbuilderrO  fontTools.colorLib.builderrP  rQ  r   rG  rE  rx   r  	LayerListrH  rJ  rI  )r   rr   rO  rP  rQ  rT  rX  s   ``   @@r   rz   rz     sG   777777CCCCCCCCWWWWQXWWWLA	d		tz3TZ5MNN2=+????????3 3/tz/ 

 5 $,
j	h*        
 	r   CPALc                 P   |                     d          }|sdS t          t                    fd}|j        dk    rB|j                                        D ]'}|D ]"}|j                                     |           #(nt|j        j	        r4|j        j	        j
        D ]"}|j                                     |           #|j        j        j        D ]"}|j                            |j        |           #t!                                                    dhz
  | j        D ]D}fdt'          |          D             |d d <   t)          |          t)                    k    sJ Et'          t+                              D ]N\  }	}
|
         D ]@}t-          |d          r|	|_        t-          |d          r|	|_        2t/          |          Ot)          | j        d                   | _        | j        d	k    rfd
| j        D             | _        t5          | j                  S )Nr@  Fc                    t          | d          r,| j        j                                     | j                   d S t          | d          r9| j        j        D ].}|j        j                                     |j                   -d S d S )NColor	ColorLine)r%   r_  PaletteIndexr#   r`  	ColorStop)r:  stopcolors_by_indexs     r   collect_colors_by_indexz2prune_post_subset.<locals>.collect_colors_by_indexG  s    UG @5;+,33EK@@@@@uk"" @( @ @tDJ+,33DJ????@ @@ @r   r   rB  c                 "    g | ]\  }}|v 	|S r   r   )r   r8   r   retained_palette_indicess      r   r:   z%prune_post_subset.<locals>.<listcomp>]  s(    RRRdaA9Q4Q4Q4Q4Q4Qr   rW  ra  r   c                 "    g | ]\  }}|v 	|S r   r   )r   r8   labelrg  s      r   r:   z%prune_post_subset.<locals>.<listcomp>l  s/       QA9Q4Q4Q54Q4Q4Qr   )r  r   rd   rE  rG  re   rW  r#   r  LayerRecordArrayLayerRecordra  rH  rI  rD  r=  r.   keyspalettesrA   r<   r   r%   AssertionErrornumPaletteEntriespaletteEntryLabelsrx   )r   r   r   r>  re  rL  rM  r  palette	new_index	old_indexrd  rg  s              @@r   r   r   ?  s    	t$$@ @ @ @ @ 	LA '')) 1 1f 1 1uEM"))%000011 
Z  6
+7 6 6uE&'..u5555
(= > >f	<%<====   4 4 6 6776(B 7 7WRRRRi00RRR'!!!*	W566	6	6	6	6	6&v.F'G'GHH ! !Y		* ! !ffi   !FNN'' !#F

 
  ! dmA.//LA   0  $ 	T#$$$r   c                     t                      }| j        D ]}|                    |j                   | j        r)| j        j        D ]}|                    |j                   |S r   )r.   MathGlyphVariantRecordr  VariantGlyphGlyphAssemblyPartRecordsr|   )r   r   variantsrY   r   s        r   rs   rs   q  sp    EE

%  Q
,,q~ )  a<<r   c                    t          |j                  }t                      }| j        rR| j                            |          }|D ]5}|                    | j        |                             |                     6| j        rR| j                            |          }|D ]5}|                    | j	        |                             |                     6|j                            |           d S r   )
r  r   r.   VertGlyphCoveragerC   ro   VertGlyphConstructionrs   HorizGlyphCoverageHorizGlyphConstruction)r   rr   r   ry  r=   r8   s         r   rs   rs   {  s    
AH

EE I",,V44' I Ia??4-a0??GGHHHH J#--f55' J Ja??4.q1@@HHIIIIr   MATHc                 `    | j         j        r!| j         j                            |           d S d S r   )r  MathVariantsrs   ry   s     r   rs   rs     s8    J ,*((+++++, ,r   c                     | j                             |j                  }t          | j        |          | _        t          | j                  | _        t          | j                  S r   )r   rK   r   r>   ItalicsCorrectionr<   ItalicsCorrectionCountrx   r   s      r   rz   rz     sR    =))&t'=wGG"4#9::T()))r   c                     | j                             |j                  }t          | j        |          | _        t          | j                  | _        t          | j                  S r   )TopAccentCoveragerK   r   r>   TopAccentAttachmentr<   TopAccentAttachmentCountrx   r   s      r   rz   rz     sS    !((22()A7KK!$T%=!>!>T*+++r   c                     | j                             |j                  }t          | j        |          | _        t          | j                  | _        t          | j                  S r   )MathKernCoveragerK   r   r>   MathKernInfoRecordsr<   MathKernCountrx   r   s      r   rz   rz     sS     ''11()A7KK$233T   r   c                    | j         r| j                             |           | j        r| j                            |           | j        r| j                            |           | j        r| j                            |j                   dS r   )MathItalicsCorrectionInforz   MathTopAccentAttachmentMathKernInfoExtendedShapeCoveragerK   r   ry   s     r   rz   rz     s    " 2 ..q111  0,,Q/// %!!!$$$ .##AH---r   c                 j   | j         rR| j                             |j                  }t          | j        |          | _        t          | j                  | _        | j        rR| j                            |j                  }t          | j        |          | _        t          | j                  | _	        dS r   )
r{  rK   r   r>   r|  r<   VertGlyphCountr}  r~  HorizGlyphCountr   s      r   rz   rz     s     8"))!(33'+D,FPP$D677$ :#**1844' ,T-H' R R$T899$r   c                     |j         |_        | j        j        r| j        j                            |           | j        j        r| j        j                            |           dS r   )glyphs_mathedr   r  MathGlyphInforz   r  ry   s     r   rz   rz     s\    OJ ,*((+++J +*''***r   glyfc                    | j         r,t          j        d| j         d d                   d         dk    rd S t          | j                   x}| _         d}d}|r||         dz  ||dz            z  }||dz            dz  ||dz            z  }||         }|dz	  ||dz   <   |dz  ||dz   <   |d	z  }t	          |          }|dz  r|d	z  }n|dz  }|dz  r|dz  }n|d
z  r|d	z  }n
|dz  r|dz  }|dz  }|d S d S )Nz>hr   r   
   r      r      r  @          )datastructunpack	bytearrayr   )r   
glyphidmapr  r8   moreflagsglyphIDs          r   remapComponentsFastr    sZ   	 	V]42A277:a??&di(((		 
q'Q,$qs)	#%1INd1Q3i''w'l$qs)n$qs)q&!
e**%
V^ Q!VQQ	Q
V^ Q!VQQv~ qAvqqv~qAvq	$      r   c                    | j         }|j         }|rwt                      }|D ]<}||vr||         }|                    |           D ]}|                    |           =||j         z  }|j                             |           |}|ud S d S r   )r   r.   getComponentNamesr  ro   )r   rr   glyphSetrK  
componentsr   glr   s           r   rs   rs     s    KX 
uu*  ax2  &&  qNN1*(//*)  
 
 
 
 
r   c                     |j         r:|j        s3| | j        d                  }|j                                         d|_        dS )Nr   r   T)r  r  r  __dict__clearr  )r   r   r   r   s       r   r  r    sH     !7 
4?1!*!&r   c                    t          | j        j                  | _        j        j        szfdt	          | j                  D             }d t	          |          D             }| j                                        D ]'}t          |d          r|                    |           (t          j
        d          j        }j        D ]&} |            | j        |<   d| j        |         _        'fd| j        D             | _        dS )Nc                 ,    g | ]\  }}|j         v |S r   rN   )r   r8   r   rr   s      r   r:   z!subset_glyphs.<locals>.<listcomp>  s$    FFF31QQXQr   c                     i | ]\  }}||	S r   r   )r   ra  os      r   r4   z!subset_glyphs.<locals>.<dictcomp>  s    000caa000r   r  r  r   c                 8    g | ]}|j         v s	|j        v |S r   )r   r  r  s     r   r:   z!subset_glyphs.<locals>.<listcomp>	  s0    YYY!!qx--1HXCXCXACXCXCXr   T)r5   r   r   r  rA   r  re   r%   r  r   getTableModuler9  r  r  )r   rr   r=   glyphmaprY   r9  r   s    `     r   rz   rz     s   DK22		 $FFFF)DO44FFF'00Yw//000(; $ $aa $(###		f	%	%	+

  Q577$+a.$+a.YYYYtYYYr   c                 z    |j          }| j                                        D ]}|                    |           dS )N)remove_hintingT)r   r   re   trim)r   r   r   r  rY   s        r   r   r   	  sE    o%
+



 ( (Q&&&''''r   cmapc                 >   d | j         D             }|D ]}|j        dk    r^|j                                        D ]CfdD             }d |v r|                    d            j                            |           Dk|j        j        	                    
                                          }j                            fd|D                        ŉj                                        _        |D ]!}j                            |j                   "d S )Nc                 :    g | ]}|                                 |S r   	isUnicoder  s     r   r:   z"closure_glyphs.<locals>.<listcomp>	  s%    
3
3
3Q[[]]
31
3
3
3r      c                 ,    h | ]\  }}|j         v |S r   )unicodes_requestedr   ur   rr   s      r   	<setcomp>z!closure_glyphs.<locals>.<setcomp>	  s*    ===CAa1(<#<#<a#<#<#<r   c              3   (   K   | ]}|         V  d S r   r   )r   r  r  s     r   r   z!closure_glyphs.<locals>.<genexpr>"	  s'      11q47111111r   )tablesformatuvsDictre   r  r   ro   r  r  r   rl  r  unicodes_missingdifference_update)r   rr   r  r  r   r   r  s    `    @r   rs   rs   	  sE   
3
3dk
3
3
3  
2 
2U
\R}##%%  t====4===Fv~~]]4HOOF	 *4&33DIIKK@@<8??1111L1111111 *//11 3 3U&&uz22223 3r   c                     |j         sd | j        D             | _        |j        sd | j        D             | _        d | j        D             | _        t          | j                  | _        dS )Nc                 b    g | ],}|                                 s|                                *|-S r   )r  isSymbolr  s     r   r:   z$prune_pre_subset.<locals>.<listcomp>-	  s2    IIIq1;;==IAJJLLIIIIr   c                 :    g | ]}|                                 |S r   )r  r  s     r   r:   z$prune_pre_subset.<locals>.<listcomp>/	  s%    <<<qqzz||<<<<r   c                 (    g | ]}|j         d k    |S r   )r  r  s     r   r:   z$prune_pre_subset.<locals>.<listcomp>2	  s    888a!(a-----r   T)legacy_cmapr  symbol_cmapr<   numSubTablesr3  s      r   r  r  )	  sw     JIIDKIII$+ =<<DK<<<$+ 984;888%%r   c                    d _         g }i }i }| j        D ]\}|j        dk    r|j        dk    r
|||j        <   |j        dk    r|j        dk    r
|||j        <   |j        dk    rSfd|j                                        D             |_        d |j                                        D             |_        |                                r}fd|j	                                        D             |_	        |j        dk    rF|j	        r?t          |j	                                                  d	k     r|                    |           2fd
|j	                                        D             |_	        ^|D ]}|j        dk    rI|j        dk    r>|j        |v r5||j                 j	        |j	        k    r|j	                                         V|j        dk    rH|j        dk    r=|j        |v r4||j                 j	        |j	        k    r|j	                                         d | j        D             | _        t          | j                  | _        dS )Nr   r   r   r  c                 4    i | ]\  }}|fd |D             S )c                 B    g | ]\  }}|j         v s	|j        v ||fS r   glyphs_requestedr  r  s      r   r:   z,subset_glyphs.<locals>.<dictcomp>.<listcomp>H	  sH     D D DSQq1%%%a.B)B)B a5)B)B)Br   r   )r   rY   r/   rr   s      r   r4   z!subset_glyphs.<locals>.<dictcomp>H	  sY     ' ' 'Qq  D D D DA D D D ' ' 'r   c                     i | ]
\  }}|||S r   r   )r   rY   r/   s      r   r4   z!subset_glyphs.<locals>.<dictcomp>K	  s#    666!A6!666r   c                 @    i | ]\  }}|j         v s	|j        v ||S r   r  r  s      r   r4   z!subset_glyphs.<locals>.<dictcomp>M	  sF     C C CSQq!$$$Q-A(A(A q(A(A(Ar      r  c                 .    i | ]\  }}|j         v ||S r   )r  r  s      r   r4   z!subset_glyphs.<locals>.<dictcomp>T	  s6     & & &SQq!$$$ q$$$r   r  r  c                 F    g | ]}|j         d k    r|j        n|j        |S )r  )r  r  r  r  s     r   r:   z!subset_glyphs.<locals>.<listcomp>i	  s8     2 2 2a(b....ai.  ..r   T)r   r  
platformID	platEncIDlanguager  r  r[   r  r  maxrl  r#   r  r<   r  )r   rr   tables_format12_bmptable_plat0_enc3table_plat3_enc1r  s    `    r   rz   rz   6	  s   
+ & &Q\Q1;!++"#AJ\Q1;!++"#AJX^^' ' ' 'IOO%%' ' '19 76qy00666199{{}} 	&C C C CAFLLNN C C C16 h"nnnC$6$6$@$@q!!!& & & &AFLLNN & & &166
   Q<1{az%%%
#(AF226<<>>>><1{bz%%%
#(AF226<<>>>2 24; 2 2 2%% 	r   DSIGc                 "    d| _         g | _        dS r  )	usNumSigssignatureRecordsr3  s      r   r  r  q	  s     r   maxpc                     |j         s<| j        dk    r1d| _        d| _        d| _        d| _        d| _        d| _        d| _        dS )Nr  r   r   T)	r   tableVersionmaxZonesmaxTwilightPoints
maxStoragemaxFunctionDefsmaxInstructionDefsmaxStackElementsmaxSizeOfInstructionsr3  s      r   r  r  x	  sU     "	*$$4=44?444 !4r   r   c                 t   t          j                  |                    d          }|rl                    d |j        D                                            d |j        D                                            d |j        D                        |                    d          }|rh|j        j        r.                    d |j        j        j        D                                            d |j        j	        j
        D                        dj        vrfd	| j        D             | _        j        sd
 | j        D             | _        dj        vrfd| j        D             | _        j        rg }| j        D ]}|j        dv r1|                                rd                    d          nd|_        nW|j        dv r1|                                rd                    d          nd|_        n|j        dk    rd|_        n
|j        dv r|                    |           || _        dS )Nfvarc                     g | ]	}|j         
S r   )
axisNameID)r   axiss     r   r:   z$prune_pre_subset.<locals>.<listcomp>	  s    888d$/888r   c                     g | ]	}|j         
S r   )subfamilyNameIDr   insts     r   r:   z$prune_pre_subset.<locals>.<listcomp>	  s    BBB4$&BBBr   c                 2    g | ]}|j         d k    |j         S )rB  )postscriptNameIDr  s     r   r:   z$prune_pre_subset.<locals>.<listcomp>	  s2     ( ( (D&& '&&&r   STATc                     g | ]	}|j         
S r   )ValueNameID)r   val_recs     r   r:   z$prune_pre_subset.<locals>.<listcomp>	  s    ZZZ77&ZZZr   c                     g | ]	}|j         
S r   )
AxisNameID)r   axis_recs     r   r:   z$prune_pre_subset.<locals>.<listcomp>	  s    WWW((%WWWr   r	   c                 &    g | ]}|j         v |S r   )nameID)r   ra  nameIDss     r   r:   z$prune_pre_subset.<locals>.<listcomp>	  s%    ===aW)<)<)<)<)<r   c                 :    g | ]}|                                 |S r   r  )r   ra  s     r   r:   z$prune_pre_subset.<locals>.<listcomp>	  s%    777a7777r   c                 0    g | ]}|j         j        v |S r   )langIDname_languages)r   ra  r   s     r   r:   z$prune_pre_subset.<locals>.<listcomp>	  s2     + + +ax7))) )))r   )r   r  z.	utf_16_be)r      r   r?  )         T)r.   name_IDsr  ro   axes	instancesr  AxisValueArray	AxisValueDesignAxisRecordAxisrc  name_legacyr  obfuscate_namesr  r  encodestringr#   )r   r   r   r  statnamerecsra  r  s     `    @r   r  r  	  sv   w   )	..88di888999	..BB4>BBBCCC	.. ( (DN ( ( ( ) ) ) Y	Z \
>>ZZdj6O6YZZZ[[[	..WWdj6Q6VWWWXXXw====4:===$* 8 874:777$*w%%%+ + + +4: + + +$* (: 	 	ah&./kkmmHw~~k***AHH	F-.[[]]Fv}}[)))AHH	AAHH	L  ??1$*r   headc                     dS r   r   r3  s      r   r   r   	  s	     	r   c                   $   e Zd Z G d de          Z G d de          Zg dZeg dz  Zg dZg dZg d	g d
g dg dddgddgg dg dg dg dd
Z	 e
 e ee	                                          g                     Zd Zd Zg fdZdS )Optionsc                       e Zd ZdS )Options.OptionErrorNr$   r  r  r   r   r   OptionErrorr%  	            r   r'  c                       e Zd ZdS )Options.UnknownOptionErrorNr&  r   r   r   UnknownOptionErrorr*  	  r(  r   r+  )	BASEJSTFr  ri  r^  EBSCSVGPCLTLTSH)FeatGlatGlocSilfSill)avarr  gaspr   hhear  vheaOS/2locar   cvtfpgmprepVDMXr  r\  MVARcvarr  )r=  rB  r>  r?  r  r@  )rvrnccmpligaloclmarkmkmkrlig)fracnumrdnom)caltcligcursr  rclt)valtvertvkrnvpalvrt2ltraltrmrtlartlm)
initmedifinaisolmed2fin2fin3cswhmsetstch)ljmovjmotjmo)abvsblwsabvmblwm)nuktakhnrphfrkrfr"  blwfhalfabvfpstfcfarvatucjctrZ  presrg  rh  pstshalndistri  rj  )
common	fractions
horizontalverticalltrrtlarabichangultibetanindicc                 z   | j         d d          | _        | j        d d          | _        d| _        | j        d d          | _        d| _        d| _        | j	        d d          | _
        dg| _        d| _        d| _        d| _        d| _        d| _        d| _        g d| _        d| _        dg| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d | _        d | _         d| _!        d| _"        d| _#        d| _$        d| _%        d| _&         | j'        di | d S )NFTr	   )r   r   r   r   r     r  i	  r  r   )(_drop_tables_defaultdrop_tables_no_subset_tables_defaultno_subset_tablespassthrough_tables_hinting_tables_defaulthinting_tableslegacy_kernlayout_closure_layout_features_defaultr  r  ignore_missing_glyphsignore_missing_unicodesr   r)  r  r  r  r  r  r  r  r  r  recommended_glyphsrecalc_boundsrecalc_timestampprune_unicode_rangesrecalc_average_widthrecalc_max_contextcanonical_orderflavorwith_zopflidesubroutinizeverbosetimingxmlfont_numberr.   )r   kwargss     r   r  zOptions.__init__	  sl   .qqq1$8;$!$4QQQ7$$$6qqq9$$$$!%$$,$$$'''$-$$$$$$!$$$"$#$!$$$+$$$,$+$($
$(Vr   c                     |                                 D ]>\  }}t          | |          s|                     d|z            t          | ||           ?d S )NUnknown option '%s')r[   r%   r+  r&   )r   r  r  rY   s       r   r.   zOptions.set
  sh    \\^^  ca
$

 =

!
!"7!";
<
<<
4A r   c                    g }g }|D ]}|}|                     d          s|                    |           0|dd          }|                    d          }d}|dk    rQ|                     d          r|dd          }	|	dk    rd }
nd}
n|}	d	}
|	                    d
          r|	d d         }	d
}
n6|d |         }	|	d         dv r|	d         dz   }|	d d         }	||dz   d          }
|	}|	                    dd          }	t          | |	          s7|d	u s||v r|                    |           %|                     d|z            t          | |	          }|
d
k    rt          d|d|           jt          |t                    rt          |
          }
nt          |t                    rt          |
          }
nt          |t                    rt          |
          }
nt          |t                    rt          |
t                    r|                     d|z            |
                    dd                                          }|dgk    rg }d |D             }|dk    r|}
nG|dk    r|}
|
                    |           n)|dk    r!|}
|D ]}||
v r|
                    |           nJ t%          | |	|
           ||z   S )Nz--r   =r  zno-r   zcanonical-orderFT?z-+r   -_r  zCurrent setting for 'z' is: z5Option '%s' requires values to be specified using '=', r?  c                 d    g | ]-}t          |          r|d          dv rt          |d           n|.S )r   
0123456789)r<   r   rU  s     r   r:   z&Options.parse_opts.<locals>.<listcomp>M
  s=    	J	J	J!s1vv
=!A$,"6"6#a)))A	J	J	Jr   z+=z-=)r  r#   findr  replacer%   r+  r   printr  rx   r   strrd   r'  r  r  r  r&   )r   argvignore_unknownposargspassthru_optionsr  orig_ar8   opr  rY   okovvvrV  s                  r   
parse_optszOptions.parse_opts
  s>   ' D Da6
,,t

 NN1u1vvc{{122gg||E 
	
122Q	 aa
aa	
Q	Qzz# 	
3B3Q	Q	"1"Au}}
B%)R	
3B3Q	!A#$$A	2yyc1
$

 >~!5!5V$$$""#81#<===a23hh
UBB7888T QAA2s AAA2s AAA2t !T YSVWWXXX	
3			"	"	$	$B	bTzz
R	J	Jr	J	J	JB	Syy	QQ	t	QXXb\\\\	t	Q  	
axx{{{ \
4A	#	##r   N)r$   r  r  	Exceptionr'  r+  r  r  r  _layout_features_groupsr0   r  iterre   r  r  r.   r  r   r   r   r#  r#  	  s}       #####9###,,,,,+,,,# # #AAAA! ! !
 KJJ
 EDD'''888666
&	
&	  $$$---= = = " 'Jss4&&(())2(/ (/ 0 0& & &P   ,. I$ I$ I$ I$ I$ I$r   r#  c                       e Zd Z G d de          Z G d de          Z G d de          ZddZg g g d	fd
Zd Z	d Z
d Zd Zd Zd ZdS )	Subsetterc                       e Zd ZdS )Subsetter.SubsettingErrorNr&  r   r   r   SubsettingErrorr  b
  r(  r   r  c                       e Zd ZdS )&Subsetter.MissingGlyphsSubsettingErrorNr&  r   r   r   MissingGlyphsSubsettingErrorr  c
  r(  r   r  c                       e Zd ZdS )(Subsetter.MissingUnicodesSubsettingErrorNr&  r   r   r   MissingUnicodesSubsettingErrorr  d
  r(  r   r  Nc                     |st                      }|| _        t                      | _        t                      | _        t                      | _        d S r   )r#  r   r.   r  glyph_names_requestedglyph_ids_requested)r   r   s     r   r  zSubsetter.__init__f
  sD    	 YY7$,EE$"uu$ UU$r   r?  c                    | j                             |           t          |t                    r|                    d          }|                    d          }t          |          dz  }t          j        d|z  |          D ]}| j         	                    |           | j
                            |           | j                            |           d S )Nutf_8z	utf-32-ber  z>%dL)r  ro   r  bytesdecoder  r<   r  r  r  r  r  )r   r   gidsunicodestext
text_utf32ncharsr  s           r   populatezSubsetter.populatep
  s      ***e 
++g

4{{;''*z??A&=&*55 " "aq!!!!##F+++!!$'''''r   c                    |                      |          D ]\}|                                | j        j        v sB|                                | j        j        v r| j        j        r|dk    r/| j        j        s#d|v rt                              d|           ||= t          j
        |          }t          |d          rt          d|z            5  ||         }d d d            n# 1 swxY w Y   t          d|z            5  |                    || j                  }d d d            n# 1 swxY w Y   |s t                              d|           ||= At                              d|           ^d S )	Nr  ry  z
%s droppedr  z	load '%s'
prune '%s'%s pruned to empty; dropped	%s pruned)_sort_tablesstripr   r  r  r   r  logr   r   r}  r%   timerr  )r   r   r  r)   r  retains         r   _prune_pre_subsetzSubsetter._prune_pre_subset{
  s   t$$    c
yy{{dl...		t|2224<;O2vt|7FdNNHH\3S	s##5e'(( 
 	{S 	!	!  #YU              	|c!	"	" 9 9$$T4<88V9 9 9 9 9 9 9 9 9 9 9 9 9 9 9  XX+S111	cXXk3)   s$   	C%%C)	,C)	D**D.	1D.	c           	          t          |                                          }|                                t                       _         j                             j                    j                            fd j        D                        t                       _         j                             j                            |                      j                            fd j        D                         j        rFt          	                    d j                    j
        j        s                      j                   j                                         _        t                       _        d|v r\t!          d          5  |d                                          j                            |           d d d            n# 1 swxY w Y   t'           j                   _         j        rNd  j        D             }t          	                    d|            j
        j        s                     |          ~ j
        j        rd|v rH j                            |                    d	                     t          	                    d
           n4 j                            d           t          	                    d            j
        j        rd|v rt7          t9          dt;          |                                                              D ]/} j                            |                    |                     0t          	                    d            j
        j        rd|v rt!          d          5  t          	                    dt;           j                             t                               j        |           |d                                          j                            |           t          	                    dt;           j                             t                               j        |           d d d            n# 1 swxY w Y   t'           j                   _        d|v rt!          d          5  t          	                    dt;           j                             t                               j        |           |d                                          j                            |           t          	                    dt;           j                             t                               j        |           d d d            n# 1 swxY w Y   t'           j                   _         dD ]}||v rt!          d|z            5  t          	                    d|t;           j                             t                               j        |           ||                                          j                            |           t          	                    d|t;           j                             t                               j        |           d d d            n# 1 swxY w Y   d|v rt!          d          5  t          	                    dt;           j                             t                               j        |           |d                                          j                            |           t          	                    dt;           j                             t                               j        |           d d d            n# 1 swxY w Y   t'           j                   _!        d|v rt!          d           5  t          	                    d!t;           j                             t                               j        |           |d                                          j                            |           t          	                    d"t;           j                             t                               j        |           d d d            n# 1 swxY w Y   t'           j                   _"        t'           j                   _#        |$                                fd# j#        D              _%        tM           j%        '                                           _(        |                                 j(                  _)        t'                       _*         j
        j+        r fd$| j#        z
  D              _*        fd% j*        D              _,        t          	                    d&t;           j#                              `d S )'Nc              3   N   K   | ]}|t                    k     |         V   d S r   r;   r   r8   glyph_orders     r   r   z,Subsetter._closure_glyphs.<locals>.<genexpr>
  sF       # #[!!!!  +1~!!!!# #r   c              3   B   K   | ]}|t                    k    |V  d S r   r;   r  s     r   r   z,Subsetter._closure_glyphs.<locals>.<genexpr>
  sA       $ $1#k"""" """"$ $r   zMissing requested glyphs: %sr  zclose glyph list over 'cmap'c                     g | ]}d |z  S )zU+%04Xr   )r   r  s     r   r:   z-Subsetter._closure_glyphs.<locals>.<listcomp>
  s    :::qhl:::r   z)Missing glyphs for requested Unicodes: %sr  r   zAdded gid0 to subsetz.notdefzAdded .notdef to subsetr  z!Added first four glyphs to subsetrs  zclose glyph list over 'GSUB'z0Closing glyph list over 'GSUB': %d glyphs before)r   z.Closed glyph list over 'GSUB': %d glyphs afterr  zclose glyph list over 'MATH'z0Closing glyph list over 'MATH': %d glyphs beforez.Closed glyph list over 'MATH': %d glyphs after)r@  r  zclose glyph list over '%s'z.Closing glyph list over '%s': %d glyphs beforez,Closed glyph list over '%s': %d glyphs afterzclose glyph list over 'glyf'z0Closing glyph list over 'glyf': %d glyphs beforez.Closed glyph list over 'glyf': %d glyphs afterzCFF zclose glyph list over 'CFF 'z0Closing glyph list over 'CFF ': %d glyphs beforez.Closed glyph list over 'CFF ': %d glyphs afterc                 "    i | ]}||         S r   r   r   r   orders     r   r4   z-Subsetter._closure_glyphs.<locals>.<dictcomp>  s    GGGQaaGGGr   c                 6    h | ]}|         j         k    |S r   )r  )r   r   r  r   s     r   r  z,Subsetter._closure_glyphs.<locals>.<setcomp>  s,    ooo%PQ(VZVnJnJn!JnJnJnr   c                 "    i | ]}||         S r   r   r  s     r   r4   z-Subsetter._closure_glyphs.<locals>.<dictcomp>
  s     I I I58 I I Ir   zRetaining %d glyphs)-r.   getGlyphOrderr  ro   r  r  glyphs_missing
differencer  r   r   r  r  r  r   r  r  rs   intersection_updater  glyphs_cmapedr  r  r  r  getGlyphNamer  r  minr<   r  r{  r  glyphs_glyfedglyphs_cffedglyphs_retainedr   r
  r  re   r  r  r  r  r  )r   r   
realGlyphsmissingr8   r  r  r  s   `     @@r   _closure_glyphszSubsetter._closure_glyphs
  sp
   4%%''((*""$$+%%$t9::: # # # #+# # # # # # $T2==jIIJJJ $ $ $ $(@ $ $ $ $ $ $	 A88*D,?@@@
,
, A

+
+D,?
@
@@%**,,$+%%$t^^,-- 0 0L%%%K##J///0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 !--$	 ::D$9:::7887AAA
,
. 7

-
-g
6
66	\ (nnKOOD%%a(()))HH#$$$$KOOIHH&'''	\$ 2nn3q#d0022334455 + +	[__T&&q))****HH0111	\  	'Vt^^,-- ' 'HH?
4;  JJt{J&&&L%%%K##J///HH=
4;  JJt{J&&&' ' ' ' ' ' ' ' ' ' ' ' ' ' ' !--$t^^,-- ' 'HH?
4;  JJt{J&&&L%%%K##J///HH=
4;  JJt{J&&&' ' ' ' ' ' ' ' ' ' ' ' ' ' ' !--$ 
( 
(etmm	+e3	4	4 ( (XX>s4;! ! !ZZ$Z'''	%[%%%	[$$Z000XX<s4;! ! !ZZ$Z'''( ( ( ( ( ( ( ( ( ( ( ( ( ( ( t^^,-- ' 'HH?
4;  JJt{J&&&L%%%K##J///HH=
4;  JJt{J&&&' ' ' ' ' ' ' ' ' ' ' ' ' ' ' !--$t^^,-- ' 'HH?
4;  JJt{J&&&L%%%K##J///HH=
4;  JJt{J&&&' ' ' ' ' ' ' ' ' ' ' ' ' ' '  ,,$"4;//$

!
!
#
#%GGGG$2FGGG$ !9!@!@!B!BCC$!//11$2JK$!$	\ poooooZ$2F%Fooo4 I I I IT5H I I I$ (( #d&:";";<<<
kkksq   6GG GCQ11Q58Q5(CVV
V
CZ%%Z)	,Z)	C^##^'*^'Cb88b<?b<c                                                     D ]<}t          j        |          }|                                 j        j        v rt                              d|           St          |d          rt          d|z            5  |         } j
         _        |                               } `d d d            n# 1 swxY w Y   |st                              d|           |= t                              d|            j        j        rt                              d|           t                              d|           |= >t          d          5                                  } j        j        s fd	|D             }n fd
|D             }                    |                                            d d d            d S # 1 swxY w Y   d S )Nz%s subsetting not neededrz   zsubset '%s'z%s subsetted to empty; droppedz%s subsettedz'%s NOT subset; don't know how to subsetz0%s NOT subset; don't know how to subset; droppedzsubset GlyphOrderc                 &    g | ]}|j         v |S r   )r  rV   s     r   r:   z,Subsetter._subset_glyphs.<locals>.<listcomp>+  s&    EEE10D+D+D!+D+D+Dr   c                 P    g | ]"}                     |          j        k     |#S r   )
getGlyphIDr  )r   r   r   r   s     r   r:   z,Subsetter._subset_glyphs.<locals>.<listcomp>-  s2    ZZZ4??1+=+=AY+Y+Y!+Y+Y+Yr   )r  r   r}  r  r   r  r  r   r%   r  r  r   rz   r  warningr  r  setGlyphOrder_buildReverseGlyphOrderDict)r   r   r  r)   r  r  r  s   ``     r   _subset_glyphszSubsetter._subset_glyphs  sw   t$$  cs##5	iikkT\222HH'----'' 	}s"	#	#  #YU'T[!!$''V		              
  #XX.444	cXXnc""""' HH6<<<<KKBCHHHS		 !! & &""$$:
,
" [EEEEZEEEJJZZZZZZZZZJj!!!##%%%& & & & & & & & & & & & & & & & & &s%   ,CC		C		%A(GG!Gc                 v   |                                 D ]"}|dk    r
|dk    rc| j        j        rV||                                         }||                             |d          }||k    r)t
                              d|t          |                     | j        j        rd |d         j	        
                                D             }t          t          |          t          |          z            }|||         j        k    r)|||         _        t
                              d||           | j        j        rIt!          |          }|||         j        k    r)|||         _        t
                              d	||           t%          j        |          }t)          |d
          rt+          d|z            5  ||         }	|	                    || j                  }
d d d            n# 1 swxY w Y   |
s t
                              d|           ||= t
                              d|           $d S )N
GlyphOrderr;  T)	pruneOnlyz%s Unicode ranges pruned: %sc                 6    g | ]}|d          d k    |d          S r  r   )r   r  s     r   r:   z0Subsetter._prune_post_subset.<locals>.<listcomp><  s%    GGGadQhhqthhhr   r  z%s xAvgCharWidth updated: %dz%s usMaxContext updated: %dr   r  r  r  )rl  r   r  getUnicodeRangesrecalcUnicodeRangesr  r   r   r  r  re   r   r  r<   xAvgCharWidthr  r   usMaxContextr   r}  r%   r  r   )r   r   r  old_unirangesnew_unirangeswidths	avg_widthmax_contextr)   r  r  s              r   _prune_post_subsetzSubsetter._prune_post_subset3  s[   YY[[    c	\8	Vmm9mI..00MI11$$1GGM%%XX,c6-3H3HIII|( ?GGT&\188::GGGVVs6{{233YT#Y,,, )d3i	hh-sI>>>|& @d##[tCy---*d3i	hh,c;???s##5e())  	|c!	"	" : :#YU%%dDL99V: : : : : : : : : : : : : : :   XX+S111	cXXk37   s   ?$G//G3	6G3	c                     g dd t                    D             t          |                                fd          }d |D             S )N)r  r7  r  r   r  c                      i | ]\  }}||d z   S )r   r   )r   r8   r  s      r   r4   z*Subsetter._sort_tables.<locals>.<dictcomp>S  s"    77741aaQ777r   c                 0                         | d          S rw  )r  )r  tagOrders    r   rD  z(Subsetter._sort_tables.<locals>.<lambda>T  s    X\\#q-A-A r   )r  c                     g | ]
}|d k    |S )r   r   r  s     r   r:   z*Subsetter._sort_tables.<locals>.<listcomp>U  s"    	/	/	/Q,..!...r   )rA   r   rl  )r   r   r  r  s      @r   r  zSubsetter._sort_tablesQ  sa    555(779X#6#6777(			!A!A!A!A	B	B	B$	/	/T	/	/	//r   c                     |                      |           |                     |           |                     |           |                     |           d S r   )r  r  r  r  )r   r   s     r   rK   zSubsetter.subsetW  sX    td$r   r   )r$   r  r  r  r  r  r  r  r  r  r  r  r  r  rK   r   r   r   r  r  `
  s        '''''y''':::::O:::<<<<<o<<<# # # # B" 	( 	( 	( 	(     .} } }~& & &D     <0 0 0         r   r  z	load fontc           	          t          j        | |||j        |j        ||j                  }|rHt          j        d          }|j        }|j        |_        |d         }	|	j        dk    rd|	_        ||_        |S )N)allowVIDcheckChecksumsrecalcBBoxesrecalcTimestamplazy
fontNumberr&  g       @r(  )	r   TTFontr  r  r  r}  decode_format_2_0decode_format_3_0r*  )
fontFiler   r  r  dontLoadGlyphNamesr  r   r&  savedr%  s
             r   	load_fontr   ^  s     	X$)/%	' 	' 	'"  !		V	$	$$

 %1$
6l!\S1< $r   zcompile and save fontc                     |j         r|j        dk    rddlm} d|_        |j        | _        |                     ||j                   d S )Nwoffr   )sfntT)reorderTables)r  r  fontTools.ttLibr#  
USE_ZOPFLIsaver  )r   outfiler   r#  s       r   	save_fontr)    sZ     GNf44""""""$/~7'"9:::::r   c           
         dd l }|                    dd|           } |                    dd|           } g }|                                 D ]}|                    d          }t          |          dk    r$|                    t          |d                     N|\  }}|                    t          t          |d          t          |d          dz                        |S )Nr   z0[xX]r  z[<+>,;&#\\xXuU\n	]r  r   r  )rer   r  r<   r#   r   r  r  )rr   r+  r/   itemfieldsstartends          r   parse_unicodesr0    s    
VVXsAVV"C++WWYY 3 3T::c??&[[A88CbMM9588E#eR..#c2,,q.112222	r   c           
         g }|                      dd                                          D ]}|                    d          }t          |          dk    r)|                    t	          |d                              S|                    t          t	          |d                   t	          |d                   dz                        |S )Nr  r  r  r   r   )r  r  r<   r#   r   r  r  )rr   r/   r,  r-  s       r   
parse_gidsr2    s    YYsC  &&(( 5 5T::c??&[[A88Cq	NN88E#fQi..#fQi.."2334444	r   c                 R    |                      dd                                          S )Nr  r  )r  r  )rr   s    r   parse_glyphsr4    s"    			#s!!###r   c                  ~    t          dt          t          j                   t          dt          j                   d S )Nzusage:filez,Try pyftsubset --help for more information.
)r  	__usage__sysstderrr   r   r   usager;    s5    x,,,,6SZHHHHHHr   z%make one with everything (TOTAL TIME)c           
         ddl m} ddlm} | t          j        dd         } d| v rt          t                     dS t                      }	 |	                    | g d          } nB# |j
        $ r5}t                       t          d	|t          j        
           Y d}~dS d}~ww xY wt          |           dk     rt                       dS  ||j        rt          j        nt          j                   |j        r*t&          j                            t          j                   ndt&          j        _        | d         }| dd         } t1          |          }d}g }g }	g }
d}d}d}| D ]}|dk    rd}|                    d          r|dd         },|                    d          r||dd         z  }O|                    d          r]t5          |dd         d          5 }||                                                    dd          z  }ddd           n# 1 swxY w Y   |                    d          r=|dd         dk    rd}n*|
                    t=          |dd                              |                    d          rt5          |dd                   5 }|                                D ]=}|
                    t=          |                     d          d                              >	 ddd           n# 1 swxY w Y   |                    d           r,|	                    tC          |dd                              |                    d!          rt5          |dd                   5 }|                                D ]=}|	                    tC          |                     d          d                              >	 ddd           n# 1 swxY w Y   |                    d"          r=|d#d         dk    rd}n*|                    tE          |d#d                              |                    d$          rt5          |dd                   5 }|                                D ]=}|                    tE          |                     d          d                              >	 ddd           n# 1 swxY w Y   q|#                    |           |j$         o| }tK          |||%          }|I ||          \  }}|j&        d&|j&        '                                z   }n|j(        d'k    rd(nd)}|d*z   |z   }t'          d+          5  |r'|                    |)                                           |rP|d,         j*        D ]B}|+                                r,|
                    |j,        -                                           Cd|vsJ 	 ddd           n# 1 swxY w Y   t\          /                    d-|z             t\          /                    d.|
           t\          /                    d/|           t\          /                    d0|	           |0                    ||	|
|1           |1                    |           te          |||           |j        rrddl3}t\          /                    d2|j4        5                    |          |fz             t\          /                    d3|j4        5                    |          |fz             |j6        r|7                    t          j8                   |9                                 dS )4z%OpenType font subsetter and optimizerr   )splitext)configLoggerNr   z--help)	r  z	gids-filer   zglyphs-filer  z	text-filer  zunicodes-filezoutput-file)r  zERROR:r6  r   )levelT)r   Fr?  r	   z--output-file=r  z--text=   z--text-file=r  zutf-8)encoding
z--unicodes=   z--unicodes-file=r  #z--gids=z--gids-file=z	--glyphs=	   z--glyphs-file=)r  r  z   z.ttfz.otfz.subsetzcompile glyph listr  z
Text: '%s'zUnicodes: %sz
Glyphs: %szGids: %s)r   r  r  r  zInput font:% 7d bytes: %szSubset font:% 7d bytes: %s):os.pathr=  	fontToolsr>  r9  r  r  __doc__r#  r  r'  r;  r:  r<   r  loggingINFOWARNINGr  r  r   setLevelDEBUGdisabledr  r  openreadr  r  r0  	readlinesr  r2  r4  r#   r)  r   r  lowersfntVersionr  r  r  r  rl  r  r   r  rK   r)  ospathgetsizer  saveXMLstdoutclose)argsr=  r>  r   efontfile	subsetterr(  r   r  r  wildcard_glyphswildcard_unicodesr  r   r%  liner  r   basenamer  extr  rT  s                           r   mainrc    s    ######L	!""$...	
99
			D   
 
 
$$ 	   '''!#*%%%%	

 IIMM'''	
GOHGLLIIIIN ,&&&&%,GQRRw'''



 , ,Q#XX?\\"## rssV7\\) 1QRR5=4\\.!! QrssVg&&& '!AFFHHT2&&&D' ' ' ' ' ' ' ' ' ' ' ' ' ' '\\-   fmmOON1RSS6**+++\\$%% QrssV 9 9 9__^DJJsOOA$677888899 9 9 9 9 9 9 9 9 9 9 9 9 9 9 \\) ;;z!ABB%  !!!\\.!! QrssV 1 1 1	[[DJJsOOA.//000011 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \\+ esllOO
MM,qu%%&&&\\"## QrssV 5 5 5]]<

3 233444455 5 5 5 5 5 5 5 5 5 5 5 5 5 5 --!--<f*(G8JKKKO""+(A^	w~##%%	%33#z11v3y 3&' !!   '	==##%%&&& $L $ $q{{}} $__QV[[]]###	6					               ,
.(###,*d
6xdKKK
$
4'"""O O)))((&"'//(*C*CX)NNOOO(('27??7+C+CW*MMNNNK ,,szsv   A& &
B%0*B  B%%,HH!	$H!	'ALL	L	AO!!O%	(O%	,ASS	S	'BW66W:=W:)r#  r  r   r)  r2  r4  r0  rc  __main__r   )FT)F)T)Fr   FT)vfontTools.misc.roundToolsr   rG  r   fontTools.ttLib.tablesr   fontTools.otlLib.maxContextCalcr   fontTools.pens.basePenr   fontTools.misc.loggingToolsr   fontTools.subset.cffr9  r  arrayrI  collectionsr
   r   	functoolsr   typesr   r8  rH  	getLoggerr  r   r   r  r,   r0   r5   r>   r   rC   rG   rK   rQ   rg  r`   SingleSubstrs   rz   MultipleSubstAlternateSubstLigatureSubstReverseChainSingleSubstDevicer   ValueRecordr   	SinglePosr   PairPos
CursivePosAnchorMarkBasePos
MarkLigPosMarkMarkPosr/  r1  ContextSubstChainContextSubst
ContextPosChainContextPosr5  r  ExtensionSubstExtensionPosr  r  r  r  r#  rw  r-  r4  ru  rM  rL  rI  rV  rv  r}  r~  r  r  r  r  r  r  r  r  r?  MathGlyphConstructionr  r  r  r  r  r  r9  r  r  r#  r  r   r)  r0  r2  r4  r;  rc  __all__r$   exitr   r   r   <module>r     s  
 . - - - - -       + + + + + + 6 6 6 6 6 6 * * * * * * - - - - - - " " " " 



    , , , , , , , ,            A		 	xE	P
 g*++K K K K ZS))
 	&W&'?@@AAA  "  ! ! !- - - X= =  = X3 3  3 X    X6 6  6 X9 9  9 X& &  & X     XK K  K X!""G G #"G X!""  #"
 X#$$  %$
 X#$$  %$
 X$%%  &% X$%%  &% X#$$  %$ X#$$  %$ X-..	/ 	/ /.	/ X-../ / /./  X_$ $ $ X!""  #" X  / / ! / X    ! 0 X/ / /< X4 4 4& X !!	/ 	/ "!	/ X_	 	 	 X !!  "! X!""/ / #"/* X!""	 	 #"	 X !!/ / "!/, X !!
 
 "!
 X!""/ / #"/* X!""	 	 #"	 X!$
 
 
 
 X!$
 
 
 
 X!$    X!$& & & & X#    	    X" }< }<	 }<~ X"   Y/ Y/   Y/v X" E/ E/	 E/N X" / /	 /0 X" / /	 / X$%%/ / &%/ X$%%/ / &%/ X$ / / / X$ / / / X$ / / / X$ / / / X_# # # #$ X_! ! !
 X_   X_# # # X_F F F X_B B B X !!J J "!J X !!  "! X !!# # "!# X !!V V "!V
 X !!  "! X    X!""  #" X!""# # #"#
 X!""    #"  X.//0 0 0/0
 X'((/ / )(/
 X'((/ / )(/ X.//% % 0/% X'(() ) )() X$ 
A 
A 
A X$ $ $ $ X_7 7 7 7 X_- - - X !!  "! X !!, , "!,
  U (())  *)  U (())  *)  U (())  *)  U (())  *)4  U ((e&!!# # # #  U ((e&!!# #6 6# #6
  U ((e&!!# #V V# #V&  U ((e&!!# #7 7# #7
  U ((e&!!# #& & &# #&,  U ((e&!!# #V V# #V  U ((e&!!# #) )# #).  U ((E! !V V! !V  U ((e&!!# # # #  U ((e&!!# #& &# #&<  U ((e&!!# #, ,# #,\  U (())! ! *)!H7 7 7.  U (())8 8 *)8:  U (())  *)
  U (())  *)  U (())  *)  U (())  *)  U (())  *)  U (())  *)  U (())$ $ *)$
  U (())  *)"  U (()): : *):  U (())  *)
  U (())  *)
    U (())    *) D  U (())% % *)%N  U (())  *)  U (()): : *):  U (())  *)
  U (())  *)  U (())9 9 *)9&    U (())  *)8  U (())  *)B  U (())/% /% *)/%b X+,,  -, X"##  $#   U (()), , *), X/00* * 10* X-.., , /., X"##! ! $#! X#$$	 	 %$	 X"##  $#  U (())  *) !U!&))/00  10.  U (())  *)  U (())  *)  U (())  *)   U (())  *)  U (())3 3 *)3*  U (())
 
 *)
  U (())8 8 *)8t  U (())  *)  U (())
 
 *)
  U (())% % *)%P  U (())  *)$\$ \$ \$ \$ \$f \$ \$ \$~{  {  {  {  {  {  {  { | { ! ! ! !F ; ;  ;
 
 

 
 
$ $ $I I I .//B B B 0/BJ	 	 	 z	$$&& r   