+
     ]iP  c                   s    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                 s~    \        V R 4      ;_uu_ 4       p\        V4      uuRRR4       #   + '       g   i     R# ; i)ZrbN)Zopenr   )fnamefh   & J/usr/lib64/python3.14/site-packages/matplotlib/backends/_backend_pdf_ps.py_cached_get_afm_from_fnamer
      s'    	eT		b2w 
			s   +<	c                sH   \         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)Zglyph_namesZrecommended_glyphsz.ttc)options)Ztext)ZFFTMZPfEdZBDFZmetaZMERGZTSIVZZapfZbdatZblocZcidgZfdscZfeatZfmtxZfondZjustZkerxZltagZmorxZtrakZxref)r   ZOptionsZdrop_tablesZendswithZfont_numberZ	load_fontZ	SubsetterZpopulate)ZfontfileZ
charactersr   fontZ	subsetters   &&   r	   get_glyphs_subsetr      s    ( nn$GG   .   H.D  1IJ'TK    c                s@    \        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)ZreorderTables)r    Zsave)r   r   r   r	   font_as_filer   O   s      
BIIbI&Ir   c                   s6   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                s    / V n         R # Nusedself   &r	   __init__ZCharacterTracker.__init__j   s	    	r   c                s    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)Z_get_fontmapZitemsr   
setdefaultr   setaddZord)r   r   sZchar_to_fontZ_cZ_fs   &&&   r	   trackZCharacterTracker.trackm   sP    ((+"((*FBII  35155c"g> +r   c                s    V P                   P                  VP                  \        4       4      P	                  V4       R# )zARecord that codepoint *glyph* is being typeset using font *font*.N)r   r   r   r   r   )r   r   Zglyphs   &&&r	   track_glyphZCharacterTracker.track_glyphs   s'    		TZZ/33E:r   r   N)
__name__
__module____qualname____firstlineno____doc__r   r   r   __static_attributes____classdictcell__)__classdict__s   @r	   r   r   b   s     ?; ;r   r   c                   sb   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<   < \         SV `  4        Wn        W n        R # r   )superr   widthheight)r   r(   r)   	__class__s   &&&r	   r   ZRendererPDFPSBase.__init__}   s    
r   c                    R # )F r   r   r	   flipyZRendererPDFPSBase.flipy   s    r   c                r+   )Tr,   r   r   r	   option_scale_imageZ$RendererPDFPSBase.option_scale_image   s    r   c                s:    \         P                  R ,          '       * # )zimage.composite_image)mplrcParamsr   r   r	   option_image_nocompositeZ*RendererPDFPSBase.option_image_nocomposite   s     << 7888r   c                sN    V P                   R ,          V P                  R ,          3# )g      R@)r(   r)   r   r   r	   get_canvas_width_heightZ)RendererPDFPSBase.get_canvas_width_height   s    zzD $++"444r   c                s  < 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# )ZTeXi  g        )Zflagsg      ?)r'   get_text_width_height_descentZ
_text2pathZmathtext_parserparser(   r)   Zdepthr/   r0   Z_use_afm_rc_name_get_font_afmZget_str_bbox_and_descentget_size_in_points_get_font_ttfZset_textr   Z	LoadFlagsZ
NO_HINTINGZget_width_heightZget_descent)r   r   propZismathr4   r   ZlZbZwZhZdZscaler*   s   &&&&        r	   r3   Z/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7Nr   c                s^    \         P                  ! VR V P                  R7      p\        V4      # )Zafm)ZfontextZ	directory)r   ZfindfontZ_afm_font_dirr
   )r   r8   r   s   && r	   r5   ZRendererPDFPSBase._get_font_afm   s*    %%%4+=+=?)%00r   c                sF   \         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)iH   zMThe PostScript/PDF backend does not currently support the selected font (%s).)r   ZfontManagerZ_find_fonts_by_propsZget_fontZclearZset_sizer6   ZRuntimeErrorloggingZ	getLoggerr   Zwarning)r   r8   Zfnamesr   s   &&  r	   r7   ZRendererPDFPSBase._get_font_ttf   s    ))>>tD		((0DJJLMM$113R8K 	h'//239; 		s   AA) )7B )r)   r(   )r   r   r    r!   r   r-   r.   r1   r2   r3   r5   r7   r#   r$   Z__classcell__)r*   r%   s   @@r	   r&   r&   x   s2     

9
541
 r   r&   )r"   Zior    Z	functoolsr9   Z	fontToolsr   Z
matplotlibr/   Z r   r   Z_afmr   Zbackend_basesr   Z	lru_cacher
   r   r   r   r&   r,   r   r	   <module>r:      sf         $  ( R 
5p&; ;,E Er   