+
    ,iP                         R t ^ RIHt ^ RIt^ RIt^ RIHt ^ RIt^RI	H
t
Ht ^RIHt ^RIHt ]P                   ! ^24      R 4       tR tR	 t ! R
 R4      t ! R R]4      tR# )z7
Common functionality between the PDF and PS backends.
)BytesION)subset)font_managerft2font)AFM)RendererBasec                 ~    \        V R 4      ;_uu_ 4       p\        V4      uuRRR4       #   + '       g   i     R# ; i)rbN)openr   )fnamefhs   & E/usr/lib/python3/dist-packages/matplotlib/backends/_backend_pdf_ps.py_cached_get_afm_from_fnamer      s'    	eT		b2w 
			s   +<	c                H   \         P                  ! RRR7      pV;P                  . RO,          un        V P                  R4      '       d   ^ Vn        \         P
                  ! W4      p\         P                  ! VR7      pVP                  VR7       VP                  V4       V# )aj  
Subset a TTF font

Reads the named fontfile and restricts the font to the characters.

Parameters
----------
fontfile : str
    Path to the font file
characters : str
    Continuous set of characters to include in subset

Returns
-------
fontTools.ttLib.ttFont.TTFont
    An open font object representing the subset, which needs to
    be closed by the caller.
T)glyph_namesrecommended_glyphsz.ttc)options)text)FFTMPfEdBDFmetaMERGTSIVZapfbdatbloccidgfdscfeatfmtxfondjustkerxltagmorxtrakxref)r   Optionsdrop_tablesendswithfont_number	load_font	Subsetterpopulate)fontfile
charactersr   font	subsetters   &&   r   get_glyphs_subsetr3      s    ( nn$GG   .   H.D  1IJ'TK    c                @    \        4       pV P                  VRR7       V# )z
Convert a TTFont object into a file-like object.

Parameters
----------
font : fontTools.ttLib.ttFont.TTFont
    A font object

Returns
-------
BytesIO
    A file object with the font saved into it
F)reorderTables)r   save)r1   r   s   & r   font_as_filer8   O   s      
BIIbI&Ir4   c                   6   a  ] tR t^bt o RtR tR tR tRtV t	R# )CharacterTrackerz
Helper for font subsetting by the pdf and ps backends.

Maintains a mapping of font paths to the set of character codepoints that
are being used from that font.
c                    / V n         R # Nusedselfs   &r   __init__CharacterTracker.__init__j   s	    	r4   c                    VP                  V4      pVP                  4        FK  w  rEV P                  P                  VP                  \        4       4      P                  \        V4      4       KM  	  R# )z:Record that string *s* is being typeset using font *font*.N)_get_fontmapitemsr>   
setdefaultr   setaddord)r@   r1   schar_to_font_c_fs   &&&   r   trackCharacterTracker.trackm   sP    ((+"((*FBII  35155c"g> +r4   c                    V P                   P                  VP                  \        4       4      P	                  V4       R# )zARecord that codepoint *glyph* is being typeset using font *font*.N)r>   rF   r   rG   rH   )r@   r1   glyphs   &&&r   track_glyphCharacterTracker.track_glyphs   s'    		TZZ/33E:r4   r=   N)
__name__
__module____qualname____firstlineno____doc__rA   rN   rR   __static_attributes____classdictcell__)__classdict__s   @r   r:   r:   b   s     ?; ;r4   r:   c                   b   a a ] tR t^xt oV 3R ltR tR tR tR tV 3R lt	R t
R tR	tVtV ;t# )
RendererPDFPSBasec                <   < \         SV `  4        Wn        W n        R # r<   )superrA   widthheight)r@   r`   ra   	__class__s   &&&r   rA   RendererPDFPSBase.__init__}   s    
r4   c                    R # )F r?   s   &r   flipyRendererPDFPSBase.flipy   s    r4   c                    R # )Tre   r?   s   &r   option_scale_image$RendererPDFPSBase.option_scale_image   s    r4   c                :    \         P                  R ,          '       * # )zimage.composite_image)mplrcParamsr?   s   &r   option_image_nocomposite*RendererPDFPSBase.option_image_nocomposite   s     << 7888r4   c                N    V P                   R ,          V P                  R ,          3# )g      R@)r`   ra   r?   s   &r   get_canvas_width_height)RendererPDFPSBase.get_canvas_width_height   s    zzD $++"444r4   c                  < VR 8X  d   \         SV `  WV4      # V'       dK   V P                  P                  P	                  V^HV4      pVP
                  VP                  VP                  3# \        P                  V P                  ,          '       dZ   V P                  V4      pVP                  V4      w  rgrp
VP                  4       R,          pW,          pW,          p	W,          p
WV
3# V P                  V4      pVP                  VR\         P"                  P$                  R7       VP'                  4       w  rVP)                  4       p
RpW,          pW,          p	W,          p
WV
3# )TeXi  g        )flagsg      ?)r_   get_text_width_height_descent
_text2pathmathtext_parserparser`   ra   depthrl   rm   _use_afm_rc_name_get_font_afmget_str_bbox_and_descentget_size_in_points_get_font_ttfset_textr   	LoadFlags
NO_HINTINGget_width_heightget_descent)r@   rJ   propismathry   r1   lbwhdscalerb   s   &&&&        r   rv   /RendererPDFPSBase.get_text_width_height_descent   s1   U?78&IIOO3399!RFE;;ekk99\\$//00%%d+D 99!<MA!++-4EJAJAJA7N%%d+DMM!S(9(9(D(DME((*DA  "AEJAJAJA7Nr4   c                ^    \         P                  ! VR V P                  R7      p\        V4      # )afm)fontext	directory)r   findfont_afm_font_dirr   )r@   r   r   s   && r   r|   RendererPDFPSBase._get_font_afm   s*    %%%4+=+=?)%00r4   c                F   \         P                  P                  V4      p \         P                  ! V4      pVP	                  4        VP                  VP                  4       ^H4       V#   \         d-    \        P                  ! \        4      P                  RT4       h i ; i)H   zMThe PostScript/PDF backend does not currently support the selected font (%s).)r   fontManager_find_fonts_by_propsget_fontclearset_sizer~   RuntimeErrorlogging	getLoggerrT   warning)r@   r   fnamesr1   s   &&  r   r   RendererPDFPSBase._get_font_ttf   s    ))>>tD		((0DJJLMM$113R8K 	h'//239; 		s   AA) )7B )ra   r`   )rT   rU   rV   rW   rA   rf   ri   rn   rq   rv   r|   r   rY   rZ   __classcell__)rb   r[   s   @@r   r]   r]   x   s2     

9
541
 r4   r]   )rX   ior   	functoolsr   	fontToolsr   
matplotlibrl    r   r   _afmr   backend_basesr   	lru_cacher   r3   r8   r:   r]   re   r4   r   <module>r      sf         $  ( R 
5p&; ;,E Er4   