Files
old-parkingkoncept/parkingkonceptvenv/lib/python3.7/site-packages/matplotlib/__pycache__/dviread.cpython-37.pyc

470 lines
35 KiB
Plaintext
Raw Normal View History

2019-11-17 12:44:16 +01:00
B
U<>]<08><00>
@s<>dZddlmZddlZddlmZmZmZddlZddl Z ddl
Z
ddl Z ddl Z ddl ZddlmZmZe<08>e<13>Ze<03>dd<07>Zedd <09>Zed
d <0B>Zed d <0A>Zdd<0F>Zdd<11>Zdd<13>Zdd<15>Zdd<17>Zdd<19>Ze eeedd<1B>eedd<1B>eedd<1D>eeeed<1E>Z!dKd d!<21>Z"Gd"d#<23>d#e#<23>Z$Gd$d%<25>d%e#<23>Z%Gd&d'<27>d'e$<24>Z&d(d)<29>Z'd*d+<2B>Z(Gd,d-<2D>d-e#<23>Z)ed.d/<2F>Z*Gd0d1<64>d1e#<23>Z+Gd2d3<64>d3e#<23>Z,d4d5<64>Z-e<05>dLd6d7<64><01>Z.e<05>d8d9<64><00>Z/ee/e)d:<3A>Z0ee/e&d;<3B>Z1ed<k<02>r<>dd=l2m3Z3ddl4Z4e3<65>Z5e5<65>6d><3E>e5j6d?d@e7ddA<64>e5<65>8<EFBFBD>Z9e$e9j:e9j;<3B><02><>Z<e+e.dB<64><01>Z=x<>e<D]<5D>Z>e?dC<64>xxe4<65>@e>jAdDdE<64><00>D]b\ZBZCe?dFeBjDdGeBjEdH<00>x@eCD]8ZAe?eAjFeAjGeAjHeIeAjH<6A><01>J<EFBFBD><00>r<>eIeAjH<6A>ndIeAjK<6A><00>qpW<00>qLWx(e>jLD]\ZFZGZMZNe?eFeGdJeMeN<65><00>q<>W<00>q,WWdQRXdS)MaC
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:
...
<EFBFBD>)<01>
namedtupleN)<03> lru_cache<68>partial<61>wraps)<02>cbook<6F>rcParamsZDviStatez!pre outer inpage post_post finale<6C>Pageztext boxes height width descent<6E>Textzx y font glyph width<74>Boxzx y height widthcCs|S)z>Return *delta* without reading anything more from the dvi file<6C>)<02>dvi<76>deltar r <00>:/tmp/pip-install-i8dhxrtk/matplotlib/matplotlib/dviread.py<70>_arg_rawFsrcCs |<02>||<01>S)ztRead *bytes* bytes, returning the bytes interpreted as a
signed integer if *signed* is true, unsigned otherwise.)<01>_arg)<04>bytes<65>signedr <00>_r r rrKsrcCs|dkr dS|<00>|d<03>S)z<>Signed, length *delta*
Read *delta* bytes, returning None if *delta* is zero, and
the bytes interpreted as a signed integer otherwise.rNT)r)r r r r r<00> _arg_slenQsrcCs|<00>|dd<02>S)z^Signed, length *delta*+1
Read *delta*+1 bytes, returning the bytes interpreted as signed.<2E>T)r)r r r r r<00>
_arg_slen1[srcCs|<00>|dd<02>S)zaUnsigned length *delta*+1
Read *delta*+1 bytes, returning the bytes interpreted as unsigned.rF)r)r r r r r<00>
_arg_ulen1bsrcCs|<00>|d|dk<02>S)z<>Optionally signed, length *delta*+1
Read *delta*+1 bytes, returning the bytes interpreted as
unsigned integer for 0<=*delta*<3 and signed if *delta*==3.r<00>)r)r r r r r<00>
_arg_olen1isrrF<>T)<08>raw<61>u1<75>u4<75>s4<73>slen<65>olen1<6E>slen1<6E>ulen1<6E>rcs<00><00><01><02><03>fdd<02>}|S)adDecorator 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*.
*table*
the dispatch table to be filled in
*min*
minimum opcode for calling this function
*max*
maximum opcode for calling this function, None if only *min* is allowed
*state*
state of the Dvi object in which these opcodes are allowed
*args*
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
csndd<02><00>D<00><01>t<00><01><01><00><01><04>fdd<04><08>}<01>dkr:|<01><06><n0x.t<01><04>d<00>D]}<02>|dks^t<02>|<01>|<qJW|S)NcSsg|] }t|<00>qSr )<01> _arg_mapping)<02>.0<EFBFBD>xr r r<00>
<listcomp><3E>sz/_dispatch.<locals>.decorate.<locals>.<listcomp>cs:<00>dk r<1A>j<00>krtd<01><01><01><03>f<01><00><04>fdd<03><08>D<00><01><02>S)Nzstate precondition failedcsg|]}|<01><02><00><00><02>qSr r )r%<00>f)<03>byte<74>min<69>selfr rr'<00>sz@_dispatch.<locals>.decorate.<locals>.wrapper.<locals>.<listcomp>)<02>state<74>
ValueError)r+r))<04>get_args<67>methodr*r,)r)r+r<00>wrapper<65>sz,_dispatch.<locals>.decorate.<locals>.wrapperr)r<00>range<67>AssertionError)r/r0<00>i)<05>args<67>maxr*r,<00>table)r.r/r<00>decorate<74>s
 z_dispatch.<locals>.decorater )r6r*r5r,r4r7r )r4r5r*r,r6r<00> _dispatch{sr8c@s<>eZdZdZdgdZeee<04>Zdd<05>Zdd<07>Zdd <09>Z d
d <0B>Z
d d <0A>Z dd<0F>Z dd<11>Z dd<13>Zd<>dd<16>Zeddejd<19>dd<1B><00>Zeddejdd<1F>d d!<21><00>Zed"ejd#d$<24>d%d&<26><00>Zed'd(ejdd<1F>d)d*<2A><00>Zd+d,<2C>Zed-ejd#d$<24>d.d/<2F><00>Zd0d1<64>Zed2<64>d3d4<64><00>Zed5ejd6d$<24>d7d8<64><00>Zed9ejd:<3A>d;d<<3C><00>Zed=ejd:<3A>d>d?<3F><00>Zed@ejd:<3A>dAdB<64><00>ZedCdDejdEd<1F>dFdG<64><00>ZedHdIejdJd<1F>dKdL<64><00>Z edMdNejdJd<1F>dOdP<64><00>Z!edQdRejdEd<1F>dSdT<64><00>Z"edUdVejdJd<1F>dWdX<64><00>Z#edYdZejdJd<1F>d[d\<5C><00>Z$ed]d^ejd<19>d_d`<60><00>Z%edadbejdd<1F>dcdd<64><00>Z&ededfdgdh<64>didj<64><00>Z'edkdldmdh<64>dndo<64><00>Z(dpdq<64>Z)edrej*dsd$<24>dtdu<64><00>Z+edvejd:<3A>dwdx<64><00>Z,edy<64>dzd{<7B><00>Z-ed|d}d~<7E>dd<7F><64><00>Z.dS)<29><>DviaH
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<>cCs<t<00>d|<01>t|d<02>|_||_i|_tj|_|<00> |<01>|_
dS)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.
zDvi: %s<>rbN) <0B>_log<6F>debug<75>open<65>file<6C>dpi<70>fonts<74> _dvistate<74>prer,<00> _get_baseline<6E>baseline)r+<00>filenamer@r r r<00>__init__<5F>s   z Dvi.__init__c
Csdtdr`tj<02>|<01>\}}|d}tj<02>|<04>r`t|d<03><02>}|<05><06><00><07>}WdQRX|\}}} t|<08>SdS)Nztext.latex.previewz .baseliner;) r<00>os<6F>path<74>splitext<78>existsr><00>read<61>split<69>float)
r+rF<00>base<73>extZbaseline_filename<6D>fd<66>l<>height<68>depth<74>widthr r rrD<00>s  
zDvi._get_baselinecCs|S)z=
Context manager enter method, does nothing.
r )r+r r r<00> __enter__<5F>sz Dvi.__enter__cCs |<00><00>dS)zX
Context manager exit method, closes the underlying file if it is open.
N)<01>close)r+<00>etypeZevalueZetracer r r<00>__exit__<5F>sz Dvi.__exit__ccsx|<00><00>r|<00><01>VqWdS)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)<02>_read<61>_output)r+r r r<00>__iter__<5F>s
z Dvi.__iter__cCs|jjs|j<00><02>dS)z:
Close the underlying file if it is open.
N)r?<00>closedrW)r+r r rrW<00>sz Dvi.closecs`tjtjtj tj f\<04>}}<02>tj }x<>|j|jD]z}t|t<05>rV|\}}}}d} n|\}}}
} }|
<EFBFBD>| <0B>\}} t<07>|<05><02>t|||<00>}t|||<00>}t<08>|| <00><02>t||<06>}q6W|j dkr<>t
|j|j|<02>||<00>|d<03>S|j d<00>|j dk<08>r<04>|<00><00>n|j <0B><01><00><01><02>fdd<06>|jD<00>} <0C><00><01><02>fdd<06>|jD<00>} t
| | |<02><00>||<00><00>d<03>S)zk
Output the text and boxes belonging to the most recent page.
page = dvi._output()
rN)<05>text<78>boxesrUrS<00>descentg<74>z<14>GRAc s>g|]6\}}}}}t|<01><00><00>|<00><00>|||<05><00><05>qSr )r )r%r&<00>yr(<00>g<>w)<04>dr`<00>maxy<78>minxr rr'szDvi._output.<locals>.<listcomp>cs>g|]6\}}}}t|<01><00><00>|<00><00>|<03>|<04><00><04>qSr )r
)r%r&ra<00>hrc)rdr`rerfr rr' s) <0C>np<6E>infr^r_<00>
isinstancer
<00>_height_depth_ofr*r5r@rrE)r+ZminyZmaxxZ maxy_pure<72>eltr&rargrc<00>e<>fontrbr^r_r )rdr`rerfrr[<00>s6 
 


  
 

z Dvi._outputcCsNxH|j<00>d<01>d}|j|||<01>|dkr.dS|jtjkr|<00><06>dSqWdS)zt
Read one page from the file. Return True if successful,
False if there were no more pages.
rr<00><>TFN)r?rL<00>_dtabler,rB<00> post_postrW)r+r)r r rrZ&s z Dvi._readFcCsP|j<00>|<01>}|d}|r(|dkr(|d}x"td|<01>D]}d|||}q4W|S)z~
Read and return an integer argument *nbytes* long.
Signedness is determined by the *signed* keyword.
r<00><>r:r)r?rLr1)r+<00>nbytesr<00>str<74>valuer3r r rr4s  zDvi._argr<00>)r*r5r,cCs*|<00>|<01>|j|j|j<00>|<01>7_dS)N)<05>_put_char_realrgrAr(<00> _width_of)r+<00>charr r r<00>_set_char_immediateAs
zDvi._set_char_immediaterr<00><>)r )r*r5r,r4cCs*|<00>|<01>|j|j|j<00>|<01>7_dS)N)rwrgrAr(rx)r+ryr r r<00> _set_charFs
z Dvi._set_char<61><72>)rr)r,r4cCs|<00>||<02>|j|7_dS)N)<02>_put_rule_realrg)r+<00>a<>br r r<00> _set_ruleKs z Dvi._set_rule<6C><65><00><>cCs|<00>|<01>dS)N)rw)r+ryr r r<00> _put_charPsz Dvi._put_charc s<><00>j<00>j}|jdkr:<3A>j<03>t<05>j<06>j|||<02>|<01><01><05>n<>|j <09>xr|j|jD]b\}}}}}t
t <0B>|j <09>|j |j |jd<01>}<08>j<03>t<05>jt |<03><00><00>jt |<04><00>|||<08>|<06><01><05>qNW<00>j<0E><0F><00>fdd<03>|j|jD<00><01>dS)N)<04>scale<6C>tfm<66>texname<6D>vfc sFg|]>\}}}}t<00>jt|<01><00><00>jt|<02><00>t|<03><00>t|<04><00><02><04>qSr )r
rg<00>_mul2012<31>v)r%r&rarr<>)r<>r+r rr'asz&Dvi._put_char_real.<locals>.<listcomp>)rAr(<00>_vfr^<00>appendr rgr<>rx<00>_scale<6C>DviFontr<74><00>_tfmr<6D>r_<00>extend) r+ryrnr&rar(rbrcZnewfr )r<>r+rrwTs 
 zDvi._put_char_real<61><6C>cCs|<00>||<02>dS)N)r~)r+rr<>r r r<00> _put_rulefsz Dvi._put_rulecCs.|dkr*|dkr*|j<00>t|j|j||<02><04>dS)Nr)r_r<>r
rgr<>)r+rr<>r r rr~jszDvi._put_rule_real<61><6C>cCsdS)Nr )r+rr r r<00>_nopnszDvi._nop<6F><70>) rrrrrrrrrrrc Cs:tj|_d\|_|_|_|_|_|_g|_ g|_
g|_ dS)N)rrrrrr) rB<00>inpager,rgr<>rcr&ra<00>z<>stackr^r_) r+Zc0Zc1<63>c2<63>c3Zc4Zc5Zc6Zc7Zc8Zc9<63>pr r r<00>_boprs
zDvi._bopro)r,cCs(tj|_|`|`|`|`|`|`|` dS)N)
rB<00>outerr,rgr<>rcr&rar<>r<>)r+rr r r<00>_eopzszDvi._eop<6F><70>cCs(|j<00>|j|j|j|j|j|jf<06>dS)N)r<>r<>rgr<>rcr&rar<>)r+rr r r<00>_pushsz Dvi._push<73><68>cCs&|j<00><01>\|_|_|_|_|_|_dS)N)r<><00>poprgr<>rcr&rar<>)r+rr r r<00>_pop<6F>szDvi._pop<6F><70><00><>)r!cCs|j|7_dS)N)rg)r+r<>r r r<00>_right<68>sz
Dvi._right<68><74><00><>)rcCs"|dk r||_|j|j7_dS)N)rcrg)r+Znew_wr r r<00>_right_w<5F>sz Dvi._right_w<5F><77><00><>cCs"|dk r||_|j|j7_dS)N)r&rg)r+Znew_xr r r<00>_right_x<5F>sz Dvi._right_x<5F><78><00><>cCs|j|7_dS)N)r<>)r+rr r r<00>_down<77>sz Dvi._down<77><6E><00><>cCs"|dk r||_|j|j7_dS)N)rar<>)r+Znew_yr r r<00>_down_y<5F>sz Dvi._down_y<5F><79><00><>cCs"|dk r||_|j|j7_dS)N)r<>r<>)r+Znew_zr r r<00>_down_z<5F>sz Dvi._down_z<5F><7A><00><>cCs
||_dS)N)r()r+<00>kr r r<00>_fnt_num_immediate<74>szDvi._fnt_num_immediate<74><65><00><>cCs
||_dS)N)r()r+<00>new_fr r r<00>_fnt_num<75>sz Dvi._fnt_num<75><6D><00><>)r")r*r5r4cCs,|j<00>|<01>}t<02>dd<02>dd<04>|D<00><01><01>dS)Nz!Dvi._xxx: encountered special: %s<>cSs4g|],}d|krdkr(nnt|<01>nd|<00>qS)<03> rvz<%02x>)<01>chr)r%<00>chr r rr'<00>szDvi._xxx.<locals>.<listcomp>)r?rLr<r=<00>join)r+Zdatalen<65>specialr r r<00>_xxx<78>s
 
zDvi._xxx<78><78><00><>)r rrrrrcCs|<00>||||||<06>dS)N)<01> _fnt_def_real)r+r<><00>c<>srdrrRr r r<00>_fnt_def<65>sz Dvi._fnt_defc Cs<>|j<00>||<00>}|| d<00><00>d<01>}t|<08>} | dkr@td|<00><01>|dkrh| jdkrh|| jkrhtd|<00><01>t|<08>}
t|| ||
d<05>|j |<dS)N<>asciizmissing font metrics file: %srztfm checksum mismatch: %s)r<>r<>r<>r<>)
r?rL<00>decode<64>_tfmfile<6C>FileNotFoundError<6F>checksumr-<00>_vffiler<65>rA) r+r<>r<>r<>rdrrR<00>nZfontnamer<65>r<>r r rr<><00>s  zDvi._fnt_def_real<61><6C>)rrrrrcCsT|j<00>|<05>}|dkr td|<00><01>|dks0|dkr8td<05><01>|dkrHtd<07><01>tj|_dS)N<>zUnknown dvi format %di<64><69><EFBFBD>i;znonstandard units in dvi filei<65>z%nonstandard magnification in dvi file)r?rLr-rBr<>r,)r+r3<00>num<75>denZmagr<67><00>commentr r r<00>_pre<72>s  zDvi._pre<72><65>cCs tj|_dS)N)rBrqr,)r+rr r r<00>_post<73>sz Dvi._post<73><74>cCst<00>dS)N)<01>NotImplementedError)r+rr r r<00>
_post_post<EFBFBD>szDvi._post_post<73><74><00><>)r*r5cCstdd|<00><02>dS)Nzunknown command: byte %dr<64>)r-)r+<00>offsetr r r<00>
_malformed<EFBFBD>szDvi._malformed)F)/<2F>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__rprr8rGrDrVrYr\rWr[rZrrBr<>rzr|r<>r<>rwr<>r~r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>rCr<>r<>r<>r<>r r r rr9<00>sN 

 )
 r9c@sDeZdZdZdZdd<04>Zdd<06>Zdd<08>Zd d
<EFBFBD>Zd d <0C>Z d d<0E>Z
dS)r<>a<>
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, and :class:`dviread.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<><00>size<7A>widthsr<73>r<>r<>cs<>t|t<01>stdt|<03><00><01>||_<04>|_||_||_|d|_yt <09>j
<EFBFBD>d}Wntk
rfd}YnX<00>fdd<06>t |<05>D<00>|_ dS)Nz$texname must be a bytestring, got %sg]<15>e<><65>>rrcs"g|]}d<00>j<00>|d<01>d?<00>qS)i<>r<00>)rU<00>get)r%ry)r<>r rr'sz$DviFont.__init__.<locals>.<listcomp>) rjrr-<00>typer<65>r<>r<>r<>r<>r5rUr1r<>)r+r<>r<>r<>r<>Zncharsr )r<>rrGs
 


zDviFont.__init__cCs(t|<00>t|<01>ko&|j|jko&|j|jkS)N)r<>r<>r<>)r+<00>otherr r r<00>__eq__!szDviFont.__eq__cCs |<00>|<01> S)N)r<>)r+r<>r r r<00>__ne__%szDviFont.__ne__cCsd<01>t|<00>j|j<03>S)Nz<{}: {}>)<04>formatr<74>r<>r<>)r+r r r<00>__repr__(szDviFont.__repr__cCs8|jj<01>|d<01>}|dk r$t||j<04>St<05>d||j<07>dS)zWidth of char in dvi units.Nz No width for char %d in font %s.r)r<>rUr<>r<>r<>r<r=r<>)r+ryrUr r rrx+s
 zDviFont._width_ofcCsrg}xh|jjdf|jjdffD]L\}}|<03>|d<03>}|dkrXt<04>d|||j<06>|<02>d<05>q|<02>t||j <09><02>qW|S)z&Height and depth of char in dvi units.rSrTNzNo %s for char %d in font %sr)
r<EFBFBD>rSrTr<>r<r=r<>r<>r<>r<>)r+ry<00>resultZmetric<69>namerur r rrk3s    zDviFont._height_depth_ofN) r<>r<>r<>r<><00> __slots__rGr<>r<>r<>rxrkr r r rr<><00>s%r<>c@s@eZdZdZdd<03>Zdd<05>Zdd<07>Zdd <09>Zd
d <0B>Zd d <0A>Z dS)<0F>Vfa<66>
A virtual font (\*.vf file) containing subroutines for dvi files.
Usage::
vf = Vf(filename)
glyph = vf[code]
glyph.text, glyph.boxes, glyph.width
Parameters
----------
filename : string or bytestring
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.
cCs6t<00>||d<01>zd|_i|_|<00><04>Wd|<00><05>XdS)Nr)r9rG<00> _first_font<6E>_charsrZrW)r+rFr r rrGXs  z Vf.__init__cCs
|j|S)N)r<>)r+<00>coder r r<00> __getitem__aszVf.__getitem__cs<>d\}}d\}}<04>j<00>d<02>d}<05>jtjkr<><72>j<00><05>d}||kr^<5E><00>||<04>d\}}}n@||krptd<05><01>n.|dks<>|dkr<>td|<00><01>tj |<00>|<05>q|d kr<>|}<03><00>
d<02><01><00>
d
<EFBFBD>}}<04><00> |<05>}tj<04>_q|d k<02>r<02>fd d <0C>d D<00>\}}}<04><00> |<03>qd|k<01>rdk<01>rvnnX<6E><00>
|d |dk<02>}<07>fdd <0C>dD<00>\}} }
} } <0C><00> ||| |
| | <0C><00>j dk<08>r<>|<07>_ q|dk<02><00>
d<02><01><00>
d<02>} }<07>j<00>|<07>}<0E><00>
d<13><01><00>
d<13>}}<10><00>| |||<10>q|dk<02>r<>Pqtd|<00><01>qWdS)zt
Read one page from the file. Return True if successful,
False if there were no more pages.
)NNrr)NNNz!Packet length mismatch in vf file)r<>ror<>z"Inappropriate opcode %d in vf filer<65>rcsg|]}<01><00>|<01><01>qSr )r)r%r&)r+r rr'<00>szVf._read.<locals>.<listcomp>)rrrr<>csg|]}<01><00>|<01><01>qSr )r)r%r&)r+r rr'<00>s)rrrrrNr<4E>rr<>zunknown vf opcode %d)r?rLr,rBr<><00>tell<6C>_finalize_packetr-r9rpr<00> _init_packetr<74>r<>r<>)r+<00> packet_charZ packet_endsZ
packet_len<EFBFBD> packet_widthr)Zbyte_atr<74>r<>r<>rdrrRr3r&<00>cs<63>dsr )r+rrZdsL   




  
 
zVf._readcCs\|jtjkrtd<01><01>d\|_|_|_|_|_|_ ggg|_
|_ |_ |j |_|j<0F><10>|S)NzMisplaced packet in vf file)rrrrrr)r,rBr<>r-rgr<>rcr&rar<>r<>r^r_r<>r(r?r<>)r+<00>plr r rr<><00>s  zVf._init_packetcCs(t|j|j|ddd<01>|j|<tj|_dS)N)r^r_rUrSr`)rr^r_r<>rBr<>r,)r+r<>r<>r r rr<><00>s
zVf._finalize_packetcCsH|jtjk rtd<01><01>|dkr(td|<00><01>t|<02>r<t<05>d|<02>tj|_dS)Nz pre command in middle of vf file<6C><65>zUnknown vf format %dzvf file comment: %s)r,rBrCr-<00>lenr<r=r<>)r+r3r&r<>r<>r r rr<><00>s   zVf._preN)
r<EFBFBD>r<>r<>r<>rGr<>rZr<>r<>r<>r r r rr<>Bs 3r<>cCs2d|krdksnt<00>|d@r*|dS|SdS)z*Convert from two's complement to negative.rllN)r2)r<>r r r<00> _fix2comp<6D>srcCs ||d?S)z1Multiply two numbers in 20.12 fixed point format.r<>r )Znum1Znum2r r rr<><00>sr<>c@seZdZdZdZdd<04>ZdS)<06>Tfma
A TeX Font Metric file.
This implementation covers only the bare minimum needed by the Dvi class.
Parameters
----------
filename : string or bytestring
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.
)r<><00> design_sizerUrSrTc
Cs|t<00>d|<01>t|d<02><02><>}|<02>d<03>}t<04>d|dd<06><00>\}}}}}} t<00>d|||||| <09>|<02>d|<00>}
t<04>d |
dd
<EFBFBD><00>\|_|_|<02>d||d <00>} |<02>d|<00>} |<02>d|<00>} |<02>d| <00>}WdQRXiii|_|_ |_
d d <0A>| | |fD<00>\} } }xzt t ||d <00><02>D]d\}}| d|}| d|d }t | |<00>|j|<t | |d?<00>|j |<t ||d@<00>|j
|<<00>qWdS)Nzopening tfm file %sr;<00>z!6Hr<48><00>z(lh=%d, bc=%d, ec=%d, nw=%d, nh=%d, nd=%drz!2I<32>rcSs$g|]}t<00>dt|<01>d|<01><02>qS)z!%dIr)<03>struct<63>unpackr)r%r&r r rr'<00>sz Tfm.__init__.<locals>.<listcomp><3E>)r<r=r>rLr r
r<>rrUrSrT<00> enumerater1r)r+rFr?Zheader1ZlhZbcZec<65>nwZnhZndZheader2Z char_infor<6F>ZheightsZdepths<68>idxryZbyte0Zbyte1r r rrG<00>s*  
  z Tfm.__init__N)r<>r<>r<>r<>r<>rGr r r rr<00>srZFontz(texname psname effects encoding filenamec@s2eZdZdZdZe<05>dd<04><00>Zdd<06>Zdd<08>Zd S)
<EFBFBD>
PsfontsMapa<EFBFBD>
A psfonts.map formatted file, mapping TeX fonts to PS fonts.
Usage::
>>> 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
Parameters
----------
filename : string or bytestring
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.
)<02>_font<6E> _filenamec Cs@t<00>|<00>}i|_t<03>|<01>|_t|d<01><02>}|<02>|<03>WdQRX|S)Nr;)<08>object<63>__new__rrH<00>fsdecoderr><00>_parse)<04>clsrFr+r?r r rr)s 
  zPsfontsMap.__new__cCs<>t|t<01>st<02>y|j|}WnHtk
rdd}|<03>|<01>d<02>|j<07>}tj |ddd<04>}t
<EFBFBD> |<04><00>YnX|j |j }}|dk r<>|<05>d<05>s<>t|<05>}|dk r<>|<06>d<05>s<>t|j <0A>}|j||d<06>S)Na$A PostScript file for the font whose TeX name is "{0}" could not be found in the file "{1}". The dviread module can only handle fonts that have an associated PostScript font file. This problem can often be solved by installing a suitable PostScript font package in your (TeX) package manager.r<>F)<02>break_on_hyphens<6E>break_long_words<64>/)rF<00>encoding)rjrr2r<00>KeyErrorr<72>r<>r<00>textwrap<61>fillr<<00>inforFr<00>
startswith<EFBFBD> find_tex_file<6C>_replace)r+r<>r<><00>fmt<6D>msg<73>fn<66>encr r rr<>2s 

zPsfontsMap.__getitem__cs~t<00>d<01><01>t<00>d<02>}t<00>d<03>}<03>fdd<05>|D<00>}<04>xF|D<00>]<}d\}}}|<02>|<05>} t| <09>}
|
<EFBFBD>d<07>pl|
<EFBFBD>d<08>} t| <09>}
|
<EFBFBD>d<07>p<>|
<EFBFBD>d<08>} x<>| D]<5D>}
|
<EFBFBD>d<08>p<>|
<EFBFBD>d<07>} | r<>| }q<>|
<EFBFBD>d <09>p<>|
<EFBFBD>d
<EFBFBD>p<>|
<EFBFBD>d <0B>p<>|
<EFBFBD>d <0C>}|r<>|d k r<>t<05>d| | <0C>|}q<>|
<EFBFBD>d<0F><01>p|
<EFBFBD>d<10>}q<>Wi}xD|<03>|<06>D]6}|<10>d<11>}|<11>rFt|<11>|d<nt|<10>d<12><01>|d<<00>q$Wt| | |||d<13>|j | <q8Wd S)a>
Parse the font mapping file.
The format is, AFAIK: texname fontname [effects and filenames]
Effects are PostScript snippets like ".177 SlantFont",
filenames begin with one or two less-than signs. A filename
ending in enc is an encoding file, other filenames are font
files. This can be overridden with a left bracket: <[foobar
indicates an encoding file named foobar.
There is some difference between <foo.pfb and <<bar.pfb in
subsetting, but I have no example of << in my TeX installation.
s%|\s*$sZ(?x) (?:
"<\[ (?P<enc1> [^"]+ )" | # quoted encoding marked by [
"< (?P<enc2> [^"]+.enc)" | # quoted encoding, ends in .enc
"<<? (?P<file1> [^"]+ )" | # quoted font file name
" (?P<eff1> [^"]+ )" | # quoted effects or font name
<\[ (?P<enc3> \S+ ) | # encoding marked by [
< (?P<enc4> \S+ .enc) | # encoding, ends in .enc
<<? (?P<file2> \S+ ) | # font file name
(?P<eff2> \S+ ) # effects or font name
)sy(?x) (?P<slant> -?[0-9]*(?:\.[0-9]+)) \s* SlantFont
| (?P<extend>-?[0-9]*(?:\.[0-9]+)) \s* ExtendFontc3s |]}<01><00>|<01>s|<01><01>VqdS)N)<02>match<63>strip)r%<00>line)<01>empty_rer r<00> <genexpr>nsz$PsfontsMap._parse.<locals>.<genexpr>)<03>NNZeff2Zeff1Zenc4Zenc3Zenc2Zenc1NzMultiple encodings for %s = %s<>file2<65>file1<65>slantr<74>)r<><00>psname<6D>effectsrrF)
<EFBFBD>re<72>compile<6C>finditer<65>next<78>groupr<r=rN<00>PsFontr)r+r?Zword_reZ
effects_re<EFBFBD>linesr(r0rrF<00>wordsrcr<>r/Zeffr%Z effects_dictr&r.r )r)rrJsJ






zPsfontsMap._parseN) r<>r<>r<>r<>r<>rrr<>rr r r rr<00>s
- rc@s0eZdZdZdZdd<04>Zdd<06>Zedd<08><00>Zd S)
<EFBFBD>Encodinga<67>
Parses a \*.enc file referenced from a psfonts.map style file.
The format this class understands is a very limited subset of
PostScript.
Usage (subject to change)::
for name in Encoding(filename):
whatever(name)
Parameters
----------
filename : string or bytestring
Attributes
----------
encoding : list
List of character names
)rc Cs@t|d<01><02>,}t<01>d|<01>|<00>|<02>|_t<01>d|j<04>WdQRXdS)Nr;zParsing TeX encoding %sz
Result: %s)r>r<r=rr)r+rFr?r r rrG<00>s   zEncoding.__init__ccs|jEdHdS)N)r)r+r r rr\<00>szEncoding.__iter__cCs|dd<02>|D<00>}d<03>|<01>}|<02>d<04>}|dkr8td<06>|<00><01><01>||d<00>}|<02>d<07>}|dkrdtd<08>|<00><01><01>|d|<04>}t<04>d |<02>S)
Ncss"|]}|<01>dd<01>d<00><01>VqdS)<04>%rrN)rMr')r%r(r r rr*<00>sz"Encoding._parse.<locals>.<genexpr>r+<00>[rz)Cannot locate beginning of encoding in {}<7D>]z#Cannot locate end of encoding in {}s/([^][{}<>\s]+))r<><00>findr-r<>r1<00>findall)r?r7<00>dataZ beginning<6E>endr r rr<00>s

 
 zEncoding._parseN) r<>r<>r<>r<>r<>rGr\<00> staticmethodrr r r rr9<00>s
r9c Cs<>t|dd<02><02>}d<03>dd<05>|D<00><01>}WdQRXt<02>d|<02><02>d<08>}d d
<EFBFBD>|<03>d<03>D<00>}td d<05>|D<00><01>rrd d
<EFBFBD>|D<00>Std <0A>|<00><01><01>dS)aR
Parses a \*.enc file referenced from a psfonts.map style file.
The format this class understands is a very limited subset of PostScript.
Parameters
----------
path : os.PathLike
Returns
-------
encoding : list
The nth entry of the list is the PostScript glyph name of the nth
glyph.
r<>)r<00>
css |]}|<01>d<00>d<00><01>VqdS)<03>%rN)rM<00>rstrip)r%r(r r rr*<00>sz_parse_enc.<locals>.<genexpr>Nz (?s)\[(.*)\]rcSsg|] }|r|<01>qSr r )r%r(r r rr'<00>sz_parse_enc.<locals>.<listcomp>css|]}|<01>d<00>VqdS)<02>/N)r)r%r(r r rr*<00>scSsg|]}|dd<01><00>qS)rNr )r%r(r r rr'<00>sz)Failed to parse {} as Postscript encoding) r>r<>r1<00>searchr5rM<00>allr-r<>)rIr?Z no_comments<74>arrayr7r r r<00>
_parse_enc<EFBFBD>srIcCs<>t|t<01>r|jddd<03>}t|t<01>r0|jddd<03>}tjdkrPtttjdd<05>d<06>}ni}dg}|dk rp|d |g7}||g7}ytj|t f|<02>}Wnt
k
r<EFBFBD>d
SXtjdkr<>|<04>d<01><01> d <0B>St<03> |<04><01> d <0C>SdS) a<>
Find a file in the texmf tree.
Calls :program:`kpsewhich` which is an interface to the kpathsea
library [1]_. Most existing TeX distributions on Unix-like systems use
kpathsea. It is also available as part of MikTeX, a popular
distribution on Windows.
*If the file is not found, an empty string is returned*.
Parameters
----------
filename : string or bytestring
format : string or bytestring
Used as the value of the `--format` option to :program:`kpsewhich`.
Could be e.g. 'tfm' or 'vf' to limit the search to that type of files.
References
----------
.. [1] `Kpathsea documentation <http://www.tug.org/kpathsea/>`_
The library that :program:`kpsewhich` is part of.
zutf-8<>replace)<01>errors<72>nt)Zcommand_line_encoding)<01>envZ kpsewhichNz --format=r<>z
rB) rjrr<>rHr<><00>dict<63>environrZ_check_and_log_subprocessr<<00> RuntimeErrorrDr)rFr<><00>kwargs<67>cmdr<64>r r rr <00>s$




r cCst||<00>}|r||<03>SdS)N)r )r<00>suffixr<78>rFr r r<00> _fontfile%s rTz.tfmz.vf<76>__main__)<01>ArgumentParserrFr@<00>?)<03>nargsr<73><00>defaultz
pdftex.mapz=== new page ===cCs|jS)N)rn)r^r r r<00><lambda><r+rZrnZscaledi<00>.ZBOX)NNr#)N)Or<4F><00> collectionsr<00>enum<75> functoolsrrr<00>loggingrHr1r rZnumpyrhZ
matplotlibrr<00> getLoggerr<72>r<<00>EnumrBrr r
rrrrrrrNr$r8rr9r<>r<>rr<>rr6rr9rIr rTr<>r<><00>argparserV<00> itertools<6C>parser<65> add_argumentrN<00>
parse_argsr4rFr@r Zfontmap<61>page<67>print<6E>groupbyr^rnr5r<>r<>r&raZglyphr<68><00> isprintablerUr_rcrgr r r r<00><module>s<> 
 







1?Yn 4
)6 6