
    kft                        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j                                         ej        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&d7d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  Z5d8d!Z6d" Z7d# Z8d$ Z9d% Z:d& Z; e;d'          Z<e*=                     e;d(          e<g           d7d)Z>d7d*Z?d7d+Z@d, ZAd9d.ZBd/ ZCd0 ZDd1 ZEd2 ZF eGeH                                eH                                e H                                e!H                                3          fd4ZIdd5lmJZJ  eJeI           [JeKd6k    r eF              eE             dS dS ):z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dS )	FontErrorN__name__
__module____qualname__     \/var/www/html/nettyfy-visnx/env/lib/python3.11/site-packages/reportlab/pdfbase/pdfmetrics.pyr   r   '           Dr   r   c                       e Zd ZdS )FontNotFoundErrorNr   r   r   r   r   r   )   r   r   r   c           	         t          | d          }t          |          dk    rB|r|d                             d          }t          |          dk    rt          d| z            i }g }d |D             }d |D             }d}|D ].}|dd         d	k    rd}|dd
         dk    rd}%|r|                    d          }d |D             }|dd         \  }}}	|                                \  }
}|
dk    sJ d|z              t	          |          }|                                \  }
}|
dk    sJ d|z              	 t	          |          }n# t          $ r t          |          }Y nw xY w|	                                \  }
}|
dk    sJ d|z              |}|                    |||f           0d}|D ]}|dd         dk    rd}|dd         d	k    rd}#|rb|dd         dk    r	 	 |                    dd          \  }}n#  t          d| d|d          xY w	 t	          |          }n#  Y nxY w|||<   ||fS )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 datac                 6    g | ]}|                                 S r   strip.0ls     r   
<listcomp>z parseAFMFile.<locals>.<listcomp>=   s     &&&1QWWYY&&&r   c                 `    g | ]+}|                                                     d           )|,S )comment)lower
startswithr&   s     r   r)   z parseAFMFile.<locals>.<listcomp>>   s3    EEE1QWWYY%9%9)%D%DEQEEEr      StartCharMetrics   EndCharMetrics;c                 6    g | ]}|                                 S r   r$   )r'   chunks     r   r)   z parseAFMFile.<locals>.<listcomp>H   s     888ekkmm888r      Czbad line in font file %sWXNStartFontMetrics   Comment z Header information error in afm z: line='')r	   lensplit
ValueErrorintfloatappend)afmFileNamelinestopLevel
glyphLevel	inMetricslinechunkscidChunk
widthChunk	nameChunkr(   r    cidwidthnameinHeaderleftrights                     r   parseAFMFilerT   ,   s    {C00E
5zz1}}.%(....%u::q==>LMMMHJ&&&&&EEEEEEEI 2 2":+++II!B$Z+++II 	2ZZ__F88888F.4QqSk+Hj) >>##DAq8887$>888a&&C ##%%DAq99984?999!A ! ! !a! ??$$DAq8887$>888DsE40111 H # #":+++H":+++HH 
	#AaCyI%%th"jjQ//eeh jT_T_T_aeaeae!fgggE

"HTN j!!s*   EE-,E-/H		H!%H55H9c                   (    e Zd Zd Zd Zd ZddZdS )TypeFacec                    || _         g | _        i | _        d| _        d| _        d | _        d| _        d| _        |dk    rd| _        n|dk    rd| _        nd | _        |t          v rd| _
        |                     |           d S d| _
        d S )Nr   ZapfDingbatsZapfDingbatsEncodingSymbolSymbolEncodingr!   )rP   
glyphNamesglyphWidthsascentdescent
familyNamebolditalicrequiredEncodingstandardFontsbuiltIn_loadBuiltInDataselfrP   s     r   __init__zTypeFace.__init__v   s    	
 	>!!$:D!!X$4D!!$(D!=  DL!!$'''''DLLLr   c                     t          |          }t          j        |         | _        t	          | j                                                  | _        t          j        |         \  | _        | _	        dS )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   widthsByFontGlyphr]   listkeysr\   ascent_descentr^   r_   rg   s     r   rf   zTypeFace._loadBuiltInData   sW     4yy$6t<t/446677#,#;D#A DLLLr   c                     g S )z=Info function, return list of the font files this depends on.r   rh   s    r   getFontFileszTypeFace.getFontFiles   s    	r   .pfbc                    |                                 |                                f}t          | d          rHt          j                            | j                  d         }|D ]}t          ||z             r||z   c S 	 t          j	        | j
                  }n#  t          | j
                  }|ru|                                 dk    rB|D ]>}t          j                            |          d         |z   }t          |          r|}<d }?n|                                 dk    r|}nd }Y nxY w|t          d|d| j
        d           |S )NpfbFileNamer   rs   z.afmzCan't find z for face 'r=   )r,   upperhasattrospathsplitextru   r   r   
findT1FilerP   bruteForceSearchForAFMr   )rh   extpossible_exts
r_basenameer    afmpfbs           r   r{   zTypeFace.findT1File   si   ciikk24&& 	*))$*:;;A>J" * *Z!^,, *%>)))*	$TY//AA	(33C 99;;&((* % % g..s33A6:$S>> % #AA $AA% YY[[F**A9Hccc4999EFFFs   B BD-N)rs   )r   r   r   ri   rf   rr   r{   r   r   r   rV   rV   u   sX          4B B B       r   rV   c                    |ddl m} t          |           r| S t          j                            |           }|D ]E}t          |          st          j                            ||          }t          |          r|c S F| S )Nr   r   )reportlab.rl_configr   r   rx   ry   basenamer   join)fn
searchPathbfndirnametfns        r   bruteForceSearchForFiler      s    UUUUUU}}Ri
'

2

C & &  *(gll73''S>>%#:::%Ir   c           	      z   ddl m} |D ]}t          |          st          |t          j        z   dz             }|D ]}}	 t          |          \  }}|d         | k    r|c c S (#  t          j                    \  }}}	d	                    t          t          |j                            d| z  z   f|_         xY wdS )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]FontNamer<   z, while looking for faceName=%rN)r   r   r   r   rx   seprT   sysexc_infor   maprk   args)
faceNamer   r   	possiblespossibletopDict	glyphDicttvbs
             r   r|   r|      s     100000    *(Gbf,/??@@	! 	 	H%1(%;%;":&(22#OOOOO 3lnn!A((3s16??334UX`4``b	 s   A$$AB7c                   D    e Zd ZdZddZd Zd Zd Zd Zd Z	d	 Z
d
 ZdS )Encodingz1Object to help you create and refer to encodings.Nc                 2   || _         d| _        |t          v r,|
J d            || _        t          j        |         | _        d S |d k    r*t          | _        t          j        t                   | _        d S t          |          r1t          |          }|j         | _        |j        d d          | _        d S t          |          rt          | _        |d d          | _        d S t          |t                    r"|j         | _        |j        d d          | _        d S d S )Nr   z2Can't have a base encoding for a standard encoding)rP   frozenstandardEncodingsbaseEncodingNamer   	encodingsvectorr   r   getEncodingr   
isinstancer   )rh   rP   basebaseEncs       r   ri   zEncoding.__init__   s
   	$$$<<!U<<<$(D!#-d3DKKKT\\$3D!#-o>DKKK4[[ 
	)!$''G$+LD!!.+DKKK4[[ 	)$3D!qqq'DKKKh'' 	)$(ID!+aaa.DKKK	) 	)r   c                     | j         |         S )z.Return glyph name for that code point, or None)r   )rh   indexs     r   __getitem__zEncoding.__getitem__   s     {5!!r   c                     | j         dk    s
J d            | j        |         |k    r/t          | j                  }|||<   t          |          | _        d S d S )Nr   Cannot modify a frozen encoding)r   r   rm   tuple)rh   r   valueLs       r   __setitem__zEncoding.__setitem__   sa    {a!B;uu$$T[!!AAeH((DKKK %$r   c                 F    t          | j                  | _        d| _        d S Nr!   )r   r   r   rq   s    r   freezezEncoding.freeze   s    DK((r   c                 v    | j         |j         k    o)t          | j                  t          |j                  k    S N)rP   r   r   )rh   others     r   isEqualzEncoding.isEqual  s/    y%*$Pt{););U5<=P=P)PPr   c                 \    | j         dk    s
J d            |}|D ]}|| j        |<   |dz   }dS )zASet a group of character names starting at the code point 'base'.r   r   r!   N)r   r   )rh   r   newNamesidxrP   s        r   modifyRangezEncoding.modifyRange  sS    {a!B 	 	D#DK'CC	 	r   c                 0   g }d}t          t          | j                            D ]X}| j        |         }||j        |         k    r|r|                    |           g }:|r|                    |           R|r||g}Y|r|                    |           |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)ranger>   r   rC   )rh   otherEncrangescurRangeiglyphs         r   getDifferenceszEncoding.getDifferences  s     s4;''(( 
	* 
	*AKNEhoa((( "MM(+++!H *OOE**** * !5zH 	$MM(###r   c                    ddl m} i }| j        }t          |          }|                     |          }|g k    r|                    |          S g }|D ]D}|                    |d                    |dd         D ]}||                    d|z              E|                    |          |d<   |dv r|                    |          |d<   |                    d	          |d
<   |                    |          }	|	S )z&Returns a PDF Object representing selfr   pdfdocr!   N/Differences)MacRomanEncodingMacExpertEncodingWinAnsiEncodingBaseEncodingr   Type)	reportlab.pdfbaser   r   r   r   PDFNamerC   PDFArrayPDFDictionary)
rh   r   Dr   r   differences	diffArrayr   	glyphNamePDs
             r   makePDFObjectzEncoding.makePDFObject,  s6    	-,,,,,0.//))'22 ">>"2333 I$ : :  q***!&qrr : :I ,!((y999:  &y99Am#]]]$*NN3C$D$D.!z22AfI%%a((BIr   r   )r   r   r   __doc__ri   r   r   r   r   r   r   r   r   r   r   r   r      s        ;;) ) ) )." " "
# # #  Q Q Q    <    r   r   c                   B    e Zd ZdZdZdZddZddZd Zd Z	d	 Z
d
 ZdS )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|pg | _	        | 
                                 t          | _        |dk    r| pt          | _        d S )NrX   )fontNamegetTypeFacefacer   encodingencNamere   rc   standardT1SubstitutionFontssubstitutionFonts_calcWidths_notdefChar_notdefFont)rh   rP   r   r   r   r   s         r   ri   zFont.__init__]  s    &x000ty"7++'+|#A8<8M8U #>"=):)@b 	 	&/8DGKr   utf8c                 (    t          | |||          S )Nr   )r   )rh   textsizer   s       r   stringWidthzFont.stringWidthi  s    $T4IIIIr   c                 <    d| j         j        d| j        j        dS )N<r<   >)	__class__r   r   rP   rq   s    r   __repr__zFont.__repr__l  s"      N333TY^^^DDr   c           	      *   dgdz  }| j         j        }| j        j        }t	          d          D ]]}||         }|Q	 ||         }|||<   # t
          $ r5 ddl}|j        j        r!t          d| j         j
        d|d           n	 Y Yw xY w^|| _        dS )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printrP   widths)rh   wgwvecr   r   rO   	reportlabs           r   r   zFont._calcWidthso  s     C#IY"m"s 	 	AAI$yME AaDD   .... *B W[W`WeWeWegpgpgpqrrrr	 % s   A		<BBc                     d}t          d          D ]I}|dz   t          t          | j        |                   d          z   }|dk    r|dz   }|dz  dk    r|d	z   }J|S )
z<returns a pretty block in PDF Array format to aid inspection   [r       r      s    ]r.         
)r   bytesrk   r   )rh   r   r   s      r   _formatWidthszFont._formatWidths  sp    s 	$ 	$A$;s4;q>':':6!B!BBDCxxe|2v||e|r   c                 x   ddl m} dt          t          |j                  dz             z   }|                                }||_        | j        j        |_	        d| j
        z  |_        | j                                        }t          |          r|dv r||_        | j        j        t           vrLd|_        d|_        |                    | j                  |_        | j                            |          |_        |                    ||          }|j        d         j        }|||<   d	|z   |j        | j
        <   d
S )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   reprr>   fontMappingPDFType1FontNamer   rP   BaseFontr   __Comment__r   r   r   r   rd   	FirstCharLastCharr   r   Widths
addObjectsFontDescriptor	Reference
idToObjectdict)rh   docr   internalNamepdfFontr   reffontDicts           r   r  zFont.addObjects  s7   
 	-,,,,, T#co"6"6q"8999%%''#9>'$-7M''))Qxx 	!1 ]]] G y~.. !G"G#__T[99GN%)Y%9%9#%>%>G"mmG\22 >,/4!( *-|);&&&r   r   r   )r   r   r   r   
_multiByte_dynamicFontri   r   r   r   r  r  r   r   r   r   r   Q  s          JL
H 
H 
H 
HJ J J JE E E  (	 	 	 <  <  <  <  <r   r      r!      r5   c                    t          ||                    t          k    st          || dz                      |k    rFt          d|t          t                    t          |          | ||          || dz            fz            |t          k    rd S | dz   } || dz            dz  || dz            dz  z  || dz            z  dz  ||          z  }| dz   } | |z   t          |          k    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  r5         z1Bad pfb file'%s' needed %d+%d bytes have only %d!)chr
PFB_MARKERr@   ordPFB_EOFr>   )pdmr   r(   s        r   	_pfbCheckr*    s^   
1Q4yy*AacFQdhjknoykzkz{~  @A  |B  |B  CD  EF  GH  EI  JK  LM  NO  LO  JP  hQ  Q  R  R  	R'zz66	AAqsVaK!AaC&1$q1v
.	2QqT:A	AAs3q66zzNRTUVWXY\]^Y_Y_Q``aaaac6Mr   c                   0    e Zd ZdZd Zd Zd Zd Zd ZdS )EmbeddedType1FacezcA Type 1 font other than one of the basic 14.

    Its glyph data will be embedded in the PDF file.c                    t                               | d            t          |t                    }t          |t                    }t          j                            |          | _        t          j                            |          | _        d | _	        | 
                    |           |                     |           d S r   )rV   ri   r
   r   rx   ry   abspathrD   ru   rc   _loadGlyphs_loadMetrics)rh   rD   ru   s      r   ri   zEmbeddedType1Face.__init__  s    $%%% "+l;;!+l;;7??;777??;77 $%%%+&&&&&r   c                     | j         | j        gS r   )rD   ru   rq   s    r   rr   zEmbeddedType1Face.getFontFiles  s     $"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
  | _        dS )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&  _binaryDatar>   _length_length1_length2_length3)	rh   ru   r(  s1l1s2l2s3l3s	            r   r/  zEmbeddedType1Face._loadGlyphs  s     .k::%%HH':['HHHH+s++1Qy55B2a
;77B2a	+66B"Qw{+++RU8AbeH,Qr"uX54+,,222r   c                    t          |          }t          |          \  }}|d         | _        |d         | _        |                    dd          | _        |                    dd          | _        |                    dd          | _        |                    dd          | _        |                    d	d          | _	        |                    d
d          | _
        |                    dg d          }|                                }g | _        |D ])}| j                            t          |                     *i }|D ]\  }}	}
|	||
<   || _        t!          |                                          | _        | j                                         |                    dd          dk    rt(          !	 ddlm} |a~n#  i at/          d          xY wdgdz  }i }i }|D ]B\  }}	}
d|cxk    rdk    r/n |
||<   t(                              |
d          }|
|||<   |||<   Ct1          j        d| j        z            }t4          j                            |||           || _        t=          ||          }t?          |           dS dS )z Loads in and parses font metricsr   
FamilyNameAscender  	Descenderr   	CapHeightItalicAnglestemVXHeightFontBBox)r   r   rC  rC  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   rT   rP   r`   getr^   r_   	capHeightitalicAnglerG  xHeightr?   bboxrC   rA   r]   rm   rn   r\   sort_postScriptNames2Unicodereportlab.pdfbase._glyphlistrL  r@   r   normalize_encodingr   	RL_Codecsadd_dynamic_codecrc   r   registerEncoding)rh   rD   rF   	glyphDatastrBboxtokenstokr]   rN   rO   rP   rL  namesexrexcodeur   encs                      r   r0  zEmbeddedType1Face._loadMetrics  s    .k:: ,[ 9 99Z(	"<0ll:t44||K33!k488#<<q99\\'1--
||It44,,z???;;	 	' 	'CISXX&&&&"+ 	& 	&S% %K&{//1122 <<($//>AA'/
OOOOOO/A,**/1,$L   FSLEBC'0 % %#udd<<<<C<<<<<"&E$K044T$??A}$%D	 $123Kdi3WXXG11'"SAAA$+D!7E**CS!!!!!; BAs   5	F? ?Gc                    ddl m} |                                }| j        |_        | j        |j        d<   | j        |j        d<   | j        |j        d<   |	                    |d| j
        z             }|                    d| j        | j        | j        d|                    | j                  |                    | j                  | j        | j        | j        |d	          }|	                    |d
| j        z             }|S )zFAdd whatever needed to PDF file, and return a FontDescriptor referencer   r   Length1Length2Length3z	fontFile:z/FontDescriptor"   )r   AscentrE  DescentFlagsrI  r   rF  StemVrH  FontFilezfontDescriptor:)r   r   	PDFStreamr5  contentr7  
dictionaryr8  r9  r  ru   r   r^   rN  r_   r   rQ  r   rP   rO  rG  rP  )rh   r  r   fontFilefontFileReffontDescriptorfontDescriptorRefs          r   r  zEmbeddedType1Face.addObjects$  s   ,,,,,,##%%+)-I&)-I&)-I& mmHkD<L.LMM--%[lty11~~di00*Jl#/ /    MM.:Kdi:WXX  r   N)	r   r   r   r   ri   rr   r/  r0  r  r   r   r   r,  r,    sj        8 8' ' '4 4 4  $;" ;" ;"z! ! ! ! !r   r,  c                     t          | t                    sJ d| z              | t          | j        <   | j        t          vrt          | j                   d S d S )NzNot a TypeFace: %s)r   rV   
_typefacesrP   rd   registerFontFamily)r   s    r   registerTypeFacerw  B  s_    dH%%BB';d'BBBB Jty9%% 	49%%%%% &%r   c                 P   t          | t                    sJ d| z              | j        t          v rR|                     t          | j                           r|                                  d S t          d| j        z            | t          | j        <   |                                  d S )NzNot an Encoding: %sz>Encoding "%s" already registered with a different name vector!)r   r   rP   
_encodingsr   r   r   )rb  s    r   rX  rX  J  s    c8$$AA&;c&AAAA
x:;;z#(+,, 	iJJLLLLL\_b_gghhh"
38

r   c                 "   ddl m} |s| }|                                 } |s|p|p|}|s|}|s|}|                    | dd|           |                    | dd|           |                    | dd|           |                    | dd|           d S )Nr   )fontsr!   )reportlab.libr{  r,   
addMapping)familynormalra   rb   
boldItalicr{  s         r   rv  rv  W  s    ######"F6\\^^F<F$<d$<fz"F6	VQ6***	VQ4(((	VQ6***	VQ:.....r   c                 D   | j         }| j        rj| j        j        }|t          vrT|t
          v r7t
          |         }|j        st          d|d| d|          |t          |<   n| xt
          |<   t          |<   n
| t          |<   | j        rt          | j                    dS dS )zGRegisters a font, including setting up info for accelerated stringWidthzAttempt to register fonts r<   z
 for face N)	r   r  r   rP   _fonts_dynFaceNamesr@   r  rv  )fontr   r   ofonts       r   registerFontr  c  s     }H  9>6!!=((%h/) -$*V[V[V[]a]a]ackck%lmmm',F8$$=AAh'&*:x * 	4=)))))	* *r   c                    	 t           |          S # t          $ r | t          v rGt          |           }t          j        |          \  |_        |_        |_        t          |           |cY S t          |           }|r}dD ];}t          j                            |          d         |z   }t          |          r n<t          |          sJ d|z              t          ||          }t          |           |cY S  w xY w)z-Lazily construct known typefaces if not found)rs   z.PFBr   zfile %s not found!)ru  r   rd   rV   r   standardFontAttributesr`   ra   rb   rw  r|   rx   ry   rz   r   r,  )r   r   r   r   r   s        r   r   r   {  s   (##   }$$H%%D8A8XYa8b5T_diT""" KKK )22C 	) - -A'**3//2Q6C ~~,uu, ~~AA';c'AAAA(c22 &&&+s    AC9)BC97C9c                     	 t           |          S # t          $ r- | t          v r"t          |           }t	          |           |cY S  w xY w)z-Lazily construct known encodings if not found)ry  r   r   r   rX  )r   rb  s     r   r   r     s`    	'""   '''7##CS!!!JJJs    3AA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)rk   typeasciir   rc   r   r   r  )r   r   r  s      r   findFontAndRegisterr    s    8}}H>>S   "H5QY??"Z    x  D 9Hh(=>>Hh88Kr   c                 \    	 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    sA    -h - - -"8,,,,,-s    ++rX   rZ   c                     t          |           }	 |j        }|j        }n#  |j        j        }|j        j        }Y nxY w|r|dz  }||z  ||z  fS ||fS )Ng     @@)r  r^   r_   r   )r   fontSizer  r^   r_   norms         r   getAscentDescentr    ss    8D$,$!)# ~d{GDL((ws     <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                  z    t          t                                                    } |                                  | S )zReturns what's in there)rm   r  rn   rR  )regs    r   getRegisteredFontNamesr    s)    
v{{}}

CHHJJJJr   r   c                 L    t          |                              | ||          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KKr   c            
         t          d           t          t                                                    } |                                  | D ]}t          d|           t                       t          d           t          t
                                                    }|                                 |D ]}t          d|           t                       t          d           t          t                                                    }|                                 |D ]A}t          |         }t          d|j        d|j        j	        d|j
        j	        d           Bd S )	NzRegistered Encodings:z   zRegistered Typefaces:zRegistered Fonts:z    z (r   ))r   rm   ry  rn   rR  ru  r  r   r   rP   r   )rn   r   facesr   kkeyr  s          r   dumpFontDatar    sJ   	
!"""
!!""DIIKKK  eG	GGG	
!"""""##E	JJLLL  eH 
GGG	
V[[]]AFFHHH V Vc{$---ASASASTUUUUV Vr   c                    dd l }t          dd         D ]}|                                 }t          |          j        }| D ]!}d}|D ]}||t	          |                   z   }"|                                 }t          d||z
  z             |                                 }| D ]%}t          |                              |d          }	&|                                 }t          d||z
  z             t                       d S )Nr   r!   zslow stringWidth took %0.4f
   z'class lookup and stringWidth took %0.4f)timerd   r  r   r%  r   r   )
textsr  r   t0r   r   r=  cht1r?  s
             r   test3widthsr    s   KKK!!A#&   YY[[H$ 	% 	%DB % %!CGG*_%YY[[+rBw7888YY[[ 	9 	9D""..tR88BBYY[[727CDDD+ r   c                     t          d                                          } t          dt          |           z             t          d           t	          | g           t                       |                                 }t          dt          |          dt          |           z  t          |          z  fz             t	          |           d S )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   r>   r  r?   )rawdatawordss     r   testStringWidthAlgorithmsr    s    BCCHHJJG	
G
,---	
#$$$		GGGMMOOE	
Cs5zzSVWZ[bWcWcScdghmdndnSnFo
opppr   c                      t          d          } t          |            t          | j        dd                    t          d          }t          |j                   t          |           t	                       d S )N	Helveticar      Wombat)rV   rw  r   r\   r  )helvwombats     r   testr    so    K  DT	$/!B$
   hF	&
VNNNNNr   )ru  ry  r  r  c                     |                                  D ]B\  }}t                      |         }|                                 |                    |           Ct          j                                         d S r   )itemsglobalsclearupdater   rV  reset_dynamic_codecs)initial_dictsr  r   r(  s       r   _resetr  '  si     ""$$  !
))A,					,,.....r   )register_reset__main__r   )NNNNr  )L__version__r   rx   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   rV  registerrd   r   ru  ry  r  r  	Exceptionr   r   rT   rV   r   r|   r   r   r   r#  r$  r3  r4  r&  r*  rS  r,  rw  rX  rv  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 z z z z z z z z z z z z z z z z z = = = = = = = = D D D D D D D D ' ' ' ' ' ' 	      '/ 

		 	 	 	 		 	 	 		 	 	 	 		 	 	 	G" G" G"R@ @ @ @ @ @ @ @D     0q q q q q q q qn ! ]< ]< ]< ]< ]< ]< ]< ]<~ 3t99

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