
    ]Mh                   %   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mZ d dlmZ d d	lmZ d d
lmZ d dlmZmZ d dlT d dlT d dlmZmZ d dlmZmZ d dlmZ 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._0         e e#j-        d                    Z1d Z2d Z3 eej4                  d             Z5 eej4                  d             Z6 eej4                  d             Z7 eej4                  d              Z8 eej9                  d!             Z5 eej9                  d"             Z: eej9                  dd%            Z7 eej9                  d&             Z8 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jA                  d/             Z< eejA                  d0             Z= eejB                  d1             ZC eejD                  d2             ZE eejF                  d3             Z= eejF                  d4             ZG eejH                  d5             Z= eejH                  d6             ZG eejI                  d7             Z= eejJ                  d8             ZE eejI                  d9             ZG eejK                  d:             Z= eejK                  d;             ZG eejL                  d<             Z= eejL                  d=             ZG eejM                  d>             Z= eejM                  d?             ZG eej;        ej>        ej?        ej@        ejA        ejF        ejH        ejI        ejK        ejL        ejM                  d@             ZN eej;        ej>        ej?        ej@        ejA        ejF        ejH        ejI        ejK        ejL        ejM                  dA             ZO eej;        ej>        ej?        ej@        ejA        ejP        ejQ        ejR        ejS        	  	        dB             ZG eej;        ej?        ejA                  dC             ZT eej>        ej@        ejP        ejQ                  dD             ZT eejP        ejQ        ejR        ejS                  dE             ZU eejP        ejQ                  dF             Z< eejP        ejR        ejQ        ejS                  dG             Z= eejP        ejQ        ejR        ejS                  dH             ZN eejP        ejQ        ejR        ejS                  dI             ZO eejV                  dJ             Z< eejV                  dK             ZT eejV        ejW                  dL             Z= eejV        ejW                  dM             ZG eejV        ejW                  dN             ZN eejV        ejW                  dO             ZO eejX                  ddP            Z< eejX                  dQ             Z= eejX                  dR             ZG eejX                  dS             ZN eejX                  dT             ZO eejX                  dU             ZT eejY                  dV             Z= eejY                  dW             ZG eejY                  dX             ZN eejY                  dY             ZZ eejY                  dZ             Z[ eej\                  d[             ZN eej]                  d\             ZN eej]                  d]             ZO eej]                  d^             Z^ eej_                  d_             ZN eej`                  d`             ZN eej`                  da             ZO eej_                  db             Z^ eej`                  dc             Z^ eeja        ejb                  dd             Z^ eeja        ejb                  de             Zc eejd                  ddf            Z^ eejd                  dg             Zc eeje                  dh             Z^ eeje                  di             Zc e ejf        dj                    dk             Z= e ejf        dl                    dm             Z= e ejf        dn                    do             Z= e ejf        dp                    dq             Z< e ejf        dp           ejf        dr                    ds             Z= e ejf        dp           ejf        dr                    dt             Zg e ejf        dp           ejf        dr                    du             ZN e ejf        dp           ejf        dr                    dv             ZZ e ejf        dp           ejf        dr                    ddw            Zh e ejf        dp           ejf        dr                    dx             Zi e ejf        dp           ejf        dr                    dy             Zj e ejf        dp           ejf        dr                    dz             Zk e ejf        dp           ejf        dr                    d{             Zl e ejf        dp           ejf        dr                    d|             Zm e ejf        dp           ejf        dr                    d}             ZG e ejf        d~                    d             Z=d Zn e ejf        d~                    d             ZG e ejf        d                    d             Zl e ejf        d                    d             Z= e ejf        d                    d             Z= e ejf        d                    d             Z= e ejf        d                    d             Z= e ejf        d                    d             Z= e ejf        d                    d             Z< e ejf        d                    d             Z= e ejf        d                    d             Z= e ejf        d                    d             Zl e ejf        d                    d             Z=d Zo e ejf        d                    d             Z= e ejf        d                    d             Z= e ejf        d                    d             Z= e ejf        d                    d             Z= e ejf        d                    d             Zl e ejf        d                    d             Z= e ejf        d                    d             Z=d Zp e ejf        d                    d             Z< e ejf        d                    d             Z= e ejf        d                    d             ZG eejq                  d             Z< eejr                  d             Z< e ejf        d                    d             Z= e ejf        d                    d             Z< e ejf        d                    d             ZG e ejf        d                    d             Z< eejs                  d             Z= eejt                  d             Z= eeju                  d             Z= eejv                  d             Z= eejr                  d             Z= e ejf        d                    d             Z= e ejw        d          jx                  d             Zy e ejf        d                    d             Z< e ejf        d                    d             Zl e ejf        d                    d             Z= e ejf        d                    d             ZG e ejf        d                    d             Z< e ejf        d                    d             Zl e ejf        d                    d             Z= e ejf        d                    d             Zl e ejf        dæ                    dĄ             Zlh dţZz e ejf        dƦ                    dǄ             ZGdd΄Z{ e ejf        dϦ                    dЄ             ZG G dф de|          Z} G dӄ de|          Z~ e1dզ          ddք            Z e1dצ          d؄             Zdل Zdڄ Zdۄ Zd܄ Z e1dݦ          ddބ            Zg dߢZdS )    )annotations)config)otRound)ttLib)otTables)USE_HARFBUZZ_REPACKER)
maxCtxFont)NullPen)Timer)makeOutputFileName)_add_method
_uniq_sort)*)varStoremultiVarStore)NameRecordVisitormakeName)mirroredN)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: a9  

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

Args:

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 '='. In some environments,
you might need to escape the question mark, like this: '--glyph-names\?'.

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

--harfbuzz-repacker
  By default, we serialize GPOS/GSUB using the HarfBuzz Repacker when
  uharfbuzz can be imported and is successful, otherwise fall back to
  the pure-python serializer. Set the option to force using the HarfBuzz
  Repacker (raises an error if uharfbuzz can't be found or fails).

--no-harfbuzz-repacker
  Always use the pure-python serializer even if uharfbuzz is available.

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', 'PCLT', 'LTSH'
  and Graphite tables: 'Feat', 'Glat', 'Gloc', 'Silf', 'Sill'.
  The tool will attempt to subset the remaining tables.

  Examples:

  --drop-tables-=BASE
      * Drop the default set of tables but keep 'BASE'.

  --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.
--prune-codepage-ranges
    Update the 'OS/2 ulCodePageRange*' bits after subsetting.  [default]
--no-prune-codepage-ranges
    Don't change the 'OS/2 ulCodePageRange*' 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.
--pretty-svg
    When subsetting SVG table, use lxml pretty_print=True option to indent
    the XML output (only recommended for debugging purposes).

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     Y/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/fontTools/subset/__init__.py	<genexpr>z_log_glyphs.<locals>.<genexpr>  s(      +O+O1OA,>+O+O+O+O+O+O    )infosortedgetReverseGlyphMap)selfglyphsfontr   s      @r    _log_glyphsr)     s|    II000 Q1133		#V+O+O+O+O+O+O+O%O%OPPPPPQ Qr"   zfontTools.subset.timer)loggerc                       fd|D             S )Nc                "    i | ]}||         S r   r   )r   r   ds     r    
<dictcomp>z _dict_subset.<locals>.<dictcomp>  s    $$$Aqt$$$r"   r   )r-   r'   s   ` r    _dict_subsetr/     s    $$$$V$$$$r"   c                B     t                      fd|D             S )Nc                ,    g | ]}|k     |         S r   r   )r   icountls     r    
<listcomp>z _list_subset.<locals>.<listcomp>  s"    ///QQYYAaDYYYr"   len)r4   indicesr3   s   ` @r    _list_subsetr9     s,    FFE/////'////r"   c                D    fdt          | j                  D             S )z3Returns ascending list of matching coverage values.c                "    g | ]\  }}|v 	|S r   r   )r   r2   r   r'   s      r    r5   zintersect.<locals>.<listcomp>  s"    @@@$!QAKKAKKKr"   )	enumerater'   r&   r'   s    `r    	intersectr>     s*     A@@@)DK00@@@@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'      55Qfq55r"   )setr'   r=   s    `r    intersect_glyphsrC     s*     5555$+555555r"   c                b    |                                }fd| j        D             | _        |S )z4Returns ascending list of remaining coverage values.c                    g | ]}|v |	S r   r   rA   s     r    r5   zsubset.<locals>.<listcomp>  s    999Q&[[1[[[r"   r>   r'   )r&   r'   r8   s    ` r    subsetrG     s8     nnV$$G9999dk999DKNr"   c                .      fd|D              _         dS )zRemaps coverage.c                *    g | ]}j         |         S r   r'   r   r2   r&   s     r    r5   zremap.<locals>.<listcomp>  s    888a4;q>888r"   NrJ   )r&   coverage_maps   ` r    remaprM     s$     9888<888DKKKr"   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*      <<AT^+<<<<<<r"   r   c                "    g | ]\  }}|v 	|S r   r   r   r   vr'   s      r    r5   zintersect.<locals>.<listcomp>  s"    
?
?
?A1;;1;;;r"   )r   anyrQ   itemsr=   s   ``r    r>   r>     sn     <<<<V<<<<<	D!"
?
?
?
?--//
?
?
?	@  r"   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   rP   rR   s     r    r!   z"intersect_class.<locals>.<genexpr>
  s/      @@(?(?1(?(?(?(?@@r"   c              3  6   K   | ]\  }}|k    |v |V  d S r   r   )r   r   rU   r'   klasss      r    r!   z"intersect_class.<locals>.<genexpr>  s3      RRTQqEzza6kkqkkkkRRr"   )rB   rQ   rW   )r&   r'   r[   s   ```r    intersect_classr\     sg     zz@@@@f@@@@@@RRRRRT^1133RRRRRRr"   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   rT   s      r    r.   zsubset.<locals>.<dictcomp>  s$    MMMtq!far"   c              3  *   K   | ]}|j         vV  d S r   rP   rR   s     r    r!   zsubset.<locals>.<genexpr>  s*      &O&O1q'>&O&O&O&O&O&Or"   r   )rQ   rW   r   rV   listvaluesrM   )r&   r'   rM   	useClass0r8   s   ``   r    rG   rG     s     NMMMt~';';'='=MMMDN  #&&O&O&O&O&O&O&O#O#OQCC
t~$$&&
'
'	( G  

7Nr"   c                \    fd| j                                         D             | _         dS )zRemaps classes.c                B    i | ]\  }}|                     |          S r   index)r   r   rU   	class_maps      r    r.   zremap.<locals>.<dictcomp>%  s+    OOO1a++OOOr"   N)rQ   rW   )r&   rg   s    `r    rM   rM   "  s3     POOO8L8L8N8NOOODNNNr"   c                    |j                             fd| j                                        D                        d S )Nc              3  *   K   | ]\  }}|v 	|V  d S r   r   )r   r   rU   
cur_glyphss      r    r!   z!closure_glyphs.<locals>.<genexpr>*  s+      JJ$!Q!z//A////JJr"   )r'   updatemappingrW   r&   srj   s     `r    closure_glyphsro   (  s@    HOOJJJJ$,"4"4"6"6JJJJJJJJr"   c                    fd| j                                         D             | _         t          | j                   S )Nc                @    i | ]\  }}|j         v |j         v ||S r   rJ   r   r   rU   rn   s      r    r.   z!subset_glyphs.<locals>.<dictcomp>/  s7       Aah1==1===r"   rl   rW   boolr&   rn   s    `r    subset_glyphsrv   -  sM       ++--  DL r"   c                    | j                                         D ]#\  }}||v r|j                            |           $d S r   )rl   rW   r'   rk   )r&   rn   rj   glyphsubsts        r    ro   ro   5  sM    **,, # #uJHOOE"""# #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   rJ   )r   subrn   s     r    r!   z+subset_glyphs.<locals>.<dictcomp>.<genexpr>A  s)       > >S > > > > > >r"   )r'   allrr   s      r    r.   z!subset_glyphs.<locals>.<dictcomp>>  sS       Aq==S > > > >A > > >>>= 	
1==r"   rs   ru   s    `r    rv   rv   <  sM       L&&((  DL
 r"   c                l     |j         j        fd| j                                        D               d S )Nc              3  *   K   | ]\  }}|v 	|V  d S r   r   )r   r   vlistrj   s      r    r!   z!closure_glyphs.<locals>.<genexpr>H  s+      WW5qJeWWr"   )r'   rk   
alternatesrW   rm   s     `r    ro   ro   F  s=    AHOWWWWDO,A,A,C,CWWWXXXXr"   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   rJ   r   rU   rn   s     r    r!   z+subset_glyphs.<locals>.<dictcomp>.<genexpr>P  s)       > >1ah > > > > > >r"   c                &    g | ]}|j         v |S r   rJ   r   s     r    r5   z,subset_glyphs.<locals>.<dictcomp>.<listcomp>N  s     ...!QXAr"   )r'   rV   )r   r   r   rn   s      r    r.   z!subset_glyphs.<locals>.<dictcomp>M  sh       Au==S > > > > > > >>>= 	
....u...==r"   )r   rW   rt   ru   s    `r    rv   rv   K  sM       --//  DO
    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   rJ   r   crn   s     r    r!   z6closure_glyphs.<locals>.<genexpr>.<listcomp>.<genexpr>Y  s)      0V0V1ah0V0V0V0V0V0Vr"   )r~   	ComponentLigGlyphr   seqrn   s     r    r5   z,closure_glyphs.<locals>.<genexpr>.<listcomp>Y  s?    WWWcS0V0V0V0V0V0V0V-V-VWS\WWWr"   Nr   )r   r   seqsrj   rn   s      r    r!   z!closure_glyphs.<locals>.<genexpr>X  sN       

 

4J XWWWTWWW

 

r"   )r'   rk   	ligaturesrW   rm   s    ``r    ro   ro   U  sZ    AHO

 

 

 

 

>//11

 

 

   r"   c                $   fd| j                                         D             | _         fd| j                                         D             | _         d | j                                         D             | _         t          | j                   S )Nc                .    i | ]\  }}|j         v ||S r   rJ   rr   s      r    r.   z!subset_glyphs.<locals>.<dictcomp>b  s&    OOOtq!aha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   rJ   r   s     r    r!   z6subset_glyphs.<locals>.<dictcomp>.<listcomp>.<genexpr>g  s)      /U/U!QX/U/U/U/U/U/Ur"   )r   r'   r~   r   r   s     r    r5   z,subset_glyphs.<locals>.<dictcomp>.<listcomp>d  sV     
 
 
|qx''C/U/U/U/Us}/U/U/U,U,U' '''r"   r   )r   r   r   rn   s      r    r.   z!subset_glyphs.<locals>.<dictcomp>c  sU        At 	
 
 
 
 

 
 
  r"   c                    i | ]
\  }}|||S r   r   )r   r   rU   s      r    r.   z!subset_glyphs.<locals>.<dictcomp>k  s#    CCCtq!CaCCCr"   )r   rW   rt   ru   s    `r    rv   rv   `  s    OOOOt~';';'='=OOODN    ~++--  DN DCt~';';'='=CCCDN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   rF   r   s     r    r!   z!closure_glyphs.<locals>.<genexpr>s  sE       "
 "
 KK!!"
 "
 "
 "
 "
 "
r"   c              3  2   K   | ]}j         |         V  d S r   )
SubstituterK   s     r    r!   z!closure_glyphs.<locals>.<genexpr>x  s*      <<q*<<<<<<r"   r   unknown format: %s)FormatCoverager>   r~   LookAheadCoverageBacktrackCoverager'   rk   )r&   rn   rj   r8   s   ``  r    ro   ro   o  s    {a-))*55 	c "
 "
 "
 "
+d.DD"
 "
 "
 
 
 	 F	<<<<G<<<<<<<<4&4444r"   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   rJ   )r   r2   r}   rn   s      r    r5   z!subset_glyphs.<locals>.<listcomp>  s$    QQQC1r"   c              3  L   K   | ]}|                     j                  V  d S r   rG   r'   r   s     r    r!   z subset_glyphs.<locals>.<genexpr>  sE         ""     r"   r   r   )r   r   rG   r'   r9   r   r<   rM   r7   
GlyphCountrt   r~   r   r   r&   rn   r8   s    ` r    rv   rv   }  s	   {a-&&qx00&t@@QQQQ9T_#=#=QQQ&t@@G$$$do..O     /$2HH    
 
 	
 	5&4444r"   c                    | j         dv S )Nr         )DeltaFormatr&   s    r    
is_hintingr     s    y((r"   c                ~    dD ]9}t          | |d           }|$|                                rt          | |           :d S )N)
XPlaDevice
YPlaDevice
XAdvDevice
YAdvDevice)getattrr   delattrr&   namerU   s      r    prune_hintsr     sN    H    D$%%=Q\\^^=D$   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   r2   r3   ra   s     r    r5   z!subset_glyphs.<locals>.<listcomp>  s"    >>>AAIIfQiIIIr"   r   r   )r   r7   r   rG   r'   Value
ValueCountrt   )r&   rn   r8   r3   ra   s      @@r    rv   rv     s    {a4=''11222			-&&qx00F>>>>>>>>
dj//DO$$$4&4444r"   c                     j          j        dk    sJ dS  j        dk    r?|j        s j                                           j                                          _        n j        dk    rd  j         v r. j        dk    sJ t          d  j         D                       sJ nT|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              3     K   | ]}|d u V  	d S r   r   r   rU   s     r    r!   z$prune_post_subset.<locals>.<genexpr>  s&      55QqDy555555r"   c                6    g | ]}|                                 S r   )getEffectiveFormatr   s     r    r5   z%prune_post_subset.<locals>.<listcomp>  s$    HHHQ1133HHHr"   c              3  :   K   | ]}|j         d          k    V  dS r   N)r   )r   rU   r&   s     r    r!   z$prune_post_subset.<locals>.<genexpr>  s.      GGqTZ] 2GGGGGGr"   )r   ValueFormatr   hintingr   r   r~   r   int__or__r   )r&   r(   optionsrU   s   `   r    prune_post_subsetr     sx   z1$$$$t {a 	%J""$$$:88::			4:#q((((55$*555555555? $ $ $AMMOOOO%
HHTZHHH!   D
 {aCGGGGDJGGGGG&*&6!&;&;TZ]]
O4r"   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   r2   r3   pairss     r    r5   z!subset_glyphs.<locals>.<listcomp>  s"    ???QQYYaYYYr"   c                0    g | ]}|j         j        v |S r   )SecondGlyphr'   )r   rrn   s     r    r5   z!subset_glyphs.<locals>.<listcomp>  s.     ! ! !0I0I0I0I0Ir"   c                &    g | ]\  }}|j         |S r   )PairValueCount)r   r2   ps      r    r5   z!subset_glyphs.<locals>.<listcomp>  s$    MMMAA<LM1MMMr"   r   c                *    g | ]}|j         k     |S r   )Class1Countr   r   r&   s     r    r5   z!subset_glyphs.<locals>.<listcomp>  s5     
 
 
 4###	  $##r"   TrM   c                *    g | ]}|j         k     |S r   )Class2Countr   s     r    r5   z!subset_glyphs.<locals>.<listcomp>  s1     
 
 
4### ###r"   F)rM   rb   c                *    g | ]}j         |         S r   )Class1RecordrK   s     r    r5   z!subset_glyphs.<locals>.<listcomp>  s!    FFFaT.q1FFFr"   c                *    g | ]}j         |         S r   )Class2Recordr   r2   r   s     r    r5   z!subset_glyphs.<locals>.<listcomp>  s     DDDAanQ/DDDr"   r   r   )r   r   rG   r'   PairSetr7   PairValueRecordr   r<   rM   r9   PairSetCountrt   	ClassDef1intersection	ClassDef2r   r   r   r   )	r&   rn   r8   r   
class1_map
class2_mapr   r3   r   s	   ``    @@@r    rv   rv     s   {a-&&qx00E

?????'??? 	6 	6A! ! ! !,! ! !A  #1#455AMM4<!8!8MMMG$$$#DL'::--D%&&&			
 
 
 
^**%%dm&:;;4 +  
 
 


 
 
 
^**1845*QQ
 
 


 GFFF:FFF" 	E 	EADDDDDDDANNz??z?? /!A%/$$QX..
 
 	
 	5&4444r"   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   Value2rt   )r&   r(   r   attr1attr2rowr   s          r    r   r     s   ? G-/
 
 +u
 121D-4'' 	G 	GCS%(( G G8 GH((***%%)D)D)F)FF%%8 GH((***%%)D)D)F)FF%%G !D$55666r"   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   r2   r3   recordss     r    r5   z!subset_glyphs.<locals>.<listcomp>  s"    IIIqq5yy
yyyr"   r   r   )r   r   rG   r'   EntryExitRecordr7   EntryExitCountrt   )r&   rn   r8   r3   r   s      @@r    rv   rv     s    {a-&&qx00&GIIIIIGIII!$"677D'(((4&4444r"   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   setattrr   r   r   s      r    r   r     s    {a			4 	* 	*DdD))A}}dD)))$):)BDKKK 
	
 %$)B)Br"   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   +  s`    ? -' 	- 	-C .++---~ -**,,,4r"   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>D  $      "N"Nq17"N"N"N"N"N"Nr"   r   r   )r   MarkCoveragerG   r'   r9   	MarkArray
MarkRecordr7   	MarkCountBaseCoverage	BaseArray
BaseRecord	BaseCountr   
ClassCountrf   r  
BaseAnchorrt   )r&   rn   mark_indicesbase_indicesclass_indicesmbs          r    rv   rv   6  sx   {a(//99$0N%|%
 %
! $'t~'@#A#A (//99$0N%|%
 %
! $'t~'@#A#A ""N"NDN4M"N"N"NNNm,,* 	3 	3A#))!'22AGG* 	E 	EA'mDDALLOU 8UT^=U
 
 	
 	5&4444r"   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   Q  s    ? $* 	+ 	+A| +((**** 	$ 	$A\ $ $ $MMOOO$ 4r"   c                d   | 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>l  r  r"   r   r   )r   r  rG   r'   r9   r  r  r7   r  LigatureCoverageLigatureArrayLigatureAttachLigatureCountr   r  rf   r  ComponentRecordLigatureAnchorrt   )r&   rn   r  ligature_indicesr  r  r4   r   s           r    rv   rv   ^  s   {a(//99$0N%|%
 %
! $'t~'@#A#A 077AA,8-/?-
 -
) ,/t/A/P+Q+Q(""N"NDN4M"N"N"NNNm,,* 	3 	3A#))!'22AGG#2 	Q 	QAy& Q Q#/0@-#P#P  QO 1(1"0
 
 	
 	5&4444r"   c                    |j         sk| j        j        D ]"}|j        r|j                                         #| j        j        D ]/}||j        D ]"}|j        D ]}|r|                                 #0dS r   )	r   r  r  r  r   r  r  r  r  )r&   r(   r   r  r4   r   r  s          r    r   r   ~  s    ? 
(* 	+ 	+A| +((***#2 	( 	(Ay& ( () ( (A ((( 4r"   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$      "O"Oq17"O"O"O"O"O"Or"   r   r   )r   Mark1CoveragerG   r'   r9   
Mark1Arrayr  r7   r  Mark2Coverage
Mark2ArrayMark2Recordr   r  rf   r  Mark2Anchorrt   )r&   rn   mark1_indicesmark2_indicesr  r  r  s          r    rv   rv     sx   {a*11!(;;%1O&&
 &
" %((B$C$C!*11!(;;&2O''
 '
# %((C$D$D!""O"ODO4N"O"O"OOOm,,+ 	3 	3A#))!'22AGG, 	G 	GA(FFAMMOW 9Wdo>W
 
 	
 	5&4444r"   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    ? $+ 	+ 	+A| +((***, 	$ 	$A] $ $ $MMOOO$ 4r"   c                    d S r   r   r&   lookup_indicess     r    subset_lookupsr.    s	     	Dr"   c                    g S r   r   r   s    r    collect_lookupsr0    s	     Ir"   c                    dS r   r   r&   r(   r   s      r    r   r     s	     4r"   c                    dS )NFr   r   s    r    may_have_non_1to1r4    s	     5r"   c                    dS r   r   r   s    r    r4  r4    s	     4r"   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>      QZ r"   c                    | j         S r   rA  rB  s    r    rC  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>      !* r"   c                    dS )Nr   r   rB  s    r    rC  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>  s     r"   c                    dS )N)NNNr   rB  s    r    rC  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>  s    -? r"   c                    | j         fS r   )InputrB  s    r    rC  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>!  
    agZ r"   c                *    | j         | j        | j        fS r   	BacktrackrJ  	LookAheadrB  s    r    rC  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>"      1;*M r"   c                >    |\  | _         d |D             \  | _        d S )Nc              3  :   K   | ]}t          |          d z   V  dS r   Nr6   r   xs     r    r!   za__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetRuleData.<locals>.<genexpr>&  ,      &=&=as1vvz&=&=&=&=&=&=r"   )rJ  r   r   r-   s     r    SetRuleDatazN__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetRuleData$  &    !"JQW&=&=1&=&=&=OQ\\\r"   c                    |\  | _         | _        | _        t          |d                   t          |d                   dz   t          |d                   c| _        | _        | _        d S Nr   r   r   rN  rJ  rO  r7   BacktrackGlyphCountInputGlyphCountLookAheadGlyphCountrW  s     r    ChainSetRuleDatazS__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.ChainSetRuleData(  \    :;7Q[!'1;
 QqTC!IIM3qt99	-)---r"   r   c                    | j         S r   rA  rB  s    r    rC  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>1  rD  r"   c                    | j         S r   rA  rB  s    r    rC  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>2  rF  r"   c                    | j         fS r   ClassDefrB  s    r    rC  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>3  s
     r"   c                *    | j         | j        | j        fS r   BacktrackClassDefInputClassDefLookAheadClassDefrB  s    r    rC  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>4  s    'O'. r"   c                    |\  | _         d S r   re  rW  s     r    SetContextDatazQ__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetContextData:  s    $%MQZZZr"   c                0    |\  | _         | _        | _        d S r   rh  rW  s     r    SetChainContextDatazV__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetChainContextData=  s    RSOQ(!/1;N;N;Nr"   c                    | j         fS r   r  rB  s    r    rC  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>@  rK  r"   c                *    | j         | j        | j        fS r   rM  rB  s    r    rC  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>A  rP  r"   c                >    |\  | _         d |D             \  | _        d S )Nc              3  :   K   | ]}t          |          d z   V  dS rS  r6   rT  s     r    r!   za__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetRuleData.<locals>.<genexpr>E  rV  r"   )r  r   rW  s     r    rX  zN__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetRuleDataC  rY  r"   c                    |\  | _         | _        | _        t          |d                   t          |d                   dz   t          |d                   c| _        | _        | _        d S r[  r\  rW  s     r    r`  zS__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.ChainSetRuleDataG  ra  r"   c                    | j         d         S Nr   rA  rB  s    r    rC  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>P  s    QZ] r"   c                    | j         d         S rv  )InputCoveragerB  s    r    rC  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>Q  s    !/!*< r"   c                    | j         S r   rA  rB  s    r    rC  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>V  rD  r"   c                0    | j         | j        z   | j        z   S r   )r   rx  r   rB  s    r    rC  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>W  s    '!/9A<OO r"   c                >    |\  | _         d |D             \  | _        d S )Nc              3  4   K   | ]}t          |          V  d S r   r6   rT  s     r    r!   za__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetRuleData.<locals>.<genexpr>]  s(      &9&9!s1vv&9&9&9&9&9&9r"   )r   r   rW  s     r    rX  zN__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetRuleData[  s&    $%MQZ&9&9q&9&9&9OQ\\\r"   c                n    |\  | _         | _        | _        d |D             \  | _        | _        | _        d S )Nc              3  4   K   | ]}t          |          V  d S r   r6   rT  s     r    r!   zf__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.ChainSetRuleData.<locals>.<genexpr>e  s(      ++AQ++++++r"   )r   rx  r   r]  r^  r_  rW  s     r    r`  zS__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.ChainSetRuleData_  sF    RSOQ(!/1;N
 ,++++	-)---r"   r   Rule	RuleCountRuleSetRuleSetCountc                    || v r|gng S r   r   r'   r   r   s      r    rC  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>|  s    Q&[[qccb r"   	ClassRuleClassRuleCountClassSetClassSetCountc                x    |r|                     | |          n"|dk    rt          |           nt                      S rv  )r\   rB   r  s      r    rC  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>  s=    <A%%fa000)*a#f+++SUU r"   rj  rf  rJ  r  rx  r   )__name__endswith
startswithTypTyper=  ChainTypInputIdxDataLenr?  r   ContextDatarm  RuleDatarX  r  r  r  r  	Intersectrf  ClassDefIndexrJ  )r&   r[   r   r  r  r=  r  r  r  r   ChainCoverager  ChainContextDatarm  ro  r  ChainRuleDatarX  r`  s                      r    __init__z9__subset_classify_context.<locals>.ContextHelper.__init__   sW   ~&&w// ~((11 s{HDHDIDJ$DM$DM"DL $~ 5D{{// 4 4//#?#? !%&*#// M M> > >> > > > 1// 4 455$ $ & & &T T T 0/ M M> > >> > > > 122 < <"#' !%&*#//! !: : :, , , , 8.7777 / -#3 &9# -#3   (#. &4# (#. {{$v-	!)K!7')3$,~$=!!P!P1${2	!),<!<'*4$,$>!" " 49 Hj*/%6QQQ"(-:WW7


105E__:


 r"   N)r  
__module____qualname__r  r   r"   r    ContextHelperr8    s-        L	F L	F L	F L	F L	Fr"   r  r   _subset__ContextHelpers)objectr   hasattr	__class__r  )r&   r  helpers      r    __subset_classify_contextr    s    MF MF MF MF MF MF MF MF^ {)##t4>#<== 413.{$.@@@t~t{;;>D.t{;>1$+>>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   cdrn   s     r    r!   z+closure_glyphs.<locals>.<genexpr>.<genexpr>  5      DDAHb!44DDDDDDr"   Nr~   r   klistr  r   rn   s     @r    r!   z!closure_glyphs.<locals>.<genexpr>  _        !E DDDDDDeDDDDD     r"   r   r   )rj   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>  r  r"   r   c              3  T   K   | ]"}|d uo|                     j                  V  #d S r   rF   r   rU  rn   s     r    r!   z!closure_glyphs.<locals>.<genexpr>  s:      UUq1D=:Q[[%:%:UUUUUUr"   r   )r  r   r>   rC   r   r  r   r  r  r  r~   zipr  rB   r?  SequenceIndex	frozensetr'   rJ  table
LookupListLookupLookupListIndexaddr4  rk   ranger7   ro   rf  r\   )r&   rn   rj   r8   r  rssrssCountr2   r   chaosllseqi
pos_glyphslookuprf  input_coveragesr   s    `              @r    ro   ro     s[   &&((Ajj((44G 	D!!22:>>J{ammD))dAI&&400 	D 	DAH}}CF}SVQV,, D D      %(ajjmm%D%D      !!Q^44 D DB ! +Du}}%)

199)2AJJt4D4D4KA4N3O)P)PJJ)2AGD1H4E3F)G)GJW/6r7IJFIIdOOO//11 DU4QW1A%B%BCCC))!
)CCCC!DD	D 	D: 
		4,,$$Z00mmD))dAI&&400 "	D "	DAH}}CF}SVQV,, D D      %(ajjmm%D%D      !!Q^44 D DB ! +Du}}%)

199)2 ( 8 8Q G G* *JJ *3 ( 8 8$%Hga.A.A$(.K!" !"* *J
 W/6r7IJFIIdOOO//11 PU4WQ5H5H1I1IA1M%N%NOOO))!
)CCCC-DD"	D "	DF 
		UUUUAJJtDTDTUUUUU 	I!!QW--!Q^,, 	< 	<B #Du}}!

199!*:!6!6JJ!*'->>qxHH" "J W'.r/ABFIIdOOO'')) DU4_)=)=)ABBCCC!!!
!;;;;%	< 	<( 	5&4444r"   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   r2   r  r  s     r    r5   z!subset_glyphs.<locals>.<listcomp>  "    777!!h,,s1v,,,r"   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   rJ   r   r   rn   s     r    r!   z5subset_glyphs.<locals>.<listcomp>.<genexpr>.<genexpr>  s)      99aAM999999r"   Nr  )r   glistrn   s     r    r!   z+subset_glyphs.<locals>.<listcomp>.<genexpr>  s@      UUe9999599999UUUUUUr"   )r~   r  )r   r   r   rn   s     r    r5   z!subset_glyphs.<locals>.<listcomp>  sa        UUUUqzzRS}}UUUUU	  r"   c                H    g | ]\  }}|t          |j                  |S r   r   r  )r   r2   rsr   s      r    r5   z!subset_glyphs.<locals>.<listcomp>#  s3    OOOBBO72qv;N;NO1OOOr"   r   Fc                P    g | ]"}|r|                     j        d           nd#S )Tr   Nr   r  s     r    r5   z!subset_glyphs.<locals>.<listcomp>-  sB     
 
 
>?a9AHHQXTH***T
 
 
r"   c                ,    g | ]}|k     |         S r   r   r  s     r    r5   z!subset_glyphs.<locals>.<listcomp>5  r  r"   c                &    g | ]\  }}|v r|nd S r   r   )r   r2   r  r8   s      r    r5   z!subset_glyphs.<locals>.<listcomp>9  s)    JJJCa7llssJJJr"   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'      661Y666666r"   Nr  r   r  r  s     @r    r!   z+subset_glyphs.<locals>.<listcomp>.<genexpr>C  sX        (	5 666666666     r"   )r~   r  r  )r   r   r   
klass_mapss     r    r5   z!subset_glyphs.<locals>.<listcomp>?  ss          ,/
AJJqMM,J,J    	  r"   c                2    g | ]\  }fd |D             S )c                :    g | ]}                     |          S r   re   r  s     r    r5   z,subset_glyphs.<locals>.<listcomp>.<listcomp>P  s%    ;;;++;;;r"   r   r  s     @r    r5   z!subset_glyphs.<locals>.<listcomp>O  sA       ,Iu <;;;U;;;  r"   c                F    g | ]}|rt          |j                  r|nd S r   r  )r   r  r   s     r    r5   z!subset_glyphs.<locals>.<listcomp>V  s3    HHHbR9GB//9rrTHHHr"   r   c              3  T   K   | ]"}|d uo|                     j                  V  #d S r   r   r  s     r    r!   z subset_glyphs.<locals>.<genexpr>c  s:      RRA1D=7QXXah%7%7RRRRRRr"   r   r   )r  r   r   rG   r'   r   r  r  r  r   r  r7   r<   rM   r9   rt   r  r  rf  r>   rX  r  r  r~   )r&   rn   r  ssr  r   r   r8   r  r  r  s    `    @@@@@r    rv   rv     s<    	&&((A{a-&&qx00dAI&&40077777w777 	. 	.B QV$$B      B B###BSWW----OOOO)C..OOOG$$$3((ai%%%anc#hh///Cyy			}##AH-- 	5mmD))
 
 
 
CN
 
 


 Q_-dAI&&40077777w777$
++55dm6JKKJJJJ9S>>JJJ 	 	B QV$$B      B B###BSWW---    03J

10N0N      IHHHCHHH 	c"goB  	c"goai%%%anc#hh/// Cyy			RRRRDAQAQRRRRRR4&4444r"   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    r5   z"subset_lookups.<locals>.<listcomp>{  s;        #%"4"F"F "F"F"Fr"   r   c                *    g | ]}|r|j         v |S r   r  r  s     r    r5   z"subset_lookups.<locals>.<listcomp>  s;        ,>> >>>r"   r   r   )	r  r   r   r  r  r   r?  rf   r  )r&   r-  r   r  r   r  s    `    r    r.  r.  h  s    	&&((A{f$	** 	R 	RB R(( R R N   ")!Q^"<"<     "!Q^44 R RB ! )7)=)=b>P)Q)QB&&RR	R 	R& 
		N   !$77  	
 	
 	
 $// 	J 	JB !/!5!5b6H!I!IB	J 	J
 	5&4444r"   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    r5   z#collect_lookups.<locals>.<listcomp>  s     
 
 

 R((	
 
 
 a00
 
 

 
 
 
 
r"   r   c                     g | ]}||j         S r   r  )r   r  s     r    r5   z#collect_lookups.<locals>.<listcomp>  s     QQQrbQ"QQQr"   r   r   )r  r   r   r  r?  )r&   r   s    @r    r0  r0    s     	&&((A{f
 
 
 
dAI..
 
 
 	
 
		QQWT1>-J-JQQQQ4&4444r"   c                v    | j         dk    r| j                            ||           d S J d| j         z              Nr   r   r   )r   ExtSubTablero   rm   s      r    ro   ro     sD    {a'':666664&4444r"   c                n    | j         dk    r| j                                        S J d| j         z              r  )r   r  r4  r   s    r    r4  r4    s:    {a113334&4444r"   c                p    | j         dk    r| j                            |          S J d| j         z              r  )r   r  rv   ru   s     r    rv   rv     s<    {a--a0004&4444r"   c                r    | j         dk    r| j                            ||          S J d| j         z              r  )r   r  r   r2  s      r    r   r     s>    {a11$@@@4&4444r"   c                p    | j         dk    r| j                            |          S J d| j         z              r  )r   r  r.  r,  s     r    r.  r.    s<    {a..~>>>4&4444r"   c                n    | j         dk    r| j                                        S J d| j         z              r  )r   r  r0  r   s    r    r0  r0    s:    {a//1114&4444r"   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getr7   rB   issubsetrk   SubTablero   )r&   rn   rj   keydoneLookupsr3   coveredsts           r    ro   ro     s    qx((
 T((C.K __S)44NE7AH-0]]CEE,BBwS)7## NN:m ) ) 	
!Z(((() )r"   c                P   fd| j         D             | _         t          | j                   | _        t          | d          rQ| j        J| j        j        vrd | _        | xj        dz  c_        n$j                            | j                  | _        t          | j                  S )Nc                B    g | ]}||                               |S r   rv   )r   r  rn   s     r    r5   z!subset_glyphs.<locals>.<listcomp>  s1    NNNB2N":J:J1:M:MNRNNNr"   MarkFilteringSeti)	r  r7   SubTableCountr  r  used_mark_sets
LookupFlagrf   rt   ru   s    `r    rv   rv     s    NNNN$-NNNDMT]++Dt'(( RT-B-N (888$(D!OOu$OOO$%$4$:$:4;P$Q$QD!"###r"   c                T    d}| j         D ]}|s|                    ||          rd}|S NFT)r  r   )r&   r(   r   retr  s        r    r   r     sF    
Cm   	g.. 	CJr"   c                D    | j         D ]}|                    |           d S r   )r  r.  )r&   r-  rn   s      r    r.  r.    s4    ] ) )	(((() )r"   c                @    t          d | j        D             g           S )Nc              3  B   K   | ]}||                                 V  d S r   )r0  r   r  s     r    r!   z"collect_lookups.<locals>.<genexpr>  s3      CCC""$$CCCCCCr"   )sumr  r   s    r    r0  r0    s#    CCt}CCCRHHHr"   c                >    t          d | j        D                       S )Nc              3  B   K   | ]}||                                 V  d S r   )r4  r  s     r    r!   z$may_have_non_1to1.<locals>.<genexpr>  s3      DD"Dr##%%DDDDDDr"   )rV   r  r   s    r    r4  r4    s!    DDDDDDDDr"   c                D    fdt          | j                  D             S )z(Returns the indices of nonempty lookups.c                H    g | ]\  }}||                               |S r   r  )r   r2   r4   rn   s      r    r5   z!subset_glyphs.<locals>.<listcomp>   s3    MMM$!QAM!//!:L:LMAMMMr"   )r<   r  ru   s    `r    rv   rv     s*     NMMM)DK00MMMMr"   c                T    d}| j         D ]}|s|                    ||          rd}|S r  )r  r   )r&   r(   r   r  r4   s        r    r   r   #  sF    
C[   	tW-- 	CJr"   c                                                         fd|D              _        t           j                   _         j        D ]}|                    |           d S )Nc                @    g | ]}|j         k     j        |         S r   )LookupCountr  rK   s     r    r5   z"subset_lookups.<locals>.<listcomp>1  s,    RRRaQAQ=Q=Q4;q>=Q=Q=Qr"   )ensureDecompiledr  r7   r  r.  )r&   r-  r4   s   `  r    r.  r.  .  st    RRRR>RRRDK4;''D[ ) )	(((() )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   r2   r4   r-  s      r    r5   z"neuter_lookups.<locals>.<listcomp>;  s8       /3q!Q.  d  r"   N)r  r<   r  r,  s    `r    neuter_lookupsr  7  sO     	   7@7M7M  DKKKr"   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  r0  rK   s     r    r!   z"closure_lookups.<locals>.<genexpr>G  sB      WW!!dFVBVBVT[^++--BVBVBVBVWWr"   c                2    g | ]}|v|j         k     |S r   )r  )r   r4   r-  r&   s     r    r5   z#closure_lookups.<locals>.<listcomp>J  s;     
 
 
&&1t/?+?+? +?+?+?r"   )r   r  extend)r&   r-  recurserecurse_lookupss   ``  r    closure_lookupsr  @  s      //NG"WWWWwWWW
 

 
 
 
 
$
 
 

  	.n---$_55o...!"r"   c                    fd| j         D             | _         fd| j         D             | _         t          | j                   | _        | j        pt          | j        t
          j                  S )z2 "Returns True if feature is non-empty afterwards.c                    g | ]}|v |	S r   r   r   r4   r-  s     r    r5   z"subset_lookups.<locals>.<listcomp>Y  s#    SSS!qN?R?RA?R?R?Rr"   c                :    g | ]}                     |          S r   re   r  s     r    r5   z"subset_lookups.<locals>.<listcomp>[  s'    RRRN0033RRRr"   )r  r7   r  
isinstanceFeatureParamsr   FeatureParamsSizer,  s    `r    r.  r.  V  s     TSSSt';SSSDRRRRT=QRRRD4/00D  zH6    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   r2   fr-  s      r    r5   z"subset_lookups.<locals>.<listcomp>l  sN       AqI$$^44 9:8N8N 	
8N8N8Nr"   )r<   FeatureRecordr,  s    `r    r.  r.  e  s9       d011   r"   c                <     t           fd|D             g           S )Nc              3  \   K   | ]&}|j         k     j        |         j        j        V  'd S r   )FeatureCountr+  r(  r  rK   s     r    r!   z"collect_lookups.<locals>.<genexpr>v  sK       	
 	
4$$$ q!)9$$$$	
 	
r"   )r  r&   feature_indicess   ` r    r0  r0  s  s@    	
 	
 	
 	
$	
 	
 	

 	  r"   c                    |                                   t          | j        |          | _        t          | j                  | _        t          | j                  S r   )r  r9   r+  r7   r.  rt   r/  s     r    subset_featuresr2    sM    %d&8/JJDD.//D!"""r"   c                *    fd| j         D             S )r%  c                R    g | ]#}|j                                       |j        $S r   )r(  r.  FeatureIndex)r   r   r-  s     r    r5   z"subset_lookups.<locals>.<listcomp>  sA       9##N33	  r"   )SubstitutionRecordr,  s    `r    r.  r.    s1       (   r"   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>  sH       	
 	
 &55nEE	
 	
 	
 	
 	
 	
r"   r  FeatureVariationRecordr,  s    `r    r.  r.    sE     	
 	
 	
 	
0	
 	
 	
 	  r"   c                F    t          fd| j        D             g           S )Nc              3  `   K   | ](}|j         j        D ]}|j        v |j        j        V  )d S r   )r9  r6  r5  r(  r  )r   vrr   r0  s      r    r!   z"collect_lookups.<locals>.<genexpr>  s^       	
 	
0C	
 	
 ~00 I% 10000		
 	
r"   r:  r/  s    `r    r0  r0    sC    	
 	
 	
 	
1	
 	
 	
 	  r"   c                   |                                   fd| j        D             | _        | j        D ]!}                    |j                  |_        "t	          | j                  | _        t          | j                  S )Nc                &    g | ]}|j         v |S r   )r5  )r   r   r0  s     r    r5   z#subset_features.<locals>.<listcomp>  s,       an.O.O.O.O.Or"   )r  r6  rf   r5  r7   SubstitutionCountrt   r&   r0  r   s    ` r    r2  r2    s       *  D $ ? ?(..q~>> !899D&'''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  r;  r9  r2  rA  popr7   FeatureVariationCountrt   rB  s      r    r2  r2    s    ( D D	"22?CCCC 	#*+

"#4	* 	#''))) 	#*+

"#4	* "%T%@!A!AD*+++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*  r0  s     r    r5   z#subset_features.<locals>.<listcomp>  s#    NNNqo9M9M9M9M9Mr"   c                B    g | ]}|v                      |          S r   re   rI  s     r    r5   z#subset_features.<locals>.<listcomp>  s8       %&qO?S?Sa  ?S?S?Sr"   )ReqFeatureIndexrf   r5  r7   r.  rt   r/  s    `r    r2  r2    s    ...44T5IJJ$NNNND$5NNND   *.*;  D D-..D!BT%9U%BCCCr"   c                    | j         d d          }| j        dk    r|                    | j                   t          |          S NrG  )r5  rK  appendr   r/  s     r    collect_featuresrO    sF    '*Ou$$t3444o&&&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   )LangSysr2  )r   r4   r0  s     r    r5   z#subset_features.<locals>.<listcomp>  s>       )B)B?)S)S	  r"   )DefaultLangSysr2  LangSysRecordr7   LangSysCountrt   )r&   r0  keepEmptyDefaultLangSyss    ` r    r2  r2    s     	##33ODD# (#
 #   %  D D.//D!8T%8999r"   c                    d | j         D             }| j        r,|                    | j                                                   t	          t          |g                     S )Nc                @    g | ]}|j                                         S r   )rR  rO  )r   r4   s     r    r5   z$collect_features.<locals>.<listcomp>  s&    PPPqy1133PPPr"   )rT  rS  rN  rO  r   r  r/  s     r    rO  rO    s_    PPT=OPPPO Gt2CCEEFFFc/2..///r"   c                    fd| j         D             | _         t          | j                   | _        t          | j                  S )Nc                `    g | ]*}|j                             |j        d k              s(|+S )DFLT)Scriptr2  	ScriptTag)r   rn   r0  retain_emptys     r    r5   z#subset_features.<locals>.<listcomp>  sR       8##OQ[F5JKK 		  r"   )ScriptRecordr7   ScriptCountrt   )r&   r0  r^  s    ``r    r2  r2    s]        "  D 4,--D !!!r"   c                Z    t          t          d | j        D             g                     S )Nc              3  H   K   | ]}|j                                         V  d S r   )r\  rO  r   rn   s     r    r!   z#collect_features.<locals>.<genexpr>  s0      RR1184466RRRRRRr"   )r   r  r_  r   s    r    rO  rO    s-    cRR@QRRRTVWWXXXr"   EBLCc                    | j         D ]:}|j        D ]}fd|j        D             |_        d |j        D             |_        ;d | j         D             | _         dS )Nc                &    g | ]}|j         v |S r   rJ   )r   nrn   s     r    r5   z!subset_glyphs.<locals>.<listcomp>  s     "S"S"SQ!(]]1]]]r"   c                     g | ]}|j         	|S r   )names)r   r2   s     r    r5   z!subset_glyphs.<locals>.<listcomp>  s     M M MqQW M M M Mr"   c                     g | ]}|j         	|S r   )indexSubTablesrc  s     r    r5   z!subset_glyphs.<locals>.<listcomp>  s     @@@!q/?@A@@@r"   T)strikesrk  ri  )r&   rn   strikeindexSubTables    `  r    rv   rv   
  s    , N N#2 	T 	TM"S"S"S"Sm.A"S"S"SM M MF,A M M M@@t|@@@DL4r"   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   rm  s     r    r.   z,subset_glyphs.<locals>.<listcomp>.<dictcomp>  s$    777!1;;F1I;;;r"   rJ   )r   rm  rn   s    @r    r5   z!subset_glyphs.<locals>.<listcomp>  s>       <B7777qx777  r"   c                    g | ]}||S r   r   )r   rm  s     r    r5   z!subset_glyphs.<locals>.<listcomp>  s    AAA&&AvAAAr"   T)
strikeData)r&   rn   ru  s    ` r    rv   rv     sJ       FJo  J
 BAJAAADO4r"   sbixc                p    | j                                         D ]fd|j        D             _        dS )Nc                >    i | ]}|j         v |j         |         S r   rJ   rs  s     r    r.   z!subset_glyphs.<locals>.<dictcomp>$  s.    UUU!v}BTBTFM!,BTBTBTr"   T)rl  ra   r'   )r&   rn   rm  s     @r    rv   rv   !  sF    ,%%'' V VUUUUahUUU4r"   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  
ScriptListrO  FeatureListr0  r   r{  r   r  r  r  r'   r  r  ro   )r&   rn   r0  r-  orig_glyphsr2   s         r    ro   ro   )  sS   jAGz */@@BBz /??PPtz.55 X$*6FFWWW//Nz 		#AH--K# B B
-999z,3A6 
%,Q/>>qAAAAah&&		 N	r"   GPOSc                    |j         |_        | j        j        r | j        j                            |          }ng }|                     |           dS r   )glyphs_gsubedr'   r  r  rv   r.  )r&   rn   r-  s      r    rv   rv   G  sP    AHz .<<Q??'''4r"   c                <    | j         t          j        d          k    S )Nry  )r  r   getTableClassr   s    r    retain_empty_scriptsr  R  s     >U08888r"   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 )zZRetains specified lookups, then removes empty features, language
    systems, and scripts.r{  N)
r  r  r.  r}  r   r{  r   r2  r|  r  )r&   r-  r0  s      r    r.  r.  Y  s?    z =
,,^<<<z *0??OOtz.55 W4:7FF~VVV 11Oz @
..???tz.55 F
$44_EEEz 

--T6688	
 	
 	
 	
 	

 
r"   c                `    | j         j        r!| j         j                            |           dS dS )r  N)r  r  r  r,  s     r    r  r  p  s:     z =
,,^<<<<<= =r"   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 lookupsr{  N)r  r|  rO  r}  r0  r   r{  r   r  r  r.  r  )r&   rM   r0  r-  s       r    prune_lookupsr  w  s    z */@@BBz /??PPtz.55 X$*6FFWWW//Nz .>>~NN ,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   r2   r*  feature_tagss      r    r5   z'subset_feature_tags.<locals>.<listcomp>  s4     
 
 
1||++ +++r"   r{  )	r  r}  r<   r+  r2  r   r{  r|  r  )r&   r  r0  s    ` r    subset_feature_tagsr    s    z 

 
 
 
!$*"8"FGG
 
 

 	
..???4:2D99 	JJ(88IIIz 

--T6688	
 	
 	
 	
 	

 
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   )r]  )r   rn   script_tagss     r    r5   z&subset_script_tags.<locals>.<listcomp>  s,     .
 .
 .
Q[K=W=WA=W=W=Wr"   z*   c                <    g | ]}|j         j                 v |S r   )
LangSysTagr]  )r   r4   langsysrecords     r    r5   z&subset_script_tags.<locals>.<listcomp>  s8     / / /|wv/?'@@@ @@@r"   dflt)rB   splitr  ljust
setdefaultr  r|  r_  r7   r`  r]  r\  rT  rU  rS  )r&   tagstag
script_taglang_tagr  r  r  s        @@@r    subset_script_tagsr    s   G%%K E E14syy~~~#s
H
((++,,,:suu--11(..2C2CDDDDz 8.
 .
 .
 .
z,9.
 .
 .

* -0
0E0R,S,S
)j+8 		8 		8F7**vWVEU=V/V/V/ / / / /#]8/ / /+
 .11L-M-M*)9!:::37FM08 8		8 		8r"   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 featuresr{  N)r  r|  rO  r}  r2  r   r{  r  r/  s     r    prune_featuresr    s     z */@@BBz @
..???tz.55 F
$44_EEEz 

--T6688	
 	
 	
 	
 	

 
r"   c                    d|j         vr|                     |j                    d|j        vr|                     |j                   |                     d           dS )Nr   Fr   T)layout_scriptsr  layout_featuresr  r  r2  s      r    prune_pre_subsetr    sj     '((( 6777
')))  !8999U###4r"   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 rM  )r  r|  r}  r+  r_  r\  rS  rT  rR  r7   r5  rK  r  remove)r&   r  featuresrn   r-   lrr4   r2   s           r    remove_redundant_langsysr    sb   JE 5#4  .H* 2 2H# 	((+ 	2 	2B
A1>""c!.&9&999!U*0AU0JKK E))A-.(1;L2MMM3q~..// 2 2AN1-.(1>!;L2MMME N &--b111#	2	2 2r"   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 )Nr{  i     T)r  r  r  r   r}  r  r  r  r{  r;  Versionr&   r(   r   r  s       r    r   r     s    JE :**4999  !  %%''' u)** 	'" 	+	+"'"9"P	+ '+E# & 	'5=J+F+F&EM4r"   GDEFc                   |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          rhj        raj        }|j        D ]}|r|                               d t%          |j                  D             |_        d |j        D             |_        dS )Nc                $    i | ]\  }}|v 	||S r   r   rT   s      r    r.   z!subset_glyphs.<locals>.<dictcomp>2  s,     .
 .
 .
Q1PV;;Aq;;;r"   c                $    i | ]\  }}|v 	||S r   r   rT   s      r    r.   z!subset_glyphs.<locals>.<dictcomp>6  s+     )
 )
 )
Qa6kkAqkkkr"   c                @    g | ]}|k     j         j        |         S r   )
AttachListAttachPoint)r   r2   r   r  s     r    r5   z!subset_glyphs.<locals>.<listcomp><  s0     (
 (
 (
01JE(+r"   MarkGlyphSetsDefc                &    g | ]\  }}|j         |S r   rJ   r   s      r    r5   z!subset_glyphs.<locals>.<listcomp>F  s#    XXX$!QqxXAXXXr"   c                     g | ]}|j         	|S r   rJ   )r   r   s     r    r5   z!subset_glyphs.<locals>.<listcomp>G  s    !P!P!Pqx!P!!P!P!Pr"   T)r  r  LigCaretListr   rG   r9   r   r7   LigGlyphCountMarkAttachClassDefrQ   rW   GlyphClassDefr  r   r  r  r  r<   r  )r&   rn   r8   markGlyphSetscoverager   r'   r  s        @@@r    rv   rv   )  s   _FJE L$-44V<<&253E3NPW&X&X#+.u/A/J+K+K( 
.
 .
 .
 .
"5?EEGG.
 .
 .
 *  
)
 )
 )
 )
"0:@@BB)
 )
 )
%  H"+226::%0
(
 (
 (
 (
 (
5<(
 (
 (
$ '*%*:*F&G&G#u()) Qe.D Q.%. 	( 	(H ('''XX)M4J*K*KXXX!P!P]-C!P!P!P4r"   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  VarStorer  )r  r  r  rB   collect_device_varidxessubset_varidxesremap_device_varidxes)r(   gdefr  storeusedVarIdxes
varidx_maps         r    
_pruneGDEFr  L  s    T<DJE5*%% NE55L 
!!,///~~V22<@@@ &&|44J 

+++~~V00<<<<< ~r"   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  rQ   r  r  r   r  r  r  VarDataCountr  r  r   rt   r  s       r    r   r   f  s   JE "%"4"B "! ((@(J (#'  #5#6#@ #"   0 ;  uj!! +4>&!++}
** *E-..'%' %.'
 "&=J&&&EM 	<#	<	< 	< MZ'BE,B		<
 MZ':EN  r"   kernc                V    d | j         D             | _         t          | j                   S )Nc                2    g | ]}t          |d           |S 	kernTable)r  r   ts     r    r5   z$prune_pre_subset.<locals>.<listcomp>  s'    MMMQWQ5L5LMqMMMr"   )
kernTablesrt   r2  s      r    r  r    s,     NM$/MMMDO   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  rU   r'   s       r    r.   z!subset_glyphs.<locals>.<dictcomp>  s@     
 
 
AF{{qF{{ FA*{{r"   c                     g | ]}|j         	|S r   r  r  s     r    r5   z!subset_glyphs.<locals>.<listcomp>  s    AAAQQ[AqAAAr"   )r  r  r  rW   rt   )r&   rn   r  r'   s      @r    rv   rv     s    _F_ 
 

 
 
 
[..00
 
 

 BA$/AAADO   r"   vmtxc                    t          | j        |j                  | _        |j        D ]}d| j        |<   t	          | j                  S )Nr   r   )r/   metricsr'   glyphs_emptiedrt   r&   rn   r   s      r    rv   rv     sF    ah77DL ! ! Qr"   hmtxc                l    t          | j        |j                  | _        |j        D ]}d| j        |<   dS )Nr  T)r/   r  r'   r  r  s      r    rv   rv     s;    ah77DL ! ! Q4r"   hdmxc                    fd| j                                         D             | _         | j         D ]}j        D ]}d| j         |         |<   t          | j                   S )Nc                B    i | ]\  }}|t          |j                  S r   )r/   r'   )r   szr4   rn   s      r    r.   z!subset_glyphs.<locals>.<dictcomp>  s+    NNN52q\!QX..NNNr"   r   )r  rW   r  rt   )r&   rn   r  r   s    `  r    rv   rv     ss    NNNNDIOO<M<MNNNDIi ! !! 	! 	!A DIbM!	!	??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   rx   r  s     r    r.   z!subset_glyphs.<locals>.<dictcomp>  s5       (-Uem=S=Su}U#=S=S=Sr"   )r  AnchorPointsr   r'   r  r7   r&   rn   r  s     @r    rv   rv     ss    J#E<185<G   12  EM u}!!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    ro   ro     s>    JE|v	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    r.   z!subset_glyphs.<locals>.<dictcomp>  sA     
 
 
 5'++E53HII
 
 
r"   r   r   c                (    i | ]\  }}|k    ||S r   r   )r   rx   r  
mostCommons      r    r.   z!subset_glyphs.<locals>.<dictcomp>  s$    WWWheQqJr"   r   T)r  r  r   r'   r7   r   ra   most_commonr  rW   r  )r&   rn   	baselines_cntr  r  s       @@r    rv   rv     s    JE|v
 
 
 

 
 
	 y>>A&y'7'7'9'9::FFqII!LJ$.E!WWWW)//2C2CWWWIy>>A#,E   Q<<5EL$4r"   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    r.   z!subset_glyphs.<locals>.<dictcomp>  s5     
 
 
+0@U@UE5<&@U@U@Ur"   r   Fzunknown 'lcar' format %s)r  LigatureCaretsr   r'   r  r7   r  s     @r    rv   rv     ss    J%E|v
 
 
 
45H
 
 
 5<  1$$?05<????r"   gvarc                L    |j         r|j        sg | j        |j        d         <   dS Nr   T)notdef_glyphnotdef_outline
variations
glyphOrderr2  s      r    r  r    s/     1G$: 1.0*+4r"   c                    t          | j        |j                  | _        t          | j                  | _        t          | j                  S r   )r/   r  r'   r7   
glyphCountrt   ru   s     r    rv   rv     s8    "4?AH==DO$/**DO   r"   c                    fd|j                                         D             }|j         | j                          }| j                                        D ]\  }}|| j        k    r|nd||<   |S )Nc                (    i | ]\  }}||         S r   r   )r   r  rU   r  s      r    r.   z$_remap_index_map.<locals>.<dictcomp>  s#    CCCAAz!}CCCr"   r   )rl   rW   last_retained_glyphreverseEmptiedGlyphMaplast_retained_order)rn   r  	table_mapmap_last_idxr   r2   s    `     r    _remap_index_mapr    s    CCCC):)@)@)B)BCCCD )+A,ABCH(..00 ? ?1!"777((QQKr"   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  rB   AdvWidthMapr/   rl   r'   rk   ra   reverseOrigGlyphMapcopyr   retain_gidsLsbMapRsbMapr  r  r  r&   rn   r  used	advIdxes_retainAdvMapr  s          r    rv   rv    	  s   JE55DIL -$01B1JAH$U$U!E%-44667777A)0022333IIKK	y,| 3+EL,@!(KKEL(//11222| 3+EL,@!(KKEL(//11222//\I 0  J  W$4Q
EDU$V$V!| M/:u|LL| M/:u|LL 4r"   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  rB   AdvHeightMapr/   rl   r'   rk   ra   r  r  r   r  TsbMapBsbMapVOrgMapr  r  r  r  s          r    rv   rv   &	  s:   JE55DIL -%1%2D2Lah%W%W"E&.55778888A)0022333IIKK	y,| 3+EL,@!(KKEL(//11222| 3+EL,@!(KKEL(//11222} 4 ,U]-BAH M MEM)0022333//\I 0  J  Y%5aUEW%X%X"| M/:u|LL| M/:u|LL} O 0J N N 4r"   VORGc                    fd| j                                         D             | _         t          | j                   | _        dS )Nc                .    i | ]\  }}|j         v ||S r   rJ   rr   s      r    r.   z!subset_glyphs.<locals>.<dictcomp>S	  s-       AQX1r"   T)VOriginRecordsrW   r7   numVertOriginYMetricsru   s    `r    rv   rv   Q	  sW       ,2244  D "%T%8!9!9D4r"   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    r.   z!subset_glyphs.<locals>.<dictcomp>^	  ;     %
 %
 %
111 5,U3111r"   r   c                >    i | ]}|j         v |j         |         S r   )OpticalBoundsPointsr  s     r    r.   z!subset_glyphs.<locals>.<dictcomp>e	  r*  r"   Fzunknown 'opbd' format %s)r  OpticalBoundsr   r'   r)  r7   r,  r  s     @r    rv   rv   Z	  s    J$E|q%
 %
 %
 %
%
 %
 %
!
 5,--11			%
 %
 %
 %
%
 %
 %
!
 5,--11?05<????r"   postc                "    |j         sd| _        dS )N      @T)glyph_names
formatTyper2  s      r    r  r  o	  s     4r"   c                    g | _         dS r   )
extraNamesru   s     r    rv   rv   v	  s    DO4r"   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   r5  s     r    r.   z!subset_glyphs.<locals>.<dictcomp>	  s=     
 
 
BCAt""1d&<==
 
 
r"   c                (    i | ]\  }}|k    ||S r   r   )r   r   r5  r  s      r    r.   z!subset_glyphs.<locals>.<dictcomp>	  s0     
 
 
4dj>P>PAt>P>P>Pr"   TFzunknown 'prop' format %s)r  GlyphPropertiesr   r9  r'   r8  r   ra   r  rW   r7   )r&   rn   r  r  r5  s      @@r    rv   rv   |	  s#   :%D{a%**			
 
 
 
GHx
 
 
 #4?#9#9#;#;<<HHKKAN
D!+
 
 
 
#'?#8#8#:#:
 
 
 t1$$DK)Q..t>04;>>>>r"   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    < + /
 
 
 JJu{#####	
 
r"   )rB   traverse)rB  colrrD  rC  s      @r    _paint_glyph_namesrG  	  s@    UUF$ $ $ $ $ 
NN4"""Mr"   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    r.   z"closure_glyphs.<locals>.<dictcomp>	  s.     
 
 
 M39
 
 
r"   )version_decompileColorLayersV0r  ColorLayersBaseGlyphListBaseGlyphPaintRecordColorLayersV1r'   rB   r  r  r   rk   rG  )r&   rn   	decomposelayersr   layerrB  s          r    ro   ro   	  sB   |a
  77
CC
 
z/D
 
 

 I
  	I 	IA)--a44 ' '

5:&&&&|a*..q11$MM"4UDJ"G"GHHH!(		      r"   c                h    ddl m} ddlm}m} j        _         fdj        D              _         j        dk    rt           j                  S  | j
        j         j
        j                   |fdD                       \   j
        _         j
        _         ` j
        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   )rO  rR   s     r    r.   z!subset_glyphs.<locals>.<dictcomp>	  s7       #$A9I4I4I4A4I4I4Ir"   c                4    i | ]}|j         v ||         S r   rJ   )r   r   colorGlyphsV1rn   s     r    r.   z!subset_glyphs.<locals>.<dictcomp>	  s'    EEEqAH}}M!}}}r"   c                4    i | ]}|j         v ||         S r   rJ   )r   r   clipsrn   s     r    r.   z!subset_glyphs.<locals>.<dictcomp>	  s&    $Q$Q$QQ1==Qa===r"   c                6    i | ]}|d  |         D             S )c                *    g | ]}|j         |j        fS r   )r   colorID)r   rU  s     r    r5   z,subset_glyphs.<locals>.<dictcomp>.<listcomp>	  s!    BBBUej%-(BBBr"   r   )r   r   layersV0s     r    r.   z!subset_glyphs.<locals>.<dictcomp>	  s.    UUUqBBhqkBBBUUUr"   T)fontTools.colorLib.unbuilderrW  fontTools.colorLib.builderrX  rY  glyphs_colredr'   rO  rM  rt   r  	LayerListrP  rR  ClipListr^  rQ  )r&   rn   rW  rX  rY  r^  r\  rb  s   ``   @@@r    rv   rv   	  s   ::::::FFFFFFFF AH   ()  D |qD$%%%!M$*"6
8PQQM5@[EEEEEmEEE6 62DJ$*2 	z&
#)$Q$Q$Q$Q$Q%$Q$Q$Q
!H:#8 JH~~N
UUUUHUUU   	 4r"   CPALc                   d|v rdS |                     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<g }t'          | j                  D ]\  }}|v r|                    |           || _        t5          | j                  S )NzSVG TrH  Fc                    t          | d          r"| j                                     |            d S t          | d          r/| j        j        D ]$}|j                                     |           #d S d S )NPaletteIndex	ColorLine)r  rk  rN  rl  	ColorStop)rB  stopcolors_by_indexs     r    collect_colors_by_indexz2prune_post_subset.<locals>.collect_colors_by_index
  s    5.)) 	@E./66u=====UK(( 	@1 @ @ 1299$????	@ 	@@ @r"   r   rG  c                "    g | ]\  }}|v 	|S r   r   )r   r2   r   retained_palette_indicess      r    r5   z%prune_post_subset.<locals>.<listcomp>
  s(    XXXDAq!?W:W:Wa:W:W:Wr"   ra  rk  r   )r  r   r`   rM  rO  ra   ra  rN  r  LayerRecordArrayLayerRecordrk  rP  rQ  rL  rE  rB   keyspalettesr<   r7   r$   r  AssertionErrornumPaletteEntriespaletteEntryLabelsrt   )r&   r(   r   rF  rp  rT  rU  r  palette	new_index	old_indexkept_labelsr2   labelro  rr  s                 @@r    r   r   	  s    ~~t88FD u!$''O@ @ @ @ @ |q&--// 	= 	=F = =.55e<<<<=	= :& 	B4@ B B 23::5AAAAj.C 	G 	GFL!!$*.EFFFF  #?#7#7#9#9::fXE= = =XXXXIg$6$6XXX
7||s#;<<<<<<< )&1I*J*J K K - -	9%i0 	- 	-Fvy)) -!*00 -&/##$V,,,	- !q!122D|q!$"9:: 	* 	*HAu,,,""5)))"-&'''r"   c                    t                      }| j        D ]}|                    |j                   | j        r)| j        j        D ]}|                    |j                   |S r   )rB   MathGlyphVariantRecordr  VariantGlyphGlyphAssemblyPartRecordsrx   )r&   r'   variantsrU   r   s        r    ro   ro   0
  sp    uuH( % %Q^$$$$ "#/ 	" 	"ALL!!!!Or"   c                   t          |j                  }t                      }| j        rR| j                            |          }|D ]5}|                    | j        |                             |                     6| j        rR| j                            |          }|D ]5}|                    | j	        |                             |                     6|j                            |           d S r   )
r  r'   rB   VertGlyphCoverager>   rk   VertGlyphConstructionro   HorizGlyphCoverageHorizGlyphConstruction)r&   rn   r'   r  r8   r2   s         r    ro   ro   ;
  s    qx  FuuH R(226:: 	R 	RAOOD6q9HHPPQQQQ S)33F;; 	S 	SAOOD7:II&QQRRRRHOOHr"   VARCc                    | j         j                            |j                  }t	          | j         j        j        |          | j         j        _        t          | j         j        j                  S r   )r  r   rG   r'   r9   VarCompositeGlyphsVarCompositeGlyphrt   r   s      r    rv   rv   M
  sX    j!((22G6B
%77 7DJ!3 
-?@@@r"   c                   | j         j        d S d t          | j         j        j                  D             }| j         j        j        }|j        }t                      }t          |          }|r}|}t                      }|D ]f}||v r|                    |          }	|	||	         }
|
j        D ]7}|j	        }|
                    |           ||vr|
                    |           8g|{d S d S )Nc                    i | ]\  }}||	S r   r   )r   r2   	glyphNames      r    r.   z"closure_glyphs.<locals>.<dictcomp>[
  s    WWWI	1WWWr"   )r  r  r<   r   r'   r  rB   r  
componentsr  r  )r&   rn   glyphMapglyphRecordsr'   r  newoldNewr  idxrx   compr   s                r    ro   ro   V
  s   z$,WW4:;N;U1V1VWWWH:0BLXFeeG
f++C
 "ee 	" 	"IG##,,y))C{ %E( " "~

4   w&&GGDMMM	"  " " " " "r"   c                   | j         }|j        }|Mt                      }|                    |           |                    |          }|                    |           |j        j        }|t                      }|j        j	        D ]-}	|	j
        D ]#}
|
j        |                    |
j                   $.t          |          }t          ||          |j        _        d t          |          D             }|j        j	        D ]%}	|	j
        D ]}
|
j        ||
j                 |
_        &|j        }||j        }t                      }|j        j	        D ]-}	|	j
        D ]#}
|
j        |                    |
j                   $.t          |          }t          ||          |_        d t          |          D             }|j        j	        D ]%}	|	j
        D ]}
|
j        ||
j                 |
_        &dS )Nc                    i | ]\  }}||	S r   r   r   r  olds      r    r.   z%prune_post_subset.<locals>.<dictcomp>
      CCCS3CCCr"   c                    i | ]\  }}||	S r   r   r  s      r    r.   z%prune_post_subset.<locals>.<dictcomp>
  r  r"   T)r  MultiVarStorerB   collect_varidxesr  remap_varidxesAxisIndicesListItemr  r  r  axisIndicesIndexr  r$   r9   r<   ConditionListConditionTableconditionIndex)r&   r(   r   r  r  r  r  axisIndicesListusedIndicesrx   r  rl   conditionListconditionTabless                 r    r   r   r
  sD   JEEuu|,,,**<88
Z(((+0O"ee-? 	; 	;E( ; ;(4OOD$9:::; [))%1/;%O%O"CCIk,B,BCCC-? 	K 	KE( K K(4,3D4I,JD)K 'M '6ee-? 	9 	9E( 9 9&2OOD$78889 [))'3O['Q'Q$CCIk,B,BCCC-? 	G 	GE( G G&2*1$2E*FD'G 4r"   MATHc                `    | j         j        r!| j         j                            |           d S d S r   )r  MathVariantsro   ru   s     r    ro   ro   
  s8    z 2
..q111112 2r"   c                    | j                             |j                  }t          | j        |          | _        t          | j                  | _        t          | j                  S r   )r   rG   r'   r9   ItalicsCorrectionr7   ItalicsCorrectionCountrt   r   s      r    rv   rv   
  sR    m""18,,G)$*@'JJD"%d&<"="=D+,,,r"   c                    | j                             |j                  }t          | j        |          | _        t          | j                  | _        t          | j                  S r   )TopAccentCoveragerG   r'   r9   TopAccentAttachmentr7   TopAccentAttachmentCountrt   r   s      r    rv   rv   
  sS    $++AH55G+D,DgNND$'(@$A$AD!-...r"   c                    | j                             |j                  }t          | j        |          | _        t          | j                  | _        t          | j                  S r   )MathKernCoveragerG   r'   r9   MathKernInfoRecordsr7   MathKernCountrt   r   s      r    rv   rv   
  sS    #**1844G+D,DgNNDT566D"###r"   c                   | j         r| j                             |           | j        r| j                            |           | j        r| j                            |           | j        r| j                            |j                   dS r   )MathItalicsCorrectionInforv   MathTopAccentAttachmentMathKernInfoExtendedShapeCoveragerG   r'   ru   s     r    rv   rv   
  s    % 8&44Q777# 6$221555 +''***! 4"))!(3334r"   c                j   | j         rR| j                             |j                  }t          | j        |          | _        t          | j                  | _        | j        rR| j                            |j                  }t          | j        |          | _        t          | j                  | _	        dS r   )
r  rG   r'   r9   r  r7   VertGlyphCountr  r  HorizGlyphCountr   s      r    rv   rv   
  s     >(//99%1$2Lg%V%V"!$"<== @)00::&243NPW&X&X#"4#>??4r"   c                    |j         |_        | j        j        r| j        j                            |           | j        j        r| j        j                            |           dS r   )glyphs_mathedr'   r  MathGlyphInforv   r  ru   s     r    rv   rv   
  s\    AHz 2
 ..q111z 1
--a0004r"   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  r2   moreflagsglyphIDs          r    remapComponentsFastr  
  sa   9 dDIbqbM::1=BB +++D49
AD
 aAa!e,A;!#tAE{2W%lQUnQU	QE

6> 	FAAFA6> 	FAAV^ 	FAAV^ 	FAv~)      r"   c                   | j         }|j         }|rwt                      }|D ]<}||vr||         }|                    |           D ]}|                    |           =||j         z  }|j                             |           |}|ud S d S r   )r'   rB   getComponentNamesr  rk   )r&   rn   glyphSetrS  r  r   glr   s           r    ro   ro     s    {HI
 
UU
 	" 	"A  !B))$// " "q!!!!"ah
	
###	  
 
 
 
 
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     G$: #$	
4r"   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   rJ   )r   r2   r   rn   s      r    r5   z!subset_glyphs.<locals>.<listcomp>   s$    MMMAqAH}}1}}}r"   c                    i | ]\  }}||	S r   r   )r   rg  os      r    r.   z!subset_glyphs.<locals>.<dictcomp>!  s    888TQAq888r"   r  r  r"   c                8    g | ]}|j         v s	|j        v |S r   )r'   r  r  s     r    r5   z!subset_glyphs.<locals>.<listcomp>)  s7       a18mmqA<L7L7L7L7L7Lr"   T)r/   r'   r   r  r<   r   ra   r  r  r   getTableModulerA  r  r  )r&   rn   r8   glyphmaprU   rA  r   s    `     r    rv   rv     s!   t{AH55DK9  0MMMM4?!;!;MMM88Yw%7%7888##%% 	0 	0Aq&!! 0%%h/// ((.E " "A!A   ?  DO 4r"   c                z    |j          }| j                                        D ]}|                    |           dS )N)remove_hintingT)r   r'   ra   trim)r&   r(   r   r  rU   s        r    r   r   0  sE     (N[!! . .	n----4r"   cmapc                   
 d | j         D             }j        j        rXt                      }j        D ](}t          |          }||                    |           )j                            |           |D ]}|j        dk    rk|j	        
                                D ]P\  }
|j        vrfd
D             }d |v r|                    d            j                            |           Qx|j        
j                            
                                          }	j                            
fd|	D                        ҉j                                        _        |D ]!}j                            |j                   "d S )Nc                :    g | ]}|                                 |S r   	isUnicoder  s     r    r5   z"closure_glyphs.<locals>.<listcomp>:  s%    666A6a666r"      c                ,    h | ]\  }}|j         v |S r   unicodes_requestedr   ur   rn   s      r    	<setcomp>z!closure_glyphs.<locals>.<setcomp>K  s*    JJJ1Q5I0I0I!0I0I0Ir"   c              3  (   K   | ]}|         V  d S r   r   )r   r  r  s     r    r!   z!closure_glyphs.<locals>.<genexpr>R  s'      ::DG::::::r"   )tablesr   bidi_closurerB   r  r   r  rk   formatuvsDictrW   r  r'   r  r   ru  r  unicodes_missingdifference_update)r&   rn   r  additional_unicodesr  mirror_ur  varSelectorr'   r   r  s    `        @r    ro   ro   8  s   66666F 	y 9!ee% 	2 	2A{{H##''111	##$7888  ; ;<2%*]%8%8%:%: ( (!Ta&:::JJJJJJJ6>>MM$'''''''( :D/<<TYY[[IILHOO::::\::::::: -2244A 9 9	,,UZ88889 9r"   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    r5   z$prune_pre_subset.<locals>.<listcomp>^  s2    OOOQO!**,,OqOOOr"   c                :    g | ]}|                                 |S r   )r  r  s     r    r5   z$prune_pre_subset.<locals>.<listcomp>`  s%    BBBQQZZ\\BqBBBr"   c                (    g | ]}|j         d k    |S )r   )r  r  s     r    r5   z$prune_pre_subset.<locals>.<listcomp>c  s    ;;;QX]]1]]]r"   T)legacy_cmapr  symbol_cmapr7   numSubTablesr2  s      r    r  r  Z  sx     POO$+OOO CBB$+BBB <;dk;;;DKDK((D4r"   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                F    i | ]\  }}|j         v |fd |D             S )c                B    g | ]\  }}|j         v s	|j        v ||fS r   glyphs_requestedr  r  s      r    r5   z,subset_glyphs.<locals>.<dictcomp>.<listcomp>{  sF       1A...!q7K2K2K F2K2K2Kr"   r  )r   rU   r4   rn   s      r    r.   z!subset_glyphs.<locals>.<dictcomp>z  s_        Aq,,,      !   -,,r"   c                    i | ]
\  }}|||S r   r   )r   rU   r4   s      r    r.   z!subset_glyphs.<locals>.<dictcomp>  s#    AAA$!QqAAAAAr"   c                @    i | ]\  }}|j         v s	|j        v ||S r   r  r  s      r    r.   z!subset_glyphs.<locals>.<dictcomp>  sD       Aq***a13G.G.G 1.G.G.Gr"      r  c                .    i | ]\  }}|j         v ||S r   )r  r  s      r    r.   z!subset_glyphs.<locals>.<dictcomp>  s,    QQQtq!a>P9P9Pa9P9P9Pr"   r  r  c                F    g | ]}|j         d k    r|j        n|j        |S )r  )r  r  r  r  s     r    r5   z!subset_glyphs.<locals>.<listcomp>  s-    WWWBafAI1r"   T)r'   r  
platformID	platEncIDlanguager  r  rW   r  r  maxru  rN  r  r7   r  )r&   rn   tables_format12_bmptable_plat0_enc3table_plat3_enc1r  s    `    r    rv   rv   h  st   AH[ R R<1!1!1+,QZ(<1!1!1+,QZ(8r>>    IOO--  AI BA!)//*;*;AAAAII[[]] 	R   FLLNN  AF x2~~!&~S-?-?'-I-I#**1---QQQQqv||~~QQQAFF !  LAq  
... ,1QV;;FLLNNNNLAr!!
... ,1QV;;FLLNNNWWdkWWWDKDK((D 4r"   DSIGc                "    d| _         g | _        dS r  )	usNumSigssignatureRecordsr2  s      r    r  r    s     DND4r"   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maxSizeOfInstructionsr2  s      r    r  r    sU    ? +
**DM%&D"DO#$D &'D#$%D!)*D&4r"   >   r   r   r   r              r   c                P   t                      }|                    |           t          j                  |j        z  dj        v rd | j        D             z  fd| j        D             | _        j        sd | j        D             | _        dj        vrfd| j        D             | _        j        rg }|j        	                    t                    }|rt          ||           | 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 )Nr   c                2    h | ]}|j         d k     |j         S )   nameIDr   rg  s     r    r  z$prune_post_subset.<locals>.<setcomp>  s!    CCCAHsNNAHNNNr"   c                &    g | ]}|j         v |S r   r*  )r   rg  nameIDss     r    r5   z%prune_post_subset.<locals>.<listcomp>  s%    ???18w+>+>!+>+>+>r"   c                :    g | ]}|                                 |S r   r  r,  s     r    r5   z%prune_post_subset.<locals>.<listcomp>  s%    ===Aq{{}}=a===r"   c                0    g | ]}|j         j        v |S r   )langIDname_languages)r   rg  r   s     r    r5   z%prune_post_subset.<locals>.<listcomp>  s(    RRRAqx7;Q/Q/Qa/Q/Q/Qr"   )r   r  z.	utf_16_be)r   r#  r   r>  )r$  r%  r&  T)r   visitrB   name_IDsseenri  name_legacyr2  obfuscate_namesr   NAME_IDS_TO_OBFUSCATE_remap_select_name_idsr+  r  encodestringrN  )r&   r(   r   visitornamerecsneedRemappingrg  r.  s     `    @r    r   r     s   !!GMM$'"##gl2G
gCCdjCCCC????TZ???DJ > >====

'(((RRRRRRR
   112GHH 	8"4777 		 		Ax6!!:;++--T7>>+666WV##9:R6==555FQ\))OOA
4r"   r(   ttLib.TTFontr@  set[int]returnNonec                   d| vrd| vrdS | d         }d |j         D             }i }|                                dz
  }|D ]/}|dz  }||vs
J d            |dk    rt          d	          |||<   0g }|j         D ]S}|j        |vrt	          |j        ||j                 |j        |j        |j                  }	|	                    |	           T|j         
                    |           |                     d          }
|
}|
j        D ]'}|                    |j        |j                  |_        (|
j        D ]F}|j        }|                    ||          |_        |j        }|                    ||          |_        G|                     d          }|dS |j        j        }|                    ||          |j        _        |j        j        r9|j        j        j        D ]'}|                    |j        |j                  |_        (|j        j        r9|j        j        j        D ])}|                    |j        |j                  |_        (dS dS )
a;  Remap a set of IDs so that the originals can be safely scrambled or
    dropped.

    For each name record whose name id is in the `needRemapping` set, make a copy
    and allocate a new unused name id in the font-specific range (> 255).

    Finally update references to these in the `fvar` and `STAT` tables.
    fvarSTATNr   c                    h | ]	}|j         
S r   r*  )r   r  s     r    r  z)_remap_select_name_ids.<locals>.<setcomp>  s    :::V6=:::r"   r   z#_findUnusedNameID did not skip gapsi  z8Ran out of name IDs while trying to remap existing ones.)ri  _findUnusedNameID
ValueErrorr+  r   r=  r  r  r1  rN  r  r  axes
axisNameID	instancessubfamilyNameIDpostscriptNameIDr  ElidedFallbackNameIDDesignAxisRecordAxis
AxisNameIDAxisValueArray	AxisValueValueNameID)r(   r@  r   existingIds	remappingnextIdnameIdcopiedRecordsr  
recordCopyrF  axisinstancer+  statelidedNameIDvalues                    r    r;  r;    s    TfD00<D ;:tz:::KI##%%)F # #![(((*O(((E>>WXXX"	& M* 
) 
)=--Mfm$M
 

 	Z((((Jm$$$
 88FDI 	N 	ND'mmDOT_MMDOO 	F 	FH-F'0}}VV'D'DH$.F(1ff(E(EH%%88FD|:2L&/mmL,&O&ODJ#z" NJ/4 	N 	ND'mmDOT_MMDOOz  TZ.8 	T 	TE )e.?AR S SET T	T 	Tr"   headc                    dS r   r   r2  s      r    r   r   /  s	     4r"   c                  8   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dgdgg dg d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    OptionErrorrg  C          r"   ri  c                      e Zd ZdS )Options.UnknownOptionErrorNrh  r   r"   r    UnknownOptionErrorrl  F  rj  r"   rm  )BASEJSTFr  ro  rd  EBSCPCLTLTSH)FeatGlatGlocSilfSill)avarrF  gasprb  hhear  vheaOS/2locar   cvtfpgmprepVDMXr  rh  MVARcvarrG  )r~  r  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randjalt)HarfHARFBuzzBUZZ)chwsvchwhaltvhal)
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cjctr  presr  r  pstshalndistr  r  )common	fractions
horizontalverticalltrrtlr  justifyprivateeast_asian_spacingarabichangultibetanindicc                   | 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| _#        tH          j%        | _&        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   r1  r  r  r6  r8  r2  r9  r  r  r  recommended_glyphsrecalc_boundsrecalc_timestampprune_unicode_rangesprune_codepage_rangesrecalc_average_widthrecalc_max_contextcanonical_orderflavorwith_zopflidesubroutinizer   defaultharfbuzz_repackerverbosetimingxmlfont_number
pretty_svglazyr  rB   )r&   kwargss     r    r  zOptions.__init__  s   4QQQ7 $ >qqq A"'":111= "#<QQQ?"e%*"'+$   
 
 
 !%h$  #"'" %$(!%)"$)!"'# #!6!>	 6r"   c                    |                                 D ]>\  }}t          | |          s|                     d|z            t          | ||           ?d S )NUnknown option '%s')rW   r  rm  r   )r&   r  r  rU   s       r    rB   zOptions.set  si    LLNN 	  	 DAq4## I--.Ca.GHHHD!Q	  	 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)r7   r   rT  s     r    r5   z&Options.parse_opts.<locals>.<listcomp>  s=    VVVa3q66Iadl.B.Bc!QiiiVVVr"   z+=z-=)r  rN  findr  replacer  rm  r   printr!  rt   r   strr`   ri  r  r  r  r   )r&   argvignore_unknownposargspassthru_optionsr  orig_ar2   opr  rU   okovvvrU  s                  r    
parse_optszOptions.parse_opts  sG    F	  F	 AF<<%% q!!!!""AsABBww<<&& 
!""A--- !!AA::c?? #2#AAbqbER5D==2B#2#Aa!eggJB		#s##A4## M!T))R>-A-A$++F333112G!2KLLLq!!BCxx222rrBCCC"d## !GGB$$ !FFB$$ !FFB%% !a&& **ORSS   YYsC((..00"::BVVSUVVV99AA4ZZAHHRLLLL4ZZA ( (66HHQKKK( !LD!Q)))r"   N)r  r  r  	Exceptionri  rm  r  r  r  _layout_features_groupsr   r  iterra   r  r  rB   r  r   r"   r    re  re  B  s           i       [   	 	 	 DDDD! ! !* NMM
 KJJ--->>><<<8333>>>
 
 
 +**333
 
 
72 2f  *zDD(//1122B77   2 2 2h      /1 K* K* K* K* K* K*r"   re  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.SubsettingErrorNrh  r   r"   r    SubsettingErrorr  -  rj  r"   r  c                      e Zd ZdS )&Subsetter.MissingGlyphsSubsettingErrorNrh  r   r"   r    MissingGlyphsSubsettingErrorr  0  rj  r"   r  c                      e Zd ZdS )(Subsetter.MissingUnicodesSubsettingErrorNrh  r   r"   r    MissingUnicodesSubsettingErrorr  3  rj  r"   r  Nc                    |st                      }|| _        t                      | _        t                      | _        t                      | _        d S r   )re  r   rB   r  glyph_names_requestedglyph_ids_requested)r&   r   s     r    r  zSubsetter.__init__6  sD     	 iiG"%%%%(UU"#&55   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  rk   r!  bytesdecoder<  r7   r  r  r  r  r  )r&   r'   gidsunicodestext
text_utf32ncharsr  s           r    populatezSubsetter.populate?  s    &&x000dE"" 	(;;w''D[[--
ZA%v
;; 	+ 	+A#''****"))&111 ''-----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  r  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  clazzr  retains         r    _prune_pre_subsetzSubsetter._prune_pre_subsetJ  s   $$T** 	/ 	/C		t|777IIKK4<#>>> L0 ? 6MM4<+CMRVs+++I',,Eu011 
/;,-- & & IE& & & & & & & & & & & & & & &<#-.. H H"33D$,GGFH H H H H H H H H H H H H H H /HH:C@@@S	HH[#...3	/ 	/s$   	C%%C)	,C)	D**D.	1D.	c           	     T    t                                                    }                                x _        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 rt9          t;          dt=                                                                        D ]/} j                                                |                     0t          
                    d           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                   _         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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   tE           d|#                                 d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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              _(        tS           j(        *                                           _+                                         j+                  _,        t)                       _-         j        j.        r fd*| j&        z
  D              _-        fd+ j-        D              _/         j        j.        s fd,D             n fd-D              _0        fd.t9          t=                              D              _1        t          
                    d/t=           j&                              `d S )0Nc              3  N   K   | ]}|t                    k     |         V   d S r   r6   r   r2   glyph_orders     r    r!   z,Subsetter._closure_glyphs.<locals>.<genexpr>l  sB       %
 %
 CDTDT@T@TKN@T@T@T@T%
 %
r"   c              3  B   K   | ]}|t                    k    |V  d S r   r6   r6  s     r    r!   z,Subsetter._closure_glyphs.<locals>.<genexpr>r  s>       #
 #
1K8H8H3H3HA3H3H3H3H#
 #
r"   zMissing requested glyphs: %sr  zclose glyph list over 'cmap'c                    g | ]}d |z  S )zU+%04Xr   )r   r  s     r    r5   z-Subsetter._closure_glyphs.<locals>.<listcomp>  s    CCCx!|CCCr"   z)Missing glyphs for requested Unicodes: %sr  r   zAdded gid0 to subsetz.notdefzAdded .notdef to subsetr  z!Added first four glyphs to subsetr  zclose glyph list over 'MATH'z0Closing glyph list over 'MATH': %d glyphs before)r(   z.Closed glyph list over 'MATH': %d glyphs afterry  zclose glyph list over 'GSUB'z0Closing glyph list over 'GSUB': %d glyphs beforez.Closed glyph list over 'GSUB': %d glyphs after)rH  r  zclose glyph list over '%s'z.Closing glyph list over '%s': %d glyphs beforez,Closed glyph list over '%s': %d glyphs afterglyphs_edr  zclose glyph list over 'VARC'z0Closing glyph list over 'VARC': %d glyphs beforez.Closed glyph list over 'VARC': %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    r.   z-Subsetter._closure_glyphs.<locals>.<dictcomp>  s    #N#N#NAAuQx#N#N#Nr"   c                6    h | ]}|         j         k    |S r   )r  )r   r   r>  r&   s     r    r  z,Subsetter._closure_glyphs.<locals>.<setcomp>  s5     # # #8t777 777r"   c                "    i | ]}||         S r   r   r=  s     r    r.   z-Subsetter._closure_glyphs.<locals>.<dictcomp>  s    &P&P&Pqq%(&P&P&Pr"   c                &    g | ]}|j         v |S r   )glyphs_retainedrR   s     r    r5   z-Subsetter._closure_glyphs.<locals>.<listcomp>  s&    SSSQd>R9R9Rq9R9R9Rr"   c                P    g | ]"}                     |          j        k     |#S r   )
getGlyphIDr  )r   r   r(   r&   s     r    r5   z-Subsetter._closure_glyphs.<locals>.<listcomp>  s9       $//!*<*<@X*X*X*X*X*Xr"   c                .    i | ]}|                  |S r   r   )r   r2   new_glyph_orderr>  s     r    r.   z-Subsetter._closure_glyphs.<locals>.<dictcomp>  s2      
  
  
-.E/!$%q 
  
  
r"   zRetaining %d glyphs)2rB   getGlyphOrderorig_glyph_orderr  rk   r  r  glyphs_missing
differencer.  r#   r   r  r  r  r'   r  r/  ro   intersection_updater  glyphs_cmapedr  r  r  r  getGlyphNamer  r  minr7   r  r  r  r   lowerglyphs_glyfedglyphs_cffedrB  r%   r  r  ra   r  r  r  r  r  rF  glyph_index_map)	r&   r(   
realGlyphsmissingr2   r  r7  rF  r>  s	   ``    @@@r    _closure_glyphszSubsetter._closure_glyphsf  s   ++--..
.2.@.@.B.BB #$$T%?@@@$$ %
 %
 %
 %
$($<%
 %
 %
 	
 	
 	
 "ee""4#8#C#CJ#O#OPPP"" #
 #
 #
 #
/#
 #
 #
 	
 	
 	
  	MHH3T5HIII<5 M778KLLL+0022 #T>>566 < <V++D111//
;;;< < < < < < < < < < < < < < < 't{33  	CCT-BCCCGHH@'JJJ<7 C99'BBB<$ 	4~~ 1 1! 4 4555/0000	***2333<* 	>~~s1c$*<*<*>*>&?&?@@AA : :AKOOD$5$5a$8$89999<===T>>566 
3 
3FDKHXHX   

4;T
222V++D111//
;;;Dc$+FVFV   

4;T
222
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 't{33<& 	36T>>566 
3 
3FDKHXHX   

4;T
222V++D111//
;;;Dc$+FVFV   

4;T
222
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 't{33% 	O 	OE}}7%?@@ 7 7HHHDK((  
 JJt{J666K..t444K33J???HHFDK((  
 JJt{J6667 7 7 7 7 7 7 7 7 7 7 7 7 7 7 D5EKKMM555y7M7MNNNNT>>566 
3 
3FDKHXHX   

4;T
222V++D111//
;;;Dc$+FVFV   

4;T
222
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 't{33T>>566 
3 
3FDKHXHX   

4;T
222V++D111//
;;;Dc$+FVFV   

4;T
222
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 't{33T>>566 
3 
3FDKHXHX   

4;T
222V++D111//
;;;Dc$+FVFV   

4;T
222
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 
3 &dk22(55''))#N#N#N#N9M#N#N#N #&t'?'F'F'H'H#I#I #'#5#5#7#78P#Q 'kk<# 	# # # # ##d&::# # #D 'Q&P&P&PD<O&P&P&P#|' 	SSSS+SSSOO    &  O  / 
  
  
  
  
27O8L8L2M2M 
  
  
 	&D,@(A(ABBBKKKs    6G""G&)G&CQ..Q25Q21CVVVCZ..Z2	5Z2	C_%%_),_)Cc::c>c>1Chhhc                >   g | _         |                     |          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                   d d d            d S # 1 swxY w Y   d S )	Nz%s subsetting not neededrv   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 GlyphOrder)r  r,  r   r  r-  r   r  r.  r#   r  r/  rB  r'   rv   r  warningsetGlyphOrderrF  r0  s         r    _subset_glyphszSubsetter._subset_glyphs  s    $$T** 	 	C',,Eyy{{dl;;;3S999900 =3.// $ $ IE"&"6DK"0066F	$ $ $ $ $ $ $ $ $ $ $ $ $ $ $
  2HH=sCCCS		HH^S11110 BCHHHHNPSTTTII&'' 	5 	5t3444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5s$   ,C

C	C	*FFFc                P   |                                 }d|v r*|                    d           |                    d           |D ]_}|dk    r
|dk    r| j        j        rf||                                         }||                             |d          }||k    r)t                              d|t          |                     | j        j
        rw||         j        dk    rf||                                         }||                             |d          }||k    r)t                              d|t          |                     | j        j        rJ||         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|           ||= Dt                              d|           ad S )Nr   
GlyphOrderr|  T)	pruneOnlyz%s Unicode ranges pruned: %sr   z%s CodePage ranges pruned: %sz%s xAvgCharWidth updated: %dz%s usMaxContext updated: %dr   r)  r*  r+  )ru  r  rN  r   r  getUnicodeRangesrecalcUnicodeRangesr.  r#   r$   r  rM  getCodePageRangesrecalcCodePageRangesr  xAvgCharWidthrecalcAvgCharWidthr  r	   usMaxContextr   r  r  r/  r   )r&   r(   	tableTagsr  old_unirangesnew_unirangesold_codepagesnew_codepagesold_avg_widthnew_avg_widthmax_contextr1  r  r2  s                 r    _prune_post_subsetzSubsetter._prune_post_subset/  s   IIKK	 YV$$$V$$$ )	/ )	/Cl""f}}<4 $(I$>$>$@$@M$(I$A$A$RV$A$W$WM$55:CAVAV   <5 
$s):Kq:P:P %)I$?$?$A$AM$(I$B$B4SW$B$X$XM$55;"=11  
 <4 U$(I$;M$(I$@$@$F$FM$55!?mTTT<2 R",T"2"2K"d3i&<<<1<S	.!>[QQQ',,Eu122 /<#-.. I I IE"44T4<HHFI I I I I I I I I I I I I I I  /HH:C@@@S		HH[#...S)	/ )	/s   ,$II 	#I 	c                    g dd t                    D             t          |                                fd          }d |D             S )N)r  r  ry  rF  rx  r  r   r  c                     i | ]\  }}||d z   S )r   r   )r   r2   r  s      r    r.   z*Subsetter._sort_tables.<locals>.<dictcomp>d  s"    ===AAq1u===r"   c                0                         | d          S rv  )r  )r  tagOrders    r    rC  z(Subsetter._sort_tables.<locals>.<lambda>e  s    8<<Q3G3G r"   )r  c                    g | ]
}|d k    |S )r[  r   r  s     r    r5   z*Subsetter._sort_tables.<locals>.<listcomp>f  s"    555a1#4#4#4#4#4r"   )r<   r$   ru  )r&   r(   r  rp  s      @r    r,  zSubsetter._sort_tablesb  sa    SSS==8)<)<===diikk'G'G'G'GHHH5545555r"   c                    |                      |           |                     |           |                     |           |                     |           d S r   )r3  rU  rY  rl  )r&   r(   s     r    rG   zSubsetter.subseth  sX    t$$$T"""D!!!%%%%%r"   r   )r  r  r  r  r  r  r  r  r'  r3  rU  rY  rl  r,  rG   r   r"   r    r  r  ,  s$           )                 ) ) ) ) !rBR 	. 	. 	. 	./ / /8l l l\5 5 561/ 1/ 1/f6 6 6& & & & &r"   r  z	load fontc                    t          j        | ||j        |j        ||j                  }|rHt          j        d          }|j        }|j        |_        |d         }|j        dk    rd|_        ||_        |S )N)checkChecksumsrecalcBBoxesrecalcTimestampr  
fontNumberr.  g       @r0  )	r   TTFontr  r  r  r  decode_format_2_0decode_format_3_0r2  )	fontFiler   rt  dontLoadGlyphNamesr  r(   r.  savedr*  s	            r    	load_fontr~  o  s    <%*0&  D$  '"6**&!%!7L<3AL!&Kr"   zcompile and save fontc                    |j         r|j        dk    rddlm} d|_        |j        | _        |j        | j        t          <   |                     ||j	                   d S )Nwoffr   )sfntT)reorderTables)
r  r  fontTools.ttLibr  
USE_ZOPFLIr  cfgr   saver  )r(   outfiler   r  s       r    	save_fontr    sj     w~77((((((.DK&-&?DH"#IIgW%<I=====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  r7   rN  r   r  r  )rn   r  r4   itemfieldsstartends          r    parse_unicodesr    s    III
xa  A
$c1--A
A		 > >Cv;;!HHSr]]####JE3HHU3ub>>3sB<<!+;<<====Hr"   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  r7   rN  r   r  r  )rn   r4   r  r  s       r    
parse_gidsr    s    
A		#s##))++ @ @Cv;;!HHS^^$$$$HHU3vay>>3vay>>A+=>>????Hr"   c                R    |                      dd                                          S )Nr  r  )r   r  )rn   s    r    parse_glyphsr    s"    99S#$$&&&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    	(ICJ////	
9
KKKKKKr"   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| }|j%        }tM          ||||%          }|8|j'        d&|j'        (                                z   nd}tS          ||dd'(          }t'          d)          5  |r'|                    |*                                           |r|d*         j+        D ]y}|,                                rc|
                    |j-        .                                           |j/        dk    r,|
                    |j0        .                                           zd|vsJ 	 ddd           n# 1 swxY w Y   tb          2                    d+|z             tb          2                    d,|
           tb          2                    d-|           tb          2                    d.|	           |3                    ||	|
|/           |4                    |           tk          |||           |j        rrddl6}tb          2                    d0|j7        8                    |          |fz             tb          2                    d1|j7        8                    |          |fz             |j9        r|:                    t          j;                   |<                                 dS )2z%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:r  r   )levelT)r   Fr>  r   z--output-file=r  z--text=   z--text-file=r  z	utf-8-sig)encoding
z--unicodes=   z--unicodes-file=r$  #z--gids=z--gids-file=z	--glyphs=	   z--glyphs-file=)r|  r  r  z.subset)	extension	overWritesuffixz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  r  r  r  __doc__re  r  ri  r  r  r7   r  loggingINFOWARNINGr  r/  r*   setLevelDEBUGdisabledr  r  openreadr   r  r  	readlinesr  r  r  rN  r1  r  r~  r  rO  r   rG  r  r  r  ru  r  r  r.  r#   r'  rG   r  ospathgetsizer  saveXMLstdoutclose)argsr  r  r   efontfile	subsetterr  r'   r"  r#  wildcard_glyphswildcard_unicodesr$  r   r*  liner|  r  r(   extr  r  s                          r    mainr    s    !     &&&&&&|x|4gqiiG!!
 
 
 " 
 
    h
++++qqqqq
 4yy1}}qLwKw||GOLLLL~ %gm,,,, $AwH8D'***IGFDHOD , ,88"O<<()) 	fG<<	"" 	AabbEMD<<'' 	af{333 3q((r2223 3 3 3 3 3 3 3 3 3 3 3 3 3 3<<&& 	v}}$(!!qv 6 6777<<*++ 	af HKKMM H HDOON4::c??13E$F$FGGGGHH H H H H H H H H H H H H H H <<	"" 	KK
1QRR5))***<<'' 	af @KKMM @ @DKK
4::c??1+= > >????@@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ <<$$ 	u||"&l1QRR511222<<()) 	af DKKMM D DDMM,tzz#q/A"B"BCCCCDD D D D D D D D D D D D D D D a$00?Z<D'.@t  D .5n.HcGN((****d$tI
 
 
 
#	$	$ 	  	  	0MM$,,../// 	:&\( : :;;== :OOAFKKMM222x2~~ 	(8(8999	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  HH\D !!!HH^X&&&HH\6"""HHZf4(NNNTdGW%%% U			,0I0I8/TTUUU-1I1I70SSTTT{ !SZ   JJLLLLLsv   A& &
B%0*B  B%%,HH!	$H!	'ALL	L	AO!!O%	(O%	,ASS	S	B9X$$X(+X()re  r  r~  r  r  r  r  r  r   )FT)F)T)r(   rA  r@  rB  rC  rD  )r   FT)
__future__r   r  r   fontTools.misc.roundToolsr   r   fontTools.ttLib.tablesr   fontTools.ttLib.tables.otBaser   fontTools.otlLib.maxContextCalcr	   fontTools.pens.basePenr
   fontTools.misc.loggingToolsr   fontTools.misc.cliToolsr   fontTools.subset.utilr   r   fontTools.subset.cfffontTools.subset.svgfontTools.varLibr   r   fontTools.ttLib.tables._n_a_m_er   r   fontTools.unicodedatar   r  r  arrayr  collectionsr   r   	functoolsr   typesr   r  r  	getLoggerr.  r)   r'   r/  r/   r9   r   r>   rC   rG   rM   rf  r\   SingleSubstro   rv   MultipleSubstAlternateSubstLigatureSubstReverseChainSingleSubstDevicer   ValueRecordr   	SinglePosr   PairPos
CursivePosAnchorMarkBasePos
MarkLigPosMarkMarkPosr.  r0  ContextSubstChainContextSubst
ContextPosChainContextPosr4  r  ExtensionSubstExtensionPosr  r  r  r  r(  r}  r2  r9  r{  rS  rR  rO  r\  r|  r  r  r  r  r  r  r  r  r  r  rG  MathGlyphConstructionr  r  r  r  r  r  rA  r  r:  r;  r  re  r  r~  r  r  r  r  r  r  __all__r   r"   r    <module>r     s  
 # " " " " "       - - - - - -       + + + + + + ? ? ? ? ? ? 6 6 6 6 6 6 * * * * * * - - - - - - 6 6 6 6 6 6 9 9 9 9 9 9 9 9 " " " " " " " " 4 4 4 4 4 4 4 4 G G G G G G G G * * * * * * 



    , , , , , , , ,            A	 Uc P g*++Q Q Q Q ZS))
 	&W&'?@@AAA% % %0 0 0
 XA A  A
 X6 6  6
 X    X9 9  9
 X    XS S  S X    & XP P  P
 X!""K K #"K X!""  #" X#$$# # %$# X#$$  %$ X$%%Y Y &%Y X$%%! ! &%! X#$$  %$ X#$$    %$  X-..
5 
5 /.
5 X-..5 5 /.5( X_) ) ) X!""    #"  X  5 5 ! 5 X    ! > X*5 *5 *5Z X7 7 7( X !!	5 	5 "!	5 X_	 	 	 X !!  "! X!""5 5 #"54 X!""	 	 #"	 X !!5 5 "!5> X !!  "! X!""5 5 #"54 X!""	 	 #"	 $ 	 	 	 $    $
 
 
 
 (183S    	    	 W? W? W?t X"H$>??l5 l5 @?l5^ 	 W5 W5 W5t 	 &5 &5 &5R 	 5 5 5& X$%%5 5 &%5 X$%%5 5 &%5 X$h&;<<5 5 =<5 X$h&;<<5 5 =<5 X$h&;<<5 5 =<5 X$h&;<<5 5 =<5 X_) ) ) )( X_	$ 	$ 	$ X_   X_) ) )
 X_I I I X_E E E X !!N N "!N
 X !!  "! X !!) ) "!) X !!  "! X !!" " "!"* X   X!""
 
 #"
 X!""  #" X!""# # #"# X.//  0/ X'((  )( X'((	 	 )(	 X.//	( 	( 0/	( X'((, , )(," X$h&677D D 87D X$h&677' ' 87' X_: : : : X_0 0 0 X !!	" 	" "!	" X !!Y Y "!Y
  U (())  *)  U (())  *)  U (())  *)  U (())  *):  U ((*=%*=f*E*EFF  GF  U ((*=%*=f*E*EFF9 9 GF9  U ((*=%*=f*E*EFF
 
 GF
,  U ((*=%*=f*E*EFF= = GF=  U ((*=%*=f*E*EFF, , , GF,.  U ((*=%*=f*E*EFF
 
 GF
$  U ((*=%*=f*E*EFF8 8 GF84  U ((*=%*=f*E*EFF
 
 GF
   U ((*=%*=f*E*EFF  GF  U ((*=%*=f*E*EFF2 2 GF2>  U ((*=%*=f*E*EFF+ + GF+\  U (())  *)D= = =4  U (())  *)D  U (())! ! *)!  U (())	! 	! *)	!  U (())  *)  U (())  *)  U (())  *)  U (())" " *)"  U (())* * *)*  U (())  *)&  U (())@ @ *)@  U (())  *)  U (())! ! *)!    U (())" " *)"J  U (())' ' *)'T  U (())  *)  U (())@ @ *)@(  U (())  *)  U (())  *)
  U (())? ? *)?,    U (())  *):  U (())0 0 *)0f  U (())9( 9( *)9(x X+,,  -, X"##  $#"  U (())A A *)A  U (())" " *)"6  U (())) ) *))X  U (())2 2 *)2
 X/00- - 10- X-../ / /./ X"##$ $ $#$ X#$$	 	 %$	 X"##  $#  U (())  *) !U!&))/00  10:  U (())  *)   U (())  *)  U (())  *)&  U (())  *)  U (())9 9 *)9B  U (())
 
 *)
  U (())? ? *)?D  U (())  *)  U (())
 
 *)
 433   U (())! ! *)!HCT CT CT CTL  U (())  *)$g* g* g* g* g*f g* g* g*T@& @& @& @& @& @& @& @&F
 {   > > >  >     ' ' 'L L L
 .//N N N 0/Nb	 	 	r"   