
    Q?hu                     x   S r SrSSKrSSKrSSKrSSKJr  SSKJr  SSK	J
r
JrJrJrJrJrJrJr  SSKJrJr  SSKJrJr  SS	KJr  S
r\R4                  R7                  5         \R8                  r\R:                  r0 r0 r0 r 0 r! " S S\"5      r# " S S\"5      r$S r% " S S5      r&S6S jr'S r( " S S5      r)/ r* " S S5      r+\," S5      r-\," S5      r.\," S5      r/\," S5      r0S r1Sq2 " S S\&5      r3S r4S  r5S7S! jr6S" r7S# r8S$ r9S% r:S& r;\;" S'5      r<\*R{                  \;" S(5      \</5        S6S) jr>S6S* jr?S6S+ jr@S, rAS8S- jrBS. rCS/ rDS0 rES1 rF\G" \R                  5       \R                  5       \ R                  5       \!R                  5       S294S3 jrISS4KJJrJ  \J" \I5        CJ\KS5:X  a  \F" 5         \E" 5         gg)9z3.3.0a  This provides a database of font metric information and
efines Font, Encoding and TypeFace classes aimed at end users.

There are counterparts to some of these in pdfbase/pdfdoc.py, but
the latter focus on constructing the right PDF objects.  These
classes are declarative and focus on letting the user construct
and query font objects.

The module maintains a registry of font objects at run time.

It is independent of the canvas or any particular context.  It keeps
a registry of Font, TypeFace and Encoding objects.  Ideally these
would be pre-loaded, but due to a nasty circularity problem we
trap attempts to access them and do it on first access.
    N)	_fontdata)warnOnce)	rl_isfilerl_globrl_isdiropen_and_readopen_and_readlinesfindInPathsisSeqisStr)defaultEncodingT1SearchPath)
unicode2T1instanceStringWidthT1)	rl_codecs   nc                       \ rS rSrSrg)	FontError'    N__name__
__module____qualname____firstlineno____static_attributes__r       N/var/www/html/env/lib/python3.13/site-packages/reportlab/pdfbase/pdfmetrics.pyr   r   '       r   r   c                       \ rS rSrSrg)FontNotFoundError)   r   Nr   r   r   r   r!   r!   )   r   r   r!   c           	         [        U S5      n[        U5      S::  a8  U(       a  US   R                  S5      n[        U5      S::  a  [        SU -  5      e0 n/ nU Vs/ s H  oDR	                  5       PM     nnU Vs/ s H*  oDR                  5       R                  S5      (       a  M(  UPM,     nnSnU H  nUSS S:X  a  SnM  USS	 S
:X  a  SnM  U(       d  M&  UR                  S5      nU Vs/ s H  oR	                  5       PM     nnUSS u  pnU	R                  5       u  pLUS:X  d
   SU-  5       e[        U5      nU
R                  5       u  pLUS:X  d
   SU-  5       e [        U5      nUR                  5       u  pLUS:X  d
   SU-  5       eUnUR                  XU45        M     SnU HU  nUSS S:X  a  SnUSS S:X  a  SnM  U(       d  M$  USS S:X  a    UR                  SS5      u  nn [        U5      nUUU'   MW     X#4$ s  snf s  snf s  snf ! [         a    [        U5      n Nf = f!   [        SU < SU< S35      e= f!    NS= f)a  Quick and dirty - gives back a top-level dictionary
with top-level items, and a 'widths' key containing
a dictionary of glyph names and widths.  Just enough
needed for embedding.  A better parser would accept
options for what data you wwanted, and preserve the
order.r   r   zAFM file %s hasn't enough datacomment   StartCharMetrics   EndCharMetrics;   Czbad line in font file %sWXNStartFontMetrics   Comment z Header information error in afm z: line='')
r	   lensplit
ValueErrorstriplower
startswithintfloatappend)afmFileNamelinestopLevel
glyphLevell	inMetricslinechunkschunkcidChunk
widthChunk	nameChunkr$   cidwidthnameinHeaderleftrights                      r   parseAFMFilerQ   ,   s    {C0E
5z1}%(...%u:q=>LMMHJ %&1WWYE&E1WWY%9%9)%DQEEI":++I!BZ++IYZZ_F178kkmF8.4Qqk+H) >>#DA8>7$>>8a&C ##%DA9?84??9!A
 ??$DA8>7$>>8Ds4019 > H":++H":++HXAayI%th"jjQ/eE
 #HTN $ !!m 'E 9  !a!*h T_ae!fggsB   H;'H&H-H HH0/I	H-,H-0I	Ic                   0    \ rS rSrS rS rS rSS jrSrg)	TypeFaceu   c                    Xl         / U l        0 U l        SU l        SU l        S U l        SU l        SU l        US:X  a  SU l        OUS:X  a  SU l        OS U l        U[        ;   a  SU l
        U R                  U5        g SU l
        g )Nr   ZapfDingbatsZapfDingbatsEncodingSymbolSymbolEncodingr%   )rM   
glyphNamesglyphWidthsascentdescent
familyNamebolditalicrequiredEncodingstandardFontsbuiltIn_loadBuiltInDataselfrM   s     r   __init__TypeFace.__init__v   s    	
 	>!$:D!X$4D!$(D!= DL!!$'DLr   c                     [        U5      n[        R                  U   U l        [	        U R                  R                  5       5      U l        [        R                  U   u  U l        U l	        g)zyCalled for the built in 14 fonts.  Gets their glyph data.
We presume they never change so this can be a shared reference.N)
strr   widthsByFontGlyphr[   listkeysrZ   ascent_descentr\   r]   re   s     r   rd   TypeFace._loadBuiltInData   sT     4y$66t<t//4467#,#;#;D#A DLr   c                     / $ )z=Info function, return list of the font files this depends on.r   rf   s    r   getFontFilesTypeFace.getFontFiles   s    	r   c                    UR                  5       UR                  5       4n[        U S5      (       aM  [        R                  R                  U R                  5      S   nU H  n[        X4-   5      (       d  M  X4-   s  $     [        R                  " U R                  5      nWc  [        SU< SU R                  < S35        U$ !   [        U R                  5      nU(       ar  UR                  5       S:X  aF  U H>  n[        R                  R                  U5      S   U-   n[        U5      (       a  UnM<  S nM@      NUR                  5       S:X  a  Un NS n N= f)NpfbFileNamer   .pfbz.afmzCan't find z for face 'r5   )r:   upperhasattrospathsplitextru   r   r   
findT1FilerM   bruteForceSearchForAFMr   )rf   extpossible_exts
r_basenameer$   afmpfbs           r   r|   TypeFace.findT1File   s   ciik24&&))$*:*:;A>J"Z^,,%>) #	$$TYY/A 9c499EF!	(3C99;&(* gg..s3A6:$S>> #A $A + YY[F*As     C A6E;EE)
r\   r_   rc   r]   r^   rZ   r[   r`   rM   ra   N)rv   )	r   r   r   r   rg   rd   rr   r|   r   r   r   r   rS   rS   u   s    4Br   rS   c                    Uc  SSK Jn  [        U 5      (       a  U $ [        R                  R                  U 5      nU HH  n[        U5      (       d  M  [        R                  R                  X25      n[        U5      (       d  MF  Us  $    U $ )Nr   r   )reportlab.rl_configr   r   ry   rz   basenamer   join)fn
searchPathbfndirnametfns        r   bruteForceSearchForFiler      si    U}}Ri
''

2
C  (ggll7'S>>#:  Ir   c           	      v   SSK Jn  U HZ  n[        U5      (       d  M  [        U[        R
                  -   S-   5      nU H   n [        U5      u  pVUS   U :X  a  Us  s  $ M"     M\     g!   [        R                  " 5       u  pxn	SR                  [        [        UR                  5      5      SU -  -   4Ul        e = f)z_Looks in all AFM files on path for face with given name.

Returns AFM file name or None.  Ouch!r   r   z*.[aA][fF][mM]FontNamer4   z, while looking for faceName=%rN)r   r   r   r   ry   seprQ   sysexc_infor   maprj   args)
faceNamer   r   	possiblespossibletopDict	glyphDicttvbs
             r   r}   r}      s     1  (Gbff,/??@	!H%1(%;":&(2#O 3 "  llnA((3s166?34UX`4``bs   A((AB8c                   L    \ 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g)Encoding   z1Object to help you create and refer to encodings.Nc                 $   Xl         SU l        U[        ;   a)  Ub   S5       eXl        [        R
                  U   U l        g US :X  a(  [        U l        [        R
                  [           U l        g [        U5      (       a1  [        U5      nUR                   U l        UR                  S S  U l        g [        U5      (       a  [        U l        US S  U l        g [        U[        5      (       a&  UR                   U l        UR                  S S  U l        g g )Nr   z2Can't have a base encoding for a standard encoding)rM   frozenstandardEncodingsbaseEncodingNamer   	encodingsvectorr   r   getEncodingr   
isinstancer   )rf   rM   basebaseEncs       r   rg   Encoding.__init__   s    	$$<U!UU<$(!#--d3DKT\$3D!#--o>DK4[[!$'G$+LLD!!..+DK4[[$3D!q'DKh''$(IID!++a.DK (r   c                      U R                   U   $ )z.Return glyph name for that code point, or None)r   )rf   indexs     r   __getitem__Encoding.__getitem__   s     {{5!!r   c                     U R                   S:X  d   S5       eU R                  U   U:w  a*  [        U R                  5      nX#U'   [        U5      U l        g g )Nr   Cannot modify a frozen encoding)r   r   rl   tuple)rf   r   valueLs       r   __setitem__Encoding.__setitem__   sP    {{aB!BB;;uu$T[[!AeH(DK %r   c                 F    [        U R                  5      U l        SU l        g Nr%   )r   r   r   rq   s    r   freezeEncoding.freeze   s    DKK(r   c                     U R                   UR                   :H  =(       a+    [        U R                  5      [        UR                  5      :H  $ N)rM   r   r   )rf   others     r   isEqualEncoding.isEqual  s1    yy%**$Pt{{);U5<<=P)PPr   c                 n    U R                   S:X  d   S5       eUnU H  nX@R                  U'   US-   nM     g)zASet a group of character names starting at the code point 'base'.r   r   r%   N)r   r   )rf   r   newNamesidxrM   s        r   modifyRangeEncoding.modifyRange  s>    {{aB!BBD#KK'C r   c                 R   / nSn[        [        U R                  5      5       Hh  nU R                  U   nXQR                  U   :X  a  U(       a  UR                  U5        / nM@  MB  U(       a  UR                  U5        M\  U(       d  Me  XE/nMj     U(       a  UR                  U5        U$ )a  
Return a compact list of the code points differing between two encodings

This is in the Adobe format: list of
   [[b1, name1, name2, name3],
   [b2, name4]]
   
where b1...bn is the starting code point, and the glyph names following
are assigned consecutive code points.

N)ranger6   r   r>   )rf   otherEncrangescurRangeiglyphs         r   getDifferencesEncoding.getDifferences  s     s4;;'(AKKNEooa((MM(+!H  OOE*U !zH ) MM(#r   c                    SSK Jn  0 nU R                  n[        U5      nU R	                  U5      nU/ :X  a  UR                  U5      $ / nU H<  nUR                  US   5        USS  H  nUc  M  UR                  SU-   5        M     M>     UR                  U5      US'   US;   a  UR                  U5      US'   UR                  S	5      US
'   UR                  U5      n	U	$ )z&Returns a PDF Object representing selfr   pdfdocr%   N/Differences)MacRomanEncodingMacExpertEncodingWinAnsiEncodingBaseEncodingr   Type)	reportlab.pdfbaser   r   r   r   PDFNamer>   PDFArrayPDFDictionary)
rf   r   Dr   r   differences	diffArrayr   	glyphNamePDs
             r   makePDFObjectEncoding.makePDFObject,  s     	-00./))'2 ">>"233 I$  q*!&qrI ,!((y9 "+ %  &y9Am#]]$*NN3C$D.!z2AfI%%a(BIr   )r   r   rM   r   r   )r   r   r   r   __doc__rg   r   r   r   r   r   r   r   r   r   r   r   r   r      s.    ;)."
#Q<r   r   c                   P    \ rS rSrSrSrSrSrSS jrSS jr	S r
S	 rS
 rS rSrg)FontiQ  a0  Represents a font (i.e combination of face and encoding).

Defines suitable machinery for single byte fonts.  This is
a concrete class which can handle the basic built-in fonts;
not clear yet if embedded ones need a new font class or
just a new typeface class (which would do the job through
composition)r   FNc                 <   Xl         [        U5      =oPl        [        U5      U l        X0l        UR                  (       a  UR                  c  [        O
U=(       d    / U l	        U R                  5         [        U l        US:H  =(       a    U =(       d    [        U l        g )NrV   )fontNamegetTypeFacefacer   encodingencNamerc   ra   standardT1SubstitutionFontssubstitutionFonts_calcWidths_notdefChar_notdefFont)rf   rM   r   r   r   r   s         r   rg   Font.__init__^  s{    &x00y"7+'+||8M8M8U #>):)@b 	 	&/8DGKr   c                     [        XX#S9$ )Nr   )r   )rf   textsizer   s       r   stringWidthFont.stringWidthj  s    $TIIr   c                 h    SU R                   R                  < SU R                  R                  < S3$ )N<r4   >)	__class__r   r   rM   rq   s    r   __repr__Font.__repr__m  s     NN33TYY^^DDr   c           	      r   S/S-  nU R                   R                  nU R                  R                  n[	        S5       H  nX4   nUc  M   X%   nXaU'   M     Xl        g! [
         aN    SSKnUR                  R                  (       a+  [        SU R                   R                  < SU< S35         Mt   Mw  f = f)z)Vector of widths for stringWidth functionr      Nz
typeface "z" does not have a glyph "z", bad font!)r   r[   r   r   r   KeyErrorr   	rl_configwarnOnMissingFontGlyphsprintrM   widths)rf   wgwvecr   r   rL   	reportlabs           r   r   Font._calcWidthsp  s     C#IYY""mm""sAI$ME aD     . **BBW[W`W`WeWegpqrs   AAB65B6c                     Sn[        S5       HF  nUS-   [        [        U R                  U   5      S5      -   nUS:X  a  US-   nUS-  S:X  d  MA  US	-   nMH     U$ )
z<returns a pretty block in PDF Array format to aid inspection   [r       utf8   s    ]r(         
)r   bytesrj   r  )rf   r   r   s      r   _formatWidthsFont._formatWidths  sb    sA$;s4;;q>':6!BBDCxe|2v|e|  r   c                    SSK Jn  S[        [        UR                  5      S-   5      -   nUR                  5       nX4l        U R                  R                  Ul	        SU R                  -  Ul        U R                  R                  5       n[        U5      (       a  US;   a  XTl        U R                  R                  [         ;  aN  SUl        SUl        UR'                  U R(                  5      Ul        U R                  R-                  U5      Ul        UR1                  XC5      nUR2                  S   R4                  nXGU'   S	U-   UR                  U R                  '   g
)zMakes and returns one or more PDF objects to be added
to the document.  The caller supplies the internal name
to be used (typically F1, F2... in sequence) r   r   Fr%   zFont %s)z/MacRomanEncodingz/MacExpertEncodingz/WinAnsiEncodingr  
BasicFontsr   N)r   r   reprr6   fontMappingPDFType1FontNamer   rM   BaseFontr   __Comment__r   r   r   r   rb   	FirstCharLastCharr   r  Widths
addObjectsFontDescriptor	Reference
idToObjectdict)rf   docr   internalNamepdfFontr   reffontDicts           r   r!  Font.addObjects  s   
 	- T#coo"6q"899%%'#99>>'$--7MM'')Qxx1 ]]  yy~~. !G"G#__T[[9GN%)YY%9%9#%>G"mmG2 >>,/44!( *-|);&r   )r   r   r   r   r   r   r   r  r   r  )r   r   r   r   r   
_multiByte_dynamicFontshapablerg   r   r   r   r  r!  r   r   r   r   r   r   Q  s9     JLH
HJE(	 <r   r      r%      r-   c                    [        X   5      [        :w  d  [        XS-      5      U:w  a1  [        SU[        [        5      [        U5      XU    XS-      4-  5      eU[        :X  a  g U S-   n XS-      S-  XS-      S-  -  XS-      -  S-  X   -  nU S-   n X-   [        U5      :  a  [        SX0U[        U5      4-  5      eX U-   4$ )Nr%   zGBad pfb file'%s' expected chr(%d)chr(%d) at char %d, got chr(%d)chr(%d)r1  r-         z1Bad pfb file'%s' needed %d+%d bytes have only %d!)chr
PFB_MARKERr8   ordPFB_EOFr6   )pdmr   rC   s        r   	_pfbCheckr<    s   
14y*AcFQdhjknoykz{~  @A  |B  CD  GH  EI  JK  NO  LO  JP  hQ  Q  R  	R'z6	AAsVaK!aC&1$q1v
.	2QT:A	AAs3q6zNRTWXY\]^Y_Q``aac6Mr   c                   6    \ rS rSrSrS rS rS rS rS r	Sr
g	)
EmbeddedType1Facei  z_A Type 1 font other than one of the basic 14.

Its glyph data will be embedded in the PDF file.c                 R   [         R                  U S 5        [        U[        5      n[        U[        5      n[        R
                  R                  U5      U l        [        R
                  R                  U5      U l        S U l	        U R                  U5        U R                  U5        g r   )rS   rg   r
   r   ry   rz   abspathr?   ru   ra   _loadGlyphs_loadMetrics)rf   r?   ru   s      r   rg   EmbeddedType1Face.__init__  sz    $% "+l;!+l;77??;777??;7 $%+&r   c                 2    U R                   U R                  /$ r   )r?   ru   rq   s    r   rr   EmbeddedType1Face.getFontFiles  s      $"2"233r   c                    [        U5      n[        U5      (       d
   SU-  5       e[        US5      n[        SU[        U5      u  p4[        XB[
        U5      u  pV[        Xb[        U5      u  px[        X[        U5        X#U X%U -   X'U -   U l        [        U R                  5      U l	        XC-
  U l
        Xe-
  U l        X-
  U l        g)zaLoads in binary glyph data, and finds the four length
measurements needed for the font descriptorzfile %s not foundr   r   N)r   r   r   r<  	PFB_ASCII
PFB_BINARYr8  _binaryDatar6   _length_length1_length2_length3)	rf   ru   r:  s1l1s2l2s3l3s	            r   rA  EmbeddedType1Face._loadGlyphs  s     .k:%%H':['HH%+s+1Qy52
;72	+6"w{+8AH,Q"X54++,r   c                    [        U5      n[        U5      u  p#US   U l        US   U l        UR	                  SS5      U l        UR	                  SS5      U l        UR	                  SS5      U l        UR	                  SS5      U l        UR	                  S	S5      U l	        UR	                  S
S5      U l
        UR	                  S/ SQ5      nUR                  5       n/ U l        U H'  nU R                  R                  [        U5      5        M)     0 nU H
  u  pn
XU
'   M     Xpl        [!        UR#                  5       5      U l        U R$                  R'                  5         UR	                  SS5      S:X  a  [(        c
   SSKJn  UqAS/S-  n0 n0 nU H@  u  pn
SUs=::  a  S::  d  M  O  M  XU'   [(        R	                  U
S5      nUc  M8  UX'   XU'   MB     [0        R2                  " SU R                  -  5      n[4        R6                  R9                  UX5        UU l        [=        UU5      n[?        U5        gg!   0 q[/        S5      e= f)z Loads in and parses font metricsr   
FamilyNameAscender  	Descenderr   	CapHeightItalicAnglestemVXHeightFontBBox)r   r   rX  rX  EncodingSchemeNFontSpecific)_glyphname2unicodezcannot import module reportlab.pdfbase._glyphlist module
you can obtain a version from here
https://www.reportlab.com/ftp/_glyphlist.py
r   r  zrl-dynamic-%s-encoding) r   rQ   rM   r^   getr\   r]   	capHeightitalicAngler\  xHeightr7   bboxr>   r<   r[   rl   rm   rZ   sort_postScriptNames2Unicodereportlab.pdfbase._glyphlistra  r8   r   normalize_encodingr   	RL_Codecsadd_dynamic_codecra   r   registerEncoding)rf   r?   rA   	glyphDatastrBboxtokenstokr[   rK   rL   rM   ra  namesexrexcodeur   encs                      r   rB  EmbeddedType1Face._loadMetrics  s+    .k: ,[ 9Z(	"<0ll:t4||K3!k48#<<q9\\'1-
||It4,,z?;	CIISX&  "+S % #,&{//12 <<($/>A'/
O/A,* FSLEBC'0#dd<C<<"&$K044T$?A}$%	 $1 (1  223Kdii3WXG11'"A$+D!7E*CS!; B/1,$L s   =	H9 9Ic                 |   SSK Jn  UR                  5       nU R                  Ul        U R
                  UR                  S'   U R                  UR                  S'   U R                  UR                  S'   UR                  USU R                  -   5      nUR                  SU R                  U R                  U R                  SUR                  U R                   5      UR#                  U R$                  5      U R&                  U R(                  U R*                  US	.5      nUR                  US
U R$                  -   5      nU$ )zFAdd whatever needed to PDF file, and return a FontDescriptor referencer   r   Length1Length2Length3z	fontFile:z/FontDescriptor"   )r   AscentrZ  DescentFlagsr^  r   r[  StemVr]  FontFilezfontDescriptor:)r   r   	PDFStreamrI  contentrK  
dictionaryrL  rM  r#  ru   r   r\   rc  r]   r   rf  r   rM   rd  r\  re  )rf   r&  r   fontFilefontFileReffontDescriptorfontDescriptorRefs          r   r!  EmbeddedType1Face.addObjects%  s   ,##%++)-I&)-I&)-I& mmHkD<L<L.LM--%[[lltyy1~~dii0**JJll#/   MM.:Kdii:WX  r   )rI  rJ  rK  rL  rM  r?   r\   rf  rc  r]   r^   rZ   r[   rd  rM   ru   ra   r\  re  N)r   r   r   r   r   rg   rr   rA  rB  r!  r   r   r   r   r>  r>    s!    8'4$;"z!r   r>  c                     [        U [        5      (       d
   SU -  5       eU [        U R                  '   U R                  [        ;  a  [        U R                  5        g g )NzNot a TypeFace: %s)r   rS   
_typefacesrM   rb   registerFontFamily)r   s    r   registerTypeFacer  C  sM    dH%%B';d'BB% Jtyy99% 	499% &r   c                 P   [        U [        5      (       d
   SU -  5       eU R                  [        ;   aP  U R	                  [        U R                     5      (       a  U R                  5         g [        SU R                  -  5      eU [        U R                  '   U R                  5         g )NzNot an Encoding: %sz>Encoding "%s" already registered with a different name vector!)r   r   rM   
_encodingsr   r   r   )rw  s    r   rm  rm  K  s|    c8$$A&;c&AA$
xx:;;z#((+,,JJL\_b_g_gghh"
388

r   c                 <   SSK Jn  U(       d  U nU R                  5       n U(       d  U=(       d    U=(       d    UnU(       d  UnU(       d  UnUR                  U SSU5        UR                  U SSU5        UR                  U SSU5        UR                  U SSU5        g )Nr   )fontsr%   )reportlab.libr  r:   
addMapping)familynormalr_   r`   
boldItalicr  s         r   r  r  X  s    #F6\\^FF$<d$<fzF6	VQ6*	VQ4(	VQ6*	VQ:.r   c                    U R                   nU R                  (       ax  U R                  R                  nU[        ;  aW  U[
        ;   a;  [
        U   nUR                  (       d  [        SU< SU < SU< 35      eU[        U'   OU =[
        U'   [        U'   O	U [        U'   U R                  (       a  [        U R                   5        gg)zGRegisters a font, including setting up info for accelerated stringWidthzAttempt to register fonts r4   z
 for face N)	r   r.  r   rM   _fonts_dynFaceNamesr8   r-  r  )fontr   r   ofonts       r   registerFontr  d  s     }}H99>>6!=(%h/))$V[]ack%lmm',F8$=AAh'&*:x 	4==)	 r   c                     [         U    $ ! [         a    U [        ;   a@  [        U 5      n[        R
                  U    u  Ul        Ul        Ul        [        U5        Us $ [        U 5      nU(       at  S H:  n[        R                  R                  U5      S   U-   n[        U5      (       d  M:    O   [        W5      (       d
   SU-  5       e[        X$5      n[        U5        Us $ e f = f)z-Lazily construct known typefaces if not found)rv   z.PFBr   zfile %s not found!)r  r  rb   rS   r   standardFontAttributesr^   r_   r`   r  r}   ry   rz   r{   r   r>  )r   r   r   r   r   s        r   r   r   |  s    (## }$H%D8A8X8XYa8b5T_diT" K )2C)A''**3/2Q6C ~~u * !~~A';c'AA~(2 &+s    AC'A
C'-6C'%C'c                 |     [         U    $ ! [         a&    U [        ;   a  [        U 5      n[	        U5        Us $ e f = f)z-Lazily construct known encodings if not found)r  r  r   r   rm  )r   rw  s     r   r   r     sD    	'"" ''7#CS!Js    ,;;c                    [        U 5      n [        U 5      [         L d   S[        U 5      -  5       e[        U 5      nUR                  (       a  [        X UR                  5      nO[        X [        5      n[        U5        U$ )z-search for and register a font given its namez$fontName=%s is not required type str)rj   typeasciir   ra   r   r   r  )r   r   r  s      r   findFontAndRegisterr    sm    8}H>S Z"H5QY?"ZZ  x DH(=(=>H8Kr   c                 L     [         U    $ ! [         a    [        U 5      s $ f = f)zLazily constructs known fonts if not found.

Names of form 'face-encoding' will be built if
face and encoding are known.  Also if the name is
just one of the standard 14, it will make up a font
in the default encoding.)r  r  r  )r   s    r   getFontr    s,    -h -"8,,-s    ##rV   rX   c                     [        U 5      n UR                  nUR                  nU(       a  US-  nX5-  XE-  4$ X44$ !   UR                  R                  nUR                  R                  n NG= f)Ng     @@)r  r\   r]   r   )r   fontSizer  r\   r]   norms         r   getAscentDescentr    sm    8D$,, ~{GL(($!!))##s	   < .A,c                     [        X5      S   $ )Nr   r  r   r  s     r   	getAscentr        H.q11r   c                     [        X5      S   $ r   r  r  s     r   
getDescentr    r  r   c                  `    [        [        R                  5       5      n U R                  5         U $ )zReturns what's in there)rl   r  rm   rg  )regs    r   getRegisteredFontNamesr    s     
v{{}
CHHJJr   c                 4    [        U5      R                  XUS9$ )zfCompute width of string in points;
not accelerated as fast enough because of instanceStringWidthT1/TTFr   )r  r   )r   r   r  r   s       r   r   r     s     8((((KKr   c            
         [        S5        [        [        R                  5       5      n U R	                  5         U  H  n[        SU5        M     [        5         [        S5        [        [
        R                  5       5      nUR	                  5         U H  n[        SU5        M     [        5         [        S5        [        [        R                  5       5      nUR	                  5         U HV  n[        U   n[        SUR                  < SUR                  R                  < SUR                  R                  < S35        MX     g )	NzRegistered Encodings:z   zRegistered Typefaces:zRegistered Fonts:z    z (r   ))r  rl   r  rm   rg  r  r  r   r   rM   r   )rm   r   facesr   kkeyr  s          r   dumpFontDatar    s    	
!"
!"DIIKeG  
G	
!""#E	JJLeH  
G	
V[[]AFFHc{$--ASASTU r   c                    SS K n[        SS  H  nUR                  5       n[        U5      R                  nU  H  nSnU H  nXd[	        U5         -   nM     M      UR                  5       n[        SX-
  -  5        UR                  5       nU  H  n[        U5      R                  US5      n	M      UR                  5       n[        SX-
  -  5        [        5         M     g )Nr   r%   zslow stringWidth took %0.4f
   z'class lookup and stringWidth took %0.4f)timerb   r  r  r7  r  r   )
textsr  r   t0r  r   rQ  cht1rS  s
             r   test3widthsr    s    !!A& YY[H$$DBCG*_   YY[+rw78YY[D"..tR8B YY[727CD+ 'r   c                  >   [        S5      R                  5       n [        S[        U 5      -  5        [        S5        [	        U /5        [        5         U R                  5       n[        S[        U5      S[        U 5      -  [        U5      -  4-  5        [	        U5        g )Nz-../../rlextra/rml2pdf/doc/rml_user_guide.prepzrawdata length %dztest one huge string...z7test %d shorter strings (average length %0.2f chars)...g      ?)openreadr  r6   r  r7   )rawdatawordss     r   testStringWidthAlgorithmsr    s    BCHHJG	
G
,-	
#$		GMMOE	
Cs5zSVWZ[bWcScdghmdnSnFo
opr   c                      [        S5      n [        U 5        [        U R                  SS 5        [        S5      n[        UR                  5        [        U5        [	        5         g )N	Helveticar      Wombat)rS   r  r  rZ   r  )helvwombats     r   testr    sL    K DT	$//!B
 hF	&

VNr   )r  r  r  r  c                     U R                  5        H3  u  p[        5       U   nUR                  5         UR                  U5        M5     [        R
                  R                  5         g r   )itemsglobalsclearupdater   rk  reset_dynamic_codecs)initial_dictsr  r   r:  s       r   _resetr  (  sL     ""$
)A,			 % ,,.r   )register_reset__main__r   )NNNNr,  )L__version__r   ry   r   r   r   r   reportlab.lib.loggerr   reportlab.lib.utilsr   r   r   r   r	   r
   r   r   r   r   r   reportlab.lib.rl_accelr   r   r   r   rk  registerrb   r   r  r  r  r  	Exceptionr   r!   rQ   rS   r   r}   r   r   r   r5  r6  rG  rH  r8  r<  rh  r>  r  rm  r  r  r   r   r  r  r   extendr  r  r  r  r   r  r  r  r  r%  copyr  r  r   r   r   r   <module>r     s  
 	   ' ) z z z = D ' 	     ''// 

			 			 	G"R@ @D0q qn ! ^< ^<@ t9

a&	q6
A	   ! !B&

/*06
- n%  " "GH$5k#B C22L
V.4	 #*#*[[])..0	/ / v ZF r   