403Webshell
Server IP : 93.86.61.54  /  Your IP : 216.73.216.60
Web Server : Apache/2.4.62 (Ubuntu)
System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64
User : www-data ( 33)
PHP Version : 8.4.22
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/reportlab/pdfbase/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/reportlab/pdfbase/__pycache__/pdfmetrics.cpython-310.pyc
o

Neb�t�@sbdZdZddlZddlZddlZddlmZddlmZddl	m
Z
mZmZm
Z
mZmZmZmZddlmZmZddlmZmZdd	lmZd
Zej��ejZejZiZiZiZ iZ!Gdd�de"�Z#Gd
d�de"�Z$dd�Z%Gdd�d�Z&dMdd�Z'dd�Z(Gdd�d�Z)gZ*Gdd�d�Z+e,d�Z-e,d�Z.e,d�Z/e,d�Z0dd �Z1da2Gd!d"�d"e&�Z3d#d$�Z4d%d&�Z5dNd'd(�Z6d)d*�Z7d+d,�Z8d-d.�Z9d/d0�Z:d1d2�Z;e;d3�Z<e*�=e;d4�e<g�dMd5d6�Z>dMd7d8�Z?dMd9d:�Z@d;d<�ZAdOd>d?�ZBd@dA�ZCdBdC�ZDdDdE�ZEdFdG�ZFeGe�H�e�H�e �H�e!�H�dH�fdIdJ�ZIddKlmJZJeJeI�[JeKdLk�r/eF�eE�dSdS)Pz3.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@�eZdZdS)�	FontErrorN��__name__�
__module__�__qualname__�rr�>/usr/lib/python3/dist-packages/reportlab/pdfbase/pdfmetrics.pyr'�rc@r)�FontNotFoundErrorNrrrrrr)rrc	Cst|d�}t|�dkr |r|d�d�}t|�dkr td|��i}g}dd�|D�}dd�|D�}d}|D]�}|dd	�d
krCd}q6|dd�dkrNd}q6|r�|�d
�}dd�|D�}|dd�\}}}	|��\}
}|
dksuJd|��t|�}|��\}
}|
dks�Jd|��zt|�}
Wn
ty�t|�}
Ynw|	��\}
}|
dks�Jd|��|}|�||
|f�q6d}|D]G}|dd	�dkr�d}|dd	�d
kr�d}q�|�r|dd�dkr�z
|�dd�\}}Wntd||f��zt|�}WnY|||<q�||fS)aQuick 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�
zAFM file %s hasn't enough datacS�g|]}|���qSr��strip��.0�lrrr�
<listcomp>=�z parseAFMFile.<locals>.<listcomp>cSsg|]}|���d�s|�qS)�comment)�lower�
startswithr"rrrr%>s��StartCharMetrics��EndCharMetrics�;cSrrr )r#�chunkrrrr%Hr&��Czbad line in font file %s�WX�N�StartFontMetrics��Comment� z-Header information error in afm %s: line='%s')r�len�split�
ValueError�int�float�append)�afmFileName�lines�topLevel�
glyphLevel�	inMetrics�line�chunks�cidChunk�
widthChunk�	nameChunkr$r�cid�width�name�inHeader�left�rightrrr�parseAFMFile,sj

���rNc@s.eZdZdd�Zdd�Zdd�Zddd	�Zd
S)�TypeFacecCs|||_g|_i|_d|_d|_d|_d|_d|_|dkr d|_n|dkr(d|_nd|_|t	vr9d|_
|�|�dSd|_
dS)Nr�ZapfDingbats�ZapfDingbatsEncoding�Symbol�SymbolEncodingr)rJ�
glyphNames�glyphWidths�ascent�descent�
familyName�bold�italic�requiredEncoding�
standardFonts�builtIn�_loadBuiltInData��selfrJrrr�__init__vs"
zTypeFace.__init__cCs:t|�}tj||_t|j���|_tj|\|_|_	dS)z�Called for the built in 14 fonts.  Gets their glyph data.
        We presume they never change so this can be a shared reference.N)
�strr�widthsByFontGlyphrU�list�keysrT�ascent_descentrVrWr_rrrr^�szTypeFace._loadBuiltInDatacCsgS)z=Info function, return list of the font files this depends on.r�r`rrr�getFontFiles�szTypeFace.getFontFiles�.pfbcCs�|��|��f}t|d�r'tj�|j�d}|D]}t||�r&||Sqzt�	|j
�}Wn5t|j
�}|rb|��dkrY|D]}tj�|�d|}t|�rU|}qBd}qBn|��dkra|}nd}Y|durrtd||j
f�|S)N�pfbFileNamerriz.afmzCan't find %s for face '%s')
r(�upper�hasattr�os�path�splitextrjrr�
findT1FilerJ�bruteForceSearchForAFMr)r`�ext�
possible_exts�
r_basename�er�afm�pfbrrrrp�s6
�
���zTypeFace.findT1FileN)ri)rrrrar^rhrprrrrrOus
rOcCsb|dur
ddlm}t|�r|Stj�|�}|D]}t|�sqtj�||�}t|�r.|Sq|S)Nr�r
)�reportlab.rl_configr
rrmrn�basenamer�join)�fn�
searchPath�bfn�dirname�tfnrrr�bruteForceSearchForFile�s
r�c

Cs�ddlm}|D]D}t|�sqt|tjd�}|D]1}zt|�\}}|d|kr0|WSWqt��\}}}	d�	t
t|j��d|f|_�qdS)zcLooks in all AFM files on path for face with given name.

    Returns AFM file name or None.  Ouch!rrxz*.[aA][fF][mM]�FontNamer7z, while looking for faceName=%rN)
ryr
rrrm�seprN�sys�exc_infor{�maprb�args)
�faceNamer
r�	possibles�possible�topDict�	glyphDict�t�v�brrrrq�s 
���rqc@sReZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�Encodingz1Object to help you create and refer to encodings.NcCs�||_d|_|tvr|dusJd��||_tj||_dS|dkr,t|_tjt|_dSt|�rBt	|�}|j|_|jdd�|_dSt
|�rRt|_|dd�|_dSt|t�re|j|_|jdd�|_dSdS)Nrz2Can't have a base encoding for a standard encoding)
rJ�frozen�standardEncodings�baseEncodingNamer�	encodings�vectorrr�getEncodingr
�
isinstancer�)r`rJ�base�baseEncrrrra�s(
�zEncoding.__init__cCs
|j|S)z.Return glyph name for that code point, or None)r�)r`�indexrrr�__getitem__�s
zEncoding.__getitem__cCsD|jdks	Jd��|j||kr t|j�}|||<t|�|_dSdS)Nr�Cannot modify a frozen encoding)r�r�rd�tuple)r`r��value�Lrrr�__setitem__�s
�zEncoding.__setitem__cCst|j�|_d|_dS�Nr)r�r�r�rgrrr�freeze�s
zEncoding.freezecCs |j|jkot|j�t|j�kS�N)rJr�r�)r`�otherrrr�isEquals zEncoding.isEqualcCs6|jdks	Jd��|}|D]}||j|<|d}q
dS)zASet a group of character names starting at the code point 'base'.rr�rN)r�r�)r`r��newNames�idxrJrrr�modifyRanges

�zEncoding.modifyRangecCsvg}d}tt|j��D]&}|j|}||j|kr#|r"|�|�g}q|r+|�|�q|r1||g}q|r9|�|�|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)�ranger8r�r=)r`�otherEnc�ranges�curRange�i�glyphrrr�getDifferencess"


��
zEncoding.getDifferencesc
Cs�ddlm}i}|j}t|�}|�|�}|gkr|�|�Sg}|D]}|�|d�|dd�D]
}|dur=|�d|�q0q!|�|�|d<|dvrQ|�|�|d<|�d	�|d
<|�|�}	|	S)z&Returns a PDF Object representing selfr��pdfdocrN�/�Differences)�MacRomanEncoding�MacExpertEncoding�WinAnsiEncoding�BaseEncodingr��Type)	�reportlab.pdfbaser�r�r�r��PDFNamer=�PDFArray�
PDFDictionary)
r`r��Dr�r��differences�	diffArrayr��	glyphName�PDrrr�
makePDFObject,s*

��
zEncoding.makePDFObjectr�)rrr�__doc__rar�r�r�r�r�r�r�rrrrr��s
r�c@sLeZdZdZdZdZddd�Zddd�Zd	d
�Zdd�Z	d
d�Z
dd�ZdS)�FontaDRepresents 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)rNcCsf||_t|�}|_t|�|_||_|jr|jdurtn|pg|_	|�
�t|_|dkr.|p/t|_dS)NrP)
�fontName�getTypeFace�facer��encoding�encNamer]r[�standardT1SubstitutionFonts�substitutionFonts�_calcWidths�_notdefChar�_notdefFont)r`rJr�r�r�r�rrrra]s
�
��z
Font.__init__�utf8cCst||||d�S)N�r�)r)r`�text�sizer�rrr�stringWidthiszFont.stringWidthcCsd|jj|jjfS)Nz<%s %s>)�	__class__rr�rJrgrrr�__repr__lsz
Font.__repr__c	Cs�dgd}|jj}|jj}td�D]2}||}|durCz
||}|||<WqtyBddl}|jjr?t	d|jj
|f�n	Yqwq||_dS)z)Vector of widths for stringWidth functionr�Nz3typeface "%s" does not have a glyph "%s", bad font!)r�rUr�r�r��KeyErrorry�	rl_config�warnOnMissingFontGlyphs�printrJ�widths)r`�w�gw�vecr�r�rI�	reportlabrrrr�os$
���

zFont._calcWidthscCsVd}td�D]"}|dtt|j|�d�}|dkr|d}|ddkr(|d	}q|S)
z<returns a pretty block in PDF Array format to aid inspection�[r�� r��s ]r*��
)r��bytesrbr�)r`r�r�rrr�
_formatWidths�s�zFont._formatWidthscCs�ddlm}dtt|j�d�}|��}||_|jj|_	d|j
|_|j�
�}t|�r0|dvr3||_|jjtvrMd|_d|_|�|j�|_|j�|�|_|�||�}|jdj}|||<d	||j|j
<d
S)z�Makes 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) rr��FrzFont %s)z/MacRomanEncodingz/MacExpertEncodingz/WinAnsiEncodingr��
BasicFontsr�N)r�r��reprr8�fontMapping�PDFType1Font�Namer�rJ�BaseFontr��__Comment__r�r�rr�r\�	FirstChar�LastCharr�r��Widths�
addObjects�FontDescriptor�	Reference�
idToObject�dict)r`�docr��internalName�pdfFontru�ref�fontDictrrrr��s$

zFont.addObjectsr��r�)rrrr��
_multiByte�_dynamicFontrar�r�r�r�r�rrrrr�Qs

r��r�r0c
Cs�t||�tkst||d�|kr(td|tt�t|�|||||df��|tkr.dS|d}||dd>||dd>B||dBd>||B}|d}||t|�krftd|||t|�f��|||fS)NrzGBad pfb file'%s' expected chr(%d)chr(%d) at char %d, got chr(%d)chr(%d)rr0��z1Bad pfb file'%s' needed %d+%d bytes have only %d!)�chr�
PFB_MARKERr:�ord�PFB_EOFr8)�p�d�mr|r$rrr�	_pfbCheck�s$,8r
c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�EmbeddedType1FacezcA Type 1 font other than one of the basic 14.

    Its glyph data will be embedded in the PDF file.cCsZt�|d�t|t�}t|t�}tj�|�|_tj�|�|_d|_	|�
|�|�|�dSr�)rOrar	r
rmrn�abspathr>rjr[�_loadGlyphs�_loadMetrics)r`r>rjrrrra�s


zEmbeddedType1Face.__init__cCs|j|jgSr�)r>rjrgrrrrh�szEmbeddedType1Face.getFontFilesc	Cs�t|�}t|�sJd|��t|d�}td|t|�\}}t||t|�\}}t||t|�\}}t||t|�|||�|||�|||�|_t|j�|_	|||_
|||_|||_dS)ziLoads in binary glyph data, and finds the four length
        measurements needed for the font descriptorzfile %s not foundr�rN)
r�rrr
�	PFB_ASCII�
PFB_BINARYr�_binaryDatar8�_length�_length1�_length2�_length3)	r`rjr�s1�l1�s2�l2�s3�l3rrrr
�s
&

zEmbeddedType1Face._loadGlyphscCs�t|�}t|�\}}|d|_|d|_|�dd�|_|�dd�|_|�dd�|_|�dd�|_|�d	d�|_	|�d
d�|_
|�dgd��}|��}g|_|D]
}|j�
t|��qOi}|D]	\}}	}
|	||
<q^||_t|���|_|j��|�d
d�dkr�tdur�zddlm}|a~Wn	iatd��dgd}i}
i}|D]'\}}	}
d|kr�dkr�nq�|
||<t�|
d�}|dur�|||<||
|<q�t�d|j�}tj�||
|�||_t||�}t|�dSdS)z Loads in and parses font metricsr��
FamilyName�Ascender���	Descenderr�	CapHeight�ItalicAngle�stemV�XHeight�FontBBox)rrrr�EncodingSchemeN�FontSpecific)�_glyphname2unicodez�cannot import module reportlab.pdfbase._glyphlist module
you can obtain a version from here
https://www.reportlab.com/ftp/_glyphlist.py
r�r�zrl-dynamic-%s-encoding) r�rNrJrX�getrVrW�	capHeight�italicAngler"�xHeightr9�bboxr=r;rUrdrerT�sort�_postScriptNames2Unicode�reportlab.pdfbase._glyphlistr'r:r��normalize_encodingr�	RL_Codecs�add_dynamic_codecr[r��registerEncoding)r`r>r@�	glyphData�strBbox�tokens�tokrUrHrIrJr'�names�ex�rex�code�ur��encrrrr�sb



�
�
�zEmbeddedType1Face._loadMetricscCs�ddlm}|��}|j|_|j|jd<|j|jd<|j|jd<|�	|d|j
�}|�d|j|j
|jd|�|j�|�|j�|j|j|j|d	��}|�	|d
|j�}|S)zFAdd whatever needed to PDF file, and return a FontDescriptor referencerr��Length1�Length2�Length3z	fontFile:z/FontDescriptor�")r��Ascentr �Descent�Flagsr$r�r!�StemVr#�FontFilezfontDescriptor:)r�r��	PDFStreamr�contentr�
dictionaryrrr�rjr�rVr)rWr�r,r�rJr*r"r+)r`r�r��fontFile�fontFileRef�fontDescriptor�fontDescriptorRefrrrr�$s,

�
zEmbeddedType1Face.addObjectsN)	rrrr�rarhr
rr�rrrrr�s
=rcCs<t|t�sJd|��|t|j<|jtvrt|j�dSdS)NzNot a TypeFace: %s)r�rO�
_typefacesrJr\�registerFontFamily)r�rrr�registerTypeFaceBs


�rPcCs`t|t�sJd|��|jtvr%|�t|j�r|��dStd|j��|t|j<|��dS)NzNot an Encoding: %sz>Encoding "%s" already registered with a different name vector!)r�r�rJ�
_encodingsr�r�r)r=rrrr3Js

r3cCs�ddlm}|s
|}|��}|s|p|p|}|s|}|s|}|�|dd|�|�|dd|�|�|dd|�|�|dd|�dS)Nr)�fontsr)�
reportlab.librRr(�
addMapping)�family�normalrYrZ�
boldItalicrRrrrrOWsrOcCs�|j}|jr0|jj}|tvr/|tvr't|}|js"td|||f��|t|<n
|t|<t|<n|t|<|jr>t|j�dSdS)zGRegisters a font, including setting up info for accelerated stringWidthz+Attempt to register fonts %r %r for face %rN)	r�r�r�rJ�_fonts�
_dynFaceNamesr:r�rO)�fontr�r��ofontrrr�registerFontcs
��r\cCs�zt|WStyZ|tvr't|�}tj|\|_|_|_t	|�|YSt
|�}|rYdD]}tj�
|�d|}t|�rAnq/t|�sLJd|��t||�}t	|�|YS�w)z-Lazily construct known typefaces if not found)riz.PFBrzfile %s not found!)rNr�r\rOr�standardFontAttributesrXrYrZrPrqrmrnrorr)r�r�rvrurwrrrr�{s&

�r�cCs<zt|WSty|tvrt|�}t|�|YS�w)z-Lazily construct known encodings if not found)rQr�r�r�r3)r�r=rrrr��s
�r�cCsZt|�}t|�tusJdt|���t|�}|jr!t|||j�}nt||t�}t|�|S)z-search for and register a font given its namez$fontName=%s is not required type str)rb�type�asciir�r[r�rr\)r�r�rZrrr�findFontAndRegister�sr`cCs&zt|WStyt|�YSw)z�Lazily 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.)rXr�r`)r�rrr�getFont�s

�rarPrRcCsVt|�}z|j}|j}Wn|jj}|jj}Y|r'|d}||||fS||fS)Ng@�@)rarVrWr�)r��fontSizerZrVrW�normrrr�getAscentDescent�s

rdcC�t||�dS)Nr�rd�r�rbrrr�	getAscent��rhcCrer�rfrgrrr�
getDescent�rirjcCstt���}|��|S)zReturns what's in there)rdrXrer-)�regrrr�getRegisteredFontNames�srlr�cCst|�j|||d�S)zjCompute width of string in points;
    not accelerated as fast enough because of instanceStringWidthT1/TTFr�)rar�)r�r�rbr�rrrr��sr�cCs�td�tt���}|��|D]}td|�qt�td�tt���}|��|D]}td|�q+t�td�tt���}|��|D]}t|}td|j|jj	|j
j	f�qFdS)NzRegistered Encodings:z   zRegistered Typefaces:zRegistered Fonts:z    %s (%s/%s))r�rdrQrer-rNrXr�r�rJr�)rer��facesr��k�keyrZrrr�dumpFontData�s&�rpc
Cs�ddl}tdd�D]K}|��}t|�j}|D]}d}|D]
}||t|�}qq|��}td||�|��}|D]
}t|��|d�}	q;|��}td||�t�q
dS)Nrrzslow stringWidth took %0.4f�
z'class lookup and stringWidth took %0.4f)�timer\rar�rr�r�)
�textsrrr��t0r�r�r�ch�t1rrrr�test3widths�s$
��rwcCsltd���}tdt|��td�t|g�t�|��}tdt|�dt|�t|�f�t|�dS)Nz-../../rlextra/rml2pdf/doc/rml_user_guide.prepzrawdata length %dztest one huge string...z7test %d shorter strings (average length %0.2f chars)...g�?)�open�readr�r8rwr9)�rawdata�wordsrrr�testStringWidthAlgorithmss
$r|cCsFtd�}t|�t|jdd��td�}t|j�t|�t�dS)N�	Helveticar��Wombat)rOrPr�rTrp)�helv�wombatrrr�tests

r�)rNrQrXrYcCs<|��D]\}}t�|}|��|�|�qtj��dSr�)�items�globals�clear�updaterr1�reset_dynamic_codecs)�
initial_dictsrnr�rrrr�_reset's

r�)�register_reset�__main__r�)NNNNr�)L�__version__r�rmr�r�r�r�reportlab.lib.loggerr�reportlab.lib.utilsrrrrrr	r
rryrr
�reportlab.lib.rl_accelrrrr�r1�registerr\r�rNrQrXrY�	ExceptionrrrNrOr�rqr�r�r�rrrrrr
r.rrPr3rOr\r�r�r`rar��extendrdrhrjrlr�rprwr|r�r��copyr�r�rrrrr�<module>s�(
I
B
w_







�
�

�

Youez - 2016 - github.com/yon3zu
LinuXploit