
    Kwgt                     n   d Z dZddlZddlZddlZddlmZ ddlmZ ddl	m
Z
mZmZmZmZmZmZmZ ddlmZmZ ddlmZmZ dd	lmZ d
Zej4                  j7                          ej8                  Zej:                  Zi Zi Zi Z i Z! G d de"      Z# G d de"      Z$d Z% G d d      Z&d6dZ'd Z( G d d      Z)g Z* G d d      Z+ e,d      Z- e,d      Z. e,d      Z/ e,d      Z0d Z1da2 G d de&      Z3d Z4d  Z5d7d!Z6d" Z7d# Z8d$ Z9d% Z:d& Z; e;d'      Z<e*j{                   e;d(      e<g       d6d)Z>d6d*Z?d6d+Z@d, ZAd8d-ZBd. ZCd/ ZDd0 ZEd1 ZF eGej                         ej                         e j                         e!j                         2      fd3ZIdd4lmJZJ  eJeI       [JeKd5k(  r eF         eE        yy)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                       e Zd Zy)	FontErrorN__name__
__module____qualname__     S/var/www/horilla/myenv/lib/python3.12/site-packages/reportlab/pdfbase/pdfmetrics.pyr   r   '       r   r   c                       e Zd Zy)FontNotFoundErrorNr   r   r   r   r   r   )   r   r   r   c           	      J   t        | d      }t        |      dk  r2|r|d   j                  d      }t        |      dk  rt        d| z        i }g }|D cg c]  }|j	                          }}|D cg c]$  }|j                         j                  d      r#|& }}d}|D ]  }|dd dk(  rd}|dd	 d
k(  rd}|s|j                  d      }|D cg c]  }|j	                          }}|dd \  }	}
}|	j                         \  }}|dk(  s
J d|z         t        |      }|
j                         \  }}|dk(  s
J d|z         	 t        |      }|j                         \  }}|dk(  s
J d|z         |}|j                  |||f        d}|D ]J  }|dd dk(  rd}|dd dk(  rd}|s|dd dk(  r	 	 |j                  dd      \  }}	 t        |      }|||<   L ||fS c c}w c c}w c c}w # t        $ r t        |      }Y w xY w#  t        d| d|d      xY w#  Y OxY w)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   parseAFMFilerM   ,   s    {C0E
5z1}%(...%u:q=>LMMHJ %&1QWWY&E&E1QWWY%9%9)%DQEEEI 2":++I!BZ++IZZ_F178ekkm8F8.4Qqk+Hj) >>#DAq8>7$>>8a&C ##%DAq9?84??9!A
 ??$DAq8>7$>>8DsE40192> H #":++H":++HAayI%th"jjQ/eE
 #HTN#$ j!!m 'E 9  !a!*h T_ae!fggsB   G2$G#G#G(G-2HH-HHHH"c                   &    e Zd Zd Zd Zd ZddZy)TypeFacec                    || _         g | _        i | _        d| _        d| _        d | _        d| _        d| _        |dk(  rd| _        n|dk(  rd| _        nd | _        |t        v rd| _
        | j                  |       y d| _
        y )Nr   ZapfDingbatsZapfDingbatsEncodingSymbolSymbolEncodingr!   )rI   
glyphNamesglyphWidthsascentdescent
familyNamebolditalicrequiredEncodingstandardFontsbuiltIn_loadBuiltInDataselfrI   s     r   __init__zTypeFace.__init__v   s    	
 	>!$:D!X$4D!$(D!= DL!!$'DLr   c                     t        |      }t        j                  |   | _        t	        | j                  j                               | _        t        j                  |   \  | _        | _	        y)zCalled for the built in 14 fonts.  Gets their glyph data.
        We presume they never change so this can be a shared reference.N)
strr   widthsByFontGlyphrV   listkeysrU   ascent_descentrW   rX   r`   s     r   r_   zTypeFace._loadBuiltInData   sT     4y$66t<t//4467#,#;#;D#A DLr   c                     g S )z=Info function, return list of the font files this depends on.r   ra   s    r   getFontFileszTypeFace.getFontFiles   s    	r   c                 v   |j                         |j                         f}t        | d      rHt        j                  j                  | j                        d   }|D ]  }t        ||z         s||z   c S  	 t        j                  | j                        }t        d|d| j                  d       |S #  t        | j                        }|rf|j                         dk(  r=|D ]7  }t        j                  j                  |      d   |z   }t        |      r|}6d }9 n|j                         dk(  r|}nd }Y xY w)NpfbFileNamer   .pfbz.afmzCan't find z for face 'r1   )r6   upperhasattrospathsplitextrm   r   r   
findT1FilerI   bruteForceSearchForAFMr   )ra   extpossible_exts
r_basenameer    afmpfbs           r   rt   z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   6B5 5BD8N)rn   )r   r   r   rb   r_   rk   rt   r   r   r   rO   rO   u   s    4Br   rO   c                     |ddl m} t        |       r| S t        j                  j                  |       }|D ]=  }t        |      st        j                  j                  ||      }t        |      s;|c S  | S )Nr   r   )reportlab.rl_configr   r   rq   rr   basenamer   join)fn
searchPathbfndirnametfns        r   bruteForceSearchForFiler      si    U}Ri
''

2
C & (ggll73'S>#:& Ir   c           	      b   ddl m} |D ]Q  }t        |      st        |t        j
                  z   dz         }|D ]  }	 t        |      \  }}|d   | k(  r|c c S ! S y#  t        j                         \  }}}	dj                  t        t        |j                              d| z  z   f|_         xY w)zcLooks in all AFM files on path for face with given name.

    Returns AFM file name or None.  Ouch!r   r}   z*.[aA][fF][mM]FontNamer0   z, while looking for faceName=%rN)r~   r   r   r   rq   seprM   sysexc_infor   maprd   args)
faceNamer   r   	possiblespossibletopDict	glyphDicttvbs
             r   ru   ru      s     1  (Gbff,/??@	! 	H%1(%;":&(2#O 3	lln!A((3s166?34UX`4``bs   AAB.c                   B    e Zd ZdZddZd Zd Zd Zd Zd Z	d	 Z
d
 Zy)Encodingz1Object to help you create and refer to encodings.Nc                    || _         d| _        |t        v r)|J d       || _        t        j
                  |   | _        y |d k(  r(t        | _        t        j
                  t           | _        y t        |      r1t        |      }|j                   | _        |j                  d d  | _        y t        |      rt        | _        |d d  | _        y t        |t              r&|j                   | _        |j                  d d  | _        y y )Nr   z2Can't have a base encoding for a standard encoding)rI   frozenstandardEncodingsbaseEncodingNamer   	encodingsvectorr   r   getEncodingr   
isinstancer   )ra   rI   basebaseEncs       r   rb   zEncoding.__init__   s    	$$<U!UU<$(D!#--d3DKT\$3D!#--o>DK4[!$'G$+LLD!!..+DK4[$3D!q'DKh'$(IID!++a.DK (r   c                      | j                   |   S )z.Return glyph name for that code point, or None)r   )ra   indexs     r   __getitem__zEncoding.__getitem__   s     {{5!!r   c                     | j                   dk(  sJ d       | j                  |   |k7  r+t        | j                        }|||<   t        |      | _        y y )Nr   Cannot modify a frozen encoding)r   r   rf   tuple)ra   r   valueLs       r   __setitem__zEncoding.__setitem__   sR    {{aB!BB;;uu$T[[!AAeH(DK %r   c                 F    t        | j                        | _        d| _        y Nr!   )r   r   r   rj   s    r   freezezEncoding.freeze   s    DKK(r   c                     | j                   |j                   k(  xr+ t        | j                        t        |j                        k(  S N)rI   r   r   )ra   others     r   isEqualzEncoding.isEqual  s1    yy%**$Pt{{);U5<<=P)PPr   c                 j    | j                   dk(  sJ d       |}|D ]  }|| j                  |<   |dz   } y)zASet a group of character names starting at the code point 'base'.r   r   r!   N)r   r   )ra   r   newNamesidxrI   s        r   modifyRangezEncoding.modifyRange  sE    {{aB!BB 	D#DKK'C	r   c                     g }d}t        t        | j                              D ]U  }| j                  |   }||j                  |   k(  r|s'|j                  |       g };|r|j                  |       O|sR||g}W |r|j                  |       |S )aZ  
        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)ranger2   r   r:   )ra   otherEncrangescurRangeiglyphs         r   getDifferenceszEncoding.getDifferences  s     s4;;'( 
	*AKKNEhooa((MM(+!HOOE* !5zH
	* MM(#r   c                    ddl m} i }| j                  }t        |      }| j	                  |      }|g k(  r|j                  |      S g }|D ]7  }|j                  |d          |dd D ]  }||j                  d|z           9 |j                  |      |d<   |dv r|j                  |      |d<   |j                  d	      |d
<   |j                  |      }	|	S )z&Returns a PDF Object representing selfr   pdfdocr!   N/Differences)MacRomanEncodingMacExpertEncodingWinAnsiEncodingBaseEncodingr   Type)	reportlab.pdfbaser   r   r   r   PDFNamer:   PDFArrayPDFDictionary)
ra   r   Dr   r   differences	diffArrayr   	glyphNamePDs
             r   makePDFObjectz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   r   r   __doc__rb   r   r   r   r   r   r   r   r   r   r   r   r      s.    ;)."
#Q<r   r   c                   @    e Zd ZdZdZdZd
dZddZd Zd Z	d Z
d	 Zy)FontaD  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   Nc                    || _         t        |      x}| _        t        |      | _        || _        |j                  r|j                  t        n|xs g | _	        | j                          t        | _        |dk(  xr | xs t        | _        y )NrQ   )fontNamegetTypeFacefacer   encodingencNamer^   r\   standardT1SubstitutionFontssubstitutionFonts_calcWidths_notdefChar_notdefFont)ra   rI   r   r   r   r   s         r   rb   zFont.__init__]  s    &x00ty"7+'+||8M8M8U #>):)@b 	 	&/8DGKr   c                      t        | |||      S )Nr   )r   )ra   textsizer   s       r   stringWidthzFont.stringWidthi  s    $T4IIr   c                 d    d| j                   j                  d| j                  j                  dS )N<r0   >)	__class__r   r   rI   rj   s    r   __repr__zFont.__repr__l  s     NN33TYY^^DDr   c           	      ^   dgdz  }| j                   j                  }| j                  j                  }t	        d      D ]  }||   }|	 ||   }|||<    || _        y# t
        $ rE ddl}|j                  j                  r't        d| j                   j                  d|d       n	 Y mw xY w)z)Vector of widths for stringWidth functionr      Nz
typeface "z" does not have a glyph "z", bad font!)r   rV   r   r   r   KeyErrorr~   	rl_configwarnOnMissingFontGlyphsprintrI   widths)ra   wgwvecr   r   rH   	reportlabs           r   r   zFont._calcWidthso  s     C#IYY""mm""s 	AAI$yME AaD	    . **BBW[W`W`WeWegpqrs   

AAB,+B,c                     d}t        d      D ]B  }|dz   t        t        | j                  |         d      z   }|dk(  r|dz   }|dz  dk(  s>|d	z   }D |S )
z<returns a pretty block in PDF Array format to aid inspection   [r       utf8   s    ]r$         
)r   bytesrd   r   )ra   r   r   s      r   _formatWidthszFont._formatWidths  sg    s 	$A$;s4;;q>':6!BBDCxe|2v|e|	$ r   c                    ddl m} dt        t        |j                        dz         z   }|j                         }||_        | j                  j                  |_	        d| j                  z  |_        | j                  j                         }t        |      r|dv r||_        | j                  j                  t         vrNd|_        d|_        |j'                  | j(                        |_        | j                  j-                  |      |_        |j1                  ||      }|j2                  d   j4                  }|||<   d	|z   |j                  | j                  <   y
)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   reprr2   fontMappingPDFType1FontNamer   rI   BaseFontr   __Comment__r   r   r   r   r]   	FirstCharLastCharr   r   Widths
addObjectsFontDescriptor	Reference
idToObjectdict)ra   docr   internalNamepdfFontry   reffontDicts           r   r
  zFont.addObjects  s   
 	- T#coo"6q"899%%'#99>>'$--7MM'')Qx1 ]] G yy~~. !G"G#__T[[9GN%)YY%9%9#%>G"mmG\2 >>,/44!( *-|);&r   r   r   )r   r   r   r   
_multiByte_dynamicFontrb   r   r   r   r   r
  r   r   r   r   r   Q  s4     JL
HJE(	 <r   r      r!      r)   c                    t        ||          t        k7  st        || dz            |k7  r3t        d|t        t              t        |      | ||    || dz      fz        |t        k(  ry | dz   } || dz      dz  || dz      dz  z  || dz      z  dz  ||    z  }| dz   } | |z   t        |      kD  rt        d|| |t        |      fz        | | |z   fS )Nr!   zGBad pfb file'%s' expected chr(%d)chr(%d) at char %d, got chr(%d)chr(%d)r  r)         z1Bad pfb file'%s' needed %d+%d bytes have only %d!)chr
PFB_MARKERr4   ordPFB_EOFr2   )pdmr   r?   s        r   	_pfbCheckr#    s7   
1Q4y*AacFQdhjknoykz{~  @A  |B  CD  EF  GH  EI  JK  LM  NO  LO  JP  hQ  Q  R  	R'z6	AAqsVaK!AaC&1$q1v
.	2QqT:A	AAs3q6zNRTUVWXY\]^Y_Q``aaac6Mr   c                   .    e Zd ZdZd Zd Zd Zd Zd Zy)EmbeddedType1FacezcA Type 1 font other than one of the basic 14.

    Its glyph data will be embedded in the PDF file.c                 R   t         j                  | d        t        |t              }t        |t              }t        j
                  j                  |      | _        t        j
                  j                  |      | _        d | _	        | j                  |       | j                  |       y r   )rO   rb   r
   r   rq   rr   abspathr;   rm   r\   _loadGlyphs_loadMetrics)ra   r;   rm   s      r   rb   zEmbeddedType1Face.__init__  sz    $% "+l;!+l;77??;777??;7 $%+&r   c                 2    | j                   | j                  gS r   )r;   rm   rj   s    r   rk   zEmbeddedType1Face.getFontFiles  s      $"2"233r   c                    t        |      }t        |      s
J d|z         t        |d      }t        d|t        |      \  }}t        ||t
        |      \  }}t        ||t        |      \  }}t        ||t        |       ||| ||| z   ||| z   | _        t        | j                        | _	        ||z
  | _
        ||z
  | _        ||z
  | _        y)ziLoads 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_BINARYr  _binaryDatar2   _length_length1_length2_length3)	ra   rm   r!  s1l1s2l2s3l3s	            r   r(  zEmbeddedType1Face._loadGlyphs  s     .k:%H':['HH%+s+1Qy5B2a
;7B2a	+6B"Qw{+R8AbH,Qr"X54++,222r   c                    t        |      }t        |      \  }}|d   | _        |d   | _        |j	                  dd      | _        |j	                  dd      | _        |j	                  dd      | _        |j	                  dd      | _        |j	                  d	d      | _	        |j	                  d
d      | _
        |j	                  dg d      }|j                         }g | _        |D ]&  }| j                  j                  t        |             ( i }|D ]  \  }}	}
|	||
<    || _        t!        |j#                               | _        | j$                  j'                          |j	                  dd      dk(  rt(        
	 ddlm} |a~dgdz  }i }i }|D ]=  \  }}	}
d|cxk  rdk  sn |
||<   t(        j	                  |
d      }|4|||<   |||<   ? t1        j2                  d| j                  z        }t4        j6                  j9                  |||       || _        t=        ||      }t?        |       yy#  i at/        d      xY w)z Loads in and parses font metricsr   
FamilyNameAscender  	Descenderr   	CapHeightItalicAnglestemVXHeightFontBBox)r   r   r<  r<  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   rM   rI   rY   getrW   rX   	capHeightitalicAngler@  xHeightr3   bboxr:   r8   rV   rf   rg   rU   sort_postScriptNames2Unicodereportlab.pdfbase._glyphlistrE  r4   r   normalize_encodingr   	RL_Codecsadd_dynamic_codecr\   r   registerEncoding)ra   r;   r=   	glyphDatastrBboxtokenstokrV   rG   rH   rI   rE  namesexrexcodeur   encs                      r   r)  zEmbeddedType1Face._loadMetrics  sJ    .k: ,[ 99Z(	"<0ll:t4||K3!k48#<<q9\\'1-
||It4,,z?;	 	'CIISX&	' "+ 	&S% %K	&&{//12 <<($/>A'/
O/A,* FSLEBC'0 %#udd<C<"&E$K044T$?A}$%D	 $1%  223Kdii3WXG11'"SA$+D!7E*CS!; B/1,$L s   ;	H3 3Ic                 |   ddl m} |j                         }| j                  |_        | j
                  |j                  d<   | j                  |j                  d<   | j                  |j                  d<   |j                  |d| j                  z         }|j                  d| j                  | j                  | j                  d|j                  | j                         |j#                  | j$                        | j&                  | j(                  | j*                  |d	      }|j                  |d
| j$                  z         }|S )zFAdd whatever needed to PDF file, and return a FontDescriptor referencer   r   Length1Length2Length3z	fontFile:z/FontDescriptor"   )r   Ascentr>  DescentFlagsrB  r   r?  StemVrA  FontFilezfontDescriptor:)r   r   	PDFStreamr.  contentr0  
dictionaryr1  r2  r  rm   r   rW   rG  rX   r   rJ  r   rI   rH  r@  rI  )ra   r  r   fontFilefontFileReffontDescriptorfontDescriptorRefs          r   r
  zEmbeddedType1Face.addObjects$  s   ,##%++)-I&)-I&)-I& mmHkD<L<L.LM--%[[lltyy1~~dii0**JJll#/   MM.:Kdii:WX  r   N)	r   r   r   r   rb   rk   r(  r)  r
  r   r   r   r%  r%    s!    8'4$;"z!r   r%  c                     t        | t              s
J d| z         | t        | j                  <   | j                  t        vrt        | j                         y y )NzNot a TypeFace: %s)r   rO   
_typefacesrI   r]   registerFontFamily)r   s    r   registerTypeFacerp  B  sJ    dH%B';d'BB% Jtyy99% 	499% &r   c                 8   t        | t              s
J d| z         | j                  t        v rK| j	                  t        | j                           r| j                          y t        d| j                  z        | t        | j                  <   | j                          y )NzNot an Encoding: %sz>Encoding "%s" already registered with a different name vector!)r   r   rI   
_encodingsr   r   r   )r[  s    r   rQ  rQ  J  sv    c8$A&;c&AA$
xx:;;z#((+,JJL\_b_g_gghh"
388

r   c                     ddl m} |s| }| j                         } |s
|xs |xs |}|s|}|s|}|j                  | dd|       |j                  | dd|       |j                  | dd|       |j                  | dd|       y )Nr   )fontsr!   )reportlab.librt  r6   
addMapping)familynormalrZ   r[   
boldItalicrt  s         r   ro  ro  W  s    #F6\\^FF$<d$<fzF6	VQ6*	VQ4(	VQ6*	VQ:.r   c                 b   | j                   }| j                  rl| j                  j                  }|t        vrW|t
        v r3t
        |   }|j                  st        d|d| d|      |t        |<   n| xt
        |<   t        |<   n	| t        |<   | j                  rt        | j                          yy)zGRegisters a font, including setting up info for accelerated stringWidthzAttempt to register fonts r0   z
 for face N)	r   r  r   rI   _fonts_dynFaceNamesr4   r  ro  )fontr   r   ofonts       r   registerFontr  c  s     }}H99>>6!=(%h/))$V[]ack%lmm',F8$=AAh'&*:x 	4==)	 r   c                    	 t         |    S # t        $ r | t        v r@t        |       }t        j
                  |    \  |_        |_        |_        t        |       |cY S t        |       }|ridD ]4  }t        j                  j                  |      d   |z   }t        |      s4 n t              s
J d|z         t        ||      }t        |       |cY S  w xY w)z-Lazily construct known typefaces if not found)rn   z.PFBr   zfile %s not found!)rn  r   r]   rO   r   standardFontAttributesrY   rZ   r[   rp  ru   rq   rr   rs   r   r%  )r   r   rz   ry   r{   s        r   r   r   {  s    (## }$H%D8A8X8XYa8b5T_diT" K )2C) -A''**3/2Q6C ~u- !~A';c'AA~(c2 &+s    ACAC1CCc                 v    	 t         |    S # t        $ r$ | t        v rt        |       }t	        |       |cY S  w xY w)z-Lazily construct known encodings if not found)rr  r   r   r   rQ  )r   r[  s     r   r   r     sD    	'"" ''7#CS!Js    )88c                     t        |       } t        |       t         u sJ dt        |       z         t        |       }|j                  rt        | | |j                        }nt        | | t              }t        |       |S )z-search for and register a font given its namez$fontName=%s is not required type str)rd   typeasciir   r\   r   r   r  )r   r   r}  s      r   findFontAndRegisterr    sq    8}H>S Z"H5QY?"ZZ  x DHh(=(=>Hh8Kr   c                 J    	 t         |    S # t        $ r t        |       cY S w xY w)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    ""rQ   rS   c                     t        |       }	 |j                  }|j                  }|r|dz  }||z  ||z  fS ||fS #  |j                  j                  }|j                  j                  }Y ExY w)Ng     @@)r  rW   rX   r   )r   fontSizer}  rW   rX   norms         r   getAscentDescentr    ss    8D$,, ~d{GDL((w$!!))##s	   : .A*c                      t        | |      d   S )Nr   r  r   r  s     r   	getAscentr        HX.q11r   c                      t        | |      d   S r   r  r  s     r   
getDescentr    r  r   c                  `    t        t        j                               } | j                          | S )zReturns what's in there)rf   r{  rg   rK  )regs    r   getRegisteredFontNamesr    s     
v{{}
CHHJJr   c                 <    t        |      j                  | ||      S )zjCompute 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((x((KKr   c            
      v   t        d       t        t        j                               } | j	                          | D ]  }t        d|        t                t        d       t        t
        j                               }|j	                          |D ]  }t        d|        t                t        d       t        t        j                               }|j	                          |D ]R  }t        |   }t        d|j                  d|j                  j                  d|j                  j                  d       T y )	NzRegistered Encodings:z   zRegistered Typefaces:zRegistered Fonts:z    z (r   ))r   rf   rr  rg   rK  rn  r{  r   r   rI   r   )rg   r   facesr   kkeyr}  s          r   dumpFontDatar    s    	
!"
!"DIIK eG 
G	
!""#E	JJL eH 
G	
V[[]AFFH Vc{$--ASASTUVr   c                    dd l }t        dd D ]  }|j                         }t        |      j                  }| D ]  }d}|D ]  }||t	        |         z   }  |j                         }t        d||z
  z         |j                         }| D ]  }t        |      j                  |d      }	 |j                         }t        d||z
  z         t                 y )Nr   r!   zslow stringWidth took %0.4f
   z'class lookup and stringWidth took %0.4f)timer]   r  r   r  r   r   )
textsr  r   t0r   r   r6  cht1r8  s
             r   test3widthsr    s    !!A&  YY[H$$ 	%DB %!CG*_%	% YY[+rBw78YY[ 	9D"..tR8B	9YY[727CD+r   c                  >   t        d      j                         } t        dt        |       z         t        d       t	        | g       t                | j                         }t        dt        |      dt        |       z  t        |      z  fz         t	        |       y )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   r2   r  r3   )rawdatawordss     r   testStringWidthAlgorithmsr    s    BCHHJG	
G
,-	
#$		GMMOE	
Cs5zSVWZ[bWcScdghmdnSnFo
opr   c                      t        d      } t        |        t        | j                  dd        t        d      }t        |j                         t        |       t	                y )N	Helveticar      Wombat)rO   rp  r   rU   r  )helvwombats     r   testr    sL    K DT	$//!B
 hF	&

VNr   )rn  rr  r{  r|  c                     | j                         D ]3  \  }}t               |   }|j                          |j                  |       5 t        j
                  j                          y r   )itemsglobalsclearupdater   rO  reset_dynamic_codecs)initial_dictsr  r   r!  s       r   _resetr  '  sS     ""$ !
)A,			 ,,.r   )register_reset__main__r   )NNNNr  )L__version__r   rq   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   rO  registerr]   r   rn  rr  r{  r|  	Exceptionr   r   rM   rO   r   ru   r   r   r   r  r  r,  r-  r  r#  rL  r%  rp  rQ  ro  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   