
    yYHh                   $   d dl mZ d dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZmZ d dl d dl d dlmZmZ d dlmZmZ d dlmZ d dl Z d dl!Z!d dl"Z"d dl#Z#d dl$m%Z%m&Z& d dl'm(Z( d dl)m*Z* dZ+de+z   dz   Z, e#jZ                  d      Z.ddZ/ e*e/e.      e._0         e e#jZ                  d            Z1d Z2d Z3 eejh                        d        Z5 eejh                        d        Z6 eejh                        d        Z7 eejh                        d         Z8 eejr                        d!        Z5 eejr                        d"        Z: eejr                        dd#       Z7 eejr                        d$        Z8 eejv                        d%        Z< eejv                        d&        Z= eej|                        d'        Z< eej|                        d(        Z= eej~                        d)        Z< eej~                        d*        Z= eej                        d+        Z< eej                        d,        Z= eej                        d-        Z< eej                        d.        Z= eej                        d/        ZC eej                        d0        ZE eej                        d1        Z= eej                        d2        ZG eej                        d3        Z= eej                        d4        ZG eej                        d5        Z= eej                        d6        ZE eej                        d7        ZG eej                        d8        Z= eej                        d9        ZG eej                        d:        Z= eej                        d;        ZG eej                        d<        Z= eej                        d=        ZG eejv                  ej|                  ej~                  ej                  ej                  ej                  ej                  ej                  ej                  ej                  ej                        d>        ZN eejv                  ej|                  ej~                  ej                  ej                  ej                  ej                  ej                  ej                  ej                  ej                        d?        ZO eejv                  ej|                  ej~                  ej                  ej                  ej                  ej                  ej                  ej                  	      d@        ZG eejv                  ej~                  ej                        dA        ZT eej|                  ej                  ej                  ej                        dB        ZT eej                  ej                  ej                  ej                        dC        ZU eej                  ej                        dD        Z< eej                  ej                  ej                  ej                        dE        Z= eej                  ej                  ej                  ej                        dF        ZN eej                  ej                  ej                  ej                        dG        ZO eej                        dH        Z< eej                        dI        ZT eej                  ej                        dJ        Z= eej                  ej                        dK        ZG eej                  ej                        dL        ZN eej                  ej                        dM        ZO eej                        ddN       Z< eej                        dO        Z= eej                        dP        ZG eej                        dQ        ZN eej                        dR        ZO eej                        dS        ZT eej                        dT        Z= eej                        dU        ZG eej                        dV        ZN eej                        dW        ZZ eej                        dX        Z[ eej                        dY        ZN eej                        dZ        ZN eej                        d[        ZO eej                        d\        Z^ eej                        d]        ZN eej                        d^        ZN eej                        d_        ZO eej                        d`        Z^ eej                        da        Z^ eej                  ej                        db        Z^ eej                  ej                        dc        Zc eej                        ddd       Z^ eej                        de        Zc eej                        df        Z^ eej                        dg        Zc e ej                  dh            di        Z= e ej                  dj            dk        Z= e ej                  dl            dm        Z= e ej                  dn            do        Z< e ej                  dn       ej                  dp            dq        Z= e ej                  dn       ej                  dp            dr        Zg e ej                  dn       ej                  dp            ds        ZN e ej                  dn       ej                  dp            dt        ZZ e ej                  dn       ej                  dp            ddu       Zh e ej                  dn       ej                  dp            dv        Zi e ej                  dn       ej                  dp            dw        Zj e ej                  dn       ej                  dp            dx        Zk e ej                  dn       ej                  dp            dy        Zl e ej                  dn       ej                  dp            dz        Zm e ej                  dn       ej                  dp            d{        ZG e ej                  d|            d}        Z=d~ Zn e ej                  d|            d        ZG e ej                  d            d        Zl e ej                  d            d        Z= e ej                  d            d        Z= e ej                  d            d        Z= e ej                  d            d        Z= e ej                  d            d        Z= e ej                  d            d        Z< e ej                  d            d        Z= e ej                  d            d        Z= e ej                  d            d        Zl e ej                  d            d        Z=d Zo e ej                  d            d        Z= e ej                  d            d        Z= e ej                  d            d        Z= e ej                  d            d        Z= e ej                  d            d        Zl e ej                  d            d        Z= e ej                  d            d        Z=d Zp e ej                  d            d        Z< e ej                  d            d        Z= e ej                  d            d        ZG eej                        d        Z< eej                        d        Z< e ej                  d            d        Z= e ej                  d            d        Z< e ej                  d            d        ZG e ej                  d            d        Z< eej                        d        Z= eej                        d        Z= eej                        d        Z= eej                        d        Z= eej                        d        Z= e ej                  d            d        Z= e ej                  d      j                        d        Zy e ej                  d            d        Z< e ej                  d            d        Zl e ej                  d            d        Z= e ej                  d            d        ZG e ej                  d            d        Z< e ej                  d            d        Zl e ej                  d            d        Z= e ej                  d            d        Zl e ej                  d            d        Zlh dãZz e ej                  dī            dń        ZGddƄZ{ e ej                  dǫ            dȄ        ZG G dɄ de|      Z} G d˄ de|      Z~ e1dͫ      dd΄       Z e1dϫ      dЄ        Zdф Zd҄ Zdӄ ZdԄ Z e1dի      ddք       Zg dעZy)    )annotations)config)otRound)ttLib)otTables)USE_HARFBUZZ_REPACKER)
maxCtxFont)NullPen)Timer)makeOutputFileName)_add_method
_uniq_sort)*)varStoremultiVarStore)NameRecordVisitormakeName)mirroredN)Counterdefaultdict)reduce)
MethodTypez3pyftsubset font-file [glyph...] [--option=value]...a  pyftsubset -- OpenType font subsetter and optimizer

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

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

Usage: a9  

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

Args:

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

Initial glyph set specification
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

These options populate the initial glyph set. Same option can appear
multiple times, and the results are accummulated.

--gids=<NNN>[,<NNN>...]
  Specify comma/whitespace-separated list of glyph IDs or ranges as decimal
  numbers.  For example, --gids=10-12,14 adds glyphs with numbers 10, 11,
  12, and 14.

--gids-file=<path>
  Like --gids but reads from a file. Anything after a '#' on any line is
  ignored as comments.

--glyphs=<glyphname>[,<glyphname>...]
  Specify comma/whitespace-separated PS glyph names to add to the subset.
  Note that only PS glyph names are accepted, not gidNNN, U+XXXX, etc
  that are accepted on the command line.  The special string '*' will keep
  the entire glyph set.

--glyphs-file=<path>
  Like --glyphs but reads from a file. Anything after a '#' on any line
  is ignored as comments.

--text=<text>
  Specify characters to include in the subset, as UTF-8 string.

--text-file=<path>
  Like --text but reads from a file. Newline character are not added to
  the subset.

--unicodes=<XXXX>[,<XXXX>...]
  Specify comma/whitespace-separated list of Unicode codepoints or
  ranges as hex numbers, optionally prefixed with 'U+', 'u', etc.
  For example, --unicodes=41-5a,61-7a adds ASCII letters, so does
  the more verbose --unicodes=U+0041-005A,U+0061-007A.
  The special strings '*' will choose all Unicode characters mapped
  by the font.

--unicodes-file=<path>
  Like --unicodes, but reads from a file. Anything after a '#' on any
  line in the file is ignored as comments.

--ignore-missing-glyphs
  Do not fail if some requested glyphs or gids are not available in
  the font.

--no-ignore-missing-glyphs
  Stop and fail if some requested glyphs or gids are not available
  in the font. [default]

--ignore-missing-unicodes [default]
  Do not fail if some requested Unicode characters (including those
  indirectly specified using --text or --text-file) are not available
  in the font.

--no-ignore-missing-unicodes
  Stop and fail if some requested Unicode characters are not available
  in the font.
  Note the default discrepancy between ignoring missing glyphs versus
  unicodes.  This is for historical reasons and in the future
  --no-ignore-missing-unicodes might become default.

Other options
^^^^^^^^^^^^^

For the other options listed below, to see the current value of the option,
pass a value of '?' to it, with or without a '='. In some environments,
you might need to escape the question mark, like this: '--glyph-names\?'.

Examples::

    $ pyftsubset --glyph-names?
    Current setting for 'glyph-names' is: False
    $ pyftsubset --name-IDs=?
    Current setting for 'name-IDs' is: [0, 1, 2, 3, 4, 5, 6]
    $ pyftsubset --hinting? --no-hinting --hinting?
    Current setting for 'hinting' is: True
    Current setting for 'hinting' is: False

Output options
^^^^^^^^^^^^^^

--output-file=<path>
  The output font file. If not specified, the subsetted font
  will be saved in as font-file.subset.

--flavor=<type>
  Specify flavor of output font file. May be 'woff' or 'woff2'.
  Note that WOFF2 requires the Brotli Python extension, available
  at https://github.com/google/brotli

--with-zopfli
  Use the Google Zopfli algorithm to compress WOFF. The output is 3-8 %
  smaller than pure zlib, but the compression speed is much slower.
  The Zopfli Python bindings are available at:
  https://pypi.python.org/pypi/zopfli

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

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

Glyph set expansion
^^^^^^^^^^^^^^^^^^^

These options control how additional glyphs are added to the subset.

--retain-gids
  Retain glyph indices; just empty glyphs not needed in-place.

--notdef-glyph
  Add the '.notdef' glyph to the subset (ie, keep it). [default]

--no-notdef-glyph
  Drop the '.notdef' glyph unless specified in the glyph set. This
  saves a few bytes, but is not possible for Postscript-flavored
  fonts, as those require '.notdef'. For TrueType-flavored fonts,
  this works fine as long as no unsupported glyphs are requested
  from the font.

--notdef-outline
  Keep the outline of '.notdef' glyph. The '.notdef' glyph outline is
  used when glyphs not supported by the font are to be shown. It is not
  needed otherwise.

--no-notdef-outline
  When including a '.notdef' glyph, remove its outline. This saves
  a few bytes. [default]

--recommended-glyphs
  Add glyphs 0, 1, 2, and 3 to the subset, as recommended for
  TrueType-flavored fonts: '.notdef', 'NULL' or '.null', 'CR', 'space'.
  Some legacy software might require this, but no modern system does.

--no-recommended-glyphs
  Do not add glyphs 0, 1, 2, and 3 to the subset, unless specified in
  glyph set. [default]

--no-layout-closure
  Do not expand glyph set to add glyphs produced by OpenType layout
  features.  Instead, OpenType layout features will be subset to only
  rules that are relevant to the otherwise-specified glyph set.

--layout-features[+|-]=<feature>[,<feature>...]
  Specify (=), add to (+=) or exclude from (-=) the comma-separated
  set of OpenType layout feature tags that will be preserved.
  Glyph variants used by the preserved features are added to the
  specified subset glyph set. By default, 'calt', 'ccmp', 'clig', 'curs',
  'dnom', 'frac', 'kern', 'liga', 'locl', 'mark', 'mkmk', 'numr', 'rclt',
  'rlig', 'rvrn', and all features required for script shaping are
  preserved. To see the full list, try '--layout-features=?'.
  Use '*' to keep all features.
  Multiple --layout-features options can be provided if necessary.
  Examples:

    --layout-features+=onum,pnum,ss01
        * Keep the default set of features and 'onum', 'pnum', 'ss01'.
    --layout-features-='mark','mkmk'
        * Keep the default set of features but drop 'mark' and 'mkmk'.
    --layout-features='kern'
        * Only keep the 'kern' feature, drop all others.
    --layout-features=''
        * Drop all features.
    --layout-features='*'
        * Keep all features.
    --layout-features+=aalt --layout-features-=vrt2
        * Keep default set of features plus 'aalt', but drop 'vrt2'.

--layout-scripts[+|-]=<script>[,<script>...]
  Specify (=), add to (+=) or exclude from (-=) the comma-separated
  set of OpenType layout script tags that will be preserved. LangSys tags
  can be appended to script tag, separated by '.', for example:
  'arab.dflt,arab.URD,latn.TRK'. By default all scripts are retained ('*').

Hinting options
^^^^^^^^^^^^^^^

--hinting
  Keep hinting [default]

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

Optimization options
^^^^^^^^^^^^^^^^^^^^

--desubroutinize
  Remove CFF use of subroutinizes.  Subroutinization is a way to make CFF
  fonts smaller.  For small subsets however, desubroutinizing might make
  the font smaller.  It has even been reported that desubroutinized CFF
  fonts compress better (produce smaller output) WOFF and WOFF2 fonts.
  Also see note under --no-hinting.

--no-desubroutinize [default]
  Leave CFF subroutinizes as is, only throw away unused subroutinizes.

Font table options
^^^^^^^^^^^^^^^^^^

--drop-tables[+|-]=<table>[,<table>...]
  Specify (=), add to (+=) or exclude from (-=) the comma-separated
  set of tables that will be be dropped.
  By default, the following tables are dropped:
  'BASE', 'JSTF', 'DSIG', 'EBDT', 'EBLC', 'EBSC', 'PCLT', 'LTSH'
  and Graphite tables: 'Feat', 'Glat', 'Gloc', 'Silf', 'Sill'.
  The tool will attempt to subset the remaining tables.

  Examples:

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

  --drop-tables+=GSUB
      * Drop the default set of tables and 'GSUB'.

  --drop-tables=DSIG
      * Only drop the 'DSIG' table, keep all others.

  --drop-tables=
      * Keep all tables.

--no-subset-tables+=<table>[,<table>...]
  Add to the set of tables that will not be subsetted.
  By default, the following tables are included in this list, as
  they do not need subsetting (ignore the fact that 'loca' is listed
  here): 'gasp', 'head', 'hhea', 'maxp', 'vhea', 'OS/2', 'loca', 'name',
  'cvt ', 'fpgm', 'prep', 'VMDX', 'DSIG', 'CPAL', 'MVAR', 'cvar', 'STAT'.
  By default, tables that the tool does not know how to subset and are not
  specified here will be dropped from the font, unless --passthrough-tables
  option is passed.

  Example:

   --no-subset-tables+=FFTM
      * Keep 'FFTM' table in the font by preventing subsetting.

--passthrough-tables
  Do not drop tables that the tool does not know how to subset.

--no-passthrough-tables
  Tables that the tool does not know how to subset and are not specified
  in --no-subset-tables will be dropped from the font. [default]

--hinting-tables[-]=<table>[,<table>...]
  Specify (=), add to (+=) or exclude from (-=) the list of font-wide
  hinting tables that will be dropped if --no-hinting is specified.

  Examples:

  --hinting-tables-=VDMX
      * Drop font-wide hinting tables except 'VDMX'.
  --hinting-tables=
      * Keep all font-wide hinting tables (but strip hints from glyphs).

--legacy-kern
  Keep TrueType 'kern' table even when OpenType 'GPOS' is available.

--no-legacy-kern
  Drop TrueType 'kern' table if OpenType 'GPOS' is available. [default]

Font naming options
^^^^^^^^^^^^^^^^^^^

These options control what is retained in the 'name' table. For numerical
codes, see: http://www.microsoft.com/typography/otspec/name.htm

--name-IDs[+|-]=<nameID>[,<nameID>...]
  Specify (=), add to (+=) or exclude from (-=) the set of 'name' table
  entry nameIDs that will be preserved. By default, only nameIDs between 0
  and 6 are preserved, the rest are dropped. Use '*' to keep all entries.

  Examples:

  --name-IDs+=7,8,9
      * Also keep Trademark, Manufacturer and Designer name entries.
  --name-IDs=
      * Drop all 'name' table entries.
  --name-IDs=*
      * keep all 'name' table entries

--name-legacy
  Keep legacy (non-Unicode) 'name' table entries (0.x, 1.x etc.).
  XXX Note: This might be needed for some fonts that have no Unicode name
  entires for English. See: https://github.com/fonttools/fonttools/issues/146

--no-name-legacy
  Drop legacy (non-Unicode) 'name' table entries [default]

--name-languages[+|-]=<langID>[,<langID>]
  Specify (=), add to (+=) or exclude from (-=) the set of 'name' table
  langIDs that will be preserved. By default only records with langID
  0x0409 (English) are preserved. Use '*' to keep all langIDs.

--obfuscate-names
  Make the font unusable as a system font by replacing name IDs 1, 2, 3, 4,
  and 6 with dummy strings (it is still fully functional as webfont).

Glyph naming and encoding options
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

Other font-specific options
^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

Application options
^^^^^^^^^^^^^^^^^^^

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

Example
^^^^^^^

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

  $ pyftsubset font.ttf --unicodes="U+0020-0025" \
    --layout-features=* --glyph-names --symbol-cmap --legacy-cmap \
    --notdef-glyph --notdef-outline --recommended-glyphs \
    --name-IDs=* --name-legacy --name-languages=*
zfontTools.subsetc                    | 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     R/var/www/html/planif/env/lib/python3.12/site-packages/fontTools/subset/__init__.py	<genexpr>z_log_glyphs.<locals>.<genexpr>  s     +O1OA,>+O   )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    #$AqtG$$$s   c                T    t        |       }|D cg c]  }||k  s	| |    c}S c c}w r   len)lindicescountis       r    _list_subsetr6     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'   r5   r   s       r    	intersectr9     s+     $DKK0@$!QAKA@@@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     5Qfq5s   	)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.r9   r'   )r&   r'   r3   r   s       r    subsetr@     s8     nnV$G"kk9Q&[19DKN :s   	88c                R    |D cg c]  }| j                   |    c}| _         yc c}w )zRemaps coverage.Nr'   )r&   coverage_mapr5   s      r    remaprD     s!     ,88a4;;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     <AT^^+<   r   )r   anyrH   items)r&   r'   r   vs   `   r    r9   r9     sT     <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   rG   rI   s     r    r!   z"intersect_class.<locals>.<genexpr>
  s     @(?1@   c              3  >   K   | ]  \  }}|k(  s|v s|  y wr   r   )r   r   rM   r'   klasss      r    r!   z"intersect_class.<locals>.<genexpr>  s!     RTQqEza6kqRs   )r<   rH   rL   )r&   r'   rR   s   ```r    intersect_classrS     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   rG   rI   s     r    r!   zsubset.<locals>.<genexpr>  s     &O1q'>&OrJ   r   )rH   rL   r   rK   listvaluesrD   )r&   r'   rD   	useClass0r   rM   r3   s   `      r    r@   r@     s     (,~~';';'=Mtq!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)rH   rL   index)r&   	class_mapr   rM   s       r    rD   rD   "  s8     9=8L8L8NO1a++ODNOs   Ac                ~    |j                   j                  fd| j                  j                         D               y )Nc              3  2   K   | ]  \  }}|v s|  y wr   r   )r   r   rM   
cur_glyphss      r    r!   z!closure_glyphs.<locals>.<genexpr>*  s     J$!Q!z/AJ   )r'   updatemappingrL   r&   sr^   s     `r    closure_glyphsrd   (  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   )ra   rL   r'   boolr&   rc   r   rM   s       r    subset_glyphsrh   -  sZ     ++-Aahh1=1DL s   A'A'A'c                    | j                   j                         D ]%  \  }}||v s|j                  j                  |       ' y r   )ra   rL   r'   r`   )r&   rc   r^   glyphsubsts        r    rd   rd   5  s:    **, #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   rB   )r   subrc   s     r    r!   z subset_glyphs.<locals>.<genexpr>A  s      >S >rJ   )ra   rL   r'   allrf   rg   s    `  r    rh   rh   <  sb     LL&&(Aq=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>H  s     W5qJeWr_   )r'   r`   
alternatesrL   rb   s     `r    rd   rd   F  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   rB   )r   rM   rc   s     r    r!   z subset_glyphs.<locals>.<genexpr>P  s      >1ahh >rJ   )rs   rL   r'   rK   rf   )r&   rc   r   rr   rM   s    `   r    rh   rh   K  s     --/ Au=S > >> 	
u.!QXXA..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   rB   r   crc   s     r    r!   z+closure_glyphs.<locals>.<genexpr>.<genexpr>Y  s     0V1ahh0VrJ   N)ro   	ComponentLigGlyph)r   r   seqsseqr^   rc   s       r    r!   z!closure_glyphs.<locals>.<genexpr>X  sG      

4J &*WcS0V0V-VS\\W

Ws   A#AAA)r'   r`   	ligaturesrL   rb   s    ``r    rd   rd   U  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   rB   ry   s     r    r!   z subset_glyphs.<locals>.<genexpr>g  s     /U!QXX/UrJ   )r   rL   r'   r|   ro   r{   rf   )r&   rc   r   rM   r}   r~   s    `    r    rh   rh   `  s    '+~~';';'=Otq!ahhadODN ~~++-  At 	

||qxx'C/Us}}/U,U 
 	
DN (,~~';';'=Ctq!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?   ry   s     r    r!   z!closure_glyphs.<locals>.<genexpr>s  s&      "
 KK!"
   %(c              3  <   K   | ]  }j                   |     y wr   )
Substituter   r5   r&   s     r    r!   z!closure_glyphs.<locals>.<genexpr>x  s     <q*<s   unknown format: %s)FormatCoverager9   ro   LookAheadCoverageBacktrackCoverager'   r`   )r&   rc   r^   r3   s   ``  r    rd   rd   o  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'   ry   s     r    r!   z subset_glyphs.<locals>.<genexpr>  s&       "r   r   )r   r   r@   r'   r6   r   r8   rD   r1   
GlyphCountrf   ro   r   r   )r&   rc   r3   r5   rn   s    `   r    rh   rh   }  s    {{a--&&qxx0&t@#,T__#=QC1Q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&   namerM   s      r    prune_hintsr     s6    H  D$%=Q\\^D$ 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   r1   r   r@   r'   Value
ValueCountrf   )r&   rc   r3   rW   r4   r5   s         r    rh   rh     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   rM   s     r    r!   z$prune_post_subset.<locals>.<genexpr>  s     5QqDy5s   c              3  B   K   | ]  }|j                   d    k(    ywr   N)r   )r   rM   r&   s     r    r!   z$prune_post_subset.<locals>.<genexpr>  s     GqTZZ] 2Gs   )r   ValueFormatr   hintingr   getEffectiveFormatro   r   int__or__r   )r&   r(   optionsrM   s   `   r    prune_post_subsetr     sG   zz1$$$ {{aJJ""$::88:		4::##q(((5$**5555?? $AMMO$%

TZZHQ113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rD   F)rD   rX   r   )r   r   r@   r'   PairSetr1   PairValueRecordSecondGlyphPairValueCountr8   rD   r6   PairSetCountrf   	ClassDef1intersectionClass1Count	ClassDef2Class2CountClass1RecordClass2Record)r&   rc   r3   pairsr4   r5   prrz   
class1_map
class2_maps              r    rh   rh     s   {{a--&&qxx0E
*1?QQYa? 	6A,,!0I!A  #1#4#45A		6 "+4<<!8MAA<L<L1MMG$#DLL':-D%%&&		 ^^**%%dmm&:&:;4 + 
 4###	 

 
 ^^**18845*Q
4### 

 

 <FFaT..q1F"" 	EA9CDAannQ/DAN	E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   Value2rf   )r&   r(   r   attr1attr2rowr   s          r    r   r     s    ??-/
 ++u
 121D-4' 	GCS%( G88HH((*%%)D)D)FF%88HH((*%%)D)D)FF%G	G !!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'   EntryExitRecordr1   EntryExitCountrf   )r&   rc   r3   recordsr4   r5   s         r    rh   rh     s    {{a--&&qxx0&&G4;Iqq5y
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		4 	*DdD)A}dD)	* $):):)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   +  sQ    ??'' 	-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>D       "Nq177"N   r   )r   MarkCoverager@   r'   r6   	MarkArray
MarkRecordr1   	MarkCountBaseCoverage	BaseArray
BaseRecord	BaseCountr   
ClassCountrZ   r   
BaseAnchorrf   )r&   rc   mark_indicesbase_indicesclass_indicesmbs          r    rh   rh   6  s   {{a((//9$0NN%%|%
! $'t~~'@'@#A ((//9$0NN%%|%
! $'t~~'@'@#A ""NDNN4M4M"NNm,** 	3A#))!''2AG	3** 	EA'mDAL	E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   Q  sx    ??** 	+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>l  r   r   r   )r   r   r@   r'   r6   r   r   r1   r   LigatureCoverageLigatureArrayLigatureAttachLigatureCountr   r   rZ   r   ComponentRecordLigatureAnchorrf   )r&   rc   r   ligature_indicesr   r   r2   rz   s           r    rh   rh   ^  s   {{a((//9$0NN%%|%
! $'t~~'@'@#A 0077A,8--/?-
) ,/t/A/A/P/P+Q(""NDNN4M4M"NNm,** 	3A#))!''2AG	3##22 	QAy&& Q#/0@0@-#P Q	Q
 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   r2   rz   r   s          r    r   r   ~  s    ??** 	+A||((*	+ ##22 	(Ay&& ()) (A((	( 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     "Oq177"Or   r   )r   Mark1Coverager@   r'   r6   
Mark1Arrayr   r1   r   Mark2Coverage
Mark2ArrayMark2Recordr   r   rZ   r   Mark2Anchorrf   )r&   rc   mark1_indicesmark2_indicesr   r   r   s          r    rh   rh     s   {{a**11!((;%1OO&&&
" %((B(B$C!**11!((;&2OO'''
# %((C(C$D!""ODOO4N4N"OOm,++ 	3A#))!''2AG	3,, 	GA(FAM	G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     sx    ??++ 	+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>  
    QZZ r*   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>      r*   c                     y)N)NNNr   r   s    r    r!  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>  r&  r*   c                    | j                   fS r   )Inputr   s    r    r!  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>!      aggZ r*   c                H    | j                   | j                  | j                  fS r   	Backtrackr)  	LookAheadr   s    r    r!  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>"      1;;*M r*   c                6    |\  | _         d |D        \  | _        y )Nc              3  8   K   | ]  }t        |      d z     ywr   Nr0   r   xs     r    r!   za__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetRuleData.<locals>.<genexpr>&       &=as1vz&=   )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.  r1   BacktrackGlyphCountInputGlyphCountLookAheadGlyphCountr7  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>1  r"  r*   c                    | j                   S r   r  r   s    r    r!  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>2  r$  r*   c                    | j                   fS r   ClassDefr   s    r    r!  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>3  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>4  s"    ''OO''. r*   c                    |\  | _         y r   rE  r7  s     r    SetContextDatazQ__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetContextData:  s    $%MQZr*   c                .    |\  | _         | _        | _        y r   rH  r7  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>A  r/  r*   c                6    |\  | _         d |D        \  | _        y )Nc              3  8   K   | ]  }t        |      d z     ywr2  r0   r3  s     r    r!   za__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetRuleData.<locals>.<genexpr>E  r5  r6  )r   r   r7  s     r    r8  zN__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetRuleDataC  r9  r*   c                    |\  | _         | _        | _        t        |d         t        |d         dz   t        |d         c| _        | _        | _        y r;  r<  r7  s     r    r@  zS__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.ChainSetRuleDataG  rA  r*   c                     | j                   d   S Nr   r  r   s    r    r!  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>P  s    QZZ] r*   c                     | j                   d   S rV  )InputCoverager   s    r    r!  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>Q  s    !//!*< r*   c                    | j                   S r   r  r   s    r    r!  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>V  r"  r*   c                N    | j                   | j                  z   | j                  z   S r   )r   rX  r   r   s    r    r!  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>W  s$    ''!//9A<O<OO r*   c                6    |\  | _         d |D        \  | _        y )Nc              3  2   K   | ]  }t        |        y wr   r0   r3  s     r    r!   za__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetRuleData.<locals>.<genexpr>]  s     &9!s1v&9   )r   r   r7  s     r    r8  zN__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.SetRuleData[  s    $%MQZ&9q&9OQ\r*   c                f    |\  | _         | _        | _        d |D        \  | _        | _        | _        y )Nc              3  2   K   | ]  }t        |        y wr   r0   r3  s     r    r!   zf__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.ChainSetRuleData.<locals>.<genexpr>e  s     +AQ+r]  )r   rX  r   r=  r>  r?  r7  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'   rz   r   s      r    r!  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>|  s    Q&[qc b r*   	ClassRuleClassRuleCountClassSetClassSetCountc                ^    |r|j                  | |      S |dk(  rt        |       S t               S rV  )rS   r<   re  s      r    r!  zK__subset_classify_context.<locals>.ContextHelper.__init__.<locals>.<lambda>  s<     %%fa0  *+a#f+  69U r*   rJ  rF  r)  r   rX  r   )__name__endswith
startswithTypTyper  ChainTypInputIdxDataLenr  r   ContextDatarM  RuleDatar8  r`  ra  rb  rc  	IntersectrF  ClassDefIndexr)  )r&   rR   r   rn  ro  r  rq  rr  rp  r   ChainCoveragers  ChainContextDatarM  rO  rt  ChainRuleDatar8  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)rk  
__module____qualname__rz  r   r*   r    ContextHelperr    s	    L	Fr*   r}  r   _subset__ContextHelpers)objectr   hasattr	__class__r~  )r&   r}  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   ru  r'   r   krz   cdrc   s     r    r!   z+closure_glyphs.<locals>.<genexpr>.<genexpr>  "     DAHHb!4D   '*Nro   r   klistr  rz   rc   s     @r    r!   z!closure_glyphs.<locals>.<genexpr>  (      !E De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   r4  rc   s     r    r!   z!closure_glyphs.<locals>.<genexpr>  s*     Uq1D=:Q[[%::U   +.r   )r  r   r9   r=   r   rs  r   rb  rc  r`  ro   ziprt  r<   r  SequenceIndex	frozensetr'   r)  table
LookupListLookupLookupListIndexaddr  r`   ranger1   rd   rF  rS   )r&   rc   r^   r3   rs  rssrssCountr5   r   chaosllseqi
pos_glyphslookuprF  input_coveragesrz   s    `              @r    rd   rd     s   &&(Ajj((4G	D!22:>J{{ammD)dAII&40 	DAH}CFSVQVV, D %(ajjm%D  !!Q^^4 DB ++Du}%)
19)2AJJt4D4K4KA4N3O)PJ)2AGGD1H4E3F)GJWW//66r7I7IJFIIdO//1U4QWW1A%BC))!
)C!DD	D: 
	4,$$Z0mmD)dAII&40 "	DAH}CFSVQVV, D %(ajjm%D  !!Q^^4 DB ++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-DD"	D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   rB   )r   r   rc   s     r    r!   z*subset_glyphs.<locals>.<genexpr>.<genexpr>  s     9aAM9rJ   Nr  )r   glistrc   s     r    r!   z subset_glyphs.<locals>.<genexpr>  s     Ue9599Us   !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>D  s     61Y6s   Nr  )r   r  r  s     @r    r!   z subset_glyphs.<locals>.<genexpr>C  s(      (	5 666s   !$r   c              3  `   K   | ]%  }|d uxr |j                  j                         ' y wr   r   r  s     r    r!   z subset_glyphs.<locals>.<genexpr>c  s*     RA1D=7QXXahh%77Rr  r   )r  r   r   r@   r'   r   rb  rc  r`  ro   rt  r   ra  r1   r8   rD   r6   rf   rs  rv  rF  r9   r  r8  rZ   )r&   rc   rz   r3   r  r  r5   rsssr   rs  r4  
klass_mapsr  r  r  s    `              r    rh   rh     sL    	&&(A{{a--&&qxx0dAII&40&7!!h,s1v77 	.BQVV$B UqzzRS}UU B  B#BSW-	. #,C.OBB72qvv;N1OOG$3(aii%annc#h/Cy		}}##AHH-mmD)CN
>?aAHHQXXTH*T9

 

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

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

10N ,Iu 6;;+;#	6 EHHbRGB/rT9H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   rb  r`  r   r  r  rZ   )r&   r  rz   r  r   r  s         r    r  r  h  s    	&&(A{{f$		* 	RBR( RNN #*!Q^^"<""4"4"F  "!Q^^4 RB )7)=)=b>P>P)QB&RR	R& 
	NN "$7",,> 	
 $/ 	JB!/!5!5b6H6H!IB	J
 	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   rb  r`  r  r  )r&   rz   r  r   r  s        r    r  r    s     	&&(A{{f dAII.
 
R(	
 a0
  


 	
 
	-4T1>>-JQrb""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   ExtSubTablerd   rb   s      r    rd   rd     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  rh   r&   rc   s     r    rh   rh     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getr1   r<   issubsetr`   SubTablerd   )r&   rc   r^   keydoneLookupsr4   coveredsts           r    rd   rd     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  rh   r1   SubTableCountr  r  used_mark_sets
LookupFlagrZ   rf   )r&   rc   r  s      r    rh   rh     s    "&--NB2":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     s<    
Cmm g.C	
 Jr*   c                H    | j                   D ]  }|j                  |        y r   )r  r  )r&   r  rc   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""$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##%Dr  )rK   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.)r8   r  rh   )r&   rc   r5   r2   s       r    rh   rh     s2     $DKK0M$!QA!//!:LAMMMs   
>>>c                \    d}| j                   D ]  }|s|j                  ||      sd} |S r  )r  r   )r&   r(   r   r  r2   s        r    r   r   #  s<    
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  r1   r  r&   r  r5   r2   s       r    r  r  .  sm    +9RaQ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  r8   r  r  s       r    neuter_lookupsr  7  sE     	7@7M/3q!Q. d*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>G  s/     W!!dFVFVBVT[[^++-Ws   :":)r   r  r  extend)r&   r  recurserecurse_lookupsr2   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  rZ   r1   r  
isinstanceFeatureParamsr   FeatureParamsSize)r&   r  r2   s      r    r  r  V  s     (,';';S!qN?RASD=A=Q=QRN003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)r8   FeatureRecordFeaturer  
FeatureTag)r&   r  r5   fs       r    r  r  e  sP     d001AqII$$^48N 	
  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>v  s>      	
4$$$ q!))99	
s   <?)r  r&   feature_indicess   ` r    r  r  s  s"    	
$	

 	 r*   c                    | j                          t        | j                  |      | _        t        | j                        | _        t        | j                        S r   )r  r6   r  r1   r  rf   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    s@    
 ((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*      	
 &&55nE	
r   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>  sP      	
00CC	
 ~~0 II%%	
%	
s   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  rZ   r1   SubstitutionCountrf   r&   r  r   s      r    r  r    s    **ann.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  popr1   FeatureVariationCountrf   r  s      r    r  r    s    (( D	""22?CD
 	##++

"
"#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  )ReqFeatureIndexrZ   r  r1   r  rf   )r&   r  r  s      r    r  r    s    ..44T5I5IJ$$($5$5Nqo9MND +/*;*;%&qO?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LangSysr1   LangSysCountrf   )r&   r  keepEmptyDefaultLangSysr2   s       r    r  r    s     	##33OD'"%%)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&   r2   r  s      r    r  r    sf    =A=O=OPqyy113PO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  	ScriptTagr1   ScriptCountrf   )r&   r  retain_emptyrc   s       r    r  r    sp    
 ""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   rc   s     r    r!   z#collect_features.<locals>.<genexpr>  s     R1188446Rs   $&)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&   rc   strikeindexSubTablenr5   s         r    rh   rh   
  s    ,, N#22 	TM.;.A.A"SQ!((]1"SM	T,2,A,A MqQWW MN  $||@!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&   rc   r'  r   r,  s        r    rh   rh     sj     GKoo<Bqxx7!1;F1I7J 
 -7A&&v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$  rW   r'   )r&   rc   r'  r   s       r    rh   rh   !  sZ    ,,%%' V67hhU!v}}BTFMM!,,UV  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   r2  r   r  r  r  r'   r  r  rd   )r&   rc   r  r  orig_glyphsr5   s         r    rd   rd   )  sN   jjAGzz**//@@Bzz//??Ptzz.5$**66FFWW/Nzz#AHH-K# B

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

%%,,Q/>>qAB ahh&  N	r*   GPOSc                    |j                   |_        | j                  j                  r&| j                  j                  j	                  |      }ng }| j                  |       yr   )glyphs_gsubedr'   r  r  rh   r  )r&   rc   r  s      r    rh   rh   G  sJ    AHzz..<<Q?'r*   c                F    | j                   t        j                  d      k(  S )Nr/  )r  r   getTableClassr   s    r    retain_empty_scriptsr;  R  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.r2  N)
r  r  r  r4  r   r2  r   r  r3  r;  )r&   r  r  s      r    r  r  Y  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  p  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 lookupsr2  N)r  r3  r  r4  r  r   r2  r   r  r  r  r  )r&   rD   r  r  s       r    prune_lookupsr?  w  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 r1  )
r  r4  r8   r  r  r  r   r2  r3  r;  )r&   feature_tagsr5   r  r  s        r    subset_feature_tagsrB    s    zz "$**"8"8"F"FG
1|||+ 
 

 	

..?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)r<   splitr  ljust
setdefaultr  r3  r  r  r1   r  r  r  
LangSysTagr  r  )
r&   tagslangsysscript_tagstag
script_taglang_tagrc   recordr2   s
             r    subset_script_tagsrR    s   G%K E14syy~#s
H
((+,:su-11(..2CDE
 zzzz,,99.
Q[[K=WA.


* -0

0E0E0R0R,S

)jj++88 		8F7*vWVEUEU=V/V $]]88/||wv/?/?'@@ /+
 .11L1L-M*)9)9!::37FMM0		8 .
/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 featuresr2  N)r  r3  r  r4  r  r   r2  r;  r  s     r    prune_featuresrT    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_scriptsrR  layout_featuresrB  r?  r  s      r    prune_pre_subsetrX    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  r3  r4  r  r  r  r  r  r  r1   r  r  r  remove)r&   r  featuresrc   r-   lrr2   r5   s           r    remove_redundant_langsysr]    sR   JJE5#4#4  ..H** 2HH##((((+ 	2B

A1>>"c!..&99!!U*0A0AU0JK  E)A--.(1;L;L2MM3q~~./ 2ANN1-.(1>>!;L2MM2
 &&--b1#	2	2r*   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)Nr2  i     T)r  r?  r  r   r4  r]  rT  r  r2  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)r8  r  LigCaretListr   r@   r6   r|   r1   LigGlyphCountMarkAttachClassDefrH   rL   GlyphClassDef
AttachListr   AttachPointr  rd  r8   r'   r  )r&   rc   r'   r  r3   r   rM   r   r5   markGlyphSetscoveragerz   s               r    rh   rh   )  sE   __FJJE$$--44V<&253E3E3N3NPW&X#+.u/A/A/J/J+K("55??EEG.
Q1PV;AqD.
  * "00::@@B)
Qa6kAqD)
% ""++226:%%00
5<(
01JE((+(
$ '*%*:*:*F*F&G#u()e.D.D..%.. 	(H'	( +4M4J4J*KX$!QqxxAX-:-C-C!Pqxx!!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 )Nrb  VarStorer6  )r  r  rn  r<   collect_device_varidxessubset_varidxesremap_device_varidxes)r(   gdefr  storeusedVarIdxes
varidx_maps         r    
_pruneGDEFrv  L  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 )Nrn  r   i  i  rd  r_  )r  re  rf  rg  rH   rh  ri  r   r  rv  rn  VarDataCountr`  rd  r   rf   ra  s       r    r   r   f  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  rf   r&   r(   r   ts       r    rX  rX    s8     #'//MQWQ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   )r8  r|  r{  rL   rf   )r&   rc   r'   r~  r   r   rM   s          r    rh   rh     s    __F__ 
 [[..0
 
AF{qF{ FAI

 #'//AQQ[[qADO  

 Bs   B!
.B( B(vmtxc                    t        | j                  |j                        | _        |j                  D ]  }d| j                  |<    t	        | j                        S )Nr   r   )r.   metricsr'   glyphs_emptiedrf   r&   rc   r   s      r    rh   rh     sI    ahh7DL ! Q!r*   hmtxc                    t        | j                  |j                        | _        |j                  D ]  }d| j                  |<    y)Nr  T)r.   r  r'   r  r  s      r    rh   rh     s=    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 rV  )r  rL   r.   r'   r  rf   )r&   rc   szr2   r   s        r    rh   rh     s    <@IIOO<MN52q\!QXX..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'   Anchorsr1   r&   rc   r  rj   s       r    rh   rh     s    JJ##E<<1G85<<GG12(-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&   rc   r  s      r    rd   rd     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  DefaultBaseliner1   r   rW   most_commonrL   )r&   rc   r  rj   	baselines
mostCommon_cntr   s           r    rh   rh     s   JJE||v 
 5''++E53H3HII
	 
 y>A&y'7'7'9:FFqI!LJ$.E!2;//2CWheQqJWI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'   Caretsr1   r  s       r    rh   rh     s    JJ%%E||v45HH
+0@UE5<<&&
 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    rX  rX    s-    G$:$:.0*+r*   c                    t        | j                  |j                        | _        t        | j                        | _        t        | j                        S r   )r.   r  r'   r1   
glyphCountrf   r  s     r    rh   rh     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 rV  )ra   rL   last_retained_glyphreverseEmptiedGlyphMaplast_retained_order)	rc   ru  	table_mapr  rM   map_last_idxr   r5   s	            r    _remap_index_mapr    s    )2):):)@)@)BCAAz!}CDC )++A,A,ABCH((..0 ?1!"7"77(QQ?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  r<   AdvWidthMapr.   ra   r'   r`   rW   reverseOrigGlyphMapcopyr   retain_gidsLsbMapRsbMaprn  rp  r  r&   rc   r  used	advIdxes_retainAdvMapru  s          r    rh   rh    	  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  r<   AdvHeightMapr.   ra   r'   r`   rW   r  r  r   r  TsbMapBsbMapVOrgMaprn  rp  r  r  s          r    rh   rh   &	  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   )VOriginRecordsrL   r'   r1   numVertOriginYMetricsrg   s       r    rh   rh   Q	  sZ     ,,224AQXX1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'   OpticalBoundsDeltasr1   OpticalBoundsPointsr  s       r    rh   rh   Z	  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    rX  rX  o	  s    r*   c                    g | _         yr   )
extraNamesr  s     r    rh   rh   v	  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   rW   r  rL   r1   )r&   rc   r  r   r  r  s         r    rh   rh   |	  s+   ::%%D{{a%%**		GHxx
BCAt""1d&<&<==
 #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*   )r<   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 rV  )version_decompileColorLayersV0r  ColorLayersBaseGlyphListBaseGlyphPaintRecord	BaseGlyphPaintColorLayersV1r'   r<   r  r  r   r`   r  )r&   rc   r   	decomposelayersr   layerr  s           r    rd   rd   	  s*   ||a
  77

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

5::&' ||a**..q1$MM"4UDJJ"GH	I 	!((		 
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  rf   r  	LayerListr  r  ClipListclipsr  r   colorID)
r&   rc   r  r  r  r   colorGlyphsV1r  layersV0r  s
             r    rh   rh   	  s   :F AH )*#$A9I9I4I4AD ||qD$$%%!$**"6"6

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

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

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

LTUqhqkBUejj%--(B	B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
  si    5.)E../66u=UK(11 @ 1 1299$?@ )r*   r   r  r  r  r   )r  r   rV   r  r  rW   r  r  r  LayerRecordArrayLayerRecordr  r  r  r  r  r<   keyspalettesr8   r1   r$   r  AssertionErrornumPaletteEntriespaletteEntryLabelsrf   )r&   r(   r   r  r  r  r  rQ  retained_palette_indicespaletter5   rz   	new_index	old_indexkept_labelslabelr  s                   @r    r   r   	  sW    ~88FD!$'O@ ||q&&--/ 	=F =.55e<=	= ::&&44@@ B 2 23::5ABjj..CC 	GFLL!!$**.EF	G
  #?#7#7#9:fXE== =$-g$6XDAq!?W:WaX
7|s#;<<<<= !*&1I*J K -	9%i0 	-Fvy)!*0&/#$V,,	-- !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   )r<   MathGlyphVariantRecordr  VariantGlyphGlyphAssemblyPartRecordsrj   )r&   r'   variantsrM   r   s        r    rd   rd   0
  sg    uH(( %Q^^$%##// 	"ALL!	"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'   r<   VertGlyphCoverager9   r`   VertGlyphConstructionrd   HorizGlyphCoverageHorizGlyphConstruction)r&   rc   r'   r  r3   r5   s         r    rd   rd   ;
  s    qxx FuH((226: 	RAOOD66q9HHPQ	R ))33F; 	SAOOD77:II&QR	S HHOOHr*   VARCc                8   | j                   j                  j                  |j                        }t	        | j                   j
                  j                  |      | j                   j
                  _        t        | j                   j
                  j                        S r   )r  r   r@   r'   r6   VarCompositeGlyphsVarCompositeGlyphrf   r&   rc   r3   s      r    rh   rh   M
  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#  r8   r   r'   r$  r<   r  
components	glyphNamer  )r&   rc   r5   r(  glyphMapglyphRecordsr'   r  newoldNewidxrj   compr   s                 r    rd   rd   V
  s   zz$$,1:4::;N;N;U;U1VWI	1WH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  MultiVarStorer<   collect_varidxesrp  remap_varidxesAxisIndicesListItemr#  r$  r'  axisIndicesIndexr  r$   r6   r8   ConditionListConditionTableconditionIndex)r&   r(   r   r  rs  rt  ru  axisIndicesListusedIndicesrj   r.  r+  oldra   conditionListconditionTabless                   r    r   r   r
  sa   JJEEu|,**<8
Z(++00O"e--?? 	;E(( ;((4OOD$9$9:;	; [)%1/;%O",5k,BCS38CC--?? 	KE(( K((4,3D4I4I,JD)K	K
 ''M '66e--?? 	9E(( 9&&2OOD$7$789	9 [)'3O['Q$,5k,BCS38CC--?? 	GE(( G&&2*1$2E2E*FD'G	G
 - D  Ds   II%MATHc                |    | j                   j                  r&| j                   j                  j                  |       y y r   )r  MathVariantsrd   r  s     r    rd   rd   
  s,    zz

..q1 r*   c                    | j                   j                  |j                        }t        | j                  |      | _        t        | j                        | _        t        | j                        S r   )r   r@   r'   r6   ItalicsCorrectionr1   ItalicsCorrectionCountrf   r%  s      r    rh   rh   
  sS    mm""188,G)$*@*@'JD"%d&<&<"=D++,,r*   c                    | j                   j                  |j                        }t        | j                  |      | _        t        | j                        | _        t        | j                        S r   )TopAccentCoverager@   r'   r6   TopAccentAttachmentr1   TopAccentAttachmentCountrf   r%  s      r    rh   rh   
  sU    $$++AHH5G+D,D,DgND$'(@(@$AD!--..r*   c                    | j                   j                  |j                        }t        | j                  |      | _        t        | j                        | _        t        | j                        S r   )MathKernCoverager@   r'   r6   MathKernInfoRecordsr1   MathKernCountrf   r%  s      r    rh   rh   
  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   )MathItalicsCorrectionInforh   MathTopAccentAttachmentMathKernInfoExtendedShapeCoverager@   r'   r  s     r    rh   rh   
  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'   r6   r  r1   VertGlyphCountr  r   HorizGlyphCountr%  s      r    rh   rh   
  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  MathGlyphInforh   r@  r  s     r    rh   rh   
  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      rE  @          )datastructunpack	bytearrayr   )r&   
glyphidmapr_  r5   moreflagsglyphIDs          r    remapComponentsFastrg  
  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'   r<   getComponentNamesr  r`   )r&   rc   glyphSetr  r'  r   glrz   s           r    rd   rd     s    {{HI
U
 	"A !B))$/ "q!"		" 	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    rX  rX    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_  rW  r*   T)r.   r'   r   r  r8   r  rW   r  rg  r   getTableModuler  r  r_  )
r&   rc   r5   r   r3   r)  oglyphmaprM   r  s
             r    rh   rh     s6   t{{AHH5DK99  !*4??!;MAqAHH}1MM%.w%78TQAqD88##% 	0Aq&!%%h/	0   (..E "A!A" ??a188mqA<L<L7LDO  N8s   E"+E" E(3!E.E.c                    |j                    }| j                  j                         D ]  }|j                  |        y)N)remove_hintingT)r   r'   rW   trim)r&   r(   r   rt  rM   s        r    r   r   0  s;     (N[[! .	n-.r*   cmapc                   | j                   D cg c]  }|j                         s| }}|j                  j                  rUt	               }|j
                  D ]!  }t        |      }||j                  |       # |j
                  j                  |       |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   urv  s     r    r!   z!closure_glyphs.<locals>.<genexpr>R  s     :DG:r"   )tables	isUnicoder   bidi_closurer<   unicodes_requestedr   r  r`   formatuvsDictrL   rZ  r'   rv  r   r  r  unicodes_missingdifference_update)r&   rc   r~  r{  additional_unicodesrz  mirror_ur  varSelectorr   r'   r   rv  s               @r    rd   rd   8  s   6Aa6F6 	yy!e%% 	2A{H##''1	2 	
##$78  ;<<2%*]]%8%8%: (!Ta&:&::(,J1Q5I5I0I!JJ6>MM$''( ::D//<<TYY[ILHHOO:\::; --224A 9	,,UZZ899 7" Ks   GGG
6G
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_cmapr{  r|  isSymbolsymbol_cmapr  r1   numSubTablesr}  s       r    rX  rX  Z  s    "&++OQ!**,qO"&++BQQZZ\qB #kk;QXX]1;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   rx     r_  rE  rY  T)r'   r{  
platformID	platEncIDlanguager  r  rL   r~  glyphs_requestedr|  rv  maxr  r  rn  r1   r  )
r&   rc   tables_format12_bmptable_plat0_enc3table_plat3_enc1r~  rM   r2   rz  r   s
             r    rh   rh   h  s   AH[[ R<<1!1+,QZZ(<<1!1+,QZZ(88r> IIOO-  Aq,,,  !1A...!q7K7K2K F AI +,))//*;A$!QqAAAI[[] FFLLNAq***a13G3G.G 1AF xx2~!&&S-?'-I#**1-'(vv||~Qtq!a>P>P9PadQAF?RF ! LLAq 

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

.. ,11QVV;FFLLN  #kkWBaffAII1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    rX  rX    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    rX  rX    sP    ??
*DM%&D"DO#$D &'D#$%D!)*D&r*   >   r   r   r   rE              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                  j                  t              }|rt        ||       | 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   rE  z.	utf_16_be)r   r  r   r  )r  r  r  T)r   visitr<   name_IDsseenr&  nameIDname_legacyr|  name_languageslangIDobfuscate_namesr   NAME_IDS_TO_OBFUSCATE_remap_select_name_idsencodestringr  )r&   r(   r   visitornameIDsr)  namerecsneedRemappings           r    r   r     s   !GMM$'""#gll2G
gdjjCAHHsNAHHCC!ZZ?188w+>!?DJ "&=Aq{{}a=

'(((!%RAqxx7;Q;Q/QaR
  112GH"47 		Axx6!:;++-7>>+6WV#9:6==5FQ\)OOA		 
9 D? > Ss0   H,0H,H1%H1H6!H6	H;'H;c                   d| vrd| vry| d   }|j                   D ch c]  }|j                   }}i }|j                         dz
  }|D ]'  }|dz  }||vsJ d       |dkD  rt        d      |||<   ) g }|j                   D ]f  }|j                  |vrt	        |j
                  ||j                     |j                  |j                  |j                        }	|j                  |	       h |j                   j                  |       | j                  d      }
|
|
j                  D ]-  }|j                  |j                  |j                        |_        / |
j                  D ]H  }|j                  }|j                  ||      |_        |j                   }|j                  ||      |_        J | j                  d      }|y|j"                  j$                  }|j                  ||      |j"                  _        |j"                  j&                  rP|j"                  j&                  j(                  D ]-  }|j                  |j*                  |j*                        |_        / |j"                  j,                  rQ|j"                  j,                  j.                  D ]-  }|j                  |j0                  |j0                        |_        / yyc c}w )	a;  Remap a set of IDs so that the originals can be safely scrambled or
    dropped.

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

    Finally update references to these in the `fvar` and `STAT` tables.
    fvarSTATNr   r   z#_findUnusedNameID did not skip gapsi  z8Ran out of name IDs while trying to remap existing ones.)r&  r  _findUnusedNameID
ValueErrorr   r  r  r  r  r  r  r  axes
axisNameID	instancessubfamilyNameIDpostscriptNameIDr  ElidedFallbackNameIDDesignAxisRecordAxis
AxisNameIDAxisValueArray	AxisValueValueNameID)r(   r  r   rQ  existingIds	remappingnextIdnameIdcopiedRecords
recordCopyr  axisinstancer  statelidedNameIDvalues                    r    r  r    s    TfD0<D 04zz:V6==:K:I##%)F #![(O*OO(E>WXX"	&# M** 
)==-MMfmm$MM

 	Z(
) 	JJm$
 88FDII 	ND'mmDOOT__MDO	N 	FH--F'0}}VV'DH$..F(1ff(EH%		F 88FD|::22L&/mmL,&ODJJ#zz""JJ//44 	ND'mmDOOT__MDO	Nzz  ZZ..88 	TE )e.?.?ARAR SE	T !c ;s   K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rk  r{  r|  r   r*   r    OptionErrorr  C      r*   r  c                      e Zd Zy)Options.UnknownOptionErrorNr  r   r*   r    UnknownOptionErrorr  F  r  r*   r  )BASEJSTFr  r*  r"  EBSCPCLTLTSH)FeatGlatGlocSilfSill)avarr  gaspr  hhear  vheaOS/2locar   cvtfpgmprepVDMXr  r   MVARcvarr  )r  r  r  r  r  r  )rvrnccmpligaloclmarkmkmkrlig)fracnumrdnom)caltcligcursry  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| _,        d| _-         | j\                  di | y )NFTr   )r   r   r   r   rE     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_defaultrW  rV  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lazyr}  r<   )r&   kwargss     r    rz  zOptions.__init__  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')rL   r  r  r   )r&   rh  r  rM   s       r    r<   zOptions.set  sH    LLN 	 DAq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   -_rj  zCurrent setting for 'z' is: z5Option '%s' requires values to be specified using '=', r  r   
0123456789z+=z-=)rm  r  findrl  replacer  r  r   printr  rf   r   strrV   r  rG  r1   r  rZ  r   )r&   argvignore_unknownposargspassthru_optionsr   orig_ar5   opr  rM   okovvvr4  s                  r    
parse_optszOptions.parse_opts  s    F	 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Va3q6adl.Bc!QiIVV9A4ZAHHRL4ZA (6HHQK( !5D!QMF	 P )))! Ws   'IN)rk  r{  r|  	Exceptionr  r  rI  rK  rN  _layout_features_groupsr   r  iterrW   rR  rz  r<   r  r   r*   r    r  r  B  s    i [ 	 DD!* N
 K-><83>
 +3
72f  *D(//12B7 2h  /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    SubsettingErrorr  -  r  r*   r  c                      e Zd Zy)&Subsetter.MissingGlyphsSubsettingErrorNr  r   r*   r    MissingGlyphsSubsettingErrorr  0  r  r*   r  c                      e Zd Zy)(Subsetter.MissingUnicodesSubsettingErrorNr  r   r*   r    MissingUnicodesSubsettingErrorr  3  r  r*   r  Nc                    |s
t               }|| _        t               | _        t               | _        t               | _        y r   )r  r   r<   r~  glyph_names_requestedglyph_ids_requested)r&   r   s     r    rz  zSubsetter.__init__6  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-berE  z>%dL)r~  r`   r  bytesdecoder  r1   r`  ra  r  r  r  )r&   r'   gidsunicodestext
text_utf32ncharsrz  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)	Nry  r6  z
%s droppedrX  z	load '%s'
prune '%s'%s pruned to empty; dropped	%s pruned)_sort_tablesstripr   rJ  rO  r   rP  logr#   r   r:  r  timerrX  r&   r(   rN  clazzr  retains         r    _prune_pre_subsetzSubsetter._prune_pre_subsetJ  s7   $$T* 	/C		t||777IIK4<<#>#>> LL006M4<<+C+CRVs+I'',Eu01;,- & IE&<#-. H"33D$,,GFHHH:C@S	HH[#.3	/ & &H H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   r0   r   r5   glyph_orders     r    r!   z,Subsetter._closure_glyphs.<locals>.<genexpr>l  s&      %
 CDT@TKN%
s   !
!c              3  @   K   | ]  }|t              k\  s|  y wr   r0   r  s     r    r!   z,Subsetter._closure_glyphs.<locals>.<genexpr>r  s"      #
1K8H3HA#
rP   zMissing requested glyphs: %srv  zclose glyph list over 'cmap'zU+%04Xz)Missing glyphs for requested Unicodes: %srW  r   zAdded gid0 to subsetz.notdefzAdded .notdef to subsetrE  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)3r<   getGlyphOrderorig_glyph_orderr  r`   r  r  glyphs_missing
differencer  r#   r   rS  r  r  r'   r  r  rd   intersection_updater  glyphs_cmapedrT  r  r  r  getGlyphNamerU  r  minr1   rU  rQ  r8  r   lowerglyphs_glyfedglyphs_cffedglyphs_retainedr%   r  r  rW   r  r  r  r  r  
getGlyphIDnew_glyph_orderglyph_index_map)r&   r(   
realGlyphsrz  missingr5   r  orderr   r  r  s             @r    _closure_glyphszSubsetter._closure_glyphsf  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//
;< 't{{3  -1-B-BCx!|CGCHH@'J<<7799'BB<<$$~ 1 1! 45/0	*23<<**~s1c$*<*<*>&?@A :AKKOOD$5$5a$89:<=T>56 
3FDKKHX 

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

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

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

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

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

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

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

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

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

4;;T
2
3 &dkk2(5'')9=9M9M#NAAuQxK#N #&t'?'?'F'F'H#I #'#5#5#78P8P#Q 'k<<## $d&:&::#8t777 #D =A<O<O&Pqq%({&P#||''*5SQd>R>R9RqSOS '$//!*<@X@X*XO   /27O8L2M 
-.E/!$%q( 
 	&D,@,@(ABKi< <
 D(
3 
3
3 
37 7$
3 
3
3 
3
3 
3  $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 neededrh   zsubset '%s'z%s subsetted to empty; droppedz%s subsettedz'%s NOT subset; don't know how to subsetz0%s NOT subset; don't know how to subset; droppedzsubset GlyphOrder)r  r  r   r:  r  r   rL  r  r#   r  r  r  r'   rh   rM  warningsetGlyphOrderr  r  s         r    _subset_glyphszSubsetter._subset_glyphs  sG    $$T* 	C'',Eyy{dll;;;3S90=3./ $ IE"&"6"6DK"006F	$
 HH=sCS	HH^S100BCHNPSTI)	, &' 	5t334	5 	5!$ $ 	5 	5s   	*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   r  r  r  )r  rZ  r  r   rX  getUnicodeRangesrecalcUnicodeRangesr  r#   r$   rY  r  getCodePageRangesrecalcCodePageRangesrZ  xAvgCharWidthrecalcAvgCharWidthr[  r	   usMaxContextr   r:  r  r  r   )r&   r(   	tableTagsrN  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/  s9   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<#-. I IE"44T4<<HFI HH:C@S	HH[#.S)	/DI I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)rb  r6  r/  r  r  r  r   rW  r   c                (    j                  | d      S rV  )r  )rN  tagOrders    r    r!  z(Subsetter._sort_tables.<locals>.<lambda>e  s    8<<Q3G r*   )r  r  )r8   r$   r  )r&   r(   r5   r~  rK  r  s        @r    r  zSubsetter._sort_tablesb  s\    S)28)<=AAq1uH=diik'GH5a1#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.subseth  s:    t$T"D!%r*   r   )rk  r{  r|  r  r  r  r  rz  r  r  r  r  r  r  r@   r   r*   r    r  r  ,  s\    )   ) !rBR 	./8l\561/f6&r*   r  z	load fontc                $   t        j                  | ||j                  |j                  ||j                        }|rTt        j
                  d      }|j                  }|j                  |_        |d   }|j                  dk(  rd|_        ||_        |S )N)checkChecksumsrecalcBBoxesrecalcTimestamprg  
fontNumberr  g       @r  )	r   TTFontrV  rW  re  r:  decode_format_2_0decode_format_3_0r  )	fontFiler   r  dontLoadGlyphNamesrg  r(   r  savedr  s	            r    	load_fontr  o  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^  r]  fontTools.ttLibr  
USE_ZOPFLIra  cfgr   saver\  )r(   outfiler   r  s       r    	save_fontr    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]rq  z[<+>,;&#\\xXuU\n	]rn  r   r  )rern   rG  r1   r  r   r  r  )rc   r  r2   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 )Nrp  rq  rn  r   r   )rt  rG  r1   r  r   r  r  )rc   r2   r  r  s       r    
parse_gidsr    s    
A		#s#))+ @Cv;!HHS^$HHU3vay>3vay>A+=>?@ Hr*   c                B    | j                  dd      j                         S )Nrp  rq  )rt  rG  )rc   s    r    parse_glyphsr    s    99S#$$&&r*   c                 z    t        dt        t        j                         t        dt        j                         y )Nzusage:filez,Try pyftsubset --help for more information.
)ru  	__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)	r  z	gids-filer'   zglyphs-filer  z	text-filer  zunicodes-filezoutput-file)rx  zERROR:r  r   )levelT)r   Fr  r   z--output-file=rx  z--text=   z--text-file=r  z	utf-8-sig)encoding
z--unicodes=   z--unicodes-file=r  #z--gids=z--gids-file=z	--glyphs=	   z--glyphs-file=)r  rg  rD  z.subset)	extension	overWritesuffixzcompile glyph listrv  z
Text: '%s'zUnicodes: %sz
Glyphs: %szGids: %s)r'   r  r  r  zInput font:% 7d bytes: %szSubset font:% 7d bytes: %s)=os.pathr  	fontToolsr  r  rw  ru  __doc__r  r  r  r  r  r1   rb  loggingINFOWARNINGrc  r  r+   setLevelDEBUGdisabledr  rm  openreadrt  r  r  	readlinesrG  r  r  r  r  rg  r  r]  r  r   r  r{  r|  rv  r  r  r  r  r#   r  r@   r  ospathgetsizerd  saveXMLstdoutclose)argsr  r  r   efontfile	subsetterr  r'   r  r  wildcard_glyphswildcard_unicodesr  r   r  liner  rg  r(   extr~  r  s                          r    mainr,    s    !&|xx|4giG!!
 " 
& 4y1}ww||GOOL~~gmm, $AwH8D'*IGFDHOD ,8"O<<()fG<<	"AabEMD<<'af{3 3q((r223<<&v}$(!qv 67<<*+af HKKM HDOON4::c?13E$FGHH <<	"KK
1QR5)*<<'af @KKM @DKK
4::c?1+= >?@@ <<$u|"&l1QR512<<()af DKKM DDMM,tzz#q/A"BCDD 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3 3H H@ @D D$	  	 sd   X 5$Y;AYAY(>AY5AZ8Z1ZY&YYY	Y%	(Y2	5Y?	Z)r  r  r  r  r  r  r  r,  r   )FT)F)T)r(   zttLib.TTFontr  zset[int]returnNone)r   FT)
__future__r   r  r   fontTools.misc.roundToolsr   r   fontTools.ttLib.tablesr   fontTools.ttLib.tables.otBaser   fontTools.otlLib.maxContextCalcr	   fontTools.pens.basePenr
   fontTools.misc.loggingToolsr   fontTools.misc.cliToolsr   fontTools.subset.utilr   r   fontTools.subset.cfffontTools.subset.svgfontTools.varLibr   r   fontTools.ttLib.tables._n_a_m_er   r   fontTools.unicodedatar   r  r`  arrayr  collectionsr   r   	functoolsr   typesr   r  r  	getLoggerr  r)   r'   r  r.   r6   r   r9   r=   r@   rD   rF  rS   SingleSubstrd   rh   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  r4  r  r  r2  r  r  r  r  r3  r:  r;  r?  rB  rR  rT  rX  r]  rv  r  r  MathGlyphConstructionr@  rM  rN  rO  rV  rp  r  rg  r  r  r  r  r  r  r  r  r  r  r  r,  __all__r   r*   r    <module>rX     s~  
 #  -  + ? 6 * - 6 9 " " 4 G * 
    ,  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 *9B  U  ()
 *
  U  ()? *?D  U  () *  U  ()
 *
 4   U  ()! *!HCTL  U  () *$g*f g*T@& @&F
 { > >  > 'L
 ./N 0Nb	r*   