+
    TBi[              	          R t ^ RIt^ RIt^ RIHt ^ RIHtHtHtH	t	 ^ RI
t
 ^ RIHtHtHt Rt ^ RIt. R!OtR. R"ORRR.RR.RRR./tRtRtRt ! R R]4      t ! R R]4      t ! R R4      t ! R R]4      t ! R R]4      t ! R R	]4      t ! R  R
]4      tR#   ] d    Rt Lyi ; i  ] d     ^ RIt L  ] d    Rt  Li ; ii ; i)#z
pygments.formatters.img
~~~~~~~~~~~~~~~~~~~~~~~

Formatter for Pixmap output.

:copyright: Copyright 2006-2025 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
N)	Formatter)get_bool_optget_int_optget_list_optget_choice_opt)Image	ImageDraw	ImageFontTFImageFormatterGifImageFormatterJpgImageFormatterBmpImageFormatterNORMALITALICObliqueItalicBOLDBold
BOLDITALICzBold ObliquezBold ItaliczDejaVu Sans MonozCourier NewMenloc                       ] tR t^4tRtRtR# )PilNotAvailablez,When Python imaging library is not available N__name__
__module____qualname____firstlineno____doc____static_attributes__r       </usr/lib/python3.14/site-packages/pygments/formatters/img.pyr   r   4   s    6r    r   c                       ] tR t^8tRtRtR# )FontNotFoundz(When there are no usable fonts specifiedr   Nr   r   r    r!   r#   r#   8   s    2r    r#   c                   n   a  ] tR t^<t o RtRR ltR tR tR tR t	RR lt
R tR	 tR
 tR tR tRtV tR# )FontManagerz6
Manages a set of fonts: normal, italic, bold, etc...
c                   Wn         W n        / V n        R V n        RV n        \        VR4      '       g&   \        P                  P                  V4      '       dE   \        P                  ! WP                  4      pRV n        \         F  pW0P                  V&   K  	  R # \        P                  P                  R4      '       d&   V'       g   \        V n         V P!                  4        R # \        P                  P                  R4      '       d&   V'       g   \"        V n         V P%                  4        R # V'       g   \&        V n         V P)                  4        R # )NFreadTwindarwin)	font_name	font_sizefontsencodingvariablehasattrospathisfiler	   truetypeSTYLESsysplatform
startswithDEFAULT_FONT_NAME_WIN_create_winDEFAULT_FONT_NAME_MAC_create_macDEFAULT_FONT_NAME_NIX_create_nix)selfr*   r+   fontstyles   &&&  r!   __init__FontManager.__init__A   s    ""
9f%%	)B)B%%i@D DM$(

5!   <<""5))!6\\$$X..!6!6r    c                   \         P                  ! R V RV 2R.\         P                  RR7      pVP                  4       w  rEVP                  ^ 8X  dn   VP                  4       pV FU  pVP                  R4      '       d   K  VP                  4       P                  4       P                  R4      pV'       g   KS  Vu # 	  R# R# )zfc-listz:style=fileN)stdoutstderrs   Fontconfig warning::)	
subprocessPopenPIPEcommunicate
returncode
splitlinesr7   decodestrip)	r>   namer@   procrE   _linesliner1   s	   &&&      r!   _get_nix_font_pathFontManager._get_nix_font_path\   s    tfGE7,CV L'1tE$$&	??a%%'E??#9::{{}**,22374K    r    c                j   \         R ,           FR  pV P                  V P                  V4      pVf   K%  \        P                  ! W P
                  4      V P                  R &    M	  \        RV P                   R24      hR F  p\         V,           FS  pV P                  V P                  V4      pVf   K%  \        P                  ! W P
                  4      V P                  V&    Ke  	  VR8X  d#   V P                  R,          V P                  V&   K  V P                  R ,          V P                  V&   K  	  R# )r   NNo usable fonts named: ""r   r   r   r   r   )r4   rU   r*   r	   r3   r+   r,   r#   )r>   rP   r1   r@   	stylenames   &    r!   r=   FontManager._create_nixj   s    8$$D**4>>4@D'0'9'9$'O

8$	 % !9$..9IKLL5E#E]]	..t~~yI#(1(:(:4(PDJJu%	 + L((,

6(:DJJu%(,

8(<DJJu% 6r    c                x    VP                  VR ,           V,           P                  4       P                  4       4      # ) )getrO   lower)r>   font_maprP   r@   s   &&&&r!   _get_mac_font_pathFontManager._get_mac_font_path~   s,    ||TCZ%/668>>@AAr    c                J  a / p\         P                  P                  \         P                  ! R 4      R4      RR3 F2  oVP	                  V3R l\         P
                  ! S4       4       4       K4  	  \        R,           FR  pV P                  WP                  V4      pVf   K%  \        P                  ! W0P                  4      V P                  R&    M	  \        RV P                   R24      hR F  p\        V,           FS  pV P                  WP                  V4      pVf   K%  \        P                  ! W0P                  4      V P                  V&    Ke  	  VR
8X  d#   V P                  R	,          V P                  V&   K  V P                  R,          V P                  V&   K  	  R# )HOMEzLibrary/Fonts/z/Library/Fonts/z/System/Library/Fonts/c              3   2  <"   T F  w   rV F  pVP                  4       P                  R4      '       g   K*  \        P                  P	                  V4      ^ ,          P                  4       \        P                  P                  SV4      3x  K  	  K  	  R# 5i)ttfN)rg   ttc)r`   endswithr0   r1   splitextjoin).0rR   filesffont_dirs   &   r!   	<genexpr>*FontManager._create_mac.<locals>.<genexpr>   sr      7#4KAqA779%%n5 L!!!$Q'--/h1JK L#4s   /BA Br   NrX   rY   r   r   rZ   )r0   r1   rk   getenvupdatewalkr4   rb   r*   r	   r3   r+   r,   r#   )r>   ra   rP   r1   r@   r[   ro   s   &     @r!   r;   FontManager._create_mac   sT   bii&79IJ*,DFHOO 7#%778#47 7F 8$$D**8^^TJD'0'9'9$'O

8$	 % !9$..9IKLL5E#E]]	..xS#(1(:(:4(PDJJu%	 + L((,

6(:DJJu%(,

8(<DJJu% 6r    c                   R FL  pV FC  p RP                  Y&;'       d
    RV,           V4      p\        P                  ! W4      w  rVu u # 	  KN  	  V'       d   \	        RV RV^ ,           R24      hR#   \         d     K|  i ; i) z{}{}{}r^   zFont z (z) not found in registryN)rw   z (TrueType))format_winregQueryValueExOSErrorr#   )
r>   keybasenamestylesfailsuffixr@   valnamevalrR   s
   &&&&&     r!   _lookup_winFontManager._lookup_win   s    )F&ooh8K8K#e)VTG$11#?FCJ	   * "U8*BvaykAX#YZZ  s   A6(A66BBc                   R p\         P                  R3\         P                  R3\         P                  R3\         P                  R3.pV EF6  p \         P                  ! V!  p V P	                  W@P
                  \        R,          R4      p\        P                  ! WPP                  4      V P                  R&   R F  pV P	                  W@P
                  \        V,          4      pV'       d0   \        P                  ! WPP                  4      V P                  V&   Ka  VR8X  d#   V P                  R,          V P                  V&   K  V P                  R,          V P                  V&   K  	   \         P                  ! V4        R # 	  V'       d   Vh\        R4      h  \         d   pTp R p?MR p?ii ; i \         P                  ! T4       EK    \         P                  ! T4       i ; i  \         d     EK  i ; i)	Nz2Software\Microsoft\Windows NT\CurrentVersion\Fontsz/Software\Microsoft\Windows\CurrentVersion\Fontsr   Tr   r   z$Can't open Windows font registry keyrZ   )ry   HKEY_CURRENT_USERHKEY_LOCAL_MACHINEOpenKeyr   r*   r4   r	   r3   r+   r,   CloseKeyr#   r{   )r>   lookuperrorkeynameskeynamer|   r1   r@   errs   &       r!   r9   FontManager._create_win   s   //1fg//1cd002gh002deh  Goow/*++CAQSWXD+4+=+=dNN+SDJJx(!A#//^^VE]S090B0B40XDJJu-$448JJv4F

5 148JJx4H

5 1 "B  $$S)'  : !!FGG $ &"%K&$$S)G$$S) sO   G*%DF+G*F2&F-(G-F22G6G*G''G**G:9G:c                $    V P                  R4      # )z
Get the character size.
M)get_text_sizer>   s   &r!   get_char_sizeFontManager.get_char_size   s     !!#&&r    c                    V P                   R,          p\        VR4      '       d   VP                  V4      R,          # VP                  V4      # )z$
Get the text size (width, height).
r   getbbox:      N)r,   r/   r   getsize)r>   textr?   s   && r!   r   FontManager.get_text_size   sB     zz(#4##<<%c**<<%%r    c                   V'       d?   V'       d7   V P                   '       d   V P                  R4      # V P                  R,          # V'       d7   V P                   '       d   V P                  R4      # V P                  R,          # V'       d7   V P                   '       d   V P                  R4      # V P                  R,          # V P                   '       d   V P                  R4      # V P                  R,          # )z.
Get the font based on bold and italic flags.
r   r   r   r   )r.   	get_styler,   )r>   boldobliques   &&&r!   get_fontFontManager.get_font   s     G}}}~~l33::l++}}}~~f--::f%%}}}~~h//::h''}}}~~h//::h''r    c                    V P                   V,          p\        V,           F  p VP                  V4       Vu # 	  V#   \         d     K+  \         d    Tu u # i ; i)ze
Get the specified style of the font if it is a variable font.
If not found, return the normal font.
)r,   r4   set_variation_by_name
ValueErrorr{   )r>   r@   r?   
style_names   &&  r!   r   FontManager.get_style   sb    
 zz%  --J**:6 (    s   >AAAA)r-   r*   r+   r,   r.   N)   )F)r   r   r   r   r   rA   rU   r=   rb   r;   r   r9   r   r   r   r   r   __classdictcell____classdict__s   @r!   r%   r%   <   sI     6=(B=:%HN'&(2 r    r%   c                      a  ] tR tRt o RtRt. ROtR.tRtRt	R t
RR ltR	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tR tR tRtV tR# )r
   i  a#	  
Create a PNG image from source code. This uses the Python Imaging Library to
generate a pixmap from the source code.

.. versionadded:: 0.10

Additional options accepted:

`image_format`
    An image format to output to that is recognised by PIL, these include:

    * "PNG" (default)
    * "JPEG"
    * "BMP"
    * "GIF"

`line_pad`
    The extra spacing (in pixels) between each line of text.

    Default: 2

`font_name`
    The font name to be used as the base font from which others, such as
    bold and italic fonts will be generated.  This really should be a
    monospace font to look sane.
    If a filename or a file-like object is specified, the user must
    provide different styles of the font.

    Default: "Courier New" on Windows, "Menlo" on Mac OS, and
             "DejaVu Sans Mono" on \*nix

`font_size`
    The font size in points to be used.

    Default: 14

`image_pad`
    The padding, in pixels to be used at each edge of the resulting image.

    Default: 10

`line_numbers`
    Whether line numbers should be shown: True/False

    Default: True

`line_number_start`
    The line number of the first line.

    Default: 1

`line_number_step`
    The step used when printing line numbers.

    Default: 1

`line_number_bg`
    The background colour (in "#123456" format) of the line number bar, or
    None to use the style background color.

    Default: "#eed"

`line_number_fg`
    The text color of the line numbers (in "#123456"-like format).

    Default: "#886"

`line_number_chars`
    The number of columns of line numbers allowable in the line number
    margin.

    Default: 2

`line_number_bold`
    Whether line numbers will be bold: True/False

    Default: False

`line_number_italic`
    Whether line numbers will be italicized: True/False

    Default: False

`line_number_separator`
    Whether a line will be drawn between the line number area and the
    source code area: True/False

    Default: True

`line_number_pad`
    The horizontal padding (in pixels) between the line number margin, and
    the source code area.

    Default: 6

`hl_lines`
    Specify a list of lines to be highlighted.

    .. versionadded:: 1.2

    Default: empty list

`hl_color`
    Specify the color for highlighting lines.

    .. versionadded:: 1.2

    Default: highlight color of the selected style
imgpngz*.pngFc                   \         '       g   \        R4      h\        P                  ! V 3/ VB  RV n        \        V P                  4      V n        V P                  P                  f	   RV n        MV P                  P                  V n        \        VR. ROV P                  RR7      V n        \        VR^
4      V n        \        VR	^4      V n        \        VR
^4      p\        VP!                  RR4      V4      V n        V P"                  P%                  4       w  V n        V n        VP!                  RR4      V n        VP!                  RR4      V n        \        VR^4      V n        \1        VRR4      V n        \1        VRR4      V n        \        VR^4      V n        \1        VRR4      V n        \1        VRR4      V n        \        VR^4      V n        \        VR^4      V n        V P8                  '       d<   V P&                  V P.                  ,          V P6                  ^,          ,           V n         M^ V n         . V n!        \E        VR. 4      pV F(  p V PB                  PG                  \I        V4      4       K*  	  VP!                  RV P                  PL                  4      ;'       g    RV n'        . V n(        R#   \J         d     Kx  i ; i)z5
See the class docstring for explanation of options.
z5Python Imaging Library is required for this formatterlatin1Nz#fffimage_formatT)normcase	image_padline_padr+   r*   rw   line_number_fgz#886line_number_bgz#eedline_number_charsline_number_boldFline_number_italicline_number_padline_numbersline_number_separatorline_number_stepline_number_starthl_lineshl_colorz#f90)r   jpeggifbmp))pil_availabler   r   rA   r-   dictr@   r~   background_colorr   default_image_formatr   r   r   r   r%   r_   r,   r   fontwfonthr   r   r   r   r   r   r   r   r   r   r   line_number_widthr   r   appendintr   highlight_colorr   	drawables)r>   optionsfontsizehl_lines_strrT   s   &,   r!   rA   ImageFormatter.__init__  s    }!GI I4+7+ 4::&::&&.$*D!$(JJ$?$?D!*^%B%%6 %Wk2>#GZ;wR8 ["!=xH
!%!9!9!;
DJ%kk*:FC%kk*:FC!,W-@!"E ,W-?!H".w/CU#L*74EqI(.$G%1'2I4&Q" +G5G K!,W6I1!M&*jj43I3I&I&*&:&:Q&>'?D" &'D"#GZ< D$$SY/ !
  J$(JJ$>$>@ J JCI 		  s   $J77KKc                    \        R 4      h)zWThe -S option is meaningless for the image formatter. Use -O style=<stylename> instead.)NotImplementedError)r>   args   &&r!   get_style_defsImageFormatter.get_style_defs  s    ! #Q R 	Rr    c                <    V P                   V P                  ,           # )z
Get the height of a line.
)r   r   r   s   &r!   _get_line_heightImageFormatter._get_line_height  s     zzDMM))r    c                P    WP                  4       ,          V P                  ,           # )z(
Get the Y coordinate of a line number.
)r   r   r>   linenos   &&r!   _get_line_yImageFormatter._get_line_y  s     --//$..@@r    c                    V P                   # )z
Get the width of a character.
)r   r   s   &r!   _get_char_widthImageFormatter._get_char_width  s     zzr    c                H    WP                   ,           V P                  ,           # )z/
Get the X coordinate of a character position.
)r   r   )r>   
linelengths   &&r!   _get_char_xImageFormatter._get_char_x  s     NN*T-C-CCCr    c                F    V P                  V4      V P                  V4      3# )z<
Get the actual position for a character and line position.
)r   r   )r>   r   r   s   &&&r!   _get_text_posImageFormatter._get_text_pos  s%     
+T-=-=f-EEEr    c                <    V P                   V P                  V4      3# )z9
Get the actual position for the start of a line number.
)r   r   r   s   &&r!   _get_linenumber_pos"ImageFormatter._get_linenumber_pos  s      0 0 899r    c                D    VR,          e   RVR,          ,           pV# RpV# )z5
Get the correct color for the token from the style.
color#z#000r   )r>   r@   fills   && r!   _get_text_colorImageFormatter._get_text_color  s/     >%w'D  Dr    c                D    VR,          e   RVR,          ,           pV# RpV# )z@
Get the correct background color for the token from the style.
bgcolorNr   r   )r>   r@   bg_colors   && r!   _get_text_bg_color!ImageFormatter._get_text_bg_color  s1     'U9--H  Hr    c                V    V P                   P                  VR,          VR,          4      # )z%
Get the correct font for the style.
r   italic)r,   r   )r>   r@   s   &&r!   _get_style_fontImageFormatter._get_style_font  s#     zz""5=%/BBr    c                    V P                  V4      V P                  ,           V P                  V^ ,           4      V P                  ,           3# )z
Get the required image size.
)r   r   r   )r>   maxlinelength	maxlinenos   &&&r!   _get_image_sizeImageFormatter._get_image_size   sB       /$..@  Q/$..@B 	Br    c                   V P                  V P                  V4      \        V4      P                  V P                  4      V P
                  P                  V P                  V P                  4      V P                  RR7       R# )z1
Remember a line number drawable to paint later.
Nr?   text_fgtext_bg)

_draw_textr   strrjustr   r,   r   r   r   r   )r>   posnor   s   &&&r!   _draw_linenumberImageFormatter._draw_linenumber  sj     	$$U+Kd445$$T%:%:%)%<%<>'' 	 	
r    c                B    V P                   P                  WW4V34       R# )z2
Remember a single drawable tuple to paint later.
N)r   r   )r>   posr   r?   r  r  s   &&&&&&r!   r  ImageFormatter._draw_text  s     	s$ABr    c                   ^ ;p;r4^ ;rVV EFK  w  rxWpP                   9  d   VP                  pK  V P                   V,          p	VP                  ^4      pVP                  R4      p
\	        V
4       F  w  rVP                  R4      pV'       d   V P                  V P                  Wb4      VV P                  V	4      V P                  V	4      V P                  V	4      R7       V P                  P                  V4      w  rWn,          p\        WV4      pV\        V4      ,          p\        WC4      pVP                  R4      '       g   K  ^ p^ pV^,          pK  	  EKN  	  WPn        W@n        W n        R# )z)
Create drawables for the token content.
T
r  N)r~   parent
expandtabsrM   	enumeraterstripr  r   r   r   r   r,   r   maxlenri   r   	maxcharnor   )r>   tokensourcer   charnor  r   r   ttypevaluer@   rS   irT   temp
temp_widthrR   s   &&              r!   _create_drawables ImageFormatter._create_drawables  sL    '(''%&&'LE{{*KK&E $$Q'E$$T*E$U+{{4(OO**:>#33E:"&"6"6u"="&"9"9%"@ $  %)JJ$<$<T$BMJ,J$'$BMc$i'F #I 6I==&&!"JFaKF' , (< +"r    c                    V P                   '       g   R# \        V P                  4       F?  pWP                  ,           pW P                  ,          ^ 8X  g   K.  V P                  W4       KA  	  R# )z(
Create drawables for the line numbers.
N)r   ranger   r   r   r  )r>   pns   &  r!   _draw_line_numbers!ImageFormatter._draw_line_numbersB  sS        t~~&A***A)))a/%%a+ 'r    c                   V P                   '       g   R# V P                  f   R# \        P                  ! V4      pVP                  R,          pV P
                  V P                  ,           V P                  ,
          pVP                  RWC3.V P                  R7       V P                  '       d#   VP                  V^ 3WC3.V P                  R7       ?R# )z0
Paint the line number background on the image.
Nr   )    r(  )r   r   r   Drawsizer   r   r   	rectangler   r   rT   )r>   imdrawrecthrectws   &&   r!   _paint_line_number_bg$ImageFormatter._paint_line_number_bgM  s        &~~b!!7!77$:N:NN/ // 	 	1%%%IIqzE>29L9LIMr    c           	        V P                  V4       V P                  4        \        P                  ! RV P	                  V P
                  V P                  4      V P                  4      pV P                  V4       \        P                  ! V4      pV P                  '       d   V P                  V P                  ,           V P                  ,
          ^,           pV P                  4       pVP                   ^ ,          V,
          pV P                   FI  pV P#                  V^,
          4      p	VP%                  WY3WW,           W,           3.V P&                  R7       KK  	  V P(                   F  w  rrpV'       d   \+        VR4      '       d   VP-                  WR7      pMVP/                  V4      R,          pVP%                  V
^ ,          V
^,          V
^ ,          V^ ,          ,           V
^,          V^,          ,           .VR7       VP1                  WWR7       K  	  VP3                  W P4                  P7                  4       4       R# )z
Format ``tokensource``, an iterable of ``(tokentype, tokenstring)``
tuples and write it into ``outfile``.

This implementation calculates where it should draw each token on the
pixmap, then calculates the required pixmap size and draws the items.
RGBr&  textsize)r   r?   :r   NN)r?   r   N)r  r#  r   newr   r   r   r   r0  r   r)  r   r   r   r   r   r*  r   r+  r   r   r/   r4  r   r   saver   upper)r>   r  outfiler,  r-  xr.  r/  
linenumberyr  r  r?   r  r  	text_sizes   &&&             r!   rx   ImageFormatter.format^  s    	{+!YY  !3!3T^^D!!

 	""2&~~b!===!7!77$:N:NNQRRA))+EGGAJNE"mm
$$Z!^4AI(>?$(MM  3 , 37...Cw4,, $5 DI $U 3B 7IAAA10Es1vPYZ[P\G\]dklIIctI: 3A 	**0023r    )r   r   r-   r   r,   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r~   N)r   IMGr   )rw   )r   r   r   r   r   rP   aliases	filenamesunicodeoutputr   rA   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r#  r0  rx   r   r   r   s   @r!   r
   r
     s     l^ D#G	IM 6pR*ADF:CB
C& P	,"#4 #4r    c                   .    ] tR tRtRtRtR.tR.tRtRt	R# )r   i  z
Create a GIF image from source code. This uses the Python Imaging Library to
generate a pixmap from the source code.

.. versionadded:: 1.0
img_gifr   z*.gifr   N
r   r   r   r   r   rP   r?  r@  r   r   r   r    r!   r   r     s"     DgG	I r    c                   0    ] tR tRtRtRtRR.tR.tRtRt	R# )	r   i  z
Create a JPEG image from source code. This uses the Python Imaging Library to
generate a pixmap from the source code.

.. versionadded:: 1.0
img_jpgjpgr   z*.jpgr   NrD  r   r    r!   r   r     s$     DfoG	I!r    c                   0    ] tR tRtRtRtRR.tR.tRtRt	R# )	r   i  z
Create a bitmap image from source code. This uses the Python Imaging Library to
generate a pixmap from the source code.

.. versionadded:: 1.0
img_bmpr   bitmapz*.bmpr   NrD  r   r    r!   r   r     s%     DhG	I r    )r
   r   r   r   )rw   RomanBookNormalRegularMedium) r   r0   r5   pygments.formatterr   pygments.utilr   r   r   r   rH   PILr   r   r	   r   ImportErrorry   winreg__all__r4   r<   r8   r:   r   	Exceptionr#   r%   r
   r   r   r   r   r    r!   <module>rW     s   
 
 (  //M  F9h'
6(>=1	
 + %  7k 739 3O Ods4Y s4r! !" "! !Y  M
    s:   B B+ 	B('B(+C
3B99	CC
CC
