
    5h[                        S r SSKrSSKrSSKJr  SSKJrJrJrJ	r	  SSK
r
 SSKJrJrJr  Sr SSKr/ SQr/ S	QS
S/S/SS/S.rSrSrSr " S S\5      r " S S\5      r " S S5      r " S S\5      r " S S\5      r " S S\5      r " S S \5      rg! \ a    Sr Ntf = f! \ a     SSKr N! \ a    Sr  Nf = ff = f)!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) RomanBookNormalRegularMediumObliqueItalicBoldzBold ObliquezBold Italic)NORMALITALICBOLD
BOLDITALICzDejaVu Sans MonozCourier NewMenloc                       \ rS rSrSrSrg)PilNotAvailable4   z,When Python imaging library is not available N__name__
__module____qualname____firstlineno____doc____static_attributes__r        b/var/www/html/cementerio_25MayoBackend/env/lib/python3.13/site-packages/pygments/formatters/img.pyr   r   4   s    6r(   r   c                       \ rS rSrSrSrg)FontNotFound8   z(When there are no usable fonts specifiedr    Nr!   r    r(   r)   r+   r+   8   s    2r(   r+   c                   b    \ rS rSrSrSS jrS rS rS rS r	SS jr
S	 rS
 rS rS rS rSrg)FontManager<   z6
Manages a set of fonts: normal, italic, bold, etc...
c                    Xl         X l        0 U l        S U l        SU l        [        US5      (       d$  [        R                  R                  U5      (       aC  [        R                  " XR                  5      nSU l        [         H  nX0R                  U'   M     g [        R                  R                  S5      (       a#  U(       d  [        U l         U R!                  5         g [        R                  R                  S5      (       a#  U(       d  ["        U l         U R%                  5         g U(       d  [&        U l         U R)                  5         g )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)selfr4   r5   fontstyles        r)   __init__FontManager.__init__A   s    ""
9f%%	)B)B%%i@D DM$(

5!   <<""5))!6\\$$X..!6!6r(   c                 t   [         R                  " SU SU 3S/[         R                  S S9nUR                  5       u  pEUR                  S:X  aj  UR                  5       nU HS  nUR                  S5      (       a  M  UR                  5       R                  5       R                  S5      nU(       d  MQ  Us  $    g g )Nzfc-listz:style=file)stdoutstderrr   s   Fontconfig warning::)	
subprocessPopenPIPEcommunicate
returncode
splitlinesrA   decodestrip)	rH   namerJ   procrO   _linesliner;   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                 B   [         S    HQ  nU R                  U R                  U5      nUc  M$  [        R                  " X R
                  5      U R                  S'     O   [        SU R                   S35      eS H  n[         U    HR  nU R                  U R                  U5      nUc  M$  [        R                  " X R
                  5      U R                  U'     M`     US:X  a  U R                  S   U R                  U'   M  U R                  S   U R                  U'   M     g )Nr   No usable fonts named: ""r   r   r   r   r   )r>   r_   r4   r
   r=   r5   r6   r+   )rH   rZ   r;   rJ   	stylenames        r)   rG   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                 h    UR                  US-   U-   R                  5       R                  5       5      $ )N )getrY   lower)rH   font_maprZ   rJ   s       r)   _get_mac_font_pathFontManager._get_mac_font_path~   s,    ||TCZ%/668>>@AAr(   c                 "  ^ 0 n[         R                  R                  [         R                  " S5      S5      SS4 H2  mUR	                  U4S j[         R
                  " T5       5       5        M4     [        S    HQ  nU R                  XR                  U5      nUc  M$  [        R                  " X0R                  5      U R                  S'     O   [        SU R                   S35      eS	 H  n[        U    HR  nU R                  XR                  U5      nUc  M$  [        R                  " X0R                  5      U R                  U'     M`     US
:X  a  U R                  S   U R                  U'   M  U R                  S   U R                  U'   M     g )NHOMEzLibrary/Fonts/z/Library/Fonts/z/System/Library/Fonts/c              3   &  >#    U H  u    pU H{  nUR                  5       R                  S 5      (       d  M)  [        R                  R	                  U5      S   R                  5       [        R                  R                  TU5      4v   M}     M     g7f))ttfttcr   N)rj   endswithr:   r;   splitextjoin).0r\   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   rb   rc   rd   r   r   )r:   r;   ru   getenvupdatewalkr>   rl   r4   r
   r=   r5   r6   r+   )rH   rk   rZ   r;   rJ   re   ry   s         @r)   rE   FontManager._create_mac   sO   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                     S HG  nU H>  n SR                  X&=(       a    SU-   U5      n[        R                  " X5      u  pUs  s  $    MI     U(       a  [	        SU SUS    S35      eg ! [         a     Mp  f = f)N)r   z (TrueType)z{}{}{}rh   zFont z (r   z) not found in registry)format_winregQueryValueExOSErrorr+   )
rH   keybasenamestylesfailsuffixrJ   valnamevalr\   s
             r)   _lookup_winFontManager._lookup_win   s    )F&ooh8K#e)VTG$11#?FCJ	   * "U8*BvaykAX#YZZ  s   7A++
A98A9c                    S n[         R                  S4[         R                  S4[         R                  S4[         R                  S4/nU GH"  n [         R                  " U6 n U R	                  X@R
                  [        S   S5      n[        R                  " XPR                  5      U R                  S'   S H  nU R	                  X@R
                  [        U   5      nU(       a/  [        R                  " XPR                  5      U R                  U'   M\  US:X  a  U R                  S   U R                  U'   M  U R                  S   U R                  U'   M      [         R                  " U5          g    U(       a  Ue[        S5      e! [         a  nUn S nAOS nAff = f [         R                  " U5        GMn  ! [         R                  " U5        f = f! [         a     GM  f = f)	Nz2Software\Microsoft\Windows NT\CurrentVersion\Fontsz/Software\Microsoft\Windows\CurrentVersion\Fontsr   Trd   r   r   z$Can't open Windows font registry key)r   HKEY_CURRENT_USERHKEY_LOCAL_MACHINEOpenKeyr   r4   r>   r
   r=   r5   r6   CloseKeyr+   r   )rH   lookuperrorkeynameskeynamer   r;   rJ   errs           r)   rC   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$C3FG
FFF9FF9 G9GG
G#"G#c                 $    U R                  S5      $ )z
Get the character size.
M)get_text_sizerH   s    r)   get_char_sizeFontManager.get_char_size   s     !!#&&r(   c                     U R                   S   n[        US5      (       a  UR                  U5      SS $ UR                  U5      $ )z$
Get the text size (width, height).
r   getbbox      )r6   r9   r   getsize)rH   textrI   s      r)   r   FontManager.get_text_size   sD     zz(#4##<<%a**<<%%r(   c                    U(       a8  U(       a1  U R                   (       a  U R                  S5      $ U R                  S   $ U(       a1  U R                   (       a  U R                  S5      $ U R                  S   $ U(       a1  U R                   (       a  U R                  S5      $ U R                  S   $ U R                   (       a  U R                  S5      $ U R                  S   $ )z.
Get the font based on bold and italic flags.
r   r   r   r   )r8   	get_styler6   )rH   boldobliques      r)   get_fontFontManager.get_font   s     G}}~~l33::l++}}~~f--::f%%}}~~h//::h''}}~~h//::h''r(   c                     U R                   U   n[        U    H  n UR                  U5        Us  $    U$ ! [         a     M*  [         a    Us s  $ f = f)ze
Get the specified style of the font if it is a variable font.
If not found, return the normal font.
)r6   r>   set_variation_by_name
ValueErrorr   )rH   rJ   rI   
style_names       r)   r   FontManager.get_style   s`    
 zz%  -J**:6 (    s   6
AAA)r7   r4   r5   r6   r8   N)   )F)r"   r#   r$   r%   r&   rK   r_   rG   rl   rE   r   rC   r   r   r   r   r'   r    r(   r)   r.   r.   <   sA    6=(B=:%HN'&(2r(   r.   c                       \ rS rSrSrSr/ SQrS/rSrSr	S r
SS	 jrS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rSrg)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)r   IMGpngz*.pngFr   c                 h   [         (       d  [        S5      e[        R                  " U 40 UD6  SU l        [        U R                  5      U l        U R                  R                  c  SU l        OU R                  R                  U l        [        US/ SQU R                  SS9U l        [        US	S
5      U l        [        USS5      U l        [        USS5      n[        UR!                  SS5      U5      U l        U R"                  R%                  5       u  U l        U l        UR!                  SS5      U l        UR!                  SS5      U l        [        USS5      U l        [1        USS5      U l        [1        USS5      U l        [        USS5      U l        [1        USS5      U l        [1        USS5      U l        [        USS5      U l        [        USS5      U l        U R8                  (       a/  U R&                  U R.                  -  U R6                  S-  -   U l         OS U l         / U l!        [E        US!/ 5      nU H(  n U RB                  RG                  [I        U5      5        M*     UR!                  S"U R                  RL                  5      =(       d    S#U l'        / U l(        g! [J         a     Mu  f = f)$z5
See the class docstring for explanation of options.
z5Python Imaging Library is required for this formatterlatin1Nz#fffimage_format)r   jpeggifbmpT)normcase	image_pad
   line_padr   r5   r   r4   r   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_startr   hl_lineshl_colorz#f90))pil_availabler   r   rK   r7   dictrJ   r   background_colorr   default_image_formatr   r   r   r   r.   ri   r6   r   fontwfonthr   r   r   r   r   r   r   r   r   r   r   line_number_widthr   r   appendintr   highlight_colorr   	drawables)rH   optionsfontsizehl_lines_strr^   s        r)   rK   ImageFormatter.__init__  sv    }!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CI 		  s   ?$J##
J10J1c                     [        S5      e)NzWThe -S option is meaningless for the image formatter. Use -O style=<stylename> instead.)NotImplementedError)rH   args     r)   get_style_defsImageFormatter.get_style_defs  s    ! #Q R 	Rr(   c                 4    U R                   U R                  -   $ )z
Get the height of a line.
)r   r   r   s    r)   _get_line_heightImageFormatter._get_line_height  s     zzDMM))r(   c                 @    XR                  5       -  U R                  -   $ )z(
Get the Y coordinate of a line number.
)r   r   rH   linenos     r)   _get_line_yImageFormatter._get_line_y  s     --//$..@@r(   c                     U R                   $ )z
Get the width of a character.
)r   r   s    r)   _get_char_widthImageFormatter._get_char_width  s     zzr(   c                 8    XR                   -   U R                  -   $ )z/
Get the X coordinate of a character position.
)r   r   )rH   
linelengths     r)   _get_char_xImageFormatter._get_char_x  s     NN*T-C-CCCr(   c                 F    U R                  U5      U R                  U5      4$ )z<
Get the actual position for a character and line position.
)r   r   )rH   r   r   s      r)   _get_text_posImageFormatter._get_text_pos  s%     
+T-=-=f-EEEr(   c                 <    U R                   U R                  U5      4$ )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                 *    US   b
  SUS   -   nU$ SnU$ )z5
Get the correct color for the token from the style.
color#z#000r    )rH   rJ   fills      r)   _get_text_colorImageFormatter._get_text_color  s/     >%w'D  Dr(   c                 *    US   b
  SUS   -   nU$ SnU$ )z@
Get the correct background color for the token from the style.
bgcolorNr   r    )rH   rJ   bg_colors      r)   _get_text_bg_color!ImageFormatter._get_text_bg_color  s1     'U9--H  Hr(   c                 F    U R                   R                  US   US   5      $ )z%
Get the correct font for the style.
r   italic)r6   r   )rH   rJ   s     r)   _get_style_fontImageFormatter._get_style_font  s#     zz""5=%/BBr(   c                     U R                  U5      U R                  -   U R                  US-   5      U R                  -   4$ )z
Get the required image size.
r   )r   r   r   )rH   maxlinelength	maxlinenos      r)   _get_image_sizeImageFormatter._get_image_size   sB       /$..@  Q/$..@B 	Br(   c                     U R                  U R                  U5      [        U5      R                  U R                  5      U R
                  R                  U R                  U R                  5      U R                  SS9  g)z1
Remember a line number drawable to paint later.
NrI   text_fgtext_bg)

_draw_textr   strrjustr   r6   r   r   r   r   )rH   posnor   s      r)   _draw_linenumberImageFormatter._draw_linenumber  sj     	$$U+Kd445$$T%:%:%)%<%<>'' 	 	
r(   c                 @    U R                   R                  XX4U45        g)z2
Remember a single drawable tuple to paint later.
N)r   r   )rH   posr   rI   r  r  s         r)   r  ImageFormatter._draw_text  s     	s$ABr(   c                    S=n=p4S=pVU GHD  u  pxXpR                   ;  a  UR                  nXpR                   ;  a  M  U R                   U   n	UR                  S5      nUR                  S5      n
[	        U
5       H  u  pUR                  S5      nU(       a  U R                  U R                  Xb5      UU R                  U	5      U R                  U	5      U R                  U	5      S9  U R                  R                  U5      u  pXn-  n[        XV5      nU[        U5      -  n[        XC5      nUR                  S5      (       d  M  SnSnUS-  nM     GMG     XPl        X@l        X l        g)z)
Create drawables for the token content.
r   r   T
r  r   N)r   parent
expandtabsrW   	enumeraterstripr  r   r  r   r   r6   r   maxlenrs   r  	maxcharnor  )rH   tokensourcer   charnor  r  r   ttypevaluerJ   r]   ir^   temp
temp_widthr\   s                   r)   _create_drawables ImageFormatter._create_drawables  sX    '(''%&&'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                     U R                   (       d  g[        U R                  5       H6  nXR                  -   nX R                  -  S:X  d  M%  U R                  X5        M8     g)z(
Create drawables for the line numbers.
Nr   )r   ranger  r   r   r  )rH   pns      r)   _draw_line_numbers!ImageFormatter._draw_line_numbersB  sP       t~~&A***A)))a/%%a+ 'r(   c                 v   U R                   (       d  gU R                  c  g[        R                  " U5      nUR                  S   nU R
                  U R                  -   U R                  -
  nUR                  SXC4/U R                  S9  U R                  (       a  UR                  US4XC4/U R                  S9  Ag)z0
Paint the line number background on the image.
N)r   r   r   r   )r   r   r	   Drawsizer   r   r   	rectangler   r   r^   )rH   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           	         U R                  U5        U R                  5         [        R                  " SU R	                  U R
                  U R                  5      U R                  5      nU R                  U5        [        R                  " U5      nU R                  (       a  U R                  U R                  -   U R                  -
  S-   nU R                  5       nUR                   S   U-
  nU R                   H:  nU R#                  US-
  5      n	UR%                  XY4XW-   X-   4/U R&                  S9  M<     U R(                   H  u  ppnU(       aa  [+        US5      (       a  UR-                  XS9nOUR/                  U5      SS nUR%                  U
S   U
S   U
S   US   -   U
S   US   -   /US9  UR1                  XXS	9  M     UR3                  X R4                  R7                  5       5        g)
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   r   r1  textsize)r   rI   r   N)rI   r   )r'  r-  r   newr  r  r  r   r9  r	   r2  r   r   r   r   r   r3  r   r4  r   r   r9   r=  r   r   saver   upper)rH   r   outfiler5  r6  xr7  r8  
linenumberyr  r#  rI   r  r  	text_sizes                   r)   r   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 3AB 7IAAA10Es1vPYZ[P\G\]dklIIctI: 3A 	**0023r(   )r   r   r7   r   r6   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r   N)r   )r"   r#   r$   r%   r&   rZ   aliases	filenamesunicodeoutputr   rK   r   r   r   r   r   r   r   r   r   r  r  r  r  r'  r-  r9  r   r'   r    r(   r)   r   r     s    l^ D#G	IM 6pR*ADF:CB
C& P	,"#4r(   r   c                   ,    \ rS rSrSrSrS/rS/rSrSr	g)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&   rZ   rG  rH  r   r'   r    r(   r)   r   r     s"     DgG	I r(   r   c                   .    \ rS rSrSrSrSS/rS/rSrSr	g)	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    NrL  r    r(   r)   r   r     s$     DfoG	I!r(   r   c                   .    \ rS rSrSrSrSS/rS/rSrSr	g)	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    NrL  r    r(   r)   r   r     s%     DhG	I r(   r   ) r&   r:   r?   pygments.formatterr   pygments.utilr   r   r   r   rR   PILr   r	   r
   r   ImportErrorr   winreg__all__r>   rF   rB   rD   r   	Exceptionr+   r.   r   r   r   r   r    r(   r)   <module>rZ     s   
 
 (  //M  Gh'(!=1	
 + %  7k 739 3O Ods4Y s4r! !" "! !Y  M
    s:   B B& B#"B#&C-B33B?;C>B??C