Ë
    ¨eh^¦  ã                   ó4  — d Z ddlmZ ddlZddlmZmZmZ ddlZddl	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ZddlmZmZ  ej*                  e«      Z ej0                  dd«      Z ed	d
«      Z edd«      Z G d„ d edd«      «      Z ed„ d„ d„ d„ d„ d„ d„ d„ ¬«      ZdJd„Z G d„ d«      Z  G d„ d«      Z! G d„ de «      Z"d „ Z# G d!„ d"«      Z$ ed#d$«      Z% G d%„ d&«      Z&d'„ Z' G d(„ d)«      Z(ed*„ «       Z)ed+„ «       Z* ee*e$d,«      Z+ ee*e"d-«      Z,ed.k(  �rñdd/l-m.Z. ddl/Z/ e.«       Z0e0jc                  d0«       e0jc                  d1d2e2d¬3«       e0jg                  «       Z4 e e4jj                  e4jl                  «      5 Z7 e& e)d4«      «      Z8e7D �]n  Z9 e:d5e9jv                  › d6e9jx                  › d7e9jz                  › d8�«        e/j|                  e9j~                  d9„ «      D ]·  \  Z@ZA e:d:e@j„                  j‡                  d;«      ›d<e@jˆ                  d=z  › �«        e:d>d?d@dAdBdCdD¬E«       eAD ]j  Z? e:e?jŠ                  e?jŒ                  e?jŽ                   eHe?jŽ                  «      j“                  «       r eHe?jŽ                  «      ndFe?jv                  dD¬E«       Œl Œ¹ e9j”                  s�Œ e:d>d?dGdBdHdIdD¬E«       e9j”                  D ]7  ZK e:eKjŠ                  eKjŒ                  eKjx                  eKjv                  dD¬E«       Œ9 �Œq 	 ddd«       yy# 1 sw Y   yxY w)KaC  
A module for reading dvi files output by TeX. Several limitations make
this not (currently) useful as a general-purpose dvi preprocessor, but
it is currently used by the pdf backend for processing usetex text.

Interface::

  with Dvi(filename, 72) as dvi:
      # iterate over pages:
      for page in dvi:
          w, h, d = page.width, page.height, page.descent
          for x, y, font, glyph, width in page.text:
              fontname = font.texname
              pointsize = font.size
              ...
          for x, y, height, width in page.boxes:
              ...
é    )Ú
namedtupleN)Ú	lru_cacheÚpartialÚwraps)ÚPath)Ú_apiÚcbookÚDviStatez!pre outer inpage post_post finaleÚPageztext boxes height width descentÚBoxzx y height widthc                   óV   — e Zd ZdZd„ Zed„ «       Zed„ «       Zed„ «       Zed„ «       Z	y)ÚTextaµ  
    A glyph in the dvi file.

    The *x* and *y* attributes directly position the glyph.  The *font*,
    *glyph*, and *width* attributes are kept public for back-compatibility,
    but users wanting to draw the glyph themselves are encouraged to instead
    load the font specified by `font_path` at `font_size`, warp it with the
    effects specified by `font_effects`, and load the glyph specified by
    `glyph_name_or_index`.
    c                 óX   — t        t        d«      «      | j                  j                     S )Nú
pdftex.map)Ú
PsfontsMapÚfind_tex_fileÚfontÚtexname©Úselfs    úP/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/matplotlib/dviread.pyÚ_get_pdftexmap_entryzText._get_pdftexmap_entryM   s!   € Üœ-¨Ó5Ó6°t·y±y×7HÑ7HÑIÐIó    c                 óþ   — | j                  «       }|j                  €Mt        dj                  |j                  j                  d«      |j                  j                  d«      «      «      ‚t        |j                  «      S )z/The `~pathlib.Path` to the font for this glyph.zINo usable font file found for {} ({}); the font may lack a Type-1 versionÚascii)r   ÚfilenameÚ
ValueErrorÚformatÚpsnameÚdecoder   r   )r   Úpsfonts     r   Ú	font_pathzText.font_pathP   sp   € ð ×*Ñ*Ó,ˆØ�?‰?Ð"Üð Bç$™f V§]¡]×%9Ñ%9¸'Ó%BØ%+§^¡^×%:Ñ%:¸7Ó%CóEóFð Fô �F—O‘OÓ$Ð$r   c                 ó.   — | j                   j                  S )zThe font size.)r   Úsizer   s    r   Ú	font_sizezText.font_size[   s   € ð �y‰y�~‰~Ðr   c                 ó6   — | j                  «       j                  S )zº
        The "font effects" dict for this glyph.

        This dict contains the values for this glyph of SlantFont and
        ExtendFont (if any), read off :file:`pdftex.map`.
        )r   Úeffectsr   s    r   Úfont_effectszText.font_effects`   s   € ð ×(Ñ(Ó*×2Ñ2Ð2r   c                 ó–   — | j                  «       }|j                  �"t        |j                  «      | j                     S | j                  S )aŒ  
        Either the glyph name or the native charmap glyph index.

        If :file:`pdftex.map` specifies an encoding for this glyph's font, that
        is a mapping of glyph indices to Adobe glyph names; use it to convert
        dvi indices to glyph names.  Callers can then convert glyph names to
        glyph indices (with FT_Get_Name_Index/get_name_index), and load the
        glyph using FT_Load_Glyph/load_glyph.

        If :file:`pdftex.map` specifies no encoding, the indices directly map
        to the font's "native" charmap; glyphs should directly load using
        FT_Load_Char/load_char after selecting the native charmap.
        )r   ÚencodingÚ
_parse_encÚglyph)r   Úentrys     r   Úglyph_name_or_indexzText.glyph_name_or_indexj   sD   € ð ×)Ñ)Ó+ˆà—>‘>Ð-ô ˜5Ÿ>™>Ó*¨4¯:©:Ñ6ð 	?Ø37·:±:ð	?r   N)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr"   r%   r(   r.   © r   r   r   r   A   s]   „ ñ	òJð ñ%ó ð%ð ñó ðð ñ3ó ð3ð ñ?ó ñ?r   r   zx y font glyph widthc                 ó   — |S ©Nr4   ©ÚdviÚdeltas     r   ú<lambda>r:   …   s   € ˜5€ r   c                 ó(   — | j                  dd¬«      S ©Né   F©Úsigned©Ú	_read_argr7   s     r   r:   r:   ‡   ó   € ˜#Ÿ-™-¨°%˜-Ó8€ r   c                 ó(   — | j                  dd¬«      S )Né   Fr>   r@   r7   s     r   r:   r:   ‰   rB   r   c                 ó(   — | j                  dd¬«      S )NrD   Tr>   r@   r7   s     r   r:   r:   ‹   s   € ˜#Ÿ-™-¨°$˜-Ó7€ r   c                 ó0   — |r| j                  |d¬«      S d S )NTr>   r@   r7   s     r   r:   r:   �   s   € Á˜CŸM™M¨%¸˜MÓ=€ ÈD€ r   c                 ó.   — | j                  |dz   d¬«      S )Nr=   Tr>   r@   r7   s     r   r:   r:   �   s   € ˜SŸ]™]¨5°1©9¸T˜]ÓB€ r   c                 ó.   — | j                  |dz   d¬«      S r<   r@   r7   s     r   r:   r:   ‘   s   € ˜SŸ]™]¨5°1©9¸U˜]ÓC€ r   c                 ó4   — | j                  |dz   |dk(  ¬«      S )Nr=   é   r>   r@   r7   s     r   r:   r:   ”   s   € ˜SŸ]™]¨5°1©9¸eÀq¹j˜]ÓJ€ r   )ÚrawÚu1Úu4Ús4ÚslenÚslen1Úulen1Úolen1c                 ó"   ‡ ‡‡‡‡— ˆˆˆˆˆ fd„}|S )a�  
    Decorator for dispatch by opcode. Sets the values in *table*
    from *min* to *max* to this method, adds a check that the Dvi state
    matches *state* if not None, reads arguments from the file according
    to *args*.

    Parameters
    ----------
    table : dict[int, callable]
        The dispatch table to be filled in.

    min, max : int
        Range of opcodes that calls the registered function; *max* defaults to
        *min*.

    state : _dvistate, optional
        State of the Dvi object in which these opcodes are allowed.

    args : list[str], default: ['raw']
        Sequence of argument specifications:

        - 'raw': opcode minus minimum
        - 'u1': read one unsigned byte
        - 'u4': read four bytes, treat as an unsigned number
        - 's4': read four bytes, treat as a signed number
        - 'slen': read (opcode - minimum) bytes, treat as signed
        - 'slen1': read (opcode - minimum + 1) bytes, treat as signed
        - 'ulen1': read (opcode - minimum + 1) bytes, treat as unsigned
        - 'olen1': read (opcode - minimum + 1) bytes, treat as unsigned
          if under four bytes, signed if four bytes
    c                 óÂ   •‡ ‡— ‰D �cg c]  }t         |   ‘Œ c}Št        ‰ «      ˆˆ ˆˆfd„«       }‰€|‰	‰<   |S t        ‰‰dz   «      D ]  }‰	|   �J ‚|‰	|<   Œ |S c c}w )Nc                 óˆ   •— ‰�| j                   ‰k7  rt        d«      ‚ ‰| g‰D �cg c]  } || |‰z
  «      ‘Œ c}¢­Ž S c c}w )Nzstate precondition failed)Ústater   )r   ÚbyteÚfÚget_argsÚmethodÚminrV   s      €€€€r   Úwrapperz,_dispatch.<locals>.decorate.<locals>.wrapper»   sI   ø€ àÐ  T§Z¡Z°5Ò%8Ü Ð!<Ó=Ð=Ù˜$ÐG¸XÖ!F¸¡! D¨$¨s©(Õ"3Ò!FÒGÐGùÒ!Fs   ¦?
r=   )Ú_arg_mappingr   Úrange)
rZ   Úxr\   ÚirY   ÚargsÚmaxr[   rV   Útables
   `   @€€€€€r   Údecoratez_dispatch.<locals>.decorate¸   s‡   ú€ Ø-1Ö2¨”L “OÒ2ˆä	ˆv‹ö	Hó 
ð	Hð ˆ;Ø ˆE�#‰Jð
 ˆô ˜3  A¡Ó&ò #�Ø˜Q‘xÐ'Ð'Ð'Ø"��a’ð#ð ˆùò 3s   ˆAr4   )rc   r[   rb   rV   ra   rd   s   ````` r   Ú	_dispatchre   ˜   s   ü€ ÷@ð ð €Or   c                   ó  — e Zd ZdZdgdz  Z eee«      Zd„ Zd„ Zd„ Z	d„ Z
d„ Zd	„ Zd
„ Zd[d„Z eddej                   ¬«      d„ «       Z eddej                   d¬«      d„ «       Z edej                   d¬«      d„ «       Z eddej                   d¬«      d„ «       Zd„ Z edej                   d¬«      d„ «       Zd„ Z ed «      d!„ «       Z ed"ej2                  d#¬«      d$„ «       Z ed%ej                   ¬&«      d'„ «       Z ed(ej                   ¬&«      d)„ «       Z ed*ej                   ¬&«      d+„ «       Z ed,d-ej                   d.¬«      d/„ «       Z ed0d1ej                   d2¬«      d3„ «       Z ed4d5ej                   d2¬«      d6„ «       Z  ed7d8ej                   d.¬«      d9„ «       Z! ed:d;ej                   d2¬«      d<„ «       Z" ed=d>ej                   d2¬«      d?„ «       Z# ed@dAej                   ¬«      dB„ «       Z$ edCdDej                   d¬«      dE„ «       Z% edFdGdH¬I«      dJ„ «       Z& edKdLdM¬I«      dN„ «       Z'dO„ Z( edPejR                  dQ¬«      dR„ «       Z* edSej2                  ¬&«      dT„ «       Z+ edU«      dV„ «       Z, edWdX¬Y«      dZ„ «       Z-y)\ÚDviaI  
    A reader for a dvi ("device-independent") file, as produced by TeX.

    The current implementation can only iterate through pages in order,
    and does not even attempt to verify the postamble.

    This class can be used as a context manager to close the underlying
    file upon exit. Pages can be read via iteration. Here is an overly
    simple way to extract text without trying to detect whitespace::

        >>> with matplotlib.dviread.Dvi('input.dvi', 72) as dvi:
        ...     for page in dvi:
        ...         print(''.join(chr(t.glyph) for t in page.text))
    Né   c                 ó¦   — t         j                  d|«       t        |d«      | _        || _        i | _        t        j                  | _        d| _	        y)zù
        Read the data from the file named *filename* and convert
        TeX's internal units to units of *dpi* per inch.
        *dpi* only sets the units and does not limit the resolution.
        Use None to return TeX's internal units.
        zDvi: %sÚrbN)
Ú_logÚdebugÚopenÚfileÚdpiÚfontsÚ	_dvistateÚprerV   Ú_missing_font)r   r   ro   s      r   Ú__init__zDvi.__init__Ý   sA   € ô 	�
‰
�9˜hÔ'Ü˜ 4Ó(ˆŒ	ØˆŒØˆŒ
Ü—]‘]ˆŒ
Ø!ˆÕr   c                 ó   — | S )z+Context manager enter method, does nothing.r4   r   s    r   Ú	__enter__zDvi.__enter__ë   s   € àˆr   c                 ó$   — | j                  «        y)zX
        Context manager exit method, closes the underlying file if it is open.
        N)Úclose)r   ÚetypeÚevalueÚetraces       r   Ú__exit__zDvi.__exit__ï   s   € ð 	�
‰
�r   c              #   ót   K  — | j                  «       r$| j                  «       –— | j                  «       rŒ#yy­w)a\  
        Iterate through the pages of the file.

        Yields
        ------
        Page
            Details of all the text and box objects on the page.
            The Page tuple contains lists of Text and Box tuples and
            the page dimensions, and the Text and Box tuples contain
            coordinates transformed into a standard Cartesian
            coordinate system at the dpi value given when initializing.
            The coordinates are floating point numbers, but otherwise
            precision is not lost and coordinate values are not clipped to
            integers.
        N)Ú_readÚ_outputr   s    r   Ú__iter__zDvi.__iter__õ   s(   è ø€ ð  �j‰jŒlØ—,‘,“.Ò ð �j‰j�lùs   ‚38¶8c                 óf   — | j                   j                  s| j                   j                  «        yy)z(Close the underlying file if it is open.N)rn   Úclosedrx   r   s    r   rx   z	Dvi.close  s"   € à�y‰y×ÒØ�I‰I�O‰OÕð  r   c                 ó>  — t         j                  x}}t         j                   x}}t         j                   }| j                  | j                  z   D ]}  }t	        |t
        «      r
|\  }}}	}
d}n|\  }}}}}
|j                  |«      \  }	}t        ||«      }t        |||	z
  «      }t        |||
z   «      }t        |||z   «      }t        ||«      }Œ | j                  �| j                  }d| _	        | j                  s| j                  st        g g ddd¬«      S | j                  €-t        | j                  | j                  ||z
  ||z
  ||z
  ¬«      S | j                  dz  }||z
  |z  }| j                  D �����
cg c])  \  }}}}}
t        ||z
  |z  ||z
  |z  |z
  |||
|z  «      ‘Œ+ }}}}}}
| j                  D ���	�
cg c]*  \  }}}	}
t        ||z
  |z  ||z
  |z  |z
  |	|z  |
|z  «      ‘Œ, }}	}}}
t        ||||z
  |z  ||z
  |z  |¬«      S c c}
}}}}w c c}
}	}}w )zk
        Output the text and boxes belonging to the most recent page.
        page = dvi._output()
        r   N©ÚtextÚboxesÚwidthÚheightÚdescentgáz®GRA)ÚnpÚinfr…   r†   Ú
isinstancer   Ú_height_depth_ofr[   rb   Ú_baseline_vr   ro   r   )r   ÚminxÚminyÚmaxxÚmaxyÚ	maxy_pureÚeltr_   ÚyÚhÚwÚer   ÚgÚdr‰   rX   r…   r†   s                      r   r   zDvi._output  sN  € ô
 —f‘fÐˆˆtÜ—v‘v�gÐˆˆtÜ—V‘V�Gˆ	Ø—9‘9˜tŸz™zÑ)ò 	*ˆCÜ˜#œsÔ#Ø ‘
��1�a˜Ø‘à#&Ñ ��1�d˜A˜qØ×,Ñ,¨QÓ/‘��1Ü�t˜Q“<ˆDÜ�t˜Q ™UÓ#ˆDÜ�t˜Q ™UÓ#ˆDÜ�t˜Q ™UÓ#ˆDÜ˜I qÓ)‰Ið	*ð ×ÑÐ'Ø×(Ñ(ˆIØ#ˆDÔà�yŠy §¢Ü˜R r°¸1ÀaÔHÐHà�8‰8Ðä˜TŸY™Y¨d¯j©jØ" 4™i°	¸$±Ø $ Y¡ô0ð 0ð
 �H‰H˜Ñ&ˆØ˜)Ñ# qÑ(ˆð (,§y¡y÷2ò 2Ù#�Q˜˜1˜a ô �a˜‘f˜a‘Z $ q¡&¨!¡¨gÑ!5°q¸!¸Q¸q¹SÕAð 2ˆô 2ð &*§Z¡Z÷1ñ 1Ù!�a˜˜A˜qô �a˜‘f˜a‘Z $ q¡&¨!¡¨gÑ!5°q¸±s¸A¸a¹CÕ@ð 1ˆó 1ô ˜ U°4¸±9¸a±-Ø% d™N¨AÑ-°wô@ð 	@ùö2ùõ1s   Å9.HÆ>/H
c                 óh  — dg}d| _         	 | j                  j                  d«      d   } | j                  |   | |«       | j                  r| j                  j                  «       ‚| j                  |   j                  }|dk(  r|j                  |d   «       n(|dk(  r|j                  «        n|dk(  r|dxx   dz  cc<   | j                   €2t        t        | d	g «      «      d
k(  r|d   dk\  r| j                  | _         |dk(  ry| j                  t        j                  u r| j                  «        y�Œ()út
        Read one page from the file. Return True if successful,
        False if there were no more pages.
        r   NTr=   Ú_pushéÿÿÿÿÚ_popÚ_downÚstackrJ   rD   éŒ   F)rŽ   rn   ÚreadÚ_dtablers   Úto_exceptionr/   ÚappendÚpopÚlenÚgetattrÚvrV   rq   Ú	post_postrx   )r   Ú
down_stackrW   Únames       r   r~   z	Dvi._read:  s  € ð. �Sˆ
ØˆÔØØ—9‘9—>‘> !Ó$ QÑ'ˆDØˆD�L‰L˜Ñ˜t TÔ*Ø×!Ò!Ø×(Ñ(×5Ñ5Ó7Ð7Ø—<‘< Ñ%×.Ñ.ˆDØ�wŠØ×!Ñ! *¨R¡.Õ1Ø˜’Ø—‘Õ Ø˜’Ø˜2“ !Ñ#“Ø× Ñ Ð(ÜœG D¨'°2Ó6Ó7¸1Ò<Ø" 2™¨!Ò+Ø#'§6¡6�Ô Ø�sŠ{ØØ�z‰zœY×0Ñ0Ñ0Ø—
‘
”Øñ) r   c                 ód   — t         j                  | j                  j                  |«      d|¬«      S )z
        Read and return a big-endian integer *nbytes* long.
        Signedness is determined by the *signed* keyword.
        Úbigr>   )ÚintÚ
from_bytesrn   r£   )r   Únbytesr?   s      r   rA   zDvi._read_argi  s&   € ô
 �~‰~˜dŸi™iŸn™n¨VÓ4°eÀFˆ~ÓKÐKr   r   é   )r[   rb   rV   c                 ó   — | j                  |«       t        | j                  | j                     t        j
                  «      ry | xj                  | j                  | j                     j                  |«      z  c_        y r6   ©Ú_put_char_realrŒ   rp   rX   r	   Ú_ExceptionInfor–   Ú	_width_of©r   Úchars     r   Ú_set_char_immediatezDvi._set_char_immediatep  óV   € à×Ñ˜DÔ!Ü�d—j‘j §¡Ñ(¬%×*>Ñ*>Ô?ØØ�Š�$—*‘*˜TŸV™VÑ$×.Ñ.¨tÓ4Ñ4Žr   é€   éƒ   )rR   )r[   rb   rV   ra   c                 ó   — | j                  |«       t        | j                  | j                     t        j
                  «      ry | xj                  | j                  | j                     j                  |«      z  c_        y r6   rµ   r¹   s     r   Ú	_set_charzDvi._set_charw  r¼   r   é„   )rN   rN   )rV   ra   c                 óR   — | j                  ||«       | xj                  |z  c_        y r6   )Ú_put_rule_realr–   ©r   ÚaÚbs      r   Ú	_set_rulezDvi._set_rule~  s   € à×Ñ˜A˜qÔ!Ø�Š�!‰Žr   é…   éˆ   c                 ó&   — | j                  |«       y r6   )r¶   r¹   s     r   Ú	_put_charzDvi._put_charƒ  s   € à×Ñ˜DÕ!r   c                 ó  — | j                   | j                     }t        |t        j                  «      r|| _        y |j                  €L| j                  j                  t        | j                  | j                  |||j                  |«      «      «       y |j                  }|j                  |   j                  D ]®  \  }}}}}t        t        ||j                  «      |j                   |j"                  |j                  ¬«      }	| j                  j                  t        | j                  t        ||«      z   | j                  t        ||«      z   |	||	j                  |«      «      «       Œ° | j$                  j'                  |j                  |   j$                  D ���
�cg c]W  \  }}}
}t)        | j                  t        ||«      z   | j                  t        ||«      z   t        |
|«      t        ||«      «      ‘ŒY c}}
}}«       y c c}}
}}w )N©ÚscaleÚtfmr   Úvf)rp   rX   rŒ   r	   r·   rs   Ú_vfr…   r¦   r   r–   rª   r¸   Ú_scaleÚDviFontÚ_mul2012Ú_tfmr   r†   Úextendr   )r   rº   r   rÎ   r_   r•   rX   r™   r—   ÚnewfrÅ   rÆ   s               r   r¶   zDvi._put_char_real‡  s«  € Ø�z‰z˜$Ÿ&™&Ñ!ˆÜ�dœE×0Ñ0Ô1Ø!%ˆDÕØ�X‰XÐØ�I‰I×ÑœT $§&¡&¨$¯&©&°$¸Ø"&§.¡.°Ó"6ó8õ 9ð —K‘KˆEØ!%§¡¨$¡×!4Ñ!4ò C‘��1�a˜˜AÜ¤X¨e°Q·X±XÓ%>Ø#$§6¡6°1·9±9ÀÇÁôH�à—	‘	× Ñ ¤ d§f¡f¬x¸¸5Ó/AÑ&AØ&*§f¡f¬x¸¸5Ó/AÑ&AØ&*¨A¨t¯~©~¸aÓ/@ó"Bõ CðCð �J‰J×Ñð 26·±¸$±×1EÑ1E÷Gñ Gñ $. 1 a¨¨Aô  # 4§6¡6¬H°Q¸Ó,>Ñ#>Ø#'§6¡6¬H°Q¸Ó,>Ñ#>Ü#+¨A¨uÓ#5´xÀÀ5Ó7Iõ Kõ Gõ Hùõ Gs   ÆAHé‰   c                 ó(   — | j                  ||«       y r6   )rÃ   rÄ   s      r   Ú	_put_rulezDvi._put_rule›  s   € à×Ñ˜A˜qÕ!r   c                 ó’   — |dkD  rB|dkD  r<| j                   j                  t        | j                  | j                  ||«      «       y y y ©Nr   )r†   r¦   r   r–   rª   rÄ   s      r   rÃ   zDvi._put_rule_realŸ  s;   € ØˆqŠ5�Q˜’UØ�J‰J×Ñœc $§&¡&¨$¯&©&°!°QÓ7Õ8ð ˆ5r   éŠ   c                  ó   — y r6   r4   ©r   Ú_s     r   Ú_nopzDvi._nop£  s   € àr   é‹   )rN   rN   rN   rN   rN   rN   rN   rN   rN   rN   rN   c                 ó¬   — t         j                  | _        dx| _        x| _        x| _        x| _        x| _        | _        g | _	        g | _
        g | _        y rÜ   )rq   ÚinpagerV   r–   rª   r—   r_   r•   Úzr¡   r…   r†   )r   Úc0Úc1Úc2Úc3Úc4Úc5Úc6Úc7Úc8Úc9Úps               r   Ú_bopzDvi._bop§  sN   € ä×%Ñ%ˆŒ
Ø>?Ð?ˆŒÐ?�”Ð?˜$œ&Ð? 4¤6Ð?¨D¬F°T´VØˆŒ
ØˆŒ	Øˆ�
r   r¢   )rV   c                 óJ   — t         j                  | _        | `| `| `| `| `| `| `	y r6   )
rq   ÚouterrV   r–   rª   r—   r_   r•   rå   r¡   rß   s     r   Ú_eopzDvi._eop¯  s*   € ä—_‘_ˆŒ
ØˆF�D�F˜D˜F D F¨D¨F°D°F¸D¹Jr   é�   c                 ó¾   — | j                   j                  | j                  | j                  | j                  | j
                  | j                  | j                  f«       y r6   )r¡   r¦   r–   rª   r—   r_   r•   rå   rß   s     r   r�   z	Dvi._push´  s9   € à�
‰
×Ñ˜4Ÿ6™6 4§6¡6¨4¯6©6°4·6±6¸4¿6¹6À4Ç6Á6ÐJÕKr   éŽ   c                 ó‚   — | j                   j                  «       \  | _        | _        | _        | _        | _        | _        y r6   )r¡   r§   r–   rª   r—   r_   r•   rå   rß   s     r   rŸ   zDvi._pop¸  s+   € à9=¿¹¿¹Ó9IÑ6ˆŒ�”˜œ ¤¨¬°µr   é�   é’   )rP   c                 ó.   — | xj                   |z  c_         y r6   )r–   )r   rÆ   s     r   Ú_rightz
Dvi._right¼  ó   € à�Š�!‰Žr   é“   é—   )rO   c                 óT   — |�|| _         | xj                  | j                   z  c_        y r6   )r—   r–   )r   Únew_ws     r   Ú_right_wzDvi._right_wÀ  ó!   € àÐØˆDŒFØ�Š�$—&‘&ÑŽr   é˜   éœ   c                 óT   — |�|| _         | xj                  | j                   z  c_        y r6   )r_   r–   )r   Únew_xs     r   Ú_right_xzDvi._right_xÆ  r  r   é�   é    c                 ó.   — | xj                   |z  c_         y r6   )rª   )r   rÅ   s     r   r    z	Dvi._downÌ  rý   r   é¡   é¥   c                 óT   — |�|| _         | xj                  | j                   z  c_        y r6   )r•   rª   )r   Únew_ys     r   Ú_down_yzDvi._down_yÐ  r  r   é¦   éª   c                 óT   — |�|| _         | xj                  | j                   z  c_        y r6   )rå   rª   )r   Únew_zs     r   Ú_down_zzDvi._down_zÖ  r  r   é«   éê   c                 ó   — || _         y r6   ©rX   )r   Úks     r   Ú_fnt_num_immediatezDvi._fnt_num_immediateÜ  s	   € àˆ�r   éë   éî   c                 ó   — || _         y r6   r  )r   Únew_fs     r   Ú_fnt_numzDvi._fnt_numà  s	   € àˆ�r   éï   éò   )rQ   )r[   rb   ra   c                 óâ   — | j                   j                  |«      }t        j                  ddj	                  |D �cg c]   }d|cxk  rdk  rn nt        |«      nd|z  ‘Œ" c}«      «       y c c}w )Nz!Dvi._xxx: encountered special: %sÚ é    r³   z<%02x>)rn   r£   rk   rl   ÚjoinÚchr)r   ÚdatalenÚspecialÚchs       r   Ú_xxxzDvi._xxxä  sa   € à—)‘)—.‘. Ó)ˆÜ�
‰
Ø/Ø�G‰GØ&ö(Øð !# b¤¨3¥”S˜”W°H¸r±MÑAò (ó )õ	*ùò(s   »%A,éó   éö   )rR   rM   rM   rM   rL   rL   c                 ó0   — | j                  ||||||«       y r6   )Ú_fnt_def_real)r   r  ÚcÚsrš   rÅ   Úls          r   Ú_fnt_defzDvi._fnt_defì  s   € à×Ñ˜1˜a  A q¨!Õ,r   c                 óÚ  — | j                   j                  ||z   «      }|| d  j                  d«      }	 t        |«      }	|dk7  r,|	j                  dk7  r||	j                  k7  rt        d|› �«      ‚	 t        |«      }t        ||	||¬«      | j                  |<   y # t        $ r6}
t
        j                  j                  |
«      | j                  |<   Y d }
~
y d }
~
ww xY w# t        $ r d }Y Œlw xY w)Nr   r   ztfm checksum mismatch: rÍ   )rn   r£   r    Ú_tfmfileÚFileNotFoundErrorr	   r·   Úfrom_exceptionrp   Úchecksumr   Ú_vffilerÓ   )r   r  r0  r1  rš   rÅ   r2  ÚnÚfontnamerÏ   ÚexcrÐ   s               r   r/  zDvi._fnt_def_realð  sâ   € Ø�I‰I�N‰N˜1˜q™5Ó!ˆØ�a�R�S�6—=‘= Ó)ˆð		Ü˜8Ó$ˆCð �Š6�c—l‘l aÒ'¨A°·±Ò,=ÜÐ6°q°cÐ:Ó;Ð;ð	Ü˜Ó"ˆBô   a¨S¸!ÀÔCˆ�
‰
�1Šøô !ò 	ô "×0Ñ0×?Ñ?ÀÓDˆD�J‰J�q‰MÜûð	ûô !ò 	ØŠBð	ús)   µB Á2C Â	CÂ#,CÃCÃC*Ã)C*é÷   )rL   rM   rM   rM   rL   c                 óÔ   — | j                   j                  |«       |dk7  rt        d|› �«      ‚|dk7  s|dk7  rt        d«      ‚|dk7  rt        d«      ‚t        j                  | _        y )Né   zUnknown dvi format iÀ’ƒi  ;zNonstandard units in dvi fileéè  z%Nonstandard magnification in dvi file)rn   r£   r   rq   ró   rV   )r   r`   ÚnumÚdenÚmagr  s         r   Ú_prezDvi._pre  sh   € à�	‰	�‰�qÔØ�Š6ÜÐ2°1°#Ð6Ó7Ð7Ø�(Š?˜c \Ò1ÜÐ<Ó=Ð=ð �$Š;ÜÐDÓEÐEô —_‘_ˆ�
r   éø   c                 ó.   — t         j                  | _        y r6   )rq   r«   rV   rß   s     r   Ú_postz	Dvi._post  s   € ä×(Ñ(ˆ�
r   éù   c                 ó   — t         ‚r6   )ÚNotImplementedErrorrß   s     r   Ú
_post_postzDvi._post_post  s   € ä!Ð!r   éú   éÿ   )r[   rb   c                 ó$   — t        dd|z   › �«      ‚)Nzunknown command: byte rL  )r   )r   Úoffsets     r   Ú
_malformedzDvi._malformed!  s   € äÐ1°#¸±,°Ð@ÓAÐAr   )F).r/   r0   r1   r2   r¤   r   re   rt   rv   r|   r€   rx   r   r~   rA   rq   rä   r»   rÀ   rÇ   rË   r¶   rÚ   rÃ   rá   ró   rñ   rô   r�   rŸ   rü   r  r  r    r  r  r  r   r+  r3  r/  rr   rD  rG  rK  rP  r4   r   r   rg   rg   Ê   s”  „ ñð ˆf�s‰l€GÙ˜	 7Ó+€Iò"òòò!ò&ò
+@òZ-ó^Lñ �1˜# Y×%5Ñ%5Ô6ñ5ó 7ð5ñ �3˜C y×'7Ñ'7¸jÔIñ5ó Jð5ñ ˆs˜)×*Ñ*°Ô>ñó ?ðñ �3˜C y×'7Ñ'7¸jÔIñ"ó Jð"òHñ( ˆs˜)×*Ñ*°Ô>ñ"ó ?ð"ò9ñ ˆsƒ^ñó ðñ ˆs˜)Ÿ/™/°
Ô;ñó <ðñ ˆs˜)×*Ñ*Ô+ñGó ,ðGñ ˆs˜)×*Ñ*Ô+ñLó ,ðLñ ˆs˜)×*Ñ*Ô+ñJó ,ðJñ �3˜C y×'7Ñ'7¸jÔIñó Jðñ �3˜C y×'7Ñ'7¸iÔHñó Iðñ
 �3˜C y×'7Ñ'7¸iÔHñó Iðñ
 �3˜C y×'7Ñ'7¸jÔIñó Jðñ �3˜C y×'7Ñ'7¸iÔHñó Iðñ
 �3˜C y×'7Ñ'7¸iÔHñó Iðñ
 �3˜C y×'7Ñ'7Ô8ñó 9ðñ �3˜C y×'7Ñ'7¸jÔIñó Jðñ �3˜C jÔ1ñ*ó 2ð*ñ �3˜CÐ&MÔNñ-ó Oð-òDñ* ˆs˜)Ÿ-™-Ð.LÔMñ%ó Nð%ñ" ˆs˜)Ÿ/™/Ô*ñ)ó +ð)ñ
 ˆsƒ^ñ"ó ð"ñ �3˜CÔ ñBó !ñBr   rg   c                   ó8   — e Zd ZdZdZd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
y	)
rÓ   au  
    Encapsulation of a font that a DVI file can refer to.

    This class holds a font's texname and size, supports comparison,
    and knows the widths of glyphs in the same units as the AFM file.
    There are also internal attributes (for use by dviread.py) that
    are *not* used for comparison.

    The size is in Adobe points (converted from TeX points).

    Parameters
    ----------
    scale : float
        Factor by which the font is scaled from its natural size.
    tfm : Tfm
        TeX font metrics for this font
    texname : bytes
       Name of the font as used internally by TeX and friends, as an ASCII
       bytestring.  This is usually very different from any external font
       names; `PsfontsMap` can be used to find the external name of the font.
    vf : Vf
       A TeX "virtual font" file, or None if this font is not virtual.

    Attributes
    ----------
    texname : bytes
    size : float
       Size of the font in Adobe points, converted from the slightly
       smaller TeX points.
    widths : list
       Widths of glyphs in glyph-space units, typically 1/1000ths of
       the point size.

    )r   r$   ÚwidthsrÒ   rÑ   rÕ   c                 ó`  — t        j                  t        |¬«       || _        || _        || _        || _        |dz  | _        	 t        |j                  «      dz   }t        |«      D �cg c]$  }d|j                  j                  |d«      z  dz	  ‘Œ& c}| _        y # t        $ r d}Y ŒLw xY wc c}w )N)r   g]Ÿeáï>r=   r   r@  é   )r   Úcheck_isinstanceÚbytesrÒ   rÕ   r   rÑ   r$   rb   r‡   r   r^   ÚgetrR  )r   rÎ   rÏ   r   rÐ   Úncharsrº   s          r   rt   zDviFont.__init__K  s¥   € Ü×Ñœe¨WÕ5ØˆŒØˆŒ	ØˆŒØˆŒØÐ3Ñ4ˆŒ	ð	Ü˜Ÿ™“^ aÑ'ˆFô $)¨£=ö2Øð ˜SŸY™YŸ]™]¨4°Ó3Ñ3¸Ó:ò 2ˆ�øô ò 	ØŠFð	üò2s   ÁB Á()B+ÂB(Â'B(c                 óš   — t        | «      t        |«      u xr4 | j                  |j                  k(  xr | j                  |j                  k(  S r6   )Útyper   r$   ©r   Úothers     r   Ú__eq__zDviFont.__eq__Y  sD   € Ü�T“
œd 5›kÐ)ò NØ—L‘L E§M¡MÑ1òNØ6:·i±iÀ5Ç:Á:Ñ6Mð	Or   c                 ó&   — | j                  |«       S r6   )r]  r[  s     r   Ú__ne__zDviFont.__ne__]  s   € Ø—;‘;˜uÓ%Ð%Ð%r   c                 óN   — dt        | «      j                  › d| j                  › d�S )Nú<z: ú>)rZ  r/   r   r   s    r   Ú__repr__zDviFont.__repr__`  s&   € Ø”4˜“:×&Ñ&Ð' r¨$¯,©,¨°qÐ9Ð9r   c                 óÂ   — | j                   j                  j                  |d«      }|�t        || j                  «      S t
        j                  d|| j                  «       y)zWidth of char in dvi units.Nz No width for char %d in font %s.r   )rÕ   r‡   rW  rÔ   rÒ   rk   rl   r   )r   rº   r‡   s      r   r¸   zDviFont._width_ofc  sK   € à—	‘	—‘×#Ñ# D¨$Ó/ˆØÐÜ˜E 4§;¡;Ó/Ð/Ü�
‰
Ð5°t¸T¿\¹\ÔJØr   c                 ó¨  — g }| j                   j                  df| j                   j                  dffD ]r  \  }}|j                  |d«      }|€4t        j                  d||| j                  «       |j                  d«       ŒN|j                  t        || j                  «      «       Œt t        j                  d| j                  «      r
|dk(  rd|d<   |S )z&Height and depth of char in dvi units.rˆ   ÚdepthNzNo %s for char %d in font %sr   s	   ^cmsy\d+$rž   )rÕ   rˆ   rf  rW  rk   rl   r   r¦   rÔ   rÒ   ÚreÚmatch)r   rº   ÚresultÚmetricr­   Úvalues         r   r�   zDviFont._height_depth_ofk  s¸   € àˆØ"Ÿi™i×.Ñ.°Ð9Ø"Ÿi™iŸo™o¨wÐ7ð9ò 	<‰LˆF�Dà—J‘J˜t TÓ*ˆEØˆ}Ü—
‘
Ð9Ø  t§|¡|ô5à—‘˜aÕ à—‘œh u¨d¯k©kÓ:Õ;ð	<ô �8‰8�M 4§<¡<Ô0°T¸Q²YØˆF�2‰JØˆr   N)r/   r0   r1   r2   Ú	__slots__rt   r]  r_  rc  r¸   r�   r4   r   r   rÓ   rÓ   &  s/   „ ñ!ðD G€Iò2òOò&ò:òór   rÓ   c                   ó@   ‡ — e Zd ZdZˆ fd„Zd„ Zd„ Zd„ Zd„ Zd„ Z	ˆ xZ
S )ÚVfaú  
    A virtual font (\*.vf file) containing subroutines for dvi files.

    Parameters
    ----------
    filename : str or path-like

    Notes
    -----
    The virtual font format is a derivative of dvi:
    http://mirrors.ctan.org/info/knuth/virtual-fonts
    This class reuses some of the machinery of `Dvi`
    but replaces the `_read` loop and dispatch mechanism.

    Examples
    --------
    ::

        vf = Vf(filename)
        glyph = vf[code]
        glyph.text, glyph.boxes, glyph.width
    c                 ó®   •— t         ‰| �  |d«       	 d | _        i | _        | j	                  «        | j                  «        y # | j                  «        w xY wrÜ   )Úsuperrt   Ú_first_fontÚ_charsr~   rx   )r   r   Ú	__class__s     €r   rt   zVf.__init__™  sB   ø€ Ü‰Ñ˜ 1Ô%ð	Ø#ˆDÔØˆDŒKØ�J‰JŒLà�J‰J�LøˆD�J‰J�Lús   “A ÁAc                 ó    — | j                   |   S r6   )rr  )r   Úcodes     r   Ú__getitem__zVf.__getitem__¢  s   € Ø�{‰{˜4Ñ Ð r   c                 ó"  — dx}}dx}}	 | j                   j                  d«      d   }| j                  t        j                  u r}| j                   j                  «       dz
  }||k(  r| j                  ||«       dx}x}}nB||kD  rt        d«      ‚|dv s|dk\  rt        d|› d�«      ‚t        j                  |   | |«       Œ¸|d	k  rL|}| j                  d«      }| j                  d
«      }| j                  |«      }t        j                  | _        �n}|d	k(  rF| j                  d«      }| j                  d«      }| j                  d«      }| j                  |«       �n2d|cxk  rdk  ršn n—| j                  |d	z
  |dk(  «      }| j                  d«      }| j                  d«      }	| j                  d«      }
| j                  d«      }| j                  d«      }| j                  |||	|
||«       | j                  €•|| _        n�|dk(  rt| j                  d«      }| j                  d«      }| j                   j                  |«      }| j                  d«      }| j                  d«      }| j                  ||||«       n|dk(  ryt        d|› �«      ‚�Œ‡)rœ   Nr=   r   z!Packet length mismatch in vf file)râ   r¢   r,  zInappropriate opcode z in vf filer"  rJ   rD   r-  r=  rE  zUnknown vf opcode )rn   r£   rV   rq   rä   ÚtellÚ_finalize_packetr   rg   r¤   rA   Ú_init_packetr/  rq  rD  )r   Úpacket_charÚpacket_endsÚ
packet_lenÚpacket_widthrW   Úbyte_atr  r0  r1  rš   rÅ   r2  r`   r_   ÚcsÚdss                    r   r~   zVf._read¥  sp  € ð
 %)Ð(ˆ�kØ$(Ð(ˆ
�\ØØ—9‘9—>‘> !Ó$ QÑ'ˆDà�z‰zœY×-Ñ-Ñ-ØŸ)™)Ÿ.™.Ó*¨1Ñ,�Ø˜kÒ)Ø×)Ñ)¨+°|ÔDØ>BÐB�JÐB ©|à˜{Ò*Ü$Ð%HÓIÐIà˜zÑ)¨T°Sª[Ü(Ð+@ÀÀÀkÐ)RÓSÐSÜ—K‘K Ñ% d¨DÔ1Øð �cŠzØ!�
Ø"Ÿn™n¨QÓ/�Ø#Ÿ~™~¨aÓ0�Ø"×/Ñ/°Ó5�Ü&×-Ñ-�–
Ø˜’Ø!Ÿ^™^¨AÓ.�
Ø"Ÿn™n¨QÓ/�Ø#Ÿ~™~¨aÓ0�Ø×!Ñ! *Ö-Ø˜Ô# Õ#Ø—N‘N 4¨#¡:¨t°s©{Ó;�Ø—N‘N 1Ó%�Ø—N‘N 1Ó%�Ø—N‘N 1Ó%�Ø—N‘N 1Ó%�Ø—N‘N 1Ó%�Ø×"Ñ" 1 a¨¨A¨q°!Ô4Ø×#Ñ#Ð+Ø'(�DÕ$Ø˜’Ø—N‘N 1Ó%�Ø—N‘N 1Ó%�Ø—I‘I—N‘N 1Ó%�Ø—^‘^ AÓ&�Ø—^‘^ AÓ&�Ø—	‘	˜!˜Q  BÕ'Ø˜’Øä Ð#5°d°VÐ!<Ó=Ð=ñc r   c                 ó:  — | j                   t        j                  k7  rt        d«      ‚dx| _        x| _        x| _        x| _        x| _        | _	        g | _
        g | _        g | _        | j                  | _        d | _        | j                   j#                  «       |z   S )NzMisplaced packet in vf filer   )rV   rq   ró   r   r–   rª   r—   r_   r•   rå   r¡   r…   r†   rq  rX   rs   rn   rx  )r   Úpls     r   rz  zVf._init_packetß  sˆ   € Ø�:‰:œŸ™Ò(ÜÐ:Ó;Ð;Ø>?Ð?ˆŒÐ?�”Ð?˜$œ&Ð? 4¤6Ð?¨D¬F°T´VØˆŒ
ØˆŒ	ØˆŒ
Ø×!Ñ!ˆŒØ!ˆÔØ�y‰y�~‰~Ó "Ñ$Ð$r   c                 ó¨   — | j                   s1t        | j                  | j                  |d d ¬«      | j                  |<   t
        j                  | _        y )Nr„   )rs   r   r…   r†   rr  rq   ró   rV   )r   r{  r~  s      r   ry  zVf._finalize_packetê  s?   € Ø×!Ò!Ü'+Ø—Y‘Y d§j¡j¸Ø Tô(+ˆD�K‰K˜Ñ$ô —_‘_ˆ�
r   c                 óä   — | j                   t        j                  urt        d«      ‚|dk7  rt        d|› �«      ‚t	        |«      rt
        j                  d|«       t        j                  | _         y )Nz pre command in middle of vf fileéÊ   zUnknown vf format zvf file comment: %s)rV   rq   rr   r   r¨   rk   rl   ró   )r   r`   r_   r€  r�  s        r   rD  zVf._preñ  sY   € Ø�:‰:œYŸ]™]Ñ*ÜÐ?Ó@Ð@Ø�Š8ÜÐ1°!°Ð5Ó6Ð6ÜˆqŒ6Ü�J‰JÐ,¨aÔ0Ü—_‘_ˆ�
r   )r/   r0   r1   r2   rt   rv  r~   rz  ry  rD  Ú__classcell__)rs  s   @r   rn  rn  �  s'   ø„ ñô.ò!ò8>òt	%ò%ö%r   rn  c                 ó   — | |z  dz	  S )z1Multiply two numbers in 20.12 fixed point format.rT  r4   )Únum1Únum2s     r   rÔ   rÔ   ü  s   € ð �‰I˜"ÑÐr   c                   ó   — e Zd ZdZdZd„ Zy)ÚTfma  
    A TeX Font Metric file.

    This implementation covers only the bare minimum needed by the Dvi class.

    Parameters
    ----------
    filename : str or path-like

    Attributes
    ----------
    checksum : int
       Used for verifying against the dvi file.
    design_size : int
       Design size of the font (unknown units)
    width, height, depth : dict
       Dimensions of each character, need to be scaled by the factor
       specified in the dvi file. These are dicts because indexing may
       not start from 0.
    )r8  Údesign_sizer‡   rˆ   rf  c           
      óÂ  — t         j                  d|«       t        |d«      5 }|j                  d«      }t	        j
                  d|dd «      \  }}}}}}	t         j                  d||||||	«       |j                  d|z  «      }
t	        j
                  d	|
d d
 «      \  | _        | _        |j                  d||z
  dz   z  «      }t	        j
                  d|› d�|j                  d|z  «      «      }t	        j
                  d|› d�|j                  d|z  «      «      }t	        j
                  d|	› d�|j                  d|	z  «      «      }d d d «       i | _        i | _	        i | _
        t        t        dz   «      «      D ]T  \  }}d|z     }|d|z  dz      }|   | j                  |<   |dz	     | j                  |<   |dz     | j                  |<   ŒV y # 1 sw Y   ŒŽxY w)Nzopening tfm file %srj   é   z!6Hr?  é   z(lh=%d, bc=%d, ec=%d, nw=%d, nh=%d, nd=%drD   z!2Ié   r=   ú!r`   é   )rk   rl   rm   r£   ÚstructÚunpackr8  r�  r‡   rˆ   rf  Ú	enumerater^   )r   r   rn   Úheader1ÚlhÚbcÚecÚnwÚnhÚndÚheader2Ú	char_inforR  ÚheightsÚdepthsÚidxrº   Úbyte0Úbyte1s                      r   rt   zTfm.__init__  sÎ  € Ü�
‰
Ð(¨(Ô3Ü�(˜DÓ!ð 	? TØ—i‘i “mˆGÜ%+§]¡]°5¸'À!ÀB¸-Ó%HÑ"ˆB��B˜˜B Ü�J‰JÐAØ˜2˜r 2 r¨2ô/à—i‘i  "¡“oˆGÜ.4¯m©m¸EÀ7È2ÈAÀ;Ó.OÑ+ˆDŒM˜4Ô+àŸ	™	 ! R¨¡U¨1¡W¡+Ó.ˆIÜ—]‘] Q r d¨! 9¨d¯i©i¸¸"¹«oÓ>ˆFÜ—m‘m a¨ t¨1 I¨t¯y©y¸¸2¹«Ó?ˆGÜ—]‘] Q r d¨! 9¨d¯i©i¸¸"¹«oÓ>ˆF÷	?ð ˆŒ
ØˆŒØˆŒ
Ü"¤5¨¨R°©T£?Ó3ò 	3‰IˆC�Ø˜a ™eÑ$ˆEØ˜a ™e A™gÑ&ˆEØ% e™}ˆD�J‰J�tÑØ '¨°©
Ñ 3ˆD�K‰K˜ÑØ% e¨c¡kÑ2ˆD�J‰J�tÒñ	3÷	?ð 	?ús   £D%GÇGN)r/   r0   r1   r2   rl  rt   r4   r   r   rŒ  rŒ    s   „ ñð( H€Ió3r   rŒ  ÚPsFontz(texname psname effects encoding filenamec                   ó0   — e Zd ZdZdZed„ «       Zd„ Zd„ Zy)r   a}  
    A psfonts.map formatted file, mapping TeX fonts to PS fonts.

    Parameters
    ----------
    filename : str or path-like

    Notes
    -----
    For historical reasons, TeX knows many Type-1 fonts by different
    names than the outside world. (For one thing, the names have to
    fit in eight characters.) Also, TeX's native fonts are not Type-1
    but Metafont, which is nontrivial to convert to PostScript except
    as a bitmap. While high-quality conversions to Type-1 format exist
    and are shipped with modern TeX distributions, we need to know
    which Type-1 fonts are the counterparts of which native fonts. For
    these reasons a mapping is needed from internal font names to font
    file names.

    A texmf tree typically includes mapping files called e.g.
    :file:`psfonts.map`, :file:`pdftex.map`, or :file:`dvipdfm.map`.
    The file :file:`psfonts.map` is used by :program:`dvips`,
    :file:`pdftex.map` by :program:`pdfTeX`, and :file:`dvipdfm.map`
    by :program:`dvipdfm`. :file:`psfonts.map` might avoid embedding
    the 35 PostScript fonts (i.e., have no filename for them, as in
    the Times-Bold example above), while the pdf-related files perhaps
    only avoid the "Base 14" pdf fonts. But the user may have
    configured these files differently.

    Examples
    --------
    >>> map = PsfontsMap(find_tex_file('pdftex.map'))
    >>> entry = map[b'ptmbo8r']
    >>> entry.texname
    b'ptmbo8r'
    >>> entry.psname
    b'Times-Bold'
    >>> entry.encoding
    '/usr/local/texlive/2008/texmf-dist/fonts/enc/dvips/base/8r.enc'
    >>> entry.effects
    {'slant': 0.16700000000000001}
    >>> entry.filename
    )Ú	_filenameÚ	_unparsedÚ_parsedc                 óR  — t         j                  | «      }t        j                  |«      |_        t        |d«      5 }i |_        |D ]B  }|j                  dd«      d   }|j                  j                  |g «      j                  |«       ŒD 	 d d d «       i |_
        |S # 1 sw Y   ŒxY w)Nrj   ó    r=   r   )ÚobjectÚ__new__ÚosÚfsdecoder§  rm   r¨  ÚsplitÚ
setdefaultr¦   r©  )Úclsr   r   rn   ÚlineÚtfmnames         r   r­  zPsfontsMap.__new__f  s¡   € ä�~‰~˜cÓ"ˆÜŸ™ XÓ.ˆŒô
 �(˜DÓ!ð 	D TØˆDŒNØò D�ØŸ*™* T¨1Ó-¨aÑ0�Ø—‘×)Ñ)¨'°2Ó6×=Ñ=¸dÕCñD÷	Dð
 ˆŒØˆ÷	Dð 	Dús   ¼ABÂB&c                 ó:  — t        |t        «      sJ ‚|| j                  v r3| j                  j                  |«      D ]  }| j	                  |«      sŒ n 	 | j
                  |   S # t        $ r- t        d|j                  d«      ›d| j                  ›d�«      d ‚w xY w)NzWAn associated PostScript font (required by Matplotlib) could not be found for TeX font r   z in zo; this problem can often be solved by installing a suitable PostScript font package in your TeX package manager)
rŒ   rV  r¨  r§   Ú_parse_and_cache_liner©  ÚKeyErrorÚLookupErrorr    r§  )r   r   r³  s      r   rv  zPsfontsMap.__getitem__v  s°   € Ü˜'¤5Ô)Ð)Ð)Ø�d—n‘nÑ$ØŸ™×*Ñ*¨7Ó3ò �Ø×-Ñ-¨dÕ3Ùðð	.Ø—<‘< Ñ(Ð(øÜò 	.Üð3Ø3:·>±>À'Ó3JÐ2Mð NØ—n‘nÐ'ð ("ð#ó$ð
 *.ð.ð	.ús   ÁA$ Á$6Bc           	      ó  — |r|j                  d«      rydx}x}x}x}}dx}x}}	t        j                  d|«      }
|
D ]²  }|j                  «       \  }}|r–|j                  d«      r|dd }Œ/|j                  d«      r|dd }ŒF|j                  d«      rL|d	d xs, t	        t        dt	        |
«      j                  «       «      «      }|j                  d
«      r|}Œž|}d}Œ£|€|}Œ¨|�Œ«|}Œ®|sŒ±|}Œ´ i }|rZt        |j                  «       «      }|D ]<  }|dk(  rt        t	        |«      «      |d<   Œ |dk(  sŒ&t        t	        |«      «      |d<   Œ> |�(|j                  d«      rd}	n|j                  d«      sd}n|�d}|	r|r|€y|s	d|v sd|v ryt        |j                  dd«      «      d	kD  ryt        |j                  dd«      «      dkD  ry|€|}|�t        |«      }|�t        |«      }t        |||||¬«      | j                  |<   y)a%  
        Parse a line in the font mapping file.

        The format is (partially) documented at
        http://mirrors.ctan.org/systems/doc/pdftex/manual/pdftex-a.pdf
        https://tug.org/texinfohtml/dvips.html#psfonts_002emap
        Each line can have the following fields:

        - tfmname (first, only required field),
        - psname (defaults to tfmname, must come immediately after tfmname if
          present),
        - fontflags (integer, must come immediately after psname if present,
          ignored by us),
        - special (SlantFont and ExtendFont, only field that is double-quoted),
        - fontfile, encodingfile (optional, prefixed by <, <<, or <[; << always
          precedes a font, <[ always precedes an encoding, < can precede either
          but then an encoding file must have extension .enc; < and << also
          request different font subsetting behaviors but we ignore that; < can
          be separated from the filename by whitespace).

        special, fontfile, and encodingfile can appear in any order.
        )r«  ó   %ó   *ó   ;ó   #NFs   "([^"]*)(?:"|$)|(\S+)s   <<r?  s   <[ó   <r=   s   .encTs	   SlantFontÚslants
   ExtendFontrÖ   )s   .ttfs   .ttcs   .otfr   )r   r   r'   r*   r   )Ú
startswithrg  ÚfinditerÚgroupsÚnextÚfilterÚendswithÚreversedr°  ÚfloatÚabsrW  r   r¥  r©  )r   r³  r´  Úbasenamer)  ÚencodingfileÚfontfileÚis_subsettedÚis_t1Úis_truetypeÚmatchesrh  ÚquotedÚunquotedÚwordr'   Úwordss                    r   r¶  z PsfontsMap._parse_and_cache_line†  s\  € ñ8 �t—‘Ð'EÔFØØAEÐEˆÐE�(ÐE˜WÐE |°hØ-2Ð2ˆÐ2�u˜{Ü—+‘+Ð7¸Ó>ˆØò 	!ˆEØ$Ÿ|™|›~ÑˆF�HÙØ×&Ñ& uÔ-Ø'¨¨˜|‘HØ×(Ñ(¨Ô/Ø#+¨A¨B <‘LØ×(Ñ(¨Ô.ð !  ˜ò Fä¤ t¬T°'«]×-AÑ-AÓ-CÓ DÓEð	 ð
 —}‘} WÔ-Ø'+™à#'˜Ø'+™Ø�_Ø&‘GØÑ%Ø'‘HÚØ ‘ð/	!ð0 ˆÙÜ˜WŸ]™]›_Ó-ˆEØò ;�Ø˜<Ò'Ü',¬T°%«[Ó'9�G˜GÒ$Ø˜]Ó*Ü(-¬d°5«kÓ(:�G˜HÒ%ð	;ð ÐØ× Ñ Ð!3Ô4Ø"‘Ø×&Ñ& wÔ/Ø‘ØÐ!ØˆEÙ™<¨LÐ,@ØÙ˜' WÑ,°¸GÑ0CØÜˆw�{‰{˜7 AÓ&Ó'¨!Ò+ØÜˆw�{‰{˜8 QÓ'Ó(¨1Ò,ØàÐØˆHØÐ#Ü(¨Ó6ˆLØÐÜ$ XÓ.ˆHÜ &Ø H°gØ!¨Hô!6ˆ�‰�WÑð r   N)	r/   r0   r1   r2   rl  r   r­  rv  r¶  r4   r   r   r   r   5  s.   „ ñ*ðV 6€Ið
 ñó ðò.ó ]r   r   c                 óh  — t        j                  ddt        | «      j                  d¬«      «      }t        j                  d|«      j                  d«      }|j                  «       D �cg c]  }|sŒ|‘Œ	 }}t        d„ |D «       «      r|D �cg c]  }|dd ‘Œ	 c}S t        d	| › d
�«      ‚c c}w c c}w )aE  
    Parse a \*.enc file referenced from a psfonts.map style file.

    The format supported by this function is a tiny subset of PostScript.

    Parameters
    ----------
    path : `os.PathLike`

    Returns
    -------
    list
        The nth entry of the list is the PostScript glyph name of the nth
        glyph.
    z%.*r$  r   )r*   z(?s)\[(.*)\]r=   c              3   ó>   K  — | ]  }|j                  d «      –— Œ y­w)ú/N)rÀ  )Ú.0r³  s     r   ú	<genexpr>z_parse_enc.<locals>.<genexpr>ù  s   è ø€ Ò
2 Dˆ4�?‰?˜3×Ñ
2ùs   ‚NzFailed to parse z as Postscript encoding)	rg  Úsubr   Ú	read_textÚsearchÚgroupr°  Úallr   )ÚpathÚno_commentsÚarrayr³  Úliness        r   r+   r+   æ  s¡   € ô  —&‘&˜ ¤D¨£J×$8Ñ$8À'Ð$8Ó$JÓK€KÜ�I‰I�o {Ó3×9Ñ9¸!Ó<€EØ#Ÿk™k›mÖ4�dªtŠTÐ4€EÐ4Ü
Ñ
2¨EÔ
2Ô2Ø%*Ö+˜T��Q�R’Ò+Ð+äÐ+¨D¨6Ð1HÐIÓJÐJùò	 5ùâ+s   Á(B*Á0B*ÂB/c                   ó(   — e Zd Zed„ «       Zd„ Zd„ Zy)Ú_LuatexKpsewhichc                 óZ   — t         j                  | «      }|j                  «       |_        |S r6   )r¬  r­  Ú	_new_procÚ_proc)r²  r   s     r   r­  z_LuatexKpsewhich.__new__   s#   € ä�~‰~˜cÓ"ˆØ—^‘^Ó%ˆŒ
Øˆr   c           	      ó¨   — t        j                  ddt        t        j                  d«      «      gt         j
                  t         j
                  ¬«      S )NÚluatexz	--luaonlyzkpsewhich.lua)ÚstdinÚstdout)Ú
subprocessÚPopenÚstrr	   Ú_get_data_pathÚPIPEr   s    r   rå  z_LuatexKpsewhich._new_proc  s?   € Ü×ÑØ�{Ü”×%Ñ% oÓ6Ó7ð9ä—/‘/¬*¯/©/ô;ð 	;r   c                 óº  — | j                   j                  «       �| j                  «       | _         | j                   j                  j	                  t        j                  |«      dz   «       | j                   j                  j                  «        | j                   j                  j                  «       j                  «       }|dk(  rd S t        j                  |«      S )Nó   
s   nil)ræ  Úpollrå  ré  Úwriter®  ÚfsencodeÚflushrê  ÚreadlineÚrstripr¯  )r   r   Úouts      r   rÛ  z_LuatexKpsewhich.search  s˜   € Ø�:‰:�?‰?ÓÐ(ØŸ™Ó)ˆDŒJØ�
‰
×Ñ×ÑœrŸ{™{¨8Ó4°uÑ<Ô=Ø�
‰
×Ñ×ÑÔ Ø�j‰j×Ñ×(Ñ(Ó*×1Ñ1Ó3ˆØ˜f’}ˆtÐ:¬"¯+©+°cÓ*:Ð:r   N)r/   r0   r1   r   r­  rå  rÛ  r4   r   r   rã  rã  ÿ  s   „ Øñó ðò
;ó;r   rã  c                 óÞ  — t        | t        «      r| j                  dd¬«      } 	 t        «       }|r|j                  | «      }nqt        j                  dk(  ri t        j                  ¥ddi¥ddœ}nt        j                  «       dd	œ}	 t        j                  d
| gt        fi |¤Žj                  d«      }|r|S t	        d| ›d�«      ‚# t        $ r d}Y Œ¥w xY w# t        t        f$ r d}Y Œ7w xY w)aÙ  
    Find a file in the texmf tree using kpathsea_.

    The kpathsea library, provided by most existing TeX distributions, both
    on Unix-like systems and on Windows (MikTeX), is invoked via a long-lived
    luatex process if luatex is installed, or via kpsewhich otherwise.

    .. _kpathsea: https://www.tug.org/kpathsea/

    Parameters
    ----------
    filename : str or path-like

    Raises
    ------
    FileNotFoundError
        If the file is not found.
    zutf-8Úreplace)ÚerrorsNÚwin32Úcommand_line_encoding)Úenvr*   Úsurrogateescape)r*   rû  Ú	kpsewhichú
z:Matplotlib's TeX implementation searched for a file named z* in your texmf tree, but could not find it)rŒ   rV  r    rã  r6  rÛ  ÚsysÚplatformr®  ÚenvironÚgetfilesystemencodingr	   Ú_check_and_log_subprocessrk   r÷  ÚRuntimeError)r   ÚlkrÞ  Úkwargss       r   r   r     s  € ô. �(œEÔ"Ø—?‘? 7°9�?Ó=ˆðÜÓˆñ 
Ø�y‰y˜Ó"‰ä�<‰<˜7Ò"ð N¤§
¡
ÐMÐ,CÀWÑMØ")ñ+‰Fô #&×";Ñ";Ó"=Ø 1ñ3ˆFð	Ü×3Ñ3°[À(Ð4KÜ48ñDØ<BñDç‘V˜D“\ð ñ ØˆäØHØˆlÐDðFóGð 	Gøô5 ò ØŠðûô( "¤<Ð0ò 	ØŠDð	ús#   ¥
C Â,C ÃCÃCÃC,Ã+C,c                 ó*   —  | t        ||z   «      «      S r6   )r   )r²  Úsuffixr   s      r   Ú	_fontfiler  P  s   € áŒ}˜W vÑ-Ó.Ó/Ð/r   z.tfmz.vfÚ__main__)ÚArgumentParserr   ro   ú?)ÚnargsrZ  Údefaultr   z=== new page === (w: z, h: z, d: ú)c                 ó   — | j                   S r6   )r   )r…   s    r   r:   r:   g  s
   € ¨D¯I©I€ r   zfont: zlatin-1z	scale: i   r_   r•   r,   r'  r—   z(glyphs)ú	)Úsepú.r–   r$  z(boxes))NN)rK   )Lr2   Úcollectionsr   ÚenumÚ	functoolsr   r   r   Úloggingr®  Úpathlibr   rg  r”  rë  r  ÚnumpyrŠ   Ú
matplotlibr   r	   Ú	getLoggerr/   rk   ÚEnumrq   r   r   r   Údictr]   re   rg   rÓ   rn  rÔ   rŒ  r¥  r   r+   rã  r   r  r5  r9  Úargparser  Ú	itertoolsÚparserÚadd_argumentrÇ  Ú
parse_argsra   r   ro   r8   ÚfontmapÚpageÚprintr‡   rˆ   r‰   Úgroupbyr…   r   rÜ  r   r    rÒ   r_   r•   r,   r'  Úisprintabler†   Úboxr4   r   r   ú<module>r,     sY  ðñõ& #Û ß /Ñ /Û Û 	Ý Û 	Û Û Û 
ã ç "à€w×Ñ˜Ó"€ð, ˆD�I‰I�jÐ"EÓF€	ñ �&Ð;Ó<€Ù�Ð*Ó+€ô:?‰:�fÐ4Ó5ô :?ñD á á8á8á7á	Pá
Bá
Cñ Kô#€ó*/÷dYBñ YB÷x
Xñ Xôvw%ˆô w%òv÷-3ñ -3ñ` 
�HÐHÓ	I€÷nñ nòbK÷2;ñ ;ð, ñ7Gó ð7Gðt ñ0ó ð0ñ �9˜c 6Ó*€Ù
�)˜R Ó
'€ð ˆzÓÝ'ÛáÓ€FØ
×Ñ˜
Ô#Ø
×Ñ˜ S¨u¸dÐÔCØ×ÑÓ€DÙ	ˆT�]‰]˜DŸH™HÓ	%ð I¨Ù™]¨<Ó8Ó9ˆØó 	IˆDÙð ØŸ™˜ E¨$¯+©+¨°e¸D¿L¹L¸>ÈðLô Mà0˜y×0Ñ0Ø—I‘IÑ5ó 7ò 	0‘��eá˜˜tŸ|™|×2Ñ2°9Ó=Ð@ð A Ø $§¡¨gÑ 5Ð6ð8ô 9á�c˜3 ¨°°ZÀTÕJØ!ò 0�DÙ˜$Ÿ&™& $§&¡&¨$¯*©*Ù-0°·±«_×-HÑ-HÔ-J™#˜dŸj™jœ/Ø"ØŸ*™*¨$ö0ñ0ð	0ð �zŒzÙ�c˜3  S¨"¨i¸TÕBØŸ:™:ò I�CÙ˜#Ÿ%™% §¡¨¯
©
°C·I±IÀ4ÖHòIñ	I÷Ið Ið ÷Ið Iús   Æ D)LÊ+ALÌL