+
    5iU                        R t ^ RIHtHtHtHtHtHtHtH	t	H
t
Ht ^ RIHt ^ RIHtHtHt ^RIHtHtHtHtHt ^RIHt ^RIHtHt ^RIHt ^RIH t H!t! ]t"R	t#R
t$Rt%. ROt&RPO                  ]&4      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      t0 ! R R4      t1 ! R R4      t2R# ) ao  
Routines for organizing lines and larger blocks of text, with manual and
automatic line wrapping.

The contents of this module are internal to fpdf2, and not part of the public API.
They may change at any time without prior warning or any deprecation period,
in non-backward-compatible ways.

Usage documentation at: <https://py-pdf.github.io/fpdf2/LineBreaks.html>
)
TYPE_CHECKINGAnyCallableDictList
NamedTupleOptionalSequenceTupleUnion)uuid4)
DeviceCMYK
DeviceGray	DeviceRGB)AlignCharVPosTextDirectionTextModeWrapMode)FPDFExceptionCoreFontTTFFont)GraphicsState)FloatToleranceescape_parens   ­-      
c                     a  ] tR t^>t o RtRJV 3R lR lltV 3R lR lt]V 3R lR l4       t]P                  V 3R	 lR
 l4       t]V 3R lR l4       t
]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       t]V 3R lR  l4       t]V 3R! lR" l4       t]V 3R# lR$ l4       t]V 3R% lR& l4       t]V 3R' lR( l4       t]V 3R) lR* l4       t]V 3R+ lR, l4       t]V 3R- lR. l4       t]V 3R/ lR0 l4       t]V 3R1 lR2 l4       t]V 3R3 lR4 l4       tV 3R5 lR6 ltV 3R7 lR8 lt V 3R9 lR: lt!RKV 3R; lR< llt"V 3R= lR> lt#RLV 3R? lR@ llt$V 3RA lRB lt%V 3RC lRD lt&V 3RE lRF lt'V 3RG lRH lt(RIt)V t*R# )MFragmentzK
A fragment of text with font/size/style and other associated information.
Nc          
      |   < V ^8  d   QhRS[ S[S[,          S[3,          RS[RS[RS[S[S[,          ,          RR/# )   
charactersgraphics_stateklinkreturnN)r   liststrStateStackTypefloatr   int)format__classdict__s   "U/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/fpdf/line_break.py__annotate__Fragment.__annotate__C   sS      $s)S.) ' 	
 sSy! 
    c                    \        V\        4      '       d   \        V4      V n        MWn        W n        W0n        W@n        R # N)
isinstancer-   r,   r'   r(   r)   r*   )selfr'   r(   r)   r*   s   &&&&&r3   __init__Fragment.__init__C   s2     j#&&":.DO(O,	r6   c                    < V ^8  d   QhRS[ /# r&   r+   r-   )r1   r2   s   "r3   r4   r5   R   s     
 
# 
r6   c           	     p    R V P                    RV P                   RV P                   RV P                   R2	# )zFragment(characters=z, graphics_state=z, k=z, link=)r'   r(   r)   r*   r:   s   &r3   __repr__Fragment.__repr__R   sC    "4??"3 4#223 4&&1.	
r6   c                0   < V ^8  d   QhRS[ S[,          /# r>   r   )r1   r2   s   "r3   r4   r5   Z   s     0 0h( 0r6   c                z    \         '       d   V P                  P                  f   Q hV P                  P                  # r8   )r   r(   current_fontrC   s   &r3   fontFragment.fontY   s1    =&&33???""///r6   c                4   < V ^8  d   QhRS[ S[,          RR/# )r&   vr+   Nr   )r1   r2   s   "r3   r4   r5   `   s      - -h( -T -r6   c                &    WP                   n        R # r8   )r(   rH   )r:   rL   s   &&r3   rI   rJ   _   s    +,(r6   c                    < V ^8  d   QhRS[ /# r>   bool)r1   r2   s   "r3   r4   r5   d   s     A AT Ar6   c                `    V P                   R J;'       d    V P                   P                  R8H  # )NTTF)rI   typerC   s   &r3   is_ttf_fontFragment.is_ttf_fontc   s&    yy$@@5)@@r6   c                    < V ^8  d   QhRS[ /# r>   r?   )r1   r2   s   "r3   r4   r5   h   s     . .C .r6   c                .    V P                   P                  # r8   )r(   
font_stylerC   s   &r3   rX   Fragment.font_styleg       ""---r6   c                    < V ^8  d   QhRS[ /# r>   r?   )r1   r2   s   "r3   r4   r5   l   s     / /S /r6   c                .    V P                   P                  # r8   )r(   font_familyrC   s   &r3   r]   Fragment.font_familyk   s    ""...r6   c                    < V ^8  d   QhRS[ /# r>   r/   )r1   r2   s   "r3   r4   r5   p   s      e r6   c                   V P                   P                  pV P                   P                  pV\        P                  8X  d   WP                   P
                  ,          pV# V\        P                  8X  d   WP                   P                  ,          pV# V\        P                  8X  d   WP                   P                  ,          pV# V\        P                  8X  d   WP                   P                  ,          pV# r8   )r(   font_size_pt	char_vposr   SUB	sub_scaleSUP	sup_scaleNOM	nom_scaleDENOMdenom_scale)r:   sizevposs   &  r3   rb   Fragment.font_size_pto   s    ""//"",,8<<''111D  X\\!''111D
 	 X\\!''111D  X^^#''333Dr6   c                    < V ^8  d   QhRS[ /# r>   r`   )r1   r2   s   "r3   r4   r5   ~   s     9 95 9r6   c                P    V P                   P                  V P                  ,          # r8   )r(   rb   r)   rC   s   &r3   	font_sizeFragment.font_size}   s    ""//$&&88r6   c                    < V ^8  d   QhRS[ /# r>   r`   )r1   r2   s   "r3   r4   r5      s     3 3 3r6   c                .    V P                   P                  # r8   )r(   font_stretchingrC   s   &r3   ru   Fragment.font_stretching   s    ""222r6   c                    < V ^8  d   QhRS[ /# r>   r`   )r1   r2   s   "r3   r4   r5      s     0 0e 0r6   c                .    V P                   P                  # r8   )r(   char_spacingrC   s   &r3   ry   Fragment.char_spacing       ""///r6   c                    < V ^8  d   QhRS[ /# r>   )r   )r1   r2   s   "r3   r4   r5           - -8 -r6   c                .    V P                   P                  # r8   )r(   	text_moderC   s   &r3   r   Fragment.text_mode       "",,,r6   c                    < V ^8  d   QhRS[ /# r>   rO   )r1   r2   s   "r3   r4   r5      s     - -4 -r6   c                .    V P                   P                  # r8   )r(   	underlinerC   s   &r3   r   Fragment.underline   r   r6   c                    < V ^8  d   QhRS[ /# r>   rO   )r1   r2   s   "r3   r4   r5      s     1 1t 1r6   c                .    V P                   P                  # r8   )r(   strikethroughrC   s   &r3   r   Fragment.strikethrough   s    ""000r6   c                P   < V ^8  d   QhRS[ S[S[,          S[,          ,          /# r>   r   r   r   r   )r1   r2   s   "r3   r4   r5      #     . .HY%;j%HI .r6   c                .    V P                   P                  # r8   )r(   
draw_colorrC   s   &r3   r   Fragment.draw_color   rZ   r6   c                P   < V ^8  d   QhRS[ S[S[,          S[,          ,          /# r>   r   )r1   r2   s   "r3   r4   r5      r   r6   c                .    V P                   P                  # r8   )r(   
fill_colorrC   s   &r3   r   Fragment.fill_color   rZ   r6   c                P   < V ^8  d   QhRS[ S[S[,          S[,          ,          /# r>   r   )r1   r2   s   "r3   r4   r5      r   r6   c                .    V P                   P                  # r8   )r(   
text_colorrC   s   &r3   r   Fragment.text_color   rZ   r6   c                    < V ^8  d   QhRS[ /# r>   r`   )r1   r2   s   "r3   r4   r5      s     . .E .r6   c                .    V P                   P                  # r8   )r(   
line_widthrC   s   &r3   r   Fragment.line_width   rZ   r6   c                    < V ^8  d   QhRS[ /# r>   )r   )r1   r2   s   "r3   r4   r5      r}   r6   c                .    V P                   P                  # r8   )r(   rc   rC   s   &r3   rc   Fragment.char_vpos   r   r6   c                    < V ^8  d   QhRS[ /# r>   r`   )r1   r2   s   "r3   r4   r5      s     7 7e 7r6   c                   V P                   P                  pV\        P                  8X  d   V P                   P                  pMV\        P
                  8X  d   V P                   P                  pMZV\        P                  8X  d   V P                   P                  pM.V\        P                  8X  d   V P                   P                  pMR pW P                   P                  ,          # )g        )r(   rc   r   rd   sub_liftrf   sup_liftrh   nom_liftrj   
denom_liftrb   )r:   rm   lifts   &  r3   r   Fragment.lift   s    "",,8<<--66DX\\!&&//DX\\!&&//DX^^#&&11DD))6666r6   c                    < V ^8  d   QhRS[ /# r>   r?   )r1   r2   s   "r3   r4   r5      s     ( ( (r6   c                8    R P                  V P                  4      # )r   )joinr'   rC   s   &r3   stringFragment.string   s    wwt''r6   c                    < V ^8  d   QhRS[ /# r>   r`   )r1   r2   s   "r3   r4   r5      s        u  r6   c                "    V P                  4       # r8   )	get_widthrC   s   &r3   widthFragment.width   s    ~~r6   c                F   < V ^8  d   QhRS[ S[S[S[3,          ,          /# r>   )r   r   r-   r   )r1   r2   s   "r3   r4   r5      s!     0 0$sCx.)A 0r6   c                .    V P                   P                  # r8   )r(   text_shapingrC   s   &r3   text_shaping_parameters Fragment.text_shaping_parameters   r{   r6   c                    < V ^8  d   QhRS[ /# r>   r   )r1   r2   s   "r3   r4   r5      s     

 

] 

r6   c                    \         '       d:   V P                  f   Q h\        V P                  R,          \        4      '       g   Q hV P                  '       d   V P                  R,          # \        P                  # )Nparagraph_directionr   r   r9   r   LTRrC   s   &r3   r   Fragment.paragraph_direction   su    =//;;;,,-BC]   
 +++ (()>?	
 ""	
r6   c                    < V ^8  d   QhRS[ /# r>   r   )r1   r2   s   "r3   r4   r5      s     

 

M 

r6   c                    \         '       d:   V P                  f   Q h\        V P                  R,          \        4      '       g   Q hV P                  '       d   V P                  R,          # \        P                  # )Nfragment_directionr   rC   s   &r3   r   Fragment.fragment_direction   su    =//;;;,,-ABM   
 +++ (()=>	
 ""	
r6   c                $   < V ^8  d   QhRS[ RR/# )r&   indexr+   Nr0   )r1   r2   s   "r3   r4   r5      s     2 2# 2$ 2r6   c                .    V P                   R V V n         R # r8   )r'   )r:   r   s   &&r3   trimFragment.trim   s    //&51r6   c                &   < V ^8  d   QhRS[ RS[/# )r&   otherr+   )r   rP   )r1   r2   s   "r3   r4   r5      s     
 
C 
D 
r6   c                    \        V\        4      '       g   R # V P                  VP                  8H  ;'       d;    V P                  VP                  8H  ;'       d    V P                  VP                  8H  # )F)r9   r$   r'   r(   r)   r:   r   s   &&r3   __eq__Fragment.__eq__   sa    %**OOu/// " "##u';';;" "%''!	
r6   c                    < V ^8  d   QhRS[ /# r>   r   )r1   r2   s   "r3   r4   r5      s     D D# Dr6   c                Z    \        V P                  V P                  V P                  34      # r8   )hashr'   r(   r)   rC   s   &r3   __hash__Fragment.__hash__   s"    T__d&9&9466BCCr6   c          
      X   < V ^8  d   QhRS[ RS[S[ ,          RS[S[,          RS[RS[/# )r&   startendchars
initial_csr+   )r0   r   r-   rP   r/   )r1   r2   s   "r3   r4   r5      sE     % %% c]% }	%
 % 
%r6   c                .   VfA   Ve   RP                  V P                  W 4      pMRP                  V P                  VR 4      pV P                  P                  W0P                  V P
                  4      w  rVV P                  pV P                  ^d8w  d3   W`P                  R,          ,          pWpP                  R,          ,          pV P                  ^ 8w  d/   V'       d   WgV,          ,          pMWgV^,
          ,          ,          pW`P                  ,          # )a  
Return the width of the string with the given font/size/style/etc.

Args:
    start (int): Index of the start character. Default start of fragment.
    end (int): Index of the end character. Default end of fragment.
    chars (str): Specific text to get the width for (not necessarily the
        same as the contents of the fragment). If given, this takes
        precedence over the start/end arguments.
Nr   g{Gz?)	r   r'   rI   get_text_widthrb   r   ry   ru   r)   )r:   r   r   r   r   char_lenwry   s   &&&&&   r3   r   Fragment.get_width   s    $ = :; 78ii..$$d&B&B
 ((3&%%,,A00477L! H,,X\2266zr6   c                $   < V ^8  d   QhRRRS[ /# )r&   r   r$   r+   rO   )r1   r2   s   "r3   r4   r5     s     
 
J 
4 
r6   c                    V P                   VP                   8H  ;'       d;    V P                  VP                  8H  ;'       d    V P                  VP                  8H  # )zFReturns if 2 fragments are equivalent other than the characters/string)r(   r)   	__class__r   s   &&r3   has_same_styleFragment.has_same_style  sQ     5#7#77 2 2%''!2 2%//1	
r6   c                2   < V ^8  d   QhRS[ RS[RS[RS[/# )r&   	characterprint_shr   r+   )r-   rP   r/   )r1   r2   s   "r3   r4   r5     s3     	F 	F	F(,	FBF	F		Fr6   c                X    V\         8X  d   V'       g   \        pV P                  WR7      # )z@
Return the width of a single character out of the stored text.
)r   r   )SOFT_HYPHENHYPHENr   )r:   r   r   r   s   &&&&r3   get_character_widthFragment.get_character_width  s$     #HI~~I~EEr6   c                D   < V ^8  d   QhRS[ RS[ RS[ RS[ RS[ RS[ RS[/# )r&   frag_ws
current_wsword_spacingadjust_xadjust_yhr+   r/   r-   )r1   r2   s   "r3   r4   r5   '  sQ     > >> > 	>
 > > > 
>r6   c                    V P                   '       d6   V P                  '       d   V P                  WEWc4      # V P                  W4      # V P	                  W4      # r8   )rT   r   render_with_text_shapingrender_pdf_text_ttfrender_pdf_text_core)r:   r   r   r   r   r   r   s   &&&&&&&r3   render_pdf_textFragment.render_pdf_text'  sX     +++44  ++GBB((==r6   c                ,   < V ^8  d   QhRS[ RS[ RS[/# )r&   r   r   r+   r   )r1   r2   s   "r3   r4   r5   8  s"     & &5 & &# &r6   c                   \        V P                  \        4      '       g   Q hR pR pV P                   FM  pV P                  P                  P                  \        V4      4      pV'       g   K;  V\        V4      ,          pKO  	  V'       Ed   V P                  P                  R4      pV P                  P                  P                  \        R4      4      pVf   Q hVP                  \        V4      4      p	. p
\        V	4       F  w  rV P                  P                  V4      pV^ 8X  d   V
P                  RV R24       K>  WP                  ,          ) R,          V P                  ,          pV
P                  VR RV V R24       K  	  RP                  V
4      pVRV R2,          pV# V P                  P                  V4      pVRV R2,          pV# )	r   r   (rA     .3f[z] TJ) Tj)r9   rI   r   r   subsetpickordchrescape_textsplit	enumerateappendr)   rb   r   )r:   r   r   retmapped_textcharmapped_charu_spacespace_char_idwords
words_strlword_iwordadjescaped_texts   &&&            r3   r   Fragment.render_pdf_text_ttf8  s   $))W----KKD))**//D	:K{s;//   <ii++C0G !II,,11#c(;M ,,,%%c-&89E$&J )% 0yy,,T2Q;%%$qk2#ff,-4t7H7HHC%%S	7)D6&CD !1 88J/LQ|nD))C 
  9900=LQ|nD))C
r6   c          
      8   < V ^8  d   QhRS[ RS[ RS[ RS[ RS[/# )r&   pos_xpos_yr   r   r+   r   )r1   r2   s   "r3   r4   r5   `  s5     5 55#(5-25BG5	5r6   c                "  a  \        S P                  \        4      '       g   Q hR pR pS P                  P                  P	                  \        R4      4      pR V 3R llpS P                  S P                  ^d,          ,          S P                  ,          p	S P                  P                  S P                  S P                  S P                  4       EF  p
V
R,          f   K  S P                  P                  \        V
R,          4      4      pV
R,          ^ 8w  g   V
R,          ^ 8w  d|   V'       d   VRV R2,          pR pW! V
R,          4      ,           pW(! V
R,          4      ,
          pVR	VS P                  ,          R
 RW=,
          S P                  ,          R
 R2,          pWk,          pW! V
R,          4      V	,           ,          pW(! V
R,          4      ,          pV'       d   V
R,          V8X  d	   W,          pV
R,          '       g   V'       g   EKD  V
R,          V8X  g   EKU  V'       d   VRV R2,          pR pVR	VS P                  ,          R
 RW2,
          S P                  ,          R
 R2,          pEK  	  V'       d   VRV R2,          pV# )r   r   c                0    V ^8  d   QhR\         R\         /# )r&   posr+   r`   )r1   s   "r3   r4   7Fragment.render_with_text_shaping.<locals>.__annotate__h  s     
	 
	E 
	e 
	r6   c                   < \         '       d#   \        SP                  \        4      '       g   Q hV SP                  P                  ,          SP
                  ,          SP                  ^d,          ,          R,          SP                  ,          # )d   r   )r   r9   rI   r   scalerb   ru   r)   )r  r:   s   &r3   
adjust_pos5Fragment.render_with_text_shaping.<locals>.adjust_posh  sr    }!$))W5555))//"##$ ''#-/ 	
 &&r6   r	  x_offsety_offsetr   z) Tj z1 0 0 1 z.2fz Tm 	x_advance	y_advanceforce_positioningr   )r9   rI   r   r   r   r   ry   ru   r)   
shape_textr   rb   r   r  r  )r:   r  r  r   r   r  textspace_mapped_coder  ry   tir  offsetxoffsetys   f&&&&         r3   r   !Fragment.render_with_text_shaping`  s7    $))W---- II,,11#c(;
	 
	 ((D,@,@3,FG$&&P))&&KK**D,H,H
B - (99((R->)?@D*~"bn&9QtfE?*CD*R
^"<<*R
^"<<4661#6a8Ns7SSWX LDZ;0<??EZ;00E= 15F F% %&&M!26G!GQtfE?*CD5DFF"23!7q!)tvv9Mc8RRVWW9
< QtfD>!C
r6   c                ,   < V ^8  d   QhRS[ RS[ RS[/# )r&   r   r   r+   r   )r1   r2   s   "r3   r4   r5     s"      E u  r6   c                    R pW8w  d   W1V P                   ,          R R2,          p\        V P                  4      pVRV R2,          pV# )r   r   z Tw r   r   )r)   r   r   )r:   r   r   r  r  s   &&&  r3   r   Fragment.render_pdf_text_core  sN     &s+400C$T[[1<.%%
r6   rB   r8   )    NNT)FT)+__name__
__module____qualname____firstlineno____doc__r;   rD   propertyrI   setterrT   rX   r]   rb   rq   ru   ry   r   r   r   r   r   r   r   rc   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __static_attributes____classdictcell__r2   s   @r3   r$   r$   >   s[     
 
 0 0
 
[[- - A A . . / /   9 9 3 3 0 0 - - - - 1 1 . . . . . . . . - - 7 7 ( (     0 0 

 

 

 

2 2
 
D D% %N
 
	F 	F> >"& &P5 5n r6   r$   c                   ~   a a ] tR tRt oRtV3R lV 3R lltV3R lR ltV3R lR ltV3R	 lV 3R
 lltRt	Vt
V ;t# )TotalPagesSubstitutionFragmenti  aH  
A special type of text fragment that represents a placeholder for the total number of pages
in a PDF document.

A placeholder will be generated during the initial content rendering phase of a PDF document.
This placeholder is later replaced by the total number of pages in the document when the final
output is being produced.
c                *   < V ^8  d   QhRS[ RS[ RR/# )r&   argskwargsr+   N)r   )r1   r2   s   "r3   r4   +TotalPagesSubstitutionFragment.__annotate__  s"      c S T r6   c                F   < \         SV `  ! V/ VB  \        4       V n        R # r8   )superr;   r   uuid)r:   r<  r=  r   s   &*,r3   r;   'TotalPagesSubstitutionFragment.__init__  s    $)&)G	r6   c                    < V ^8  d   QhRS[ /# r>   r?   )r1   r2   s   "r3   r4   r>    s     . . .r6   c                "    RV P                    R2# )z
This method returns a placeholder string containing a universally unique identifier (UUID4),
ensuring that the placeholder is distinct and does not conflict with other placeholders
within the document.
z::placeholder:z::)rA  rC   s   &r3   get_placeholder_string5TotalPagesSubstitutionFragment.get_placeholder_string  s      		{"--r6   c                ,   < V ^8  d   QhRS[ RS[ RS[/# )r&   r<  r=  r+   )r   r-   )r1   r2   s   "r3   r4   r>    s"     
- 
-S 
-C 
-C 
-r6   c                :    Wn         W n        V P                  4       # )a;  
This method is invoked during the page content rendering phase, which is common to all
`Fragment` instances. It stores the provided arguments and keyword arguments to preserve
the necessary information and graphic state for the final substitution rendering.

The method then returns the unique placeholder string.
)_render_args_render_kwargsrE  )r:   r<  r=  s   &*,r3   r   .TotalPagesSubstitutionFragment.render_pdf_text  s     !$**,,r6   c                &   < V ^8  d   QhRS[ RS[ /# )r&   replacement_textr+   r?   )r1   r2   s   "r3   r4   r>    s     R R R Rr6   c                l   < \        V4      V n        \        SV `  ! V P                  / V P
                  B # )z
This method is invoked at the output phase. It calls `render_pdf_text()` from the superclass
to render the fragment with the preserved rendering state (stored in `_render_args` and `_render_kwargs`)
and insert the final text in place of the placeholder.
)r,   r'   r@  r   rI  rJ  )r:   rM  r   s   &&r3   render_text_substitution7TotalPagesSubstitutionFragment.render_text_substitution  s3     /0w&(9(9QT=P=PQQr6   )rI  rJ  r'   rA  )r/  r0  r1  r2  r3  r;   rE  r   rO  r6  r7  __classcell__)r   r2   s   @@r3   r:  r:    s:      . .
- 
-R R Rr6   r:  c                   J   a  ] tR tRt o RtRt^ tV 3R lR ltV 3R ltRt	V t
R# )TextLinei  Fc                0   < V ^8  d   QhRS[ S[,          /# r>   )r   r$   )r1   r2   s   "r3   r4   TextLine.__annotate__  s     ! !tH~ !r6   c                   V P                   '       g   . # . pR pV P                    FP  pVe,   VP                  V8X  d   VR,          P                  V4       K2  VP                  V.4       VP                  pKR  	  V P                   ^ ,          P                  \        P
                  8X  gT   V P                   ^ ,          P                  '       g=   V P                   ^ ,          P                  \        P
                  8X  d   VR R R1,          p. pV F>  pTV^ ,          P                  \        P
                  8X  d   VR R R1,          MT,          pK@  	  V# )N)	fragmentsr   r  r   r   RTL)r:   directional_runs	directionfragmentordered_fragmentsruns   &     r3   get_ordered_fragmentsTextLine.get_ordered_fragments  s   ~~~I13	H$)D)D	)Q $++H5 ''
3$77	 ' >>!00M4E4EEq!555q!448I8II/"5,.#C V66-:K:KKDbD	QT $ ! r6   c                   < V ^8  d   Qh/ S[ S[,          ;R&   S[;R&   S[;R&   S[;R&   S[;R&   S[S[,          ;R&   S[;R&   S[;R&   S[;R	&   # )
r&   rX  
text_widthnumber_of_spacesalignheight	max_widthtrailing_nltrailing_form_feedindent)r	   r$   r/   r0   r   r   rP   )r1   r2   s   "r3   r4   rU    s}     !!     L	 
 M      $   r6    N)r/  r0  r1  r2  rg  rh  ri  r_  __annotate_func__r6  r7  r8  s   @r3   rS  rS    s(      K$F! !  r6   rS  c                   ,   a  ] tR tRt o V 3R ltRtV tR# )	SpaceHinti  c                b   < V ^8  d   Qh/ S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[;R&   S[ ;R&   # )r&   original_fragment_indexoriginal_character_indexcurrent_line_fragment_indexcurrent_line_character_indexr   rc  )r0   r/   )r1   r2   s   "r3   r4   SpaceHint.__annotate__  sO        !!  "%$  #&%	 
    r6   rj  Nr/  r0  r1  r2  rk  r6  r7  r8  s   @r3   rm  rm          r6   rm  c                   ,   a  ] tR tRt o V 3R ltRtV tR# )
HyphenHinti  c                   < V ^8  d   Qh/ S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[;R&   S[ ;R&   S[;R&   S[;R&   S[;R	&   S[;R
&   # )r&   ro  rp  rq  rr  r   rc  curcharcurchar_widthr(   r)   )r0   r/   r-   r.   )r1   r2   s   "r3   r4   HyphenHint.__annotate__  s        !!  "%$  #&%	 
     L    #"  H r6   rj  Nrt  r8  s   @r3   rw  rw    ru  r6   rw  c                      a  ] tR tRt o RV 3R lR llt]V 3R lR l4       tRV 3R lR lltV 3R	 lR
 ltV 3R lR lt	RV 3R lR llt
V 3R lR ltV 3R lR ltRtV tR# )CurrentLinei  c                0   < V ^8  d   QhRS[ RS[RS[ RR/# )r&   rf  r   ri  r+   N)r/   rP   )r1   r2   s   "r3   r4   CurrentLine.__annotate__  s-     < <<*.<@E<	<r6   c                p    Wn         W n        W0n        . V n        ^ V n        ^ V n        RV n        RV n        R# )z
Per-line text fragment management for use by MultiLineBreak.
    Args:
        print_sh (bool): If true, a soft-hyphen will be rendered
            normally, instead of triggering a line break. Default: False
N)rf  r   ri  rX  re  rc  space_break_hinthyphen_break_hint)r:   rf  r   ri  s   &&&&r3   r;   CurrentLine.__init__  s;     # )+%& 6:7;r6   c                    < V ^8  d   QhRS[ /# r>   r`   )r1   r2   s   "r3   r4   r  %  s      u r6   c                |    ^ p\        V P                  4       F   w  r#WP                  V^ 8  R7      ,          pK"  	  V# )r.  r   )r  rX  r   )r:   r   ir\  s   &   r3   r   CurrentLine.width$  s;    $T^^4KA''1q5'99E 5r6   Nc                x   < V ^8  d   QhRS[ RS[RS[S[,          RS[RS[RS[RS[S[ S[,          ,          RR	/# )
r&   r   character_widthoriginal_fragmentro  rp  re  urlr+   N)r-   r/   r$   rw  r0   r   )r1   r2   s   "r3   r4   r  +  ss     E9 E9E9 E9 $j0	E9
 "%E9 #&E9 E9 cCi E9 
E9r6   c                <   V\         8w  g   Q hW`n        V P                  '       g\   \        V\        4      '       g   Q hV P                  P                  VP                  R VP                  VP                  VR7      4       M\        V\        4      '       d   \        V P                  R,          \        4      '       dk   VP                  V P                  R,          4      '       gC   V P                  P                  VP                  R VP                  VP                  VR7      4       V P                  R,          pV\        9   dj   \        VV\        V P                  4      \        VP                  4      V P                  V P                  4      V n        V ;P                  ^,          un        MV\"        8X  d!   \$        pV ;P                  ^,          un        MV\&        8X  d~   V P(                  '       gl   \+        VV\        V P                  4      \        VP                  4      V P                  V P                  \,        VVP                  VP                  4
      V n        V\&        8w  g   V P(                  '       d   VP                  P                  V4       R# R# )r   rB   NrW  )NEWLINEre  rX  r9   r$   r  r   r(   r)   r   BREAKING_SPACE_SYMBOLS_STRrm  lenr'   r   rc  r  NBSPSPACEr   r   rw  r   r  )	r:   r   r  r  ro  rp  re  r  active_fragments	   &&&&&&&& r3   add_characterCurrentLine.add_character+  s
    G###~~~/::::NN!!!++!#4#C#C'))	 ,  )844r"H '66t~~b7IJJ%%%//#%'8'G'G+-- 	 0  ..,22$-'(DNN#O../

%%%D! !!Q&!$I!!Q&!+%dmmm%/'(DNN#O../

%%!00!##&D" #t}}}&&--i8 (5r6   c                   < V ^8  d   QhRR/# )r&   r+   Nrj  )r1   r2   s   "r3   r4   r  r  s     1 1d 1r6   c                `   V P                   '       g   R # V P                   R,          pVP                  R,          pVR8X  dm   VP                  R4       VP                  '       g   V P                   R V P                   '       g   R # V P                   R,          pVP                  R,          pKs  R # )Nr   rW  )rX  r'   r   )r:   	last_frag	last_chars   &  r3   trim_trailing_spaces CurrentLine.trim_trailing_spacesr  s    ~~~NN2&	((,	3NN2'''NN2&>>>r*I!,,R0I r6   c                4   < V ^8  d   QhRS[ S[,          RR/# )r&   
break_hintr+   N)rm  rw  )r1   r2   s   "r3   r4   r    s      	< 	<	J0F 	<4 	<r6   c                    V P                   RVP                   V n         V P                   '       d-   V P                   R,          P                  VP                  4       VP                  V n        R# )z
This function mutates the current_line, applying one of the states
observed in the past and stored in
`hyphen_break_hint` or `space_break_hint` attributes.
NrW  )rX  rq  r   rr  rc  )r:   r  s   &&r3   _apply_automatic_hint!CurrentLine._apply_automatic_hint  sQ     (P**P*PQ>>>NN2##J$K$KL * ; ;r6   c                2   < V ^8  d   QhRS[ RS[RS[RS[/# )r&   rd  rg  rh  r+   )r   rP   rS  )r1   r2   s   "r3   r4   r    s-     
 

)-
KO
	
r6   c                    \        V P                  V P                  V P                  VV P                  V P
                  V P                  ,
          VVV P                  R 7	      # ))	rX  rb  rc  rd  re  rf  rg  rh  ri  )rS  rX  r   rc  re  rf  ri  )r:   rd  rg  rh  s   &&&&r3   manual_breakCurrentLine.manual_break  sO     nnzz!22;;nnt{{2#1;;

 
	
r6   c                    < V ^8  d   QhRS[ /# r>   rO   )r1   r2   s   "r3   r4   r    s     W W$ Wr6   c                J    V P                   R J;'       g    V P                  R J# r8   )r  r  rC   s   &r3   automatic_break_possible$CurrentLine.automatic_break_possible  s'    %%T1VVT5J5JRV5VVr6   c                @   < V ^8  d   QhRS[ RS[S[S[S[3,          /# )r&   rd  r+   )r   r
   r0   rS  )r1   r2   s   "r3   r4   r    s'     
 
U 
uS#x5G/H 
r6   c                :   V P                  4       '       g   Q hV P                  Ee   V P                  e0   V P                  P                  V P                  P                  8  d   V P	                  V P                  4       V P                  V P                  P                  V P                  P                  V P                  V P                  P                  V P                  P                  V P                  4       V P                  P                  V P                  P                  V P                  V4      3# V P                  f   Q hV P	                  V P                  4       V P                  P                  V P                  P                  V P                  V4      3# r8   )r  r  r  r   r  r  ry  rz  ro  rp  re  r  )r:   rd  s   &&r3   automatic_breakCurrentLine.automatic_break  sS   ,,....!!-!!)%%0043H3H3S3SS&&t'='=>&&..&&44&&&&>>&&?? &&>>&&??!!%( 
 $$000""4#8#89!!99!!::e$
 	
r6   )rX  re  r  ri  rf  rc  r   r  )Fr.  r8   )FF)r/  r0  r1  r2  r;   r4  r   r  r  r  r  r  r  r6  r7  r8  s   @r3   r}  r}    sd     < <<  E9 E9N1 1	< 	<
 
W W
 
r6   r}  c                   |   a  ] tR tRt o ]P
                  R]P                  RR^ 3V 3R lR lltV 3R lR lt	Rt
V tR	# )
MultiLineBreaki  Fg      ?c                   < V ^8  d   QhRS[ S[,          RS[S[S[S[.S[3,          3,          RS[ S[,          RS[RS[RS[RS[RS[R	S[/	# )
r&   rX  rf  marginsrd  r   wrapmodeline_heightskip_leading_spacesfirst_line_indent)r	   r$   r   r/   r   r   rP   r   )r1   r2   s   "r3   r4   MultiLineBreak.__annotate__  s     2# 2#H%2# %% 8892# %	2#
 2# 2# 2# 2# "2# !2#r6   c
                   a V  Wn         \        S4      '       d	   SV n        MV3R lV n        W0n        W@n        WPn        W`n        Wpn        Wn        ^ V n	        ^ V n
        RV n        Wn        RV n        R# )a  Accept text as Fragments, to be split into individual lines depending
on line width and text height.
Args:
    fragments: A sequence of Fragment()s containing text.
    max_width: Either a fixed width as float or a callback function
        get_width(height). If a function, it gets called with the largest
        height encountered on the current line, and must return the
        applicable width for the line with the given height at the current
        vertical position. The height is relevant in those cases where the
        lateral boundaries of the enclosing TextRegion() are not vertical.
    margins (sequence of floats): The extra clearance that may apply at the beginning
        and/or end of a line (usually either FPDF.c_margin or 0.0 for each side).
    align (Align): The horizontal alignment of the current text block.
    print_sh (bool): If True, a soft-hyphen will be rendered
        normally, instead of triggering a line break. Default: False
    wrapmode (WrapMode): Selects word or character based wrapping.
    line_height (float, optional): A multiplier relative to the font
        size changing the vertical space occupied by a line of text. Default 1.0.
    skip_leading_spaces (bool, optional): On each line, any space characters
        at the beginning will be skipped. Default value: False.
    first_line_indent (float, optional): left spacing before first line of text in paragraph.
c                    < S# r8   rj  )re  rf  s   &r3   <lambda>)MultiLineBreak.__init__.<locals>.<lambda>  s    Ir6   NT)rX  callabler   r  rd  r   r  r  r  fragment_indexcharacter_indexidx_last_forced_breakr  _is_first_line)
r:   rX  rf  r  rd  r   r  r  r  r  s
   &&f&&&&&&&r3   r;   MultiLineBreak.__init__  sm    D 	"I&DN5DN
  &#6 #$$%48"!2"r6   c                0   < V ^8  d   QhRS[ S[,          /# r>   )r   rS  )r1   r2   s   "r3   r4   r    s     | |(8, |r6   c           	     f   R pV P                   pRV n         V P                  \        V P                  4      8X  d   R# ^ pV P	                  V4      p\        TV P                  V P                  '       d   V P                  M^ R7      pV P                   F  pV\        V4      ,          pK  	  V P                  '       d   W@P                  ,          pV P                  '       d   V P                  \        V P                  4      8  d   V P                  \        V P                  V P                  ,          P                  4      8  d#   ^ V n        V ;P                  ^,          un        K  V P                  V P                  ,          P                  V P                  ,          pV\        8X  d   V ;P                  ^,          un        K   V P                  \        V P                  4      8  Ed   V P                  V P                  ,          p\        P                   ! VP"                  V4      '       dm   VP"                  pV P	                  V4      pWEn        V P                   F  pV\        V4      ,          pK  	  V P                  '       d   W@P                  ,          pV P                  \        VP                  4      8  d$   ^ V n        V ;P                  ^,          un        EK  VP                  V P                  ,          pVP'                  WpP                  V'       * R7      p	RpV\(        \*        39   d   V ;P                  ^,          un        VP                  '       g   W0P,                  ,          Vn        RV n        TP1                  V P2                  \4        P6                  8X  d   \4        P8                  MV P2                  V\(        8H  V\*        8H  R7      # \        P                   ! VP:                  V	,           V4      '       Ede   RV n        V\<        9   d5   V ;P                  ^,          un        VP1                  V P2                  4      # V P>                  \@        PB                  8X  d,   VPE                  4        VP1                  V P2                  4      # VPG                  4       '       dE   VPI                  V P2                  4      w  V n        V n        p
V ;P                  ^,          un        V
# W P                  8X  d   \K        R4      hV P                  V n         TP1                  V P2                  \4        P6                  8X  d   \4        P8                  4      # V P2                  4      # VPM                  VV	VV P                  V P                  W0P,                  ,          VPN                  4       V ;P                  ^,          un        EK  VP:                  '       dV   RV n        TP1                  V P2                  \4        P6                  8X  d   \4        P8                  4      # V P2                  4      # R# )TN)rf  r   ri  r  F)rg  rh  z8Not enough horizontal space to render a single character)(r  r  r  rX  r   r}  r   r  r  r  r/   r  r  r'   r  r   greater_thanrq   rf  r   r  	FORM_FEEDr  re  r  rd  r   JLr   r  r  r   CHARr  r  r  r   r  r*   )r:   
first_charr  current_font_heightrf  current_linemarginr   current_fragmentr  lines   &          r3   get_lineMultiLineBreak.get_line  s   
 $ : :%)"#dnn"55%&NN#67	"]]-1-@-@-@4))a
 llFv&I #///I### %%DNN(;;''3NN4#6#67BB,  ,-D(''1,' NN4+>+>?JJ((	 %((A-(!!C$77#~~d.A.AB** **,?  '7&@&@# NN+>?	)2&"llFv.I +&&&!7!77I##s+;+F+F'GG'($##q(#(33D4H4HII.BB==^ C O JWi00$$)$#---*=@P@P*PL'&+##00#zzUWW4EGG$** )W 4'0I'= 1  
 **""_4i  ',#!;;((A-('44TZZ@@==HMM1 !557'44TZZ@@88::
 %44TZZ@	+,((A-(K(,@,@@'R  .2-A-A*#00#zzUWW4EGG :>**  && ##$$#&6&66 %%   A%  "'D,,::0 6:jj  r6   )r  rd  r  r  r  rX  r   r  r  r  r   r  r  N)r/  r0  r1  r2  r   r  r   WORDr;   r  r6  r7  r8  s   @r3   r  r    s8      ww%]] $)#$2# 2#j| |r6   r  N)r   u   ​u    u    u    u    u    u    u    u    u    u    u    u   　	)3r3  typingr   r   r   r   r   r   r   r	   r
   r   rA  r   fpdf.drawing_primitivesr   r   r   enumsr   r   r   r   r   errorsr   fontsr   r   r(   r   utilr   r   r.   r   r   r  BREAKING_SPACE_SYMBOLSr   r  r  r  r  r$   r:  rS  rm  rw  r}  r  rj  r6   r3   <module>r     s   	    E E E E ! $ ) /	 "  WW%;< 
	_ _D)RX )RX !z  !F
 
 
r
 r
jr rr6   