
    Mcg                    $   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 d dl 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jP                  d      Z)ddZ* e%e*e)      e)_+         e ejP                  d            Z,d Z-d Z. eej^                        d        Z0 eej^                        d        Z1 eej^                        d        Z2 eej^                        d        Z3 eejh                        d        Z0 eejh                        d         Z5 eejh                        dd!       Z2 eejh                        d"        Z3 eejl                        d#        Z7 eejl                        d$        Z8 eejr                        d%        Z7 eejr                        d&        Z8 eejt                        d'        Z7 eejt                        d(        Z8 eejv                        d)        Z7 eejv                        d*        Z8 eejx                        d+        Z7 eejx                        d,        Z8 eejz                        d-        Z> eej~                        d.        Z@ eej                        d/        Z8 eej                        d0        ZB eej                        d1        Z8 eej                        d2        ZB eej                        d3        Z8 eej                        d4        Z@ eej                        d5        ZB eej                        d6        Z8 eej                        d7        ZB eej                        d8        Z8 eej                        d9        ZB eej                        d:        Z8 eej                        d;        ZB eejl                  ejr                  ejt                  ejv                  ejx                  ej                  ej                  ej                  ej                  ej                  ej                        d<        ZI eejl                  ejr                  ejt                  ejv                  ejx                  ej                  ej                  ej                  ej                  ej                  ej                        d=        ZJ eejl                  ejr                  ejt                  ejv                  ejx                  ej                  ej                  ej                  ej                  	      d>        ZB eejl                  ejt                  ejx                        d?        ZO eejr                  ejv                  ej                  ej                        d@        ZO eej                  ej                  ej                  ej                        dA        ZP eej                  ej                        dB        Z7 eej                  ej                  ej                  ej                        dC        Z8 eej                  ej                  ej                  ej                        dD        ZI eej                  ej                  ej                  ej                        dE        ZJ eej                        dF        Z7 eej                        dG        ZO eej                  ej                        dH        Z8 eej                  ej                        dI        ZB eej                  ej                        dJ        ZI eej                  ej                        dK        ZJ eej                        ddL       Z7 eej                        dM        Z8 eej                        dN        ZB eej                        dO        ZI eej                        dP        ZJ eej                        dQ        ZO eej                        dR        Z8 eej                        dS        ZB eej                        dT        ZI eej                        dU        ZU eej                        dV        ZV eej                        dW        ZI eej                        dX        ZI eej                        dY        ZJ eej                        dZ        ZY eej                        d[        ZI eej                        d\        ZI eej                        d]        ZJ eej                        d^        ZY eej                        d_        ZY eej                  ej                        d`        ZY eej                  ej                        da        Z^ eej                        ddb       ZY eej                        dc        Z^ eej                        dd        ZY eej                        de        Z^ e ej                  df            dg        Z8 e ej                  dh            di        Z8 e ej                  dj            dk        Z8 e ej                  dl            dm        Z7 e ej                  dl       ej                  dn            do        Z8 e ej                  dl       ej                  dn            dp        Zb e ej                  dl       ej                  dn            dq        ZI e ej                  dl       ej                  dn            dr        ZU e ej                  dl       ej                  dn            dds       Zc e ej                  dl       ej                  dn            dt        Zd e ej                  dl       ej                  dn            du        Ze e ej                  dl       ej                  dn            dv        Zf e ej                  dl       ej                  dn            dw        Zg e ej                  dl       ej                  dn            dx        Zh e ej                  dl       ej                  dn            dy        ZB e ej                  dz            d{        Z8d| Zi e ej                  dz            d}        ZB e ej                  d~            d        Zg e ej                  d~            d        Z8 e ej                  d            d        Z8 e ej                  d            d        Z8 e ej                  d            d        Z8 e ej                  d            d        Z8 e ej                  d            d        Z7 e ej                  d            d        Z8 e ej                  d            d        Z8 e ej                  d            d        Zg e ej                  d            d        Z8d Zj e ej                  d            d        Z8 e ej                  d            d        Z8 e ej                  d            d        Z8 e ej                  d            d        Z8 e ej                  d            d        Zg e ej                  d            d        Z8 e ej                  d            d        Z8d Zk e ej                  d            d        Z7 e ej                  d            d        Z8 e ej                  d            d        ZB eej                        d        Z7 eej                        d        Z7 e ej                  d            d        Z8 e ej                  d            d        Z7 e ej                  d            d        ZB e ej                  d            d        Z7 eej                        d        Z8 eej                        d        Z8 eej                        d        Z8 eej                        d        Z8 eej                        d        Z8 e ej                  d            d        Z8 e ej                  d      j                        d        Zt e ej                  d            d        Z7 e ej                  d            d        Zg e ej                  d            d        Z8 e ej                  d            d        ZB e ej                  d            d        Z7 e ej                  d            d        Zg e ej                  d            d        Z8 e ej                  d            d        Zg e ej                  d            d        Zg e ej                  d            d        ZB e ej                  dë            dĄ        ZB G dń deu      Zv G dǄ deu      Zw e,dɫ      ddʄ       Zx e,d˫      d̄        Zyd̈́ Zzd΄ Z{dτ Z|dЄ Z} e,dѫ      dd҄       Z~g dӢZy)    )config)otRound)ttLib)otTables)USE_HARFBUZZ_REPACKER)
maxCtxFont)NullPen)Timer)makeOutputFileName)_add_method
_uniq_sort)*)varStoremultiVarStore)NameRecordVisitorN)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                     | j                  dt        |             |r5|j                         | j                  dt        fd|D                     y y )NzGlyph names: %szGlyph IDs:   %sc              3   (   K   | ]	  }|     y wN ).0greverseGlyphMaps     T/var/www/html/bid-api/venv/lib/python3.12/site-packages/fontTools/subset/__init__.py	<genexpr>z_log_glyphs.<locals>.<genexpr>  s     +O1OA,>   )infosortedgetReverseGlyphMap)selfglyphsfontr   s      @r   _log_glyphsr&     sF    II0113		#V+O+O%OP     zfontTools.subset.timer)loggerc                 4    |D ci c]  }|| |   
 c}S c c}w r   r   )dr$   r   s      r   _dict_subsetr+     s"    #$VAqtGV$$$s   c                 T    t        |       }|D cg c]  }||k  s	| |    c}S c c}w r   len)lindicescountis       r   _list_subsetr3     s-    FE!/'QQYAaD'///s   
%%c                 h    t        | j                        D cg c]  \  }}||v s| c}}S c c}}w )z3Returns ascending list of matching coverage values.)	enumerater$   )r#   r$   r2   r   s       r   	intersectr6     s1     $DKK0@0$!QAKA0@@@s   ..c                 @    t        fd| j                  D              S )z#Returns set of intersecting glyphs.c              3   ,   K   | ]  }|v s|  y wr   r   )r   r   r$   s     r   r   z#intersect_glyphs.<locals>.<genexpr>  s     5+Qfq+s   	)setr$   )r#   r$   s    `r   intersect_glyphsr:     s     5$++555r'   c                 z    | j                  |      }| j                  D cg c]	  }||v s| c}| _        |S c c}w )z4Returns ascending list of remaining coverage values.r6   r$   )r#   r$   r0   r   s       r   subsetr=     s<     nnV$G"kk9kQ&[1k9DKN :s   	88c                 R    |D cg c]  }| j                   |    c}| _         yc c}w )zRemaps coverage.Nr$   )r#   coverage_mapr2   s      r   remaprA     s%     ,88<a4;;q><8DK8s   $c           	           t        t         fd|D              rdgng  j                  j                         D cg c]  \  }}||v s| c}}z         S c c}}w )z0Returns ascending list of matching class values.c              3   :   K   | ]  }|j                   v  y wr   	classDefsr   r   r#   s     r   r   zintersect.<locals>.<genexpr>  s     <VAT^^+V   r   )r   anyrE   items)r#   r$   r   vs   `   r   r6   r6     sZ     <V<<!"--/
?/A1;1/
?	@ 
?s   A	Ac                      dk(  rt         fdD              S t        fd j                  j                         D              S )z%Returns set of glyphs matching class.r   c              3   @   K   | ]  }|j                   vs|  y wr   rD   rF   s     r   r   z"intersect_class.<locals>.<genexpr>  s     @f(?1f   c              3   >   K   | ]  \  }}|k(  s|v s|  y wr   r   )r   r   rJ   r$   klasss      r   r   z"intersect_class.<locals>.<genexpr>  s$     R3TQqEza6kq3s   )r9   rE   rI   )r#   r$   rO   s   ```r   intersect_classrP     s;     z@f@@@RT^^113RRRr'   c                 :     j                   j                         D ci c]  \  }}||v s|| c}} _         t        |rt         fd|D              rdgng t	         j                   j                               z         }|r j                  |       |S c c}}w )z,Returns ascending list of remaining classes.c              3   :   K   | ]  }|j                   v  y wr   rD   rF   s     r   r   zsubset.<locals>.<genexpr>  s     &O1q'>rG   r   )rE   rI   r   rH   listvaluesrA   )r#   r$   rA   	useClass0r   rJ   r0   s   `      r   r=   r=     s     (,~~';';'=M'=tq!fad'=MDN  3&O&O#O C
t~~$$&
'	(G 

7N Ns
   BBc                     | j                   j                         D ci c]  \  }}||j                  |       c}}| _         yc c}}w )zRemaps classes.N)rE   rI   index)r#   	class_mapr   rJ   s       r   rA   rA     s>     9=8L8L8NO8N1a++8NODNOs   Ac                 ~    |j                   j                  fd| j                  j                         D               y )Nc              3   2   K   | ]  \  }}|v s|  y wr   r   )r   r   rJ   
cur_glyphss      r   r   z!closure_glyphs.<locals>.<genexpr>'  s     J"6$!Q!z/A"6   )r$   updatemappingrI   r#   sr[   s     `r   closure_glyphsra   %  s&    HHOOJ$,,"4"4"6JJr'   c                     | j                   j                         D ci c]&  \  }}||j                  v s||j                  v s$||( c}}| _         t        | j                         S c c}}w r   )r^   rI   r$   boolr#   r`   r   rJ   s       r   subset_glyphsre   *  s_     ++--Aahh1=1-DL s   A'A'A'c                     | j                   j                         D ]%  \  }}||v s|j                  j                  |       ' y r   )r^   rI   r$   r]   )r#   r`   r[   glyphsubsts        r   ra   ra   2  s5    **,uJHHOOE" -r'   c                     | j                   j                         D ci c]*  \  }}|j                  v rt        fd|D              r||, c}}| _         t	        | j                         S c c}}w )Nc              3   :   K   | ]  }|j                   v   y wr   r?   )r   subr`   s     r   r   z subset_glyphs.<locals>.<genexpr>>  s      >ASArG   )r^   rI   r$   allrc   rd   s    `  r   re   re   9  sg     LL&&((DAq=S >A >> 	
1(DL
 s   /A,c                 z     |j                   j                  fd| j                  j                         D          y )Nc              3   2   K   | ]  \  }}|v s|  y wr   r   )r   r   vlistr[   s      r   r   z!closure_glyphs.<locals>.<genexpr>E  s     W,C5qJe,Cr\   )r$   r]   
alternatesrI   r_   s     `r   ra   ra   C  s(    AHHOOWDOO,A,A,CWXr'   c                 .   | j                   j                         D ci c]G  \  }}|j                  v r4t        fd|D              r ||D cg c]  }|j                  v s| c}I c}}}| _         t	        | j                         S c c}w c c}}}w )Nc              3   :   K   | ]  }|j                   v   y wr   r?   )r   rJ   r`   s     r   r   z subset_glyphs.<locals>.<genexpr>M  s      >1ahhrG   )rp   rI   r$   rH   rc   )r#   r`   r   ro   rJ   s    `   r   re   re   H  s     --//HAu=S > >> 	
u.u!QXXAu../DO
   	 /s   /BB#B'BBc                 ~     j                   j                  fd| j                  j                         D          y )Nc              3      K   | ]D  \  }}|v r;|D cg c]-  }t        fd |j                  D              s"|j                  / c} F yc c}w w)c              3   :   K   | ]  }|j                   v   y wr   r?   r   cr`   s     r   r   z+closure_glyphs.<locals>.<genexpr>.<genexpr>V  s     0V1ahhrG   N)rl   	ComponentLigGlyph)r   r   seqsseqr[   r`   s       r   r   z!closure_glyphs.<locals>.<genexpr>U  sN      

14J &*WTcS0V0V-VS\\TW1 Xs   A#AAA)r$   r]   	ligaturesrI   r_   s    ``r   ra   ra   R  s/    AHHOO

>>//1

r'   c                 @   | j                   j                         D ci c]  \  }}|j                  v s|| c}}| _         | j                   j                         D ci c]L  \  }}||D cg c]:  }|j                  j                  v r t	        fd|j
                  D              r|< c}N c}}}| _         | j                   j                         D ci c]  \  }}|s	|| c}}| _         t        | j                         S c c}}w c c}w c c}}}w c c}}w )Nc              3   :   K   | ]  }|j                   v   y wr   r?   rv   s     r   r   z subset_glyphs.<locals>.<genexpr>d  s     /U}!QXX}rG   )r|   rI   r$   ry   rl   rx   rc   )r#   r`   r   rJ   rz   r{   s    `    r   re   re   ]  s   '+~~';';'=O'=tq!ahhad'=ODN ~~++- .GAt 	

||qxx'C/Us}}/U,U 
 	

 .DN (,~~';';'=C'=tq!ad'=CDN P
 Ds.   DD"D/?D.D
D%DDc                 (     j                   dk(  rn j                  j                  |      }|r+t        fd j                   j
                  z   D              sy j                  j                   fd|D               y J d j                   z         )N   c              3   T   K   | ]  }|j                  j                         ! y wr   r<   rv   s     r   r   z!closure_glyphs.<locals>.<genexpr>p  s&      "
D KK!D   %(c              3   <   K   | ]  }j                   |     y wr   )
Substituter   r2   r#   s     r   r   z!closure_glyphs.<locals>.<genexpr>u  s     <Gq*Gs   unknown format: %s)FormatCoverager6   rl   LookAheadCoverageBacktrackCoverager$   r]   )r#   r`   r[   r0   s   ``  r   ra   ra   l  sz    {{a--))*5c "
++d.D.DD"
 
 	<G<<4&44qr'   c                 h   | j                   dk(  r| j                  j                  j                        }t	        | j
                  |      | _        t        | j
                        D cg c]  \  }}|j                  v s| }}}t	        | j
                  |      | _        | j                  j                  |       t        | j
                        | _	        t        | j                  xr+ t        fd| j                  | j                  z   D                    S J d| j                   z         c c}}w )Nr   c              3   T   K   | ]  }|j                  j                         ! y wr   r=   r$   rv   s     r   r   z subset_glyphs.<locals>.<genexpr>  s&      HA "Hr   r   )r   r   r=   r$   r3   r   r5   rA   r.   
GlyphCountrc   rl   r   r   )r#   r`   r0   r2   rk   s    `   r   re   re   z  s    {{a--&&qxx0&t@#,T__#=Q#=C1#=Q&t@G$doo.OO  //$2H2HH 
 	
 	5&44q Rs   *D.D.c                     | j                   dv S )Nr         )DeltaFormatr#   s    r   
is_hintingr     s    y((r'   c                 l    dD ]/  }t        | |d       }||j                         s$t        | |       1 y )N)
XPlaDevice
YPlaDevice
XAdvDevice
YAdvDevice)getattrr   delattrr#   namerJ   s      r   prune_hintsr     s2    HD$%=Q\\^D$ Ir'   c                    | j                   dk(  r.t        | j                  j                  |j                              S | j                   dk(  r| j                  j                  |j                        }| j
                  }t        |      }|D cg c]  }||k  s	||    c}| _        t        | j
                        | _        t        | j                        S J d| j                   z         c c}w )Nr   r   r   )r   r.   r   r=   r$   Value
ValueCountrc   )r#   r`   r0   rT   r1   r2   s         r   re   re     s    {{a4==''122		--&&qxx0F)0>AAIfQi>
djj/DOO$$4&44q	 ?s   
C*C*c                 *     j                    j                  dk(  sJ y j                  dk(  rF|j                  s j                   j	                           j                   j                          _        n j                  dk(  rd  j                   v r/ j                  dk(  sJ t        d  j                   D              suJ |j                  s! j                   D ]  }|j	                           t        t        j                   j                   D cg c]  }|j                          c}d       _         j                  dk(  rLt         fd j                   D              r.d _         j                  dk7  r j                   d   nd  _          `
yc c}w )Nr   Tr   r   c              3   $   K   | ]  }|d u  
 y wr   r   r   rJ   s     r   r   z$prune_post_subset.<locals>.<genexpr>  s     5*QqDy*s   c              3   B   K   | ]  }|j                   d    k(    ywr   N)r   )r   rJ   r#   s     r   r   z$prune_post_subset.<locals>.<genexpr>  s     GJqTZZ] 2Js   )r   ValueFormatr   hintingr   getEffectiveFormatrl   r   int__or__r   )r#   r%   optionsrJ   s   `   r   prune_post_subsetr     sF   zz1$$$ {{aJJ""$::88:		4::##q(((5$**5555??AMMO $%

TZZHZQ113ZH! D
 {{aCGDJJGG&*&6&6!&;TZZ]
O Is   F
c                 6   | j                   dk(  rV| j                  j                  |j                        }| j                  }t        |      }|D cg c]  }||k  s	||    c}| _        | j                  D ]T  }|j                  D cg c]  }|j                  |j                  v s| c}|_        t        |j                        |_        V t        | j                        D cg c]  \  }}|j                  s| }}}| j                  j                  |       t        | j                  |      | _        t        | j                        | _        t        | j                        S | j                   dk(  rl| j                  j                  |j                  j                  | j                  j                        d      D cg c]  }|| j                   k  r| }	}| j"                  j                  |j                  dd      D cg c]  }|| j$                  k  r| }
}|	D cg c]  }| j&                  |    c}| _        | j&                  D ]$  }|
D cg c]  }|j(                  |    c}|_        & t        |	      | _        t        |
      | _        t        | j                   xr6 | j$                  dkD  xr% | j                  j                  |j                              S J d| j                   z         c c}w c c}w c c}}w c c}w c c}w c c}w c c}w )Nr   r   TrA   F)rA   rU   r   )r   r   r=   r$   PairSetr.   PairValueRecordSecondGlyphPairValueCountr5   rA   r3   PairSetCountrc   	ClassDef1intersectionClass1Count	ClassDef2Class2CountClass1RecordClass2Record)r#   r`   r0   pairsr1   r2   prrw   
class1_map
class2_maps              r   re   re     s   {{a--&&qxx0E
*1?'QQYa'?A,,!,a0I,!A  #1#4#45A	  "+4<<!8M!8AA<L<L1!8MG$#DLL':-D%%&&		 ^^**%%dmm&:&:;4 + 
 4###	  	 
 ^^**18845*Q
Q4### Q 	 

 <FF:aT..q1:F""A9CDAannQ/DAN #z?z? /!!A%/$$QXX.
 	
 	5&44qK @!
 N


 GDs<   
K7K7K<&K<&L;LLL%LLc                 6   |j                   sddd| j                     \  }}dx| _        | _        t	        | |      D ]  }t	        ||      D ]  }|j
                  rG|j
                  j                          | xj                  |j
                  j                         z  c_        |j                  sc|j                  j                          | xj                  |j                  j                         z  c_          t        | j                  | j                  z        S )N)r   r   )r   r   r   r   r   )
r   r   ValueFormat1ValueFormat2r   Value1r   r   Value2rc   )r#   r%   r   attr1attr2rowr   s          r   r   r     s    ??-/
 ++u
 121D-4'CS%(88HH((*%%)D)D)FF%88HH((*%%)D)D)FF% ) ( !!D$5$5566r'   c                 d   | j                   dk(  r| j                  j                  |j                        }| j                  }t        |      }|D cg c]  }||k  s	||    c}| _        t        | j                        | _        t        | j                        S J d| j                   z         c c}w Nr   r   )r   r   r=   r$   EntryExitRecordr.   EntryExitCountrc   )r#   r`   r0   recordsr1   r2   s         r   re   re     s    {{a--&&qxx0&&G4;IGqq5y
GI!$"6"67D''((4&44q	  Js   
B-B-c                     | j                   dk(  rd| _         y | j                   dk(  rWdD ]0  }t        | |d       }||j                         s$t        | |d        2 | j                  | j
                  d| _         y y y y )Nr   r   r   )XDeviceTableYDeviceTable)r   r   r   setattrr   r   r   s      r   r   r     s    {{a		4DdD)A}dD) 5 $):):)BDK *C$ 
r'   c                     |j                   s^| j                  D ]O  }|j                  r|j                  j                          |j                  s6|j                  j                          Q yNT)r   r   EntryAnchorr   
ExitAnchor)r#   r%   r   recs       r   r   r   (  sL    ??''C++-~~**,	 (
 r'   c                 *   | j                   dk(  r| j                  j                  |j                        }t	        | j
                  j                  |      | j
                  _        t        | j
                  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                  j                  D ]  }t	        |j"                  |      |_         t%        | j                  xr. | j
                  j                  xr | j                  j                        S J d| j                   z         )Nr   c              3   4   K   | ]  }|j                     y wr   Classr   s     r   r   z subset_glyphs.<locals>.<genexpr>A       "N4Mq1774M   r   )r   MarkCoverager=   r$   r3   	MarkArray
MarkRecordr.   	MarkCountBaseCoverage	BaseArray
BaseRecord	BaseCountr   
ClassCountrW   r   
BaseAnchorrc   )r#   r`   mark_indicesbase_indicesclass_indicesmbs          r   re   re   3  sz   {{a((//9$0NN%%|%
! $'t~~'@'@#A ((//9$0NN%%|%
! $'t~~'@'@#A ""NDNN4M4M"NNm,**A#))!''2AG +**A'mDAL +OOU 8 8UT^^=U=U
 	
 	5&44qr'   c                    |j                   s| j                  j                  D ])  }|j                  s|j                  j	                          + | j
                  j                  D ]&  }|j                  D ]  }|s|j	                           ( yr   )r   r   r   
MarkAnchorr   r   r   r   )r#   r%   r   r   r   as         r   r   r   N  si    ??**A||((* + **A\\MMO " + r'   c                 R   | j                   dk(  r| j                  j                  |j                        }t	        | j
                  j                  |      | j
                  _        t        | j
                  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                  j                  D ]1  }||j"                  D ]  }t	        |j$                  |      |_         3 t'        | j                  xr. | j
                  j                  xr | j                  j                        S J d| j                   z         )Nr   c              3   4   K   | ]  }|j                     y wr   r   r   s     r   r   z subset_glyphs.<locals>.<genexpr>i  r   r   r   )r   r   r=   r$   r3   r   r   r.   r   LigatureCoverageLigatureArrayLigatureAttachLigatureCountr   r   rW   r   ComponentRecordLigatureAnchorrc   )r#   r`   r   ligature_indicesr   r   r/   rw   s           r   re   re   [  s   {{a((//9$0NN%%|%
! $'t~~'@'@#A 0077A,8--/?-
) ,/t/A/A/P/P+Q(""NDNN4M4M"NNm,**A#))!''2AG +##22Ay&&#/0@0@-#P  ' 3
 OO 1((1""00
 	
 	5&44qr'   c                 F   |j                   s| j                  j                  D ])  }|j                  s|j                  j	                          + | j
                  j                  D ]:  }||j                  D ]&  }|j                  D ]  }|s|j	                           ( < yr   )	r   r   r   r   r   r   r   r   r   )r#   r%   r   r   r/   rw   r   s          r   r   r   {  s    ??**A||((* + ##22Ay&&))A * ' 3 r'   c                 *   | j                   dk(  r| j                  j                  |j                        }t	        | j
                  j                  |      | j
                  _        t        | j
                  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                  j                  D ]  }t	        |j                   |      |_         t#        | j                  xr. | j
                  j                  xr | j                  j                        S J d| j                   z         )Nr   c              3   4   K   | ]  }|j                     y wr   r   r   s     r   r   z subset_glyphs.<locals>.<genexpr>  s     "O4Nq1774Nr   r   )r   Mark1Coverager=   r$   r3   
Mark1Arrayr   r.   r   Mark2Coverage
Mark2ArrayMark2Recordr   r   rW   r   Mark2Anchorrc   )r#   r`   mark1_indicesmark2_indicesr   r   r   s          r   re   re     sz   {{a**11!((;%1OO&&&
" %((B(B$C!**11!((;&2OO'''
# %((C(C$D!""ODOO4N4N"OOm,++A#))!''2AG ,,,A(FAM -OOW 9 9Wdoo>W>W
 	
 	5&44qr'   c                    |j                   s| j                  j                  D ])  }|j                  s|j                  j	                          + | j
                  j                  D ]&  }|j                  D ]  }|s|j	                           ( yr   )r   r   r   r   r   r   r  r  )r#   r%   r   r   r   s        r   r   r     si    ??++A||((* , ,,A]]MMO # - r'   c                      y r   r   r#   lookup_indicess     r   subset_lookupsr	    s     	r'   c                     g S r   r   r   s    r   collect_lookupsr    s	     Ir'   c                      yr   r   r#   r%   r   s      r   r   r     s     r'   c                      y)NFr   r   s    r   may_have_non_1to1r    s     r'   c                      yr   r   r   s    r   r  r    s     r'   c                     G d dt               }| j                  dvry 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y)0__subset_classify_context.<locals>.ContextHelperc                    |j                   j                  d      rd}d}nd}d}|j                   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 }nN|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(  r1|d$z   | _        |d%z   | _        |d&z   | _        |d'z   | _        d( | _        y |dk(  rX|d)z   | _        |d*z   | _        |d+z   | _        |d,z   | _        d- | _        |rd.nd/| _        |rdnd| _        |rd0| _        y d1| _        y |dk(  r|rd2nd3| _        y y )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>      QZZr'   c                     | j                   S r   r  r  s    r   r  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>      !**r'   c                      y)Nr   r   r  s    r   r  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>  s    r'   c                      y)N)NNNr   r  s    r   r  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>  s    -?r'   c                     | j                   fS r   )Inputr  s    r   r  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>  
    aggZr'   c                 H    | j                   | j                  | j                  fS r   	Backtrackr%  	LookAheadr  s    r   r  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>      1;;*Mr'   c                 6    |\  | _         d |D        \  | _        y )Nc              3   8   K   | ]  }t        |      d z     ywr   Nr-   r   xs     r   r   za__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetRuleData.<locals>.<genexpr>#       &=1as1vz1   )r%  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| _        | _        | _        y Nr   r   r   r)  r%  r*  r.   BacktrackGlyphCountInputGlyphCountLookAheadGlyphCountr3  s     r   ChainSetRuleDatazS__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.ChainSetRuleData%  P    :;7Q[!'1;
 QqTC!IM3qt9	-)-r'   r   c                     | j                   S r   r  r  s    r   r  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>.  r  r'   c                     | j                   S r   r  r  s    r   r  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>/  r!  r'   c                     | j                   fS r   ClassDefr  s    r   r  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>0  s
    r'   c                 H    | j                   | j                  | j                  fS r   BacktrackClassDefInputClassDefLookAheadClassDefr  s    r   r  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>1  s     ''OO''.r'   c                     |\  | _         y r   rA  r3  s     r   SetContextDatazQ__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetContextData7  s    $%MQZr'   c                 .    |\  | _         | _        | _        y r   rD  r3  s     r   SetChainContextDatazV__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetChainContextData:  s    RSOQ(!/1;Nr'   c                     | j                   fS r   r   r  s    r   r  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>=  r&  r'   c                 H    | j                   | j                  | j                  fS r   r(  r  s    r   r  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>>  r+  r'   c                 6    |\  | _         d |D        \  | _        y )Nc              3   8   K   | ]  }t        |      d z     ywr.  r-   r/  s     r   r   za__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetRuleData.<locals>.<genexpr>B  r1  r2  )r   r   r3  s     r   r4  zN__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetRuleData@  r5  r'   c                     |\  | _         | _        | _        t        |d         t        |d         dz   t        |d         c| _        | _        | _        y r7  r8  r3  s     r   r<  zS__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.ChainSetRuleDataD  r=  r'   c                      | j                   d   S Nr   r  r  s    r   r  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>M  s    QZZ]r'   c                      | j                   d   S rR  )InputCoverager  s    r   r  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>N  s    !//!*<r'   c                     | j                   S r   r  r  s    r   r  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>S  r  r'   c                 N    | j                   | j                  z   | j                  z   S r   )r   rT  r   r  s    r   r  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>T  s    ''!//9A<O<OOr'   c                 6    |\  | _         d |D        \  | _        y )Nc              3   2   K   | ]  }t        |        y wr   r-   r/  s     r   r   za__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetRuleData.<locals>.<genexpr>Z  s     &9q!s1vq   )r   r   r3  s     r   r4  zN__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetRuleDataX  s    $%MQZ&9q&9OQ\r'   c                 f    |\  | _         | _        | _        d |D        \  | _        | _        | _        y )Nc              3   2   K   | ]  }t        |        y wr   r-   r/  s     r   r   zf__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.ChainSetRuleData.<locals>.<genexpr>b  s     +AQrY  )r   rT  r   r9  r:  r;  r3  s     r   r<  zS__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.ChainSetRuleData\  s7    RSOQ(!/1;N
 ,+	-)-r'   r   Rule	RuleCountRuleSetRuleSetCountc                     || v r|gS g S r   r   r$   rw   r   s      r   r  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>y  s    Q&[qc6Pb6Pr'   	ClassRuleClassRuleCountClassSetClassSetCountc                 ^    |r|j                  | |      S |dk(  rt        |       S t               S rR  )rP   r9   ra  s      r   r  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>  s8     %%fa0 <)*a#f+<58U<r'   rF  rB  r%  r   rT  r   )__name__endswith
startswithTypTyper  ChainTypInputIdxDataLenr  r   ContextDatarI  RuleDatar4  r\  r]  r^  r_  	IntersectrB  ClassDefIndexr%  )r#   rO   r   rj  rk  r  rm  rn  rl  r   ChainCoveragero  ChainContextDatarI  rK  rp  ChainRuleDatar4  r<  s                      r   __init__z9__subset_classify_context.<locals>.ContextHelper.__init__  st   ~~&&w/~~((1s{HDHDIDJ$DM$DM"DL $~ 5D{/ 4/#? !%&*#/ M>> 1/ 45$ &T 0 M>> 12 <"#' !%&*#/!:, 8.77q -#3 &9# -#3  (#. &4# (#. {$v-	!)K!7')3$,~$=!!P1${2	!),<!<'*4$,$>!" 49j*/QQ"(-W
7
105_:
 r'   N)rg  
__module____qualname__rv  r   r'   r   ContextHelperr    s	    L	Fr'   ry  r   _subset__ContextHelpers)objectr   hasattr	__class__rz  )r#   ry  helpers      r   __subset_classify_contextr    s    MF MF^ {{)#4>>#<=13.{{$..@@@t~~t{{;>D..t{{;>>11$++>>r'   c                 &   | j                         j                  |       j                  |      }|sg S j                  |       j                  |      }| j                  dk(  rj                  |       }t        | j                        }t        | j                        }|D ]w  }||k\  s||   st        ||   j                        D ]L  }|st        fdt        |j                  |            D              s6t               }	t        |j                        D ]  }
|
s|
j                  }||	v rd }nJ|dk(  r)t!        j                  |       j"                  |   g      }nt!        |j$                  |dz
     g      }j&                  j(                  j*                  |
j,                     }|	j/                  |       |j1                         r1|	j3                  t5        |t7        |j$                        dz                |j9                  |        O z y | j                  dk(  rt        | j:                        }|j                  |      }j                  |       }t        | j                        }t        | j                        }|D ]  }||k\  s||   st        ||   j                        D ]n  }|st        fdt        |j                  |            D              s6t               }	t        |j                        D ]  }
|
s|
j                  }||	v rd }n`|dk(  rt!        |j=                  ||            }n?t!        |j=                  j"                  t        |j$                        |dz
                 }j&                  j(                  j*                  |
j,                     }|	j/                  |       |j1                         r;|	j3                  t5        |t7        t        |j$                              dz                |j9                  |        q  y | j                  dk(  r9t        fdj                  |       D              sg S | }t        |j$                        }t               }	t        |j                        D ]  }
|
s|
j                  }||	v rd }n8|dk(  rt!        |      }n't!        ||   j                  j"                              }j&                  j(                  j*                  |
j,                     }|	j/                  |       |j1                         r'|	j3                  t5        |t7        |      dz                |j9                  |        y J d	| j                  z         )
Nr   c              3   R   K   | ]  \  }t        fd |D                yw)c              3   X   K   | ]!  }j                  j                  |       # y wr   rq  r$   r   krw   cdr`   s     r   r   z+closure_glyphs.<locals>.<genexpr>.<genexpr>  #     DeAHHb!4e   '*Nrl   r   klistr  rw   r`   s     @r   r   z!closure_glyphs.<locals>.<genexpr>  (      %D	E DeDD%D   #'r   r   )r[   c              3   R   K   | ]  \  }t        fd |D                yw)c              3   X   K   | ]!  }j                  j                  |       # y w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   `   K   | ]%  }|d uxr |j                  j                         ' y wr   r<   r   r0  r`   s     r   r   z!closure_glyphs.<locals>.<genexpr>  s-     UDTq1D=:Q[[%::DT   +.r   )r  r   r6   r:   r   ro  r   r^  r_  r\  rl   ziprp  r9   r  SequenceIndex	frozensetr$   r%  table
LookupListLookupLookupListIndexaddr  r]   ranger.   ra   rB  rP   )r#   r`   r[   r0   ro  rssrssCountr2   r   chaosllseqi
pos_glyphslookuprB  input_coveragesrw   s    `              @r   ra   ra     s   &&(Ajj((4G	D!22:>J{{ammD)dAII&40AH}CFSVQVV, %(ajjm%D  !!Q^^4B ++Du}%)
19)2AJJt4D4K4KA4N3O)PJ)2AGGD1H4E3F)GJWW//66r7I7IJFIIdO//1U4QWW1A%BC))!
)C! 5 - : 
	4,$$Z0mmD)dAII&40AH}CFSVQVV, %(ajjm%D  !!Q^^4B ++Du}%)
19)2 ( 8 8Q G*J *3 ( 8 8$%HHga.A$(.K!"*J
 WW//66r7I7IJFIIdO//1U4WQ5H1IA1M%NO))!
)C- 5 - F 
	UAJJtDTUUI!!QWW-!Q^^,B##Du}!
19!*:!6J!*'->>qxxH"J WW''..r/A/ABFIIdO'')U4_)=)ABC!!!
!;% -( 	5&44qr'   c                 	   | j                         }| j                  dk(  r| j                  j                  j                        }t        | |j                        }t        | |j                        }|D cg c]  }||k  s	||    }}|D ]  }|st        ||j                        }|D 	cg c])  }	|	r%t        fd|j                  |	      D              r|	+ }}	t        ||j                  |       t        ||j                  t        |              t        |      D cg c]!  \  }}|s	t        ||j                        s |# }}}| j                  j                  |       t!        ||      }t        | |j                  |       t        | |j                  t        |             t#        |      S | j                  dk(  r| j                  j                  j                        sy|j%                  |       }
|
D cg c]#  }|r|j                  j                  d      nd % }}||j&                     }t        | |j                        }t        | |j                        }|D cg c]  }||k  s	||    }}~t        | |j(                        j+                  | j                  j                        }t        |      D cg c]  \  }}||v r|nd  c}}}|D ]  }|st        ||j                        }|D 	cg c]1  }	|	r-t        d t-        ||j                  |	            D              r|	3 }}	t        ||j                  |       t        ||j                  t        |             |D ]_  }	|j/                  |	t-        ||j                  |	            D cg c]$  \  }}|D cg c]  }|j1                  |       c}& c}}}       a  |D cg c]  }|rt        ||j                        r|nd   }}|r|d   |d= |r|d   t        | |j                  |       t        | |j                  t        |             t#        |      S | j                  d	k(  r#t        fd
|j                  |       D              S J d| j                  z         c c}w c c}	w c c}}w c c}w c c}w c c}}w c c}	w c c}w c c}}}w c c}w )Nr   c              3   F   K   | ]  }t        fd |D                yw)c              3   :   K   | ]  }|j                   v   y wr   r?   )r   r   r`   s     r   r   z*subset_glyphs.<locals>.<genexpr>.<genexpr>  s     95aAM5rG   Nr  )r   glistr`   s     r   r   z subset_glyphs.<locals>.<genexpr>  s     U}e9599}s   !r   FTr   c              3   L   K   | ]  \  }t        fd |D                yw)c              3   &   K   | ]  }|v  
 y wr   r   )r   r  	klass_maps     r   r   z*subset_glyphs.<locals>.<genexpr>.<genexpr>A  s     61Ys   Nr  )r   r  r  s     @r   r   z subset_glyphs.<locals>.<genexpr>@  s)      ,J(	5 666,Js   !$r   c              3   `   K   | ]%  }|d uxr |j                  j                         ' y wr   r   r  s     r   r   z subset_glyphs.<locals>.<genexpr>`  s-     RAQA1D=7QXXahh%77AQr  r   )r  r   r   r=   r$   r   r^  r_  r\  rl   rp  r   r]  r.   r5   rA   r3   rc   ro  rr  rB  r6   r  r4  rW   )r#   r`   rw   r0   r  r  r2   rsssr   ro  r0  
klass_mapsr  r  r  s    `              r   re   re     sR    	&&(A{{a--&&qxx0dAII&40&7w!!h,s1vw7BQVV$B AUqzzRS}UU    B#BSW-  #,C.O.BB72qvv;N1.OG$3(aii%annc#h/Cy		}}##AHH-mmD)CN
CNaaAHHQXXTH*T9; 	 

 Q__-dAII&40&7w!!h,s1vw7$

+55dmm6J6JK;DS>J>Ca7ls,>JBQVV$B A ,/
AJJqM,J     B#BSW-  14J

10N0N,Iu 6;;U+U;0N # 6 EHHCbRGB/rT9CHc"goB c"goaii%annc#h/ Cy		RDAQRRR4&44qa 8
 P
 8 K" < Is`   7
RR-.R$
R /R R (R&*
R+5R+R0>6R6S )R;S #S;S c                 0   | j                         }| j                  dv rt        | |j                        D ]  }|st        ||j                        D ]  }|st        ||j                  t        ||j                        D cg c]  }|r|j                  |v r| c}       t        ||j                        D ]%  }|s|j                  |j                        |_        '   y | j                  dk(  rt        | |j                  t        | |j                        D cg c]  }|r|j                  |v r| c}       t        | |j                        D ]%  }|s|j                  |j                        |_        ' y J d| j                  z         c c}w c c}w Nr   r   r   )	r  r   r   r^  r\  r   r  r  rW   )r#   r  rw   r  r   r  s         r   r	  r	  e  s    	&&(A{{f$		*BR(NN #*!Q^^"<"<B""4"4"F "< "!Q^^4B )7)=)=b>P>P)QB& 5 ) +& 
	NN "$77B",,> 7	
 $/B!/!5!5b6H6H!IB 0
 	5&44q3s    FFc           
         | j                         }| j                  dv rnt        | |j                        D cg c]J  }|rFt        ||j                        D ]-  }|r)t        ||j
                        D ]  }|r|j                   / L c}}}S | j                  dk(  r1t        | |j
                        D cg c]  }|s|j                   c}S J d| j                  z         c c}}}w c c}w r  )r  r   r   r^  r\  r  r  )r#   rw   r  r   r  s        r   r  r    s     	&&(A{{f dAII.
.R(a0 
 1  ) .
 	
 
	-4T1>>-JQ-Jrb""-JQQ4&44q
 Rs   AC!4C(<C(c                     | j                   dk(  r| j                  j                  ||       y J d| j                   z         r   )r   ExtSubTablera   r_   s      r   ra   ra     s8    {{a'':64&44qr'   c                 |    | j                   dk(  r| j                  j                         S J d| j                   z         r   )r   r  r  r   s    r   r  r    s7    {{a11334&44qr'   c                 ~    | j                   dk(  r| j                  j                  |      S J d| j                   z         r   )r   r  re   r#   r`   s     r   re   re     s9    {{a--a004&44qr'   c                     | j                   dk(  r| j                  j                  ||      S J d| j                   z         r   )r   r  r   r  s      r   r   r     s;    {{a11$@@4&44qr'   c                 ~    | j                   dk(  r| j                  j                  |      S J d| j                   z         r   )r   r  r	  r  s     r   r	  r	    s9    {{a..~>>4&44qr'   c                 |    | j                   dk(  r| j                  j                         S J d| j                   z         r   )r   r  r  r   s    r   r  r    s7    {{a//114&44qr'   c                    |t        |j                        }t        |       }|j                  }|j	                  |d      \  }}|t        |j                        k7  r't        |j                        t               fx\  }}||<   |j                  |      ry |j                  |       | j                  D ]  }|s|j                  ||        y )Nr   )r  r$   id_doneLookupsgetr.   r9   issubsetr]   SubTablera   )r#   r`   r[   keydoneLookupsr1   coveredsts           r   ra   ra     s    qxx(
 T(C..K __S)4NE7AHH-0]CE,BBwS)7#NN:mm
!Z( r'   c                    | j                   D cg c]  }|s|j                  |      s| c}| _         t        | j                         | _        t	        | d      rk| j
                  _| j
                  |j                  vrd | _        | xj                  dz  c_        n*|j                  j                  | j
                        | _        t        | j                        S c c}w )NMarkFilteringSeti)
r  re   r.   SubTableCountr|  r  used_mark_sets
LookupFlagrW   rc   )r#   r`   r  s      r   re   re     s    "&--N-B2":J:J1:MR-NDMT]]+Dt'(T-B-B-N  (8(88$(D!OOu$O$%$4$4$:$:4;P;P$QD!""## Os   CCCc                 \    d}| j                   D ]  }|s|j                  ||      sd} |S NFT)r  r   )r#   r%   r   retr  s        r   r   r     s7    
Cmmg.C	 
 Jr'   c                 H    | j                   D ]  }|j                  |        y r   )r  r	  )r#   r  r`   s      r   r	  r	  
  s    ]]	( r'   c                 <    t        d | j                  D        g       S )Nc              3   B   K   | ]  }|s|j                           y wr   )r  r   r  s     r   r   z"collect_lookups.<locals>.<genexpr>  s     C}""$}   )sumr  r   s    r   r  r    s    Ct}}CRHHr'   c                 :    t        d | j                  D              S )Nc              3   B   K   | ]  }|s|j                           y wr   )r  r  s     r   r   z$may_have_non_1to1.<locals>.<genexpr>  s     D"r##%r  )rH   r  r   s    r   r  r    s    DDDDr'   c                     t        | j                        D cg c]  \  }}|s	|j                  |      s| c}}S c c}}w )z(Returns the indices of nonempty lookups.)r5   r  re   )r#   r`   r2   r/   s       r   re   re     s8     $DKK0M0$!QA!//!:LA0MMMs   
>>>c                 \    d}| j                   D ]  }|s|j                  ||      sd} |S r  )r  r   )r#   r%   r   r  r/   s        r   r   r      s7    
C[[tW-C	 
 Jr'   c                 
   | j                          |D cg c]!  }|| j                  k  s| j                  |   # c}| _        t        | j                        | _        | j                  D ]  }|j	                  |        y c c}w r   )ensureDecompiledLookupCountr  r.   r	  r#   r  r2   r/   s       r   r	  r	  +  sl    +9R>aQAQAQ=Q4;;q>>RDK4;;'D[[	(  Ss
   B B c                     | j                          t        | j                        D cg c]  \  }}||v r|nd c}}| _        yc c}}w z+Sets lookups not in lookup_indices to None.N)r  r5   r  r  s       r   neuter_lookupsr  4  sJ     	7@7M7Mtq!Q. d*7MDK s   Ac                      t        |      }|}	 t         fd|D        g       }|D cg c]  }||vr| j                  k  r| }}|st        |      S t        |      }|j                  |       |}cc c}w )zBReturns sorted index of all lookups reachable from lookup_indices.c              3   x   K   | ]1  }|j                   k  sj                  |   j                          3 y wr   )r  r  r  r   s     r   r   z"closure_lookups.<locals>.<genexpr>D  s0     Ww!!dFVFVBVT[[^++-ws   :":)r   r  r  extend)r#   r  recurserecurse_lookupsr/   s   `    r   closure_lookupsr  =  s      /NG
WwW
 %
$&1t/?/?+? $ 	 

 n--$_5o.! 

s   A3c                 R   | j                   D cg c]	  }||v s| c}| _         | j                   D cg c]  }|j                  |       c}| _         t        | j                         | _        | j                  xs$ t	        | j
                  t        j                        S c c}w c c}w )z2 "Returns True if feature is non-empty afterwards.)r  rW   r.   r  
isinstanceFeatureParamsr   FeatureParamsSize)r#   r  r/   s      r   r	  r	  S  s     (,';';S';!qN?RA';SD=A=Q=QR=QN003=QRD4//0D  zH66   TRs   	BBB$c                     t        | j                        D cg c]1  \  }}|j                  j                  |      s|j                  dk(  r|3 c}}S c c}}w ))Returns the indices of nonempty features.pref)r5   FeatureRecordFeaturer	  
FeatureTag)r#   r  r2   fs       r   r	  r	  b  sU     d0011DAqII$$^48N 	
1  s   6Ac                 .     t         fd|D        g       S )Nc              3      K   | ]6  }|j                   k  r%j                  |   j                  j                   8 y wr   )FeatureCountr  r  r  r   s     r   r   z"collect_lookups.<locals>.<genexpr>s  s>      	
$4$$$ q!))99$s   <?)r  r#   feature_indicess   ` r   r  r  p  s"    	
$	

 	 r'   c                     | j                          t        | j                  |      | _        t        | j                        | _        t        | j                        S r   )r  r3   r  r.   r  rc   r  s     r   subset_featuresr  |  sG    %d&8&8/JDD../D!!""r'   c                     | j                   D cg c])  }|j                  j                  |      r|j                  + c}S c c}w )r  )SubstitutionRecordr  r	  FeatureIndex)r#   r  r   s      r   r	  r	    sE    
 (((A99##N3 	
(  s   .A c                 B    t        fd| j                  D        g       S )r  c              3   T   K   | ]  }|j                   j                         ! y wr   )FeatureTableSubstitutionr	  )r   r  r  s     r   r   z!subset_lookups.<locals>.<genexpr>  s*      	
0 &&55nE0r   r  FeatureVariationRecordr  s    `r   r	  r	    s*     	
00	
 	 r'   c                 B    t        fd| j                  D        g       S )Nc              3      K   | ]C  }|j                   j                  D ](  }|j                  v r|j                  j                   * E y wr   )r  r  r  r  r  )r   vrr   r  s      r   r   z"collect_lookups.<locals>.<genexpr>  sH      	
100CC~~0 II%%C &1s   A	Ar  r  s    `r   r  r    s(    	
11	
 	 r'   c                 H   | j                          | j                  D cg c]  }|j                  |v s| c}| _        | j                  D ]"  }|j                  |j                        |_        $ t	        | j                        | _        t        | j
                        S c c}w r   )r  r  r  rW   r.   SubstitutionCountrc   r#   r  r   s      r   r  r    s    ***aann.O*D $$(..q~~> % !8!89D&&''s
   BBc                    | j                          | j                  D ]  }|j                  j                  |        | j                  rm| j                  d   j                  j                  sJ| j                  j                          | j                  r$| j                  d   j                  j                  sJt        | j                        | _        t        | j                        S )Nr  )	r  r  r  r  r  popr.   FeatureVariationCountrc   r  s      r   r  r    s    ((	""22?C )
 	##++

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

"
"#4#45
 "%T%@%@!AD**++r'   c                    | j                   |v r!|j                  | j                         | _         nd| _         | j                  D cg c]	  }||v s| c}| _        | j                  D cg c]  }||v s|j                  |       c}| _        t        | j                        | _        t        | j                  xs | j                   dk7        S c c}w c c}w N  )ReqFeatureIndexrW   r  r.   r  rc   )r#   r  r  s      r   r  r    s    ..44T5I5IJ$$($5$5N$5qo9M$5ND +/*;*;*;QqO?Sa *;D D--.D!!BT%9%9U%BCC Os   	CC)	C3Cc                     | j                   d d  }| j                  dk7  r|j                  | j                         t        |      S r  )r  r
  appendr   r  s     r   collect_featuresr    s?    ''*Ou$t334o&&r'   c                 \   | j                   r$| j                   j                  |      s	|sd | _         | j                  D cg c]   }|j                  j                  |      s|" c}| _        t	        | j                        | _        t        | j
                  xs | j                         S c c}w r   )DefaultLangSysr  LangSysRecordLangSysr.   LangSysCountrc   )r#   r  keepEmptyDefaultLangSysr/   s       r   r  r    s     	##33OD'"%%%a)B)B?)S%D D../D!!8T%8%899	s    B) B)c                    | j                   D cg c]  }|j                  j                          }}| j                  r)|j	                  | j                  j                                t        t        |g             S c c}w r   )r  r  r  r  r  r   r  )r#   r/   r  s      r   r  r    si    =A=O=OP=Oqyy113=OOPt22CCEFc/2.// Qs   !A<c                     | j                   D cg c]/  }|j                  j                  ||j                  dk(        s|r|1 c}| _         t	        | j                         | _        t        | j
                        S c c}w )NDFLT)ScriptRecordScriptr  	ScriptTagr.   ScriptCountrc   )r#   r  retain_emptyr`   s       r   r  r    su    
 """A88##OQ[[F5JK 	
"D 4,,-D  !!s   4A:c                 N    t        t        d | j                  D        g             S )Nc              3   P   K   | ]  }|j                   j                            y wr   )r  r  )r   r`   s     r   r   z#collect_features.<locals>.<genexpr>  s      R@Q1188446@Qs   $&)r   r  r  r   s    r   r  r    s!    cR@Q@QRTVWXXr'   EBLCc                 r   | j                   D ]m  }|j                  D ]0  }|j                  D cg c]  }||j                  v s| c}|_        2 |j                  D cg c]  }|j                  s| c}|_        o | j                   D cg c]  }|j                  s| c}| _         yc c}w c c}w c c}w r   )strikesindexSubTablesnamesr$   )r#   r`   strikeindexSubTablenr2   s         r   re   re     s    ,,#22M.;.A.A"S.AQ!((]1.A"SM 3,2,A,A M,AqQWW,A M   $||@|!q/?/?A|@DL	 #T M@s#   B*B*B//B/B4B4EBDTc           
          | j                   D cg c]%  }|j                  D ci c]  }||v s|||    c}' }}}|D cg c]  }|s|	 c}| _         yc c}w c c}}w c c}w r   )
strikeDatar$   )r#   r`   r#  r   r(  s        r   re   re     st     GKooFUFqxx7x!1;F1Ix7o  
 -7AJ&&vJADO 	8
 Bs&   A	AAAA!	A!Asbixc                     | j                   j                         D ]>  }|j                  D ci c]!  }||j                  v s||j                  |   # c}|_        @ yc c}w r   )r   rT   r$   )r#   r`   r#  r   s       r   re   re     sW    ,,%%'67hhUh!v}}BTFMM!,,hU (  Vs   A AGSUBc                 B   | j                   |_         | j                   j                  r%| j                   j                  j                         }ng }| j                   j                  r&| j                   j                  j	                  |      }ng }t        | j                   dd       r(|| j                   j                  j	                  |      z  }t        |      }| j                   j                  ri |_	        	 t        |j                        }|D ]|  }|| j                   j                  j                  k\  r'| j                   j                  j                  |   sK| j                   j                  j                  |   j                  |       ~ ||j                  k(  rn|`	|` y NFeatureVariations)r  
ScriptListr  FeatureListr  r   r.  r   r  r  r  r$   r  r  ra   )r#   r`   r  r  orig_glyphsr2   s         r   ra   ra   &  sG   jjAGzz**//@@Bzz//??Ptzz.5$**66FFWW/Nzz#AHH-K#

--999zz,,33A6

%%,,Q/>>qA $ ahh&  N	r'   GPOSc                     |j                   |_        | j                  j                  r&| j                  j                  j	                  |      }ng }| j                  |       yr   )glyphs_gsubedr$   r  r  re   r	  )r#   r`   r  s      r   re   re   D  sJ    AHzz..<<Q?'r'   c                 F    | j                   t        j                  d      k(  S )Nr+  )r}  r   getTableClassr   s    r   retain_empty_scriptsr7  O  s     >>U00888r'   c                    | j                   j                  r%| j                   j                  j                  |       | j                   j                  r&| j                   j                  j                  |      }ng }t	        | j                   dd      r(|| j                   j
                  j                  |      z  }t        |      }| j                   j                  r%| j                   j                  j                  |       t	        | j                   dd      r%| j                   j
                  j                  |       | j                   j                  r5| j                   j                  j                  || j                                yy)zZRetains specified lookups, then removes empty features, language
    systems, and scripts.r.  N)
r  r  r	  r0  r   r.  r   r  r/  r7  )r#   r  r  s      r   r	  r	  V  s    zz

,,^<zz**00??Otzz.54::77FF~VV 1Ozz

..?tzz.5

$$44_Ezz

--T668	
 r'   c                 |    | j                   j                  r&| j                   j                  j                  |       yyr  )r  r  r  r  s     r   r  r  m  s.     zz

,,^< r'   c                 T   | j                   j                  r%| j                   j                  j                         }ng }| j                   j                  r&| j                   j                  j	                  |      }ng }t        | j                   dd      r(|| j                   j                  j	                  |      z  }t        |      }| j                   j                  r&| j                   j                  j                  |      }ng }|r| j                  |       y| j                  |       y)z/Remove (default) or neuter unreferenced lookupsr.  N)r  r/  r  r0  r  r   r.  r   r  r  r	  r  )r#   rA   r  r  s       r   prune_lookupsr;  t  s     zz**//@@Bzz//??Ptzz.5$**66FFWW/Nzz..>>~NN+N+r'   c                 ,   | j                   j                  rt        | j                   j                  j                        D cg c]  \  }}|j                  |v r| }}}| j                   j                  j                  |       t        | j                   dd       r(| j                   j                  j                  |       ng }| j                   j                  r5| j                   j                  j                  || j                                y y c c}}w r-  )
r  r0  r5   r  r  r  r   r.  r/  r7  )r#   feature_tagsr2   r  r  s        r   subset_feature_tagsr>    s    zz "$**"8"8"F"FG
G1|||+ G 	 

 	

..?4::2D9JJ((88Izz

--T668	
 
s   Dc                 P   i }t               }|D ]v  }d|v r|j                  d      n|df\  }}|j                  |j                  d             |j	                  |t                     j                  |j                  d             x | j
                  j                  r~| j
                  j                  j                  D cg c]  }|j                  |v s| c}| j
                  j                  _        t        | j
                  j                  j                        | j
                  j                  _
        | j
                  j                  j                  D ]  }|j                  |v sd||j                     vs$|j                  j                  D 	cg c]  }	|	j                  ||j                     v r|	! c}	|j                  _        t        |j                  j                        |j                  _        d||j                     vsd |j                  _         y y c c}w c c}	w )N.r      z*   dflt)r9   splitr  ljust
setdefaultr  r/  r  r  r.   r  r  r  
LangSysTagr  r  )
r#   tagslangsysscript_tagstag
script_taglang_tagr`   recordr/   s
             r   subset_script_tagsrN    s   G%K14syy~#s
H
((+,:su-11(..2CD 
 zzzz,,99.
9!Q[[K=WA9.


* -0

0E0E0R0R,S

)jj++88F7*vWVEUEU=V/V $]]88/8||wv/?/?'@@ 8/+
 .11L1L-M*)9)9!::37FMM0 9 .
/s   HH$H#c                    | j                   j                  r%| j                   j                  j                         }ng }| j                   j                  r%| j                   j                  j	                  |       t        | j                   dd      r%| j                   j                  j	                  |       | j                   j                  r5| j                   j                  j	                  || j                                yy)zRemove unreferenced featuresr.  N)r  r/  r  r0  r  r   r.  r7  r  s     r   prune_featuresrP    s     zz**//@@Bzz

..?tzz.5

$$44_Ezz

--T668	
 r'   c                     d|j                   vr| j                  |j                          d|j                  vr| j                  |j                         | j	                  d       y)Nr   Fr   T)layout_scriptsrN  layout_featuresr>  r;  r  s      r   prune_pre_subsetrT    s\     '((( 6 67
')))  !8!89U#r'   c                    | j                   }|j                  r|j                  sy |j                  j                  }|j                  j                  D ]0  }|j
                  j                  }|s|j
                  j                  d d  D ]  }|j                  }t        |j                        t        |j                        k7  r;|j                  dk(  |j                  dk(  k7  r[|j                  dk7  r ||j                     ||j                     k7  rt        t        |j                              D ])  }||j                  |      ||j                  |      k7  s)  |j
                  j                  j                  |        3 y r  )r  r/  r0  r  r  r  r  r  r  r.   r  r
  r  remove)r#   r  featuresr`   r*   lrr/   r2   s           r   remove_redundant_langsysrY    sC   JJE5#4#4  ..H**HH##((((+B

A1>>"c!..&99!!U*0A0AU0JK  E)A--.(1;L;L2MM3q~~./ANN1-.(1>>!;L2MM 0
 &&--b1# ,	 +r'   c                    | j                   }| j                          |j                  r|j                  j                  ||       |j                  sd |_        |j                  r | j                          | j                          t        |d      rW|j                  r)|j                  r|j                  j                  sd |_        |j                  s|j                  dk(  rd|_
        y)Nr.  i     T)r  r;  r  r   r0  rY  rP  r|  r.  r  Versionr#   r%   r   r  s       r   r   r     s    JJE**49  %%' u)*""%"9"9"P"P&*E# &&5==J+F&EMr'   GDEFc                    |j                   }| j                  }|j                  r|j                  j                  j	                  |      }t        |j                  j                  |      |j                  _        t        |j                  j                        |j                  _        |j                  rL|j                  j                  j                         D ci c]  \  }}||v s|| c}}|j                  _
        |j                  rL|j                  j                  j                         D ci c]  \  }}||v s|| c}}|j                  _
        |j                  r|j                  j                  j	                  |      }|j                  j                  }|D cg c]!  }||k  s	|j                  j                  |   # c}|j                  _        t        |j                  j                        |j                  _        t!        |d      r|j"                  r|j"                  }	|	j                  D ]  }
|
s|
j	                  |        t%        |	j                        D cg c]  \  }}|j&                  s| c}}|_        |	j                  D cg c]  }|j&                  s| c}|	_        yc c}}w c c}}w c c}w c c}}w c c}w )NMarkGlyphSetsDefT)r4  r  LigCaretListr   r=   r3   ry   r.   LigGlyphCountMarkAttachClassDefrE   rI   GlyphClassDef
AttachListr   AttachPointr|  r`  r5   r$   r  )r#   r`   r$   r  r0   r   rJ   r   r2   markGlyphSetscoveragerw   s               r   re   re   &  sZ   __FJJE$$--44V<&253E3E3N3NPW&X#+.u/A/A/J/J+K("55??EEG.
GTQ1PV;AqDG.
  * "00::@@B)
BTQa6kAqDB)
% ""++226:%%00
5<(
5<JE((+W(
$ '*%*:*:*F*F&G#u()e.D.D..%..H' / +4M4J4J*KX*K$!QqxxA*KX-:-C-C!P-Cqxx!-C!P/.
)
(
 Y!Ps<   J8'J82J>?J>"
K-K)K	>K	K+Kc                 f   d| vry | d   }|j                   }t        |d      sy |j                  }t               }|j	                  |       d| v r| d   j                   j	                  |       |j                  |      }|j                  |       d| v r| d   j                   j                  |       y y )Nr^  VarStorer2  )r  r|  rj  r9   collect_device_varidxessubset_varidxesremap_device_varidxes)r%   gdefr  storeusedVarIdxes
varidx_maps         r   
_pruneGDEFrr  I  s    T<DJJE5*%NNE5L 
!!,/~V22<@ &&|4J 

+~V00< r'   c                 ~   | 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      r:t        |       |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                  xsf |j                  xsX |j
                  xsJ |j                  xs< |j                  dk\  xr |j                  xs |j                  dk\  xr |j                        S )Nrj  r   i  i  r`  r[  )r  ra  rb  rc  rE   rd  re  r   r|  rr  rj  VarDataCountr\  r`  r   rc   r]  s       r   r   r   c  sx   JJE%"4"4"B"B!(@(@(J(J#' 5#6#6#@#@" 0 0 ; ;uj!4>>&&!+}}
* *E-.%%%%..!%==J&&EM 	<##	<	< 	< MMZ'BE,B,B		<
 MMZ':ENN r'   kernc                     | j                   D cg c]  }t        |d      s| c}| _         t        | j                         S c c}w )N	kernTable)
kernTablesr|  rc   r#   r%   r   ts       r   rT  rT    s<     #'//M/QWQ5Lq/MDO   Ns
   AAc           	      Z   |j                   }| j                  D ]D  }|j                  j                         D ci c]  \  \  }}}||v r	||v r||f| c}}}|_        F | j                  D cg c]  }|j                  s| c}| _        t	        | j                        S c c}}}w c c}w r   )r4  rx  rw  rI   rc   )r#   r`   r$   rz  r   r   rJ   s          r   re   re     s    __F__ [[..0
0	AF{qF{ FAI0
  #'//A/QQ[[q/ADO  

 Bs   B!
.B( B(vmtxc                     t        | j                  |j                        | _        |j                  D ]  }d| j                  |<    t	        | j                        S )Nr   r   )r+   metricsr$   glyphs_emptiedrc   r#   r`   r   s      r   re   re     sD    ahh7DL Q r'   hmtxc                     t        | j                  |j                        | _        |j                  D ]  }d| j                  |<    y)Nr~  T)r+   r  r$   r  r  s      r   re   re     s8    ahh7DL Q r'   hdmxc           	      .   | j                   j                         D ci c]  \  }}|t        ||j                         c}}| _         | j                   D ]%  }|j                  D ]  }d| j                   |   |<    ' t        | j                         S c c}}w rR  )r  rI   r+   r$   r  rc   )r#   r`   szr/   r   s        r   re   re     s    <@IIOO<MN<M52q\!QXX..<MNDIii!!A DIIbM! "  		?	 Os   !Bankrc                 &   | j                   j                  }|j                  dk(  sJ d|j                  z         |j                  D ci c]!  }||j                  v s||j                  |   # c}|_        t        |j                        dkD  S c c}w )Nr   zunknown 'ankr' format %s)r  AnchorPointsr   r$   Anchorsr.   r#   r`   r  rg   s       r   re   re     s    JJ##E<<1G85<<GG1219Uemm=Su}}U##EM u}}!!s   BBbslnc                     | j                   j                  }|j                  dv r&|j                  j	                  |j
                         y y )N)r   r   )r  Baseliner   r$   r  StandardGlyph)r#   r`   r  s      r   ra   ra     s8    JJE||v	U(() r'   c                    | j                   j                  }|j                  dv r|j                  D ci c])  }||j                  j                  ||j                        + }}t        |      dkD  r^t        |j                               j                  d      d   \  }}||_        |j                         D ci c]  \  }}||k7  s|| }}}t        |      dkD  r||_        yddd|j                     |_        |`yc c}w c c}}w )N)r   r   r   r   r   T)r  r  r   r$   BaselineValuesr  DefaultBaseliner.   r   rT   most_commonrI   )r#   r`   r  rg   	baselines
mostCommon_cntr   s           r   re   re     s   JJE||v 
! 5''++E53H3HII! 	 
 y>A&y'7'7'9:FFqI!LJ$.E!2;//2CW2CheQqJ2CIWy>A#,E    !Q<5EL$
 Xs   .C?9DDlcarc                 $   | j                   j                  }|j                  dv rT|j                  D ci c]!  }||j                  v s||j                  |   # c}|_        t        |j                        dkD  S J d|j                  z         c c}w )N)r   r   r   zunknown 'lcar' format %s)r  LigatureCaretsr   r$   Caretsr.   r  s       r   re   re     s    JJ%%E||v45HH
4<5@UE5<<&&H
 5<< 1$$?05<<??u
s   BBgvarc                 l    |j                   r(|j                  sg | j                  |j                  d   <   yNr   T)notdef_glyphnotdef_outline
variations
glyphOrderr  s      r   rT  rT    s-    G$:$:.0*+r'   c                     t        | j                  |j                        | _        t        | j                        | _        t        | j                        S r   )r+   r  r$   r.   
glyphCountrc   r  s     r   re   re     s7    "4??AHH=DO$//*DO  r'   c                    |j                   j                         D ci c]  \  }}|||    }}}||j                   | j                        }| j                  j                         D ]  \  }}|| j                  kD  r|nd||<    |S c c}}w rR  )r^   rI   last_retained_glyphreverseEmptiedGlyphMaplast_retained_order)	r`   rq  	table_mapr  rJ   map_last_idxr   r2   s	            r   _remap_index_mapr    s    )2):):)@)@)BC)BAAz!})BDC )++A,A,ABCH((..01!"7"77(QQ 1K Ds   BHVARc                     | j                   }t               }t               }d}|j                  rmt        |j                  j                  |j
                        |j                  _        |j                  |j                  j                  j                                nO|j                  |j                  j                                |j                         }|j                  j                  }|j                  rlt        |j                  j                  |j
                        |j                  _        |j                  |j                  j                  j                                |j                  rlt        |j                  j                  |j
                        |j                  _        |j                  |j                  j                  j                                |j                  j                  |||      }|j                  r&t!        |||j                        |j                  _        |j                  r&t!        |||j                        |j                  _        |j                  r&t!        |||j                        |j                  _        yNF)retainFirstMapadvIdxesT)r  r9   AdvWidthMapr+   r^   r$   r]   rT   reverseOrigGlyphMapcopyr   retain_gidsLsbMapRsbMaprj  rl  r  r#   r`   r  used	advIdxes_retainAdvMaprq  s          r   re   re     s   JJE5DIL$01B1B1J1JAHH$U!E%%--4467A))0023IIK	yy,,||+ELL,@,@!((KELL((//12||+ELL,@,@!((KELL((//12//\I 0 J $4Q
EDUDU$V!||/:u||L||/:u||L r'   VVARc                 t   | j                   }t               }t               }d}|j                  rmt        |j                  j                  |j
                        |j                  _        |j                  |j                  j                  j                                nO|j                  |j                  j                                |j                         }|j                  j                  }|j                  rlt        |j                  j                  |j
                        |j                  _        |j                  |j                  j                  j                                |j                  rlt        |j                  j                  |j
                        |j                  _        |j                  |j                  j                  j                                |j                  rlt        |j                  j                  |j
                        |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                  _        yr  )r  r9   AdvHeightMapr+   r^   r$   r]   rT   r  r  r   r  TsbMapBsbMapVOrgMaprj  rl  r  r  s          r   re   re   #	  s$   JJE5DIL%1%2D2D2L2Lahh%W"E&&..5578A))0023IIK	yy,,||+ELL,@,@!((KELL((//12||+ELL,@,@!((KELL((//12}} ,U]]-B-BAHH MEMM))0023//\I 0 J %5aUEWEW%X"||/:u||L||/:u||L}} 0J N r'   VORGc                     | j                   j                         D ci c]  \  }}||j                  v s|| c}}| _         t        | j                         | _        yc c}}w r   )VOriginRecordsrI   r$   r.   numVertOriginYMetricsrd   s       r   re   re   N	  s_     ,,2244AQXX14D "%T%8%8!9D	s
   AAopbdc                    | j                   j                  }|j                  dk(  rS|j                  D ci c]   }||j                  v r||j                  |   " c}|_        t        |j                        dkD  S |j                  dk(  rS|j                  D ci c]   }||j                  v r||j                  |   " c}|_        t        |j                        dkD  S J d|j                  z         c c}w c c}w )Nr   r   zunknown 'opbd' format %s)r  OpticalBoundsr   r$   OpticalBoundsDeltasr.   OpticalBoundsPointsr  s       r   re   re   W	  s    JJ$$E||q %
!111 5,,U33!%
!
 5,,-11		 %
!111 5,,U33!%
!
 5,,-11?05<<??u%
%
s   %C/%C4postc                 *    |j                   sd| _        y)N      @T)glyph_names
formatTyper  s      r   rT  rT  l	  s    r'   c                     g | _         yr   )
extraNamesr  s     r   re   re   s	  s    DOr'   propc                    | j                   j                  }|j                  dk(  r|j                  dk7  S |j                  dk(  r|j                  D ci c])  }||j
                  j                  ||j                        + c}|_        t        |j
                  j                               j                  d      d   \  }}||_        |j
                  j                         D ci c]  \  }}||k7  s|| c}}_        t        |j
                        dk(  r|`d|_        |j                  dk7  S yJ d|j                  z         c c}w c c}}w )Nr   r   Tzunknown 'prop' format %s)r  GlyphPropertiesr   DefaultPropertiesr$   
Propertiesr  r   rT   r  rI   r.   )r#   r`   r  r   r  r  s         r   re   re   y	  s4   ::%%D{{a%%**		GHxx
GO!At""1d&<&<==x
 #4??#9#9#;<HHKAN
D!+#'??#8#8#:
#:4dj>PAtG#:
 t1$DK))Q..>04;;>>u


s   .E$E
2E
c                 J    t               fd}| j                  ||       S )Nc                     | j                   t        j                  j                  t        j                  j                  hv rj                  | j                         y y r   )r   r   PaintFormat
PaintGlyphPaintColrGlyphr  Glyph)paintresults    r   callbackz$_paint_glyph_names.<locals>.callback	  sI    <<  ++  //
 
 JJu{{#	
r'   )r9   traverse)r  colrr  r  s      @r   _paint_glyph_namesr  	  s$    UF$ 
NN4"Mr'   COLRc                    | j                   dkD  rh| j                  | j                        | _        | j                  j                  j
                  D ci c]  }|j                  |j                   c}| _        |j                  }|rt               }|D ]  }| j                  j                  |g       D ]  }|j                  |j                          | j                   dkD  sO| j                  j                  |      }|m|j                  t        || j                                ||j                  z  }|j                  j                  |       |}|ry y c c}w rR  )version_decompileColorLayersV0r  ColorLayersBaseGlyphListBaseGlyphPaintRecord	BaseGlyphPaintColorLayersV1r$   r9   r  r  r   r]   r  )r#   r`   r   	decomposelayersr   layerr  s           r   ra   ra   	  s#   ||a
  77

C zz//DD
D MM399$D

 I
A))--a4

5::& 5 ||a**..q1$MM"4UDJJ"GH  	!((		 
s   Ec                 .   ddl m} ddlm}m} |j
                  |_        |j                  D ci c]!  }|| j                  v s|| j                  |   # c}| _        | j                  dk(  rt        | j                        S  || j                  j                  | j                  j                        } ||D ci c]  }||j                  v s|||    c}      \  | j                  _        | j                  _        | `| j                  j                  \| j                  j                  j                  }|D ci c]  }||j                  v s|||    c}| j                  j                  _        | j                  }| j                  j                  j                   sd| _        | `
t        |      S  || j                  |D 	ci c],  }|||   D 	cg c]  }	|	j"                  |	j$                  f c}	. c}	}       | `yc c}w c c}w c c}w c c}	w c c}	}w )Nr   )unbuildColrV1)buildColrV1populateCOLRv0T)fontTools.colorLib.unbuilderr  fontTools.colorLib.builderr  r  glyphs_colredr$   r  r  rc   r  	LayerListr  r  ClipListclipsr  r   colorID)
r#   r`   r  r  r  r   colorGlyphsV1r  layersV0r  s
             r   re   re   	  s   :F AH )*(01A9I9I4I4AD ||qD$$%%!$**"6"6

8P8PQM5@&3EmqAHH}M!	mE62DJJ$**2 	zz&

##)):?$Q%Q1=Qa[%$Q

!H::##88JH~

LTUHqhqkBkUejj%--(kB	BHU 	 = 	F %R CUs;   G=G=7HH7HHHH-HHCPALc                    d|v ry|j                  d      }|syt        t              fd}|j                  dk(  rE|j                  j                         D ]'  }|D ]   }|j                     j                  |       " ) n|j                  j                  rC|j                  j                  j                  D ]   }|j                     j                  |       " |j                  j                  j                  D ](  }|j                  j                  |j                  |       * t!        j#                               dhz
  }| j$                  D ]A  }	t'        |	      D 
cg c]  \  }
}|
|v s| c}}
|	d d  t)        |	      t)        |      k(  rAJ  t'        t+        |            D ]A  \  }}|   D ]4  }t-        |d      r||_        t-        |d	      r||_        +t/        |       C t)        | j$                  d         | _        | j                  d
k(  r<g }t'        | j2                        D ]  \  }
}|
|v s|j                  |        || _        t5        | j0                        S c c}}
w )NzSVG Tr  Fc                     t        | d      r| j                     j                  |        y t        | d      r:| j                  j                  D ]   }|j                     j                  |       " y y )NPaletteIndex	ColorLine)r|  r  r  r   	ColorStop)r  stopcolors_by_indexs     r   collect_colors_by_indexz2prune_post_subset.<locals>.collect_colors_by_index 
  sb    5.)E../66u=UK(11 1 1299$? 2 )r'   r   r	  r  r  r   )r  r   rS   r  r  rT   r  r  r  LayerRecordArrayLayerRecordr  r  r  r  r  r9   keyspalettesr5   r.   r!   r|  AssertionErrornumPaletteEntriespaletteEntryLabelsrc   )r#   r%   r   r  r  r  r  rM  retained_palette_indicespaletter2   rw   	new_index	old_indexkept_labelslabelr  s                   @r   r   r   	  s4    ~88FD!$'O@ ||q&&--/F.55e<   0 ::&&44@@ 2 23::5A Ajj..CCFLL!!$**.EF D
  #?#7#7#9:fXE==$-g$6X$6DAq!?W:Wa$6X
7|s#;<<<< ! !*&1I*J K	9%i0Fvy)!*0&/#$V,, 1 !L !q!12D||q!$"9"9:HAu,,""5) ; #.&&'') Ys   !I).I)c                     t               }| j                  D ]  }|j                  |j                          | j                  r6| j                  j
                  D ]  }|j                  |j                          |S r   )r9   MathGlyphVariantRecordr  VariantGlyphGlyphAssemblyPartRecordsrg   )r#   r$   variantsrJ   r   s        r   ra   ra   -
  s]    uH((Q^^$ )##//ALL! 0Or'   c                    t        |j                        }t               }| j                  rO| j                  j	                  |      }|D ]/  }|j                  | j                  |   j                  |             1 | j                  rO| j                  j	                  |      }|D ]/  }|j                  | j                  |   j                  |             1 |j                  j                  |       y r   )
r  r$   r9   VertGlyphCoverager6   r]   VertGlyphConstructionra   HorizGlyphCoverageHorizGlyphConstruction)r#   r`   r$   r  r0   r2   s         r   ra   ra   8
  s    qxx FuH((226:AOOD66q9HHPQ  ))33F;AOOD77:II&QR  HHOOHr'   VARCc                 8   | j                   j                  j                  |j                        }t	        | j                   j
                  j                  |      | j                   j
                  _        t        | j                   j
                  j                        S r   )r  r   r=   r$   r3   VarCompositeGlyphsVarCompositeGlyphrc   r#   r`   r0   s      r   re   re   J
  si    jj!!((2G6B

%%777DJJ!!3 

--??@@r'   c                 .   | j                   j                  y t        | j                   j                  j                        D ci c]  \  }}||
 }}}| j                   j                  j
                  }|j                  }t               }t        |      }|ry|}	t               }|	D ]d  }||v r|j                  |      }
|
||
   }|j                  D ]5  }|j                  }|j                  |       ||vs%|j                  |       7 f |rxy y c c}}w r   )r  r  r5   r   r$   r   r9   r  
components	glyphNamer  )r#   r`   r2   r$  glyphMapglyphRecordsr$   r  newoldNewidxrg   compr   s                 r   ra   ra   S
  s    zz$$,1:4::;N;N;U;U1VW1VI	11VHW::00BBLXXFeG
f+C
eIG#,,y)C{ %E((~~

4 w&GGDM	 )    Xs   Dc                    | j                   }|j                  }|=t               }|j                  |       |j	                  |      }|j                  |       |j                  j                  }|t               }|j                  j                  D ];  }	|	j                  D ]*  }
|
j                  |j                  |
j                         , = t        |      }t        ||      |j                  _        t        |      D ci c]  \  }}||
 }}}|j                  j                  D ]4  }	|	j                  D ]#  }
|
j                  ||
j                     |
_        % 6 |j                   }||j"                  }t               }|j                  j                  D ];  }	|	j                  D ]*  }
|
j$                  |j                  |
j$                         , = t        |      }t        ||      |_        t        |      D ci c]  \  }}||
 }}}|j                  j                  D ]4  }	|	j                  D ]#  }
|
j$                  ||
j$                     |
_        % 6 yc c}}w c c}}w r   )r  MultiVarStorer9   collect_varidxesrl  remap_varidxesAxisIndicesListItemr  r   r#  axisIndicesIndexr  r!   r3   r5   ConditionListConditionTableconditionIndex)r#   r%   r   r  ro  rp  rq  axisIndicesListusedIndicesrg   r*  r'  oldr^   conditionListconditionTabless                   r   r   r   o
  s;   JJEEu|,**<8
Z(++00O"e--??E((((4OOD$9$9: ) @ [)%1/;%O",5k,BC,BS38,BC--??E((((4,3D4I4I,JD) ) @
 ''M '66e--??E((&&2OOD$7$78 ) @ [)'3O['Q$,5k,BC,BS38,BC--??E((&&2*1$2E2E*FD' ) @
 - D  Ds   II%MATHc                 |    | j                   j                  r&| j                   j                  j                  |       y y r   )r  MathVariantsra   r  s     r   ra   ra   
  s,    zz

..q1 r'   c                     | j                   j                  |j                        }t        | j                  |      | _        t        | j                        | _        t        | j                        S r   )r   r=   r$   r3   ItalicsCorrectionr.   ItalicsCorrectionCountrc   r!  s      r   re   re   
  sS    mm""188,G)$*@*@'JD"%d&<&<"=D++,,r'   c                     | j                   j                  |j                        }t        | j                  |      | _        t        | j                        | _        t        | j                        S r   )TopAccentCoverager=   r$   r3   TopAccentAttachmentr.   TopAccentAttachmentCountrc   r!  s      r   re   re   
  sU    $$++AHH5G+D,D,DgND$'(@(@$AD!--..r'   c                     | j                   j                  |j                        }t        | j                  |      | _        t        | j                        | _        t        | j                        S r   )MathKernCoverager=   r$   r3   MathKernInfoRecordsr.   MathKernCountrc   r!  s      r   re   re   
  sU    ##**1884G+D,D,DgNDT556D""##r'   c                 P   | j                   r| j                   j                  |       | j                  r| j                  j                  |       | j                  r| j                  j                  |       | j                  r%| j                  j                  |j                         yr   )MathItalicsCorrectionInfore   MathTopAccentAttachmentMathKernInfoExtendedShapeCoverager=   r$   r  s     r   re   re   
  s}    %%&&44Q7##$$2215''*!!""))!((3r'   c                    | j                   rZ| j                   j                  |j                        }t        | j                  |      | _        t        | j                        | _        | j                  rZ| j                  j                  |j                        }t        | j                  |      | _        t        | j                        | _	        yr   )
r  r=   r$   r3   r  r.   VertGlyphCountr  r  HorizGlyphCountr!  s      r   re   re   
  s    ((//9%1$2L2Lg%V"!$"<"<=))00:&243N3NPW&X#"4#>#>?r'   c                    |j                   |_        | j                  j                  r%| j                  j                  j	                  |       | j                  j
                  r%| j                  j
                  j	                  |       yr   )glyphs_mathedr$   r  MathGlyphInfore   r<  r  s     r   re   re   
  sZ    AHzz

  ..q1zz

--a0r'   glyfc                    | j                   r)t        j                  d| j                   d d       d   dk\  ry 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  }|ry y )Nz>hr   r   
   r      r      rA  @          )datastructunpack	bytearrayr   )r#   
glyphidmapr[  r2   moreflagsglyphIDs          r   remapComponentsFastrc  
  s   99dDIIbqM:1=B ++D49
AD
aAa!e,A;!#tAE{2W%lQUnQU	QE
6>FAFA6>FAV^FAV^FAv~) r'   c                    | j                   }|j                   }|rrt               }|D ]3  }||vr||   }|j                  |       D ]  }|j                  |        5 ||j                   z  }|j                   j	                  |       |}|rqy y r   )r$   r9   getComponentNamesr  r]   )r#   r`   glyphSetr  r#  r   glrw   s           r   ra   ra   
  s    {{HI
U
A !B))$/q! 0	  	ahh
	
#	 r'   c                     |j                   r?|j                  s3| | j                  d      }|j                  j	                          d|_        y)Nr   r'   T)r  r  r  __dict__clearr[  )r#   r%   r   r   s       r   rT  rT    s@    G$:$:#$	

r'   c                    t        | j                  |j                        | _        |j                  j                  st	        | j
                        D cg c]  \  }}||j                  v s| }}}t	        |      D ci c]  \  }}||
 }}}| j                  j                         D ]   }t        |d      s|j                  |       " t        j                  d      j                  }	|j                  D ]*  } |	       | j                  |<   d| j                  |   _        , | j
                  D cg c]!  }||j                  v s||j                  v s |# c}| _        yc c}}w c c}}w c c}w )Nr[  rS  r'   T)r+   r$   r   r  r5   r  rT   r|  rc  r   getTableModuler  r  r[  )
r#   r`   r2   r   r0   r%  oglyphmaprJ   r  s
             r   re   re     s6   t{{AHH5DK99  !*4??!;M!;AqAHH}1!;M%.w%78%7TQAqD%78##%Aq&!%%h/ &   (..EA!A  ??"aa188mqA<L<L7L?DO  N8s   E"+E" E(3!E.E.c                     |j                    }| j                  j                         D ]  }|j                  |        y)N)remove_hintingT)r   r$   rT   trim)r#   r%   r   rp  rJ   s        r   r   r   -  s6     (N[[!	n- "r'   cmapc                   
 | j                   D cg c]  }|j                         s| }}|D ]  }|j                  dk(  r|j                  j	                         D ]g  \  }
||j
                  vr
D ch c]  \  }}||j
                  v s| }}}d |v r|j                  d        |j                  j                  |       i |j                  
|j
                  j                  
j                               }	|j                  j                  
fd|	D                |j
                  j                         |_        |D ]'  }|j                  j                  |j                         ) y c c}w c c}}w )N   c              3   (   K   | ]	  }|     y wr   r   )r   urr  s     r   r   z!closure_glyphs.<locals>.<genexpr>F  s     :\DG\r   )tables	isUnicodeformatuvsDictrI   unicodes_requestedrV  r$   r]   rr  r   r  r  unicodes_missingdifference_update)r#   r`   rz  rw  r  varSelectorrv  r   r$   r   rr  s             @r   ra   ra   5  s3   6AaF6 <<2%*]]%8%8%:!Ta&:&::(,J1Q5I5I0I!J6>MM$'' &; ::D//<<TYY[ILHHOO:\::  --224A	,,UZZ8 ' 7 Ks   E,E,4E1
E1
c                    |j                   s@| j                  D cg c]%  }|j                         s|j                         s$|' c}| _        |j                  s0| j                  D cg c]  }|j                         r| c}| _        | j                  D cg c]  }|j
                  dk7  s| c}| _        t        | j                        | _        yc c}w c c}w c c}w r  )legacy_cmaprw  rx  isSymbolsymbol_cmapry  r.   numSubTablesry  s       r   rT  rT  N  s    "&++O+Q!**,q+O"&++B+QQZZ\q+B #kk;kQXX]1k;DKDKK(D PB <s#   %CC'C=CC,C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(  r|j                  j                         D 	ci c]G  \  }}||j                  v r4||D 	cg c]%  \  }}	|	|j                  v s||j                  v r||	f' c}	}I c}	}}}|_        |j                  j                         D ci c]  \  }}|s	|| c}}|_        |j                         r|j                  j                         D 	ci c]$  \  }}	|	|j                  v s||j                  v r||	& c}	}|_        |j
                  dk(  s|j                  st        |j                  j                               dk  s|j                  |       |j                  j                         D 	ci c]  \  }}	|	|j                  v s||	 c}	}|_         |D ]  }|j                  dk(  r^|j                  dk(  rO|j                  |v rA||j                     j                  |j                  k(  r|j                  j                          p|j                  dk(  s|j                  dk(  s|j                  |v s||j                     j                  |j                  k(  s|j                  j                           | j                  D cg c].  }|j
                  dk7  r|j                  sn|j                  s-|0 c}| _        t!        | j                        | _        y	c c}	}w c c}	}}}w c c}}w c c}	}w c c}	}w c c}w )
Nr   r   r   rt     r[  rA  rU  T)r$   rw  
platformID	platEncIDlanguagery  rz  rI   r{  glyphs_requestedrx  rr  maxr  r  rj  r.   r  )
r#   r`   tables_format12_bmptable_plat0_enc3table_plat3_enc1rz  rJ   r/   rv  r   s
             r   re   re   \  s   AH[[<<1!1+,QZZ(<<1!1+,QZZ(88r> IIOO- .DAq,,,  ! !1A...!q7K7K2K F ! 
 .AI +,))//*;A*;$!QqA*;AAI[[] FFLLN*DAq***a13G3G.G 1*AF xx2~!&&S-?'-I#**1-'(vv||~Q~tq!a>P>P9Pad~QAF? F !LLAq 

.. ,11QVV;FFLLNLLAr!

.. ,11QVV;FFLLN !  #kkWkBaffAII1kWDKDKK(D [ B R( XsH   &N*M;,N
N	%N	")NN"N% NNN;NDSIGc                      d| _         g | _        yr  )	usNumSigssignatureRecordsr  s      r   rT  rT    s     DNDr'   maxpc                     |j                   s@| j                  dk(  r1d| _        d| _        d| _        d| _        d| _        d| _        d| _        y)Nr[  r   r   T)	r   tableVersionmaxZonesmaxTwilightPoints
maxStoragemaxFunctionDefsmaxInstructionDefsmaxStackElementsmaxSizeOfInstructionsr  s      r   rT  rT    sP    ??
*DM%&D"DO#$D &'D#$%D!)*D&r'   r   c                 &   t               }|j                  |       t        |j                        |j                  z  }d|j                  v r7|| j
                  D ch c]  }|j                  dk  s|j                    c}z  }| j
                  D cg c]  }|j                  |v s| c}| _        |j                  s0| j
                  D cg c]  }|j                         s| c}| _        d|j                  vr8| j
                  D cg c]  }|j                  |j                  v s| c}| _        |j                  rg }| j
                  D ]  }|j                  dv r)|j                         rdj                  d      nd|_        n]|j                  dv r)|j                         rdj                  d      nd|_        n&|j                  dk(  rd	|_        n|j                  d
v r|j                  |        || _        yc c}w c c}w c c}w c c}w )Nr      )r   rA  z.	utf_16_be)r      r   r  )         T)r   visitr9   name_IDsseenr"  nameIDname_legacyrx  name_languageslangIDobfuscate_namesencodestringr  )r#   r%   r   visitornameIDsr%  namerecss          r   r   r     s   !GMM$'""#gll2G
gdjjCjAHHsNAHHjCC!ZZ?Z188w+>!Z?DJ "&=Aq{{}a=

'(((!%RAqxx7;Q;Q/QaR
Axx6!:;++-7>>+6WV#9:6==5FQ\)OOA  
/ D? > Ss0   G?0G?H%HH	!H		H'Hheadc                      yr   r   r  s      r   r   r     s     r'   c                      e Zd Z G d de      Z G d de      Zg dZeg dz  Zg dZg dZg d	g d
g dg dddgddgdgdgg dg dg dg dg dg ddZ	 e
 e ee	j                               g             Zd Zd Zg fdZy)Optionsc                       e Zd Zy)Options.OptionErrorNrg  rw  rx  r   r'   r   OptionErrorr        r'   r  c                       e Zd Zy)Options.UnknownOptionErrorNr  r   r'   r   UnknownOptionErrorr    r  r'   r  )BASEJSTFr  r&  r  EBSCPCLTLTSH)FeatGlatGlocSilfSill)avarfvargaspr  hhear  vheaOS/2locar   cvtfpgmprepVDMXr  r  MVARcvarSTAT)r  r  r  r  r  r  )rvrnccmpligaloclmarkmkmkrlig)fracnumrdnom)caltcligcursru  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        jJ                  | _&        d| _'        d| _(        d| _)        d| _*        d| _+        d| _,         | jZ                  di | y )NFTr   )r   r   r   r   rA     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_defaultrS  rR  ignore_missing_glyphsignore_missing_unicodesr   r  r  r  r  r  r  r  r  r  r  recommended_glyphsrecalc_boundsrecalc_timestampprune_unicode_ranges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lazyr9   )r#   kwargss     r   rv  zOptions.__init__J  s}   44Q7 $ > >q A"'"::1= "#<<Q?"e%*"'+$   
 !%h$  #"'" %$(!%)"$)!"'# #!6!>!>	6r'   c                     |j                         D ]2  \  }}t        | |      s| j                  d|z        t        | ||       4 y )NUnknown option '%s')rI   r|  r  r   )r#   rD  r  rJ   s       r   r9   zOptions.set}  sC    LLNDAq4#--.Ca.GHHD!Q #r'   c                    g }g }|D ]I  }|}|j                  d      s|j                  |       )|dd  }|j                  d      }d}|dk(  r>|j                  d      r|dd  }	|	dk(  rd }
nd}
n|}	d	}
|	j                  d
      r)|	d d }	d
}
n!|d | }	|	d   dv r|	d   dz   }|	d d }	||dz   d  }
|	}|	j	                  dd      }	t        | |	      s.|d	u s||v r|j                  |       | j                  d|z        t        | |	      }|
d
k(  rt        d|d|       t        |t              rt        |
      }
n	t        |t              rt        |
      }
nt        |t              rt        |
      }
nt        |t              rt        |
t              r| j                  d|z        |
j	                  dd      j                         }|dgk(  rg }|D cg c]"  }t!        |      r|d   dv rt        |d      n|$ }}|dk(  r|}
n@|dk(  r|}
|
j#                  |       n'|dk(  r |}
|D ]  }||
v s|
j%                  |        nJ t'        | |	|
       L ||z   S c c}w )Nz--r   =r  zno-r   zcanonical-orderFT?z-+r   -_rF  zCurrent setting for 'z' is: z5Option '%s' requires values to be specified using '=', r  r   
0123456789z+=z-=)ri  r  findrh  replacer|  r  r   printr  rc   r   strrS   r  rC  r.   r  rV  r   )r#   argvignore_unknownposargspassthru_optionsr   orig_ar2   opr  rJ   okovvvr0  s                  r   
parse_optszOptions.parse_opts  s   AF<<%q!!"AsABBw<<&!"A-- !!AA::c?#2AAbqER5D=2B#2Aa!egJB		#s#A4#!T)R>-A$++F3112G!2KLLq!BCx2rBC"d#GB$FB$FB%a&**ORSS  YYsC(..0":BSUVSUa3q6adl.Bc!QiISUV9A4ZAHHRL4ZA6HHQK   !5D!QM P )))! Ws   'IN)rg  rw  rx  	Exceptionr  r  r%  r'  r*  _layout_features_groupsr   r  iterrT   r.  rv  r9   r\  r   r'   r   r  r    s    i [ 	 DD!* N
 K-><83>
 +3
72f  *D(//12B7 1f  /1 K*r'   r  c                       e Zd Z G d de      Z G d de      Z G d de      ZddZg g g d	fd
Zd Z	d Z
d Zd Zd Zd Zy)	Subsetterc                       e Zd Zy)Subsetter.SubsettingErrorNr  r   r'   r   SubsettingErrorrc    r  r'   rd  c                       e Zd Zy)&Subsetter.MissingGlyphsSubsettingErrorNr  r   r'   r   MissingGlyphsSubsettingErrorrf    r  r'   rg  c                       e Zd Zy)(Subsetter.MissingUnicodesSubsettingErrorNr  r   r'   r   MissingUnicodesSubsettingErrorri    r  r'   rj  Nc                     |s
t               }|| _        t               | _        t               | _        t               | _        y r   )r  r   r9   r{  glyph_names_requestedglyph_ids_requested)r#   r   s     r   rv  zSubsetter.__init__  s1    iG"%%%(U"#&5 r'   r  c                    | j                   j                  |       t        |t              r|j	                  d      }|j                  d      }t        |      dz  }t        j                  d|z  |      D ]  }| j                   j                  |        | j                  j                  |       | j                  j                  |       y )Nutf_8z	utf-32-berA  z>%dL)r{  r]   r  bytesdecoder  r.   r\  r]  r  rl  rm  )r#   r$   gidsunicodestext
text_utf32ncharsrv  s           r   populatezSubsetter.populate  s    &&x0dE";;w'D[[-
ZA%v
;A##''* <""))&1  ''-r'   c                    | j                  |      D ]B  }|j                         | j                  j                  v s[|j                         | j                  j                  v r| j                  j
                  r|dk(  r4| j                  j                  sd|v rt        j                  d|       ||= t        j                  |      }t        |d      st        d|z        5  ||   }d d d        t        d|z        5  j                  || j                        }d d d        st        j                  d|       ||= -t        j                  d|       E y # 1 sw Y   sxY w# 1 sw Y   LxY w)	Nru  r2  z
%s droppedrT  z	load '%s'
prune '%s'%s pruned to empty; dropped	%s pruned)_sort_tablesstripr   r&  r+  r   r,  logr    r   r6  r|  timerrT  r#   r%   rJ  clazzr  retains         r   _prune_pre_subsetzSubsetter._prune_pre_subset  s   $$T*C		t||777IIK4<<#>#>> LL006M4<<+C+CRVs+I'',Eu01;,- IE .<#-."33D$,,GF /HH:C@S	HH[#.3 +  .-..s   !E=E%E"	%E.	c           	      t  
 t        |j                               }|j                         x| _        
t               | _        | j                  j	                  | j
                         | j                  j	                  
fd| j                  D               t               | _        | j                  j	                  | j                  j                  |             | j                  j	                  
fd| j                  D               | j                  rQt        j                  d| j                         | j                  j                  s| j                  | j                        | j                  j                         | _        t               | _        d|v rCt#        d      5  |d   j%                  |        | j                  j'                  |       d d d        t)        | j                        | _        | j                   rZ| j                   D cg c]  }d|z  	 }}t        j                  d|       | j                  j,                  s| j/                  |      ~| j                  j0                  rtd|v r@| j                  j3                  |j5                  d	             t        j                  d
       n0| j                  j3                  d       t        j                  d       | j                  j6                  rtd|v rpt9        t;        dt=        |j                                           D ],  }| j                  j3                  |j5                  |             . t        j                  d       d|v rt#        d      5  t        j                  dt=        | j                               t        j                  | j                  |       |d   j%                  |        | j                  j'                  |       t        j                  dt=        | j                               t        j                  | j                  |       d d d        t)        | j                        | _        | j                  j@                  rd|v rt#        d      5  t        j                  dt=        | j                               t        j                  | j                  |       |d   j%                  |        | j                  j'                  |       t        j                  dt=        | j                               t        j                  | j                  |       d d d        t)        | j                        | _!        dD ]  }||v rt#        d|z        5  t        j                  d|t=        | j                               t        j                  | j                  |       ||   j%                  |        | j                  j'                  |       t        j                  d|t=        | j                               t        j                  | j                  |       d d d        tE        | d|jG                          dt)        | j                                d|v rt#        d      5  t        j                  d t=        | j                               t        j                  | j                  |       |d   j%                  |        | j                  j'                  |       t        j                  d!t=        | j                               t        j                  | j                  |       d d d        t)        | j                        | _$        d|v rt#        d"      5  t        j                  d#t=        | j                               t        j                  | j                  |       |d   j%                  |        | j                  j'                  |       t        j                  d$t=        | j                               t        j                  | j                  |       d d d        t)        | j                        | _$        d%|v rt#        d&      5  t        j                  d't=        | j                               t        j                  | j                  |       |d%   j%                  |        | j                  j'                  |       t        j                  d(t=        | j                               t        j                  | j                  |       d d d        t)        | j                        | _%        t)        | j                        | _&        |jO                         }| jL                  D ci c]  }|||   
 c}| _(        tS        | jP                  jU                               | _+        |j                         | jV                     | _,        t)               | _-        | j                  j\                  r4|| jL                  z
  D ch c]  }||   | jV                  k  r| c}| _-        | jZ                  D ci c]  }|||   
 c}| _/        | j                  j\                  s
D cg c]  }|| jL                  v s| }	}n.
D cg c]#  }|ja                  |      | jV                  k  s"|% }	}|	| _1        t9        t=        |	            D ci c]  }||	|      | c}| _2        t        j                  d)t=        | jL                               | `y # 1 sw Y   	oxY wc c}w # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   !xY w# 1 sw Y   xY w# 1 sw Y   6xY w# 1 sw Y   NxY wc c}w c c}w c c}w c c}w c c}w c c}w )*Nc              3   F   K   | ]  }|t              k  s|     y wr   r-   r   r2   glyph_orders     r   r   z,Subsetter._closure_glyphs.<locals>.<genexpr>  s&      %
$<qCDT@TKN$<s   !
!c              3   @   K   | ]  }|t              k\  s|  y wr   r-   r  s     r   r   z,Subsetter._closure_glyphs.<locals>.<genexpr>  s"      #
/!1K8H3HA/rM   zMissing requested glyphs: %srr  zclose glyph list over 'cmap'zU+%04Xz)Missing glyphs for requested Unicodes: %srS  r   zAdded gid0 to subsetz.notdefzAdded .notdef to subsetrA  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 afterr+  zclose glyph list over 'GSUB'z0Closing glyph list over 'GSUB': %d glyphs beforez.Closed glyph list over 'GSUB': %d glyphs after)r  r  zclose glyph list over '%s'z.Closing glyph list over '%s': %d glyphs beforez,Closed glyph list over '%s': %d glyphs 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 afterzRetaining %d glyphs)3r9   getGlyphOrderorig_glyph_orderr  r]   rl  rm  glyphs_missing
differencer~  r    r   r/  rg  r  r$   r|  r  ra   intersection_updater  glyphs_cmapedr0  rj  r  r  getGlyphNamer1  r  minr.   rQ  r-  r4  r   lowerglyphs_glyfedglyphs_cffedglyphs_retainedr"   r  r  rT   r  r  r  r  r  
getGlyphIDnew_glyph_orderglyph_index_map)r#   r%   
realGlyphsrv  missingr2   r  orderr   r  r  s             @r   _closure_glyphszSubsetter._closure_glyphs  s   ++-.
.2.@.@.BB #$$T%?%?@$$ %
$($<$<%
 	
 "e""4#8#8#C#CJ#OP"" #
//#
 	
 HH3T5H5HI<<55778K8KLL++002 #T>56V++D1//
; 7 't{{3  -1-B-BC-Bx!|-BGCHH@'J<<7799'BB<<$$~ 1 1! 45/0	*23<<**~s1c$*<*<*>&?@AAKKOOD$5$5a$89 B<=T>56FDKKHX 

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

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

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

4;;T
2 7 't{{3%E}7%?@HHHDKK(
 JJt{{J6K..t4KK33J?HHFDKK(
 JJt{{J6 A DGEKKM?"5y7MN# && T>56FDKKHX 

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

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

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

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

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

4;;T
2 7 &dkk2(5'')9=9M9M#N9MAAuQxK9M#N #&t'?'?'F'F'H#I #'#5#5#78P8P#Q 'k<<## $d&:&::#:A8t777 :#D =A<O<O&P<Oqq%({<O&P#||''*5S+Qd>R>R9Rq+OS '&a$//!*<@X@X*X;    /27O8L2M 
2MQE/!$%q(2M 
 	&D,@,@(ABKi 76
 D( 76 76 A@$ 76 76 76  $O# 'Q T 
s   0l<m	:CmCmCm(Cm5
Cn?Cnn2n!#n&n+&n+1#n0n08n5<mmm%(m2	5m?nnc                     g | _         | j                  |      D ]  }t        j                  |      }|j	                         | j
                  j                  v rt        j                  d|       Vt        |d      rst        d|z        5  ||   }| j                  | _        |j                  |       }| `d d d        st        j                  d|       ||= t        j                  d|       | j
                  j                  rt        j                  d|       t        j                  d|       ||=  t        d      5  |j!                  | j"                         d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)	Nz%s subsetting not neededre   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   r6  r}  r   r(  r~  r    r|  r  r  r$   re   r)  warningsetGlyphOrderr  r  s         r   _subset_glyphszSubsetter._subset_glyphs  s2    $$T*C'',Eyy{dll;;;3S90=3./ IE"&"6"6DK"006F	 0
 HH=sCS	HH^S100BCHNPSTI) +, &'t334 ('! 0/  ('s   	*E(E4(E1	4E=c                    |j                         }d|v r"|j                  d       |j                  d       |D ]   }|dk(  r
|dk(  r| j                  j                  rN||   j                         }||   j                  |d      }||k7  r t        j                  d|t        |             | j                  j                  r`||   j                  dk\  rN||   j                         }||   j                  |d      }||k7  r t        j                  d|t        |             | j                  j                  r?||   j                  }||   j!                  |      }	||	k7  rt        j                  d	||	       | j                  j"                  r>t%        |      }
|
||   j&                  k7  r!|
||   _        t        j                  d
||
       t)        j*                  |      }t-        |d      st/        d|z        5  ||   }|j1                  || j                        }d d d        st        j                  d|       ||= t        j                  d|       # y # 1 sw Y   @xY w)Nr   
GlyphOrderr  T)	pruneOnlyz%s Unicode ranges pruned: %sr   z%s CodePage ranges pruned: %sz%s xAvgCharWidth updated: %dz%s usMaxContext updated: %dr   ry  rz  r{  )r  rV  r  r   r4  getUnicodeRangesrecalcUnicodeRangesr~  r    r!   r5  r  getCodePageRangesrecalcCodePageRangesr6  xAvgCharWidthrecalcAvgCharWidthr7  r   usMaxContextr   r6  r|  r  r   )r#   r%   	tableTagsrJ  old_unirangesnew_unirangesold_codepagesnew_codepagesold_avg_widthnew_avg_widthmax_contextr  r  r  s                 r   _prune_post_subsetzSubsetter._prune_post_subset  s)   IIK	 YV$V$Cl"f}<<44$(I$>$>$@M$(I$A$A$RV$A$WM$5:CAV <<55$s):K:Kq:P %)I$?$?$AM$(I$B$B4SW$B$XM$5;"=1
 <<44$(I$;$;M$(I$@$@$FM$5!?mT<<22",T"2K"d3i&<&<<1<S	.!>[Q'',Eu12<#-. IE"44T4<<HF / HH:C@S	HH[#.S D /.s   ="II'	c                     g dt              D ci c]  \  }}||dz    c}}t        |j                         fd      }|D cg c]
  }|dk7  s	| c}S c c}}w c c}w )N)r^  r2  r+  r  r  r  r   rS  r   c                 (    j                  | d      S rR  )r  )rJ  tagOrders    r   r  z(Subsetter._sort_tables.<locals>.<lambda>
  s    8<<Q3Gr'   )r  r  )r5   r!   r  )r#   r%   r2   rz  rG  r  s        @r   r|  zSubsetter._sort_tables  sf    S)28)<=)<AAq1uH)<=diik'GH54a1#4455 >5s   A

A"A"c                     | j                  |       | j                  |       | j                  |       | j                  |       y r   )r  r  r  r  )r#   r%   s     r   r=   zSubsetter.subset  s:    t$T"D!%r'   r   )rg  rw  rx  r]  rd  rg  rj  rv  rw  r  r  r  r  r|  r=   r   r'   r   ra  ra    s\    )   ) !rBR 	./8l\561/f6&r'   ra  z	load fontc                 $   t        j                  | ||j                  |j                  ||j                        }|rTt        j
                  d      }|j                  }|j                  |_        |d   }|j                  dk(  rd|_        ||_        |S )N)checkChecksumsrecalcBBoxesrecalcTimestamprC  
fontNumberr  g       @r  )	r   TTFontr2  r3  rA  r6  decode_format_2_0decode_format_3_0r  )	fontFiler   r  dontLoadGlyphNamesrC  r%   r  savedr  s	            r   	load_fontr    s    <<%**00&&D$ ""6*&&!%!7!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                  ||j                         y )Nwoffr   )sfntT)reorderTables)
r:  r9  fontTools.ttLibr  
USE_ZOPFLIr=  cfgr   saver8  )r%   outfiler   r  s       r   	save_fontr  4  sV    w~~7(..DK&-&?&?DHH"#IIgW%<%<I=r'   c           
      l   dd l }|j                  dd|       } |j                  dd|       } g }| j                         D ]t  }|j                  d      }t        |      dk(  r|j	                  t        |d             >|\  }}|j                  t        t        |d      t        |d      dz                v |S )Nr   z0[xX]rM  z[<+>,;&#\\xXuU\n	]rJ  r   r  )rerk   rC  r.   r  r   r  r  )r`   r  r/   itemfieldsstartends          r   parse_unicodesr  ?  s    
xa A
$c1-A
A	Cv;!HHSr]#JE3HHU3ub>3sB<!+;<=  Hr'   c           
      :   g }| j                  dd      j                         D ]u  }|j                  d      }t        |      dk(  r|j                  t	        |d                @|j                  t        t	        |d         t	        |d         dz                w |S )NrL  rM  rJ  r   r   )rP  rC  r.   r  r   r  r  )r`   r/   r  r  s       r   
parse_gidsr  O  s    
A		#s#))+Cv;!HHS^$HHU3vay>3vay>A+=>? , Hr'   c                 B    | j                  dd      j                         S )NrL  rM  )rP  rC  )r`   s    r   parse_glyphsr  Z  s    99S#$$&&r'   c                  z    t        dt        t        j                         t        dt        j                         y )Nzusage:filez,Try pyftsubset --help for more information.
)rQ  	__usage__sysstderrr   r'   r   usager  ^  s!    	(ICJJ/	
9

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               yt               }	 |j                  | g d      } t        |       dk  rt                y ||j                  rt        j                   nt        j"                         |j$                  r.t&        j(                  j+                  t        j,                         ndt&        j(                  _        | d   }| dd } t1        |      }d}g }g }	g }
d}d}d}| D ]  }|dk(  rd}|j3                  d      r|dd }#|j3                  d      r	||dd z  }=|j3                  d      r=t5        |dd d      5 }||j7                         j9                  dd      z  }ddd       |j3                  d      r)|dd dk(  rd}n|
j;                  t=        |dd              |j3                  d      r[t5        |dd       5 }|j?                         D ].  }|
j;                  t=        |jA                  d      d                0 	 ddd       1|j3                  d       r|	j;                  tC        |dd              a|j3                  d!      r[t5        |dd       5 }|j?                         D ].  }|	j;                  tC        |jA                  d      d                0 	 ddd       |j3                  d"      r*|d#d dk(  rd}n|j;                  tE        |d#d              |j3                  d$      r[t5        |dd       5 }|j?                         D ].  }|j;                  tE        |jA                  d      d                0 	 ddd       t|jG                  |        |jH                   xr | }|jJ                  }tM        ||||%      }|:|jN                  d&|jN                  jQ                         z   nd}tS        ||dd'(      }t'        d)      5  |r|j;                  |jU                                |r|d*   jV                  D ]u  }|jY                         s|
j;                  |jZ                  j]                                |j^                  dk(  sM|
j;                  |j`                  j]                                w d|vsJ 	 ddd       tb        je                  d+|z         tb        je                  d,|
       tb        je                  d-|       tb        je                  d.|	       |jg                  ||	|
|/       |ji                  |       tk        |||       |j                  rjddl6}tb        je                  d0|jn                  jq                  |      |fz         tb        je                  d1|jn                  jq                  |      |fz         |jr                  r|ju                  t        jv                         |jy                          y# |j                  $ r0}t                t        d	|t        j                  
       Y d}~yd}~ww xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w)2z%OpenType font subsetter and optimizerr   )splitext)configLoggerNr   z--help)	rr  z	gids-filer$   zglyphs-filert  z	text-filers  zunicodes-filezoutput-file)rT  zERROR:r  r   )levelT)r   Fr  r   z--output-file=rt  z--text=   z--text-file=r  zutf-8)encoding
z--unicodes=   z--unicodes-file=r  #z--gids=z--gids-file=z	--glyphs=	   z--glyphs-file=)r  rC  r@  z.subset)	extension	overWritesuffixzcompile glyph listrr  z
Text: '%s'zUnicodes: %sz
Glyphs: %szGids: %s)r$   rr  rs  rt  zInput font:% 7d bytes: %szSubset font:% 7d bytes: %s)=os.pathr  	fontToolsr  r  rS  rQ  __doc__r  r\  r  r  r  r.   r>  loggingINFOWARNINGr?  r  r(   setLevelDEBUGdisabledra  ri  openreadrP  r  r  	readlinesrC  r  r  r  r  rC  r  r9  r  r   r  rw  rx  rr  r  ry  rz  r~  r    rw  r=   r  ospathgetsizer@  saveXMLstdoutclose)argsr  r  r   efontfile	subsetterr  r$   rr  rs  wildcard_glyphswildcard_unicodesrt  r   r  liner  rC  r%   extrz  r  s                          r   mainr  c  sc    !&|xx|4giG!!
 " 
& 4y1}ww||GOOL~~gmm, $AwH8D'*IGFDHOD8"O<<()fG<<	"AabEMD<<'afw/1((r22 0<<&v}$(!qv 67<<*+afKKMDOON4::c?13E$FG *  <<	"KK
1QR5)*<<'afKKMDKK
4::c?1+= >? *  <<$u|"&l1QR512<<()afKKMDMM,tzz#q/A"BC *  aY \ %000?Z<<D'.@tD .5nn.HcGNN((**d$tI
 
#	$MM$,,./&\((;;=OOAFFKKM2xx2~ 		(89	 )
  
% HH\D !HH^X&HH\6"HHZf4(NTdGW%,0I8/TTU-1I70SST{{SZZ JJLe  h

+J 0/   $ 
%	$sd   X 5$Y;AYAY(>AY5AZ8Z1ZY&YYY	Y%	(Y2	5Y?	Z)r  ra  r  r  r  r  r  r  r   )FT)F)T)r   FT)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  r\  arrayr  collectionsr   r   	functoolsr   typesr   r  r  	getLoggerr~  r&   r$   r  r+   r3   r   r6   r:   r=   rA   rB  rP   SingleSubstra   re   MultipleSubstAlternateSubstLigatureSubstReverseChainSingleSubstDevicer   ValueRecordr   	SinglePosr   PairPos
CursivePosAnchorMarkBasePos
MarkLigPosMarkMarkPosr	  r  ContextSubstChainContextSubst
ContextPosChainContextPosr  r  ExtensionSubstExtensionPosr  r  r  r  r  r0  r  r  r.  r  r  r  r  r/  r6  r7  r;  r>  rN  rP  rT  rY  rr  r  r  MathGlyphConstructionr<  rI  rJ  rK  rR  rl  r  rc  r{  r  ra  r  r  r  r  r  r  r  __all__r   r'   r   <module>r0     sf  
  -  + ? 6 * - 6 9 " " 4 = 
    ,  A	 Uc P g*+Q S)
 	&W&&'?@A%0
 XA  A
 X6  6
 X   X9  9
 X   XS  S X  & XP  P
 X!!"K #K X!!" # X##$# %# X##$ % X$$%Y &Y X$$%! &! X##$ % X##$  %  X--.
5 /
5 X--.5 /5( X__) ) X!!"  #  X 5 !5 X  !> X*5 *5Z X7 7( X  !	5 "	5 X__	 	 X  ! " X!!"5 #54 X!!"	 #	 X  !5 "5> X  ! " X!!"5 #54 X!!"	 #	 $$		 $$ $$

 (1183S3S 	 	W?W?t X""H$>$>?l5 @l5^ 	W5W5t 	&5&5R 	55& X$$%5 &5 X$$%5 &5 X$$h&;&;<5 =5 X$$h&;&;<5 =5 X$$h&;&;<5 =5 X$$h&;&;<5 =5 X__) )( X__	$ 	$ X__  X__) )
 X__I I X__E E X  !N "N
 X  ! " X  !) ") X  ! " X  !" ""* X  X!!"
 #
 X!!" # X!!"# ## X../ 0 X''( ) X''(	 )	 X../	( 0	( X''(, )," X$$h&6&67D 8D X$$h&6&67' 8' X__: : X__0 0 X  !	" "	" X  !Y "Y
  U  () *  U  () *  U  () *  U  () *:  U  (*=%*=*=f*EF G  U  (*=%*=*=f*EF9 G9  U  (*=%*=*=f*EF
 G
,  U  (*=%*=*=f*EF= G=  U  (*=%*=*=f*EF, G,.  U  (*=%*=*=f*EF
 G
$  U  (*=%*=*=f*EF8 G84  U  (*=%*=*=f*EF
 G
   U  (*=%*=*=f*EF G  U  (*=%*=*=f*EF2 G2>  U  (*=%*=*=f*EF+ G+\  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f  U  ()9( *9(x X++, - X""# $"  U  ()A *A  U  ()" *"6  U  ()) *)X  U  ()2 *2
 X//0- 1- X--./ // X""#$ $$ X##$	 %	 X""# $  U  () * !U!!&)//0 1:  U  () *   U  () *  U  () *&  U  () *  U  ()9 *90  U  ()
 *
  U  ()? *?D  U  () *  U  ()
 *
  U  () *>  U  () *$f*f f*R@& @&F
 { > >  > 'L
 ./N 0Nb	r'   