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__/cidfonts.cpython-310.pyc
o

Neb�I�@sPdZdZddlZddlZddlZzddlmZWney'ddlmZYnwddlm	Z	ddl
mZmZm
Z
mZmZddlmZddlmZdd	lmZdd
lmZddlmZmZdZd
d�Zdd�ZGdd�de	j�ZGdd�de	j�Z Gdd�de	j!�Z"Gdd�de"�Z#dd�Z$dd�Z%e&dkr�ddl'Z'ddlm(Z(e'�)e(�dSdS)z3.3.0z�CID (Asian multi-byte) font support.

This defines classes to represent CID fonts.  They know how to calculate
their own width and how to write themselves into PDF files.�N)�md5)�
pdfmetrics)�allowedTypeFaces�allowedEncodings�CIDFontInfo�defaultUnicodeEncodings�widthsByUnichar)�Canvas)�pdfdoc��	escapePDF)�CMapSearchPath)�isSeq�isBytesTcCs8tD]}|tj|}tj�|�r|Sqtd|��)z&Returns full filename, or raises errorz'CMAP file for encodings "%s" not found!)r
�os�sep�path�isfile�IOError)�name�dirname�cmapfile�r�</usr/lib/python3/dist-packages/reportlab/pdfbase/cidfonts.py�findCMapFile!s�rcCsht|t�ri}|��D]
\}}t|�||<qt�|�St|�r2g}|D]	}|�t|��q#t�|�S|S)zCConverts deeply nested structure to PDFdoc dictionary/array objects)	�
isinstance�dict�items�structToPDFr
�
PDFDictionaryr�append�PDFArray)�	structure�newDict�k�v�newList�elemrrrr*s


rc@sJeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�CIDEncodingz�Multi-byte encoding.  These are loaded from CMAP files.

    A CMAP file is like a mini-codec.  It defines the correspondence
    between code points in the (multi-byte) input data and Character
    IDs. �cCs�||_d|_g|_g|_i|_d|_tsV|rOddlm}|d�}t	j
�|t	j|d�r>|�
|�|t	j|d|_dS|�|�d||_|�|�dS|�|�dSdS)Nr)�get_rl_tempdir�	FastCMAPS�.fastmapzCMAP: )r�_mapFileHash�_codeSpaceRanges�
_notDefRanges�_cmap�source�DISABLE_CMAP�reportlab.lib.utilsr*rrrr�fastLoad�
parseCMAPFile�fastSave)�selfr�useCacher*�
fontmapdirrrr�__init__Es$


�zCIDEncoding.__init__cCst�}|�|�|��S�N)r�update�digest)r7�text�hasherrrr�_hashZs
zCIDEncoding._hashcCsTt|�}t|d���}|�|�|_|�d�}|dkr-|d|�}|��}|d}|�|�|��}|gk�r(|ddkry|dd�}|ddkrx|d|d|d	d�}}	}t|dd�d
�}
t|	dd�d
�}|j	�
|
|f�|ddksHn�|ddkr�|dd�}|ddkr�|dd
�\}}	}t|dd�d
�}
t|	dd�d
�}t|�}
|j�
|
||
f�|d
d�}|ddks�nb|ddk�r|dd�}|ddk�r|dd
�\}}	}t|dd�d
�}
t|	dd�d
�}t|�}
d}|
||k�r|
||j|
|<|d}|
||ks�|d
d�}|ddks�n|dd�}|gks6dSdS)zvThis is a tricky one as CMAP files are Postscript
        ones.  Some refer to others with a 'usecmap'
        command�r�usecmap���r�begincodespaceranger)N�endcodespacerange���beginnotdefrange�endnotdefrange��
begincidrange�endcidrange)
r�open�readr@r-�find�splitr5�intr.r r/r0)r7rr�rawdata�usecmap_pos�chunk�words�
otherCMAPName�strStart�strEnd�start�end�strValue�value�offsetrrrr5_s`


 ��������zCIDEncoding.parseCMAPFilec
Cs�g}|j}d}|D]h}|dkrt|�dt|�}nt|�}|}d}|jD]D\}}	||kr3|	krinq%z||}
Wn$ty_d}
|jD]\}}}
||krV|kr\nqG|
}
nqGYnw|�|
�d}nq%|rod}q	|}q	|S)z$Convert a string into a list of CIDs��rr))r0�ordr.�KeyErrorr/r )r7r>�output�cmap�lastChar�char�num�found�low�high�cid�low2�high2�notdefrrr�	translate�s<���
	�zCIDEncoding.translatecCs^ttj�||jd�d�}t�|j|�t�|j|�t�|j	|�t�|j
|�|��dS)Nr,�wb)rMrr�joinr�marshal�dumpr-r.r/r0�close)r7�	directory�frrrr6�szCIDEncoding.fastSavecCsft��}ttj�||jd�d�}t�|�|_	t�|�|_
t�|�|_t�|�|_|�
�t��}dS)Nr,�rb)�time�clockrMrrrprrq�loadr-r.r/r0rs)r7rt�startedru�finishedrrrr4�szCIDEncoding.fastLoadcCs|j|j|j|jd�S)z@Simple persistence helper.  Return a dict with all that matters.)�mapFileHash�codeSpaceRanges�notDefRangesrc)r-r.r/r0)r7rrr�getData�s
�zCIDEncoding.getDataN)r))�__name__�
__module__�__qualname__�__doc__r:r@r5rnr6r4rrrrrr(9s
A%r(c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�CIDTypeFacez�Multi-byte type face.

    Conceptually similar to a single byte typeface,
    but the glyphs are identified by a numeric Character
    ID (CID) and not a glyph name. cCstj�||�|�|�dS)zmInitialised from one of the canned dictionaries in allowedEncodings

        Or rather, it will be shortly...N)r�TypeFacer:�_extractDictInfo)r7rrrrr:�szCIDTypeFace.__init__cCszzt|}Wntytd|dtt���w|dd}|dd|_|dd|_|d|_|�|d	�|_dS)
Nz/Unable to find information on CID typeface '%s'z#Only the following font names work:�DescendantFontsr�FontDescriptor�Ascent�Descent�DW�W)	rra�reprr�ascent�descent�
_defaultWidth�
_expandWidths�_explicitWidths)r7r�fontDict�descFontrrrr��s���
zCIDTypeFace._extractDictInfoc
Cs�|dd�}i}|rX|d|dd�}}t|d�r8|d|dd�}}tt|��D]
}|||||<q,n|d|d|dd�}}}t||d�D]}	|||	<qO|s
|S)a�Expands Adobe nested list structure to get a dictionary of widths.

        Here is an example of such a structure.::
        
            (
            # starting at character ID 1, next n  characters have the widths given.
            1,  (277,305,500,668,668,906,727,305,445,445,508,668,305,379,305,539),
            # all Characters from ID 17 to 26 are 668 em units wide
            17, 26, 668,
            27, (305, 305, 668, 668, 668, 566, 871, 727, 637, 652, 699, 574, 555,
                 676, 687, 242, 492, 664, 582, 789, 707, 734, 582, 734, 605, 605,
                 641, 668, 727, 945, 609, 609, 574, 445, 668, 445, 668, 668, 590,
                 555, 609, 547, 602, 574, 391, 609, 582, 234, 277, 539, 234, 895,
                 582, 605, 602, 602, 387, 508, 441, 582, 562, 781, 531, 570, 555,
                 449, 246, 449, 668),
            # these must be half width katakana and the like.
            231, 632, 500
            )
        
        Nrr)rF)r�range�len)
r7�compactWidthArray�data�widthsrYrr]rZ�width�idxrrrr��s� 
�
zCIDTypeFace._expandWidthscCs|j�||j�Sr;)r��getr�)r7�characterIdrrr�getCharWidth szCIDTypeFace.getCharWidthN)r�r�r�r�r:r�r�r�rrrrr��s#r�c@s6eZdZdZdZdd�Zdd�Zddd	�Zd
d�ZdS)
�CIDFontz%Represents a built-in multi-byte fontr)cCs�|tvsJd|tf��||_t|�|_|tvs Jd|tf��||_t|�|_|jd|j|_|j|_	|jddk|_
g|_dS)Nz9TypeFace '%s' not supported! Use any of these instead: %sz:Encoding '%s' not supported!  Use any of these instead: %s�-rC�V)r�faceNamer��facer�encodingNamer(�encoding�fontNamer�
isVertical�substitutionFonts)r7r�r�rrrr:'s


zCIDFont.__init__cCst|�}|Sr;r)r7r>�encodedrrr�formatForPdf<szCIDFont.formatForPdfNcCsH|j�|�}|jrt|�|Sd}|D]
}||j�|�}qd||S)zJThis presumes non-Unicode input.  UnicodeCIDFont wraps it for that contextr���MbP?)r�rnr�r�r�r�)r7r>�sizer��cidlist�wrjrrr�stringWidthAszCIDFont.stringWidthcCsxdtt|j�d�}t|jj}d||d<d|j|d<t|�}|�||�}|j	dj
}|||<d||j|j<dS)z�The explicit code in addMinchoObjects and addGothicObjects
        will be replaced by something that pulls the data from
        _cidfontdata.py in the next few days.�Fr)�/�Name�Encoding�
BasicFontsN)r�r��fontMappingrr�rr�r�	Reference�
idToObjectr)r7�doc�internalName�bigDict�cidObjrAr�rrr�
addObjectsOszCIDFont.addObjectsr;)	r�r�r�r��
_multiByter:r�r�r�rrrrr�#s
r�c@s,eZdZdZd
dd�Zdd�Zddd	�ZdS)�UnicodeCIDFontu�Wraps up CIDFont to hide explicit encoding choice;
    encodes text for output as UTF16.

    lang should be one of 'jpn',chs','cht','kor' for now.
    if vertical is set, it will select a different widths array
    and possibly glyphs for some punctuation marks.

    halfWidth is only for Japanese.


    >>> dodgy = UnicodeCIDFont('nonexistent')
    Traceback (most recent call last):
    ...
    KeyError: "don't know anything about CID font nonexistent"
    >>> heisei = UnicodeCIDFont('HeiseiMin-W3')
    >>> heisei.name
    'HeiseiMin-W3'
    >>> heisei.language
    'jpn'
    >>> heisei.encoding.name
    'UniJIS-UCS2-H'
    >>> #This is how PDF data gets encoded.
    >>> print(heisei.formatForPdf('hello'))
    \000h\000e\000l\000l\000o
    >>> tokyo = u'東䫬'
    >>> print(heisei.formatForPdf(tokyo))
    gqJ\354
    >>> print(heisei.stringWidth(tokyo,10))
    20.0
    >>> print(heisei.stringWidth('hello world',10))
    45.83
    FcCs�zt|\}}Wn
tytd|��w||_|dd�}|r%|d}|r,|d}n|d}t�|||�||_|_||_||_t	|j|_
dS)Nz%don't know anything about CID font %srCzHW-r��H)rra�languager�r:rr��vertical�isHalfWidthr�
unicodeWidths)r7r�r�r��lang�defaultEncoding�encrrrr:�s"�
zUnicodeCIDFont.__init__cCs6ddlm}t|�r|�d�}||�d}t|�}|S)Nr)�utf_16_be_encode�utf8)�codecsr�r�decoder)r7r>r��utfTextr�rrrr��s
zUnicodeCIDFont.formatForPdfNcs6t|�r	|�d�}|j�|dt�fdd�|D��S)z8Just ensure we do width test on characters, not bytes...r�r�csg|]}��|d��qS)i�)r�)�.0�uch�r�rr�
<listcomp>�sz.UnicodeCIDFont.stringWidth.<locals>.<listcomp>)rr�r��sum)r7r>r�r�rr�rr��s
zUnicodeCIDFont.stringWidth)FFr;)r�r�r�r�r:r�r�rrrrr�cs

!r�cCsvddl}|�|�}|D]-}|j�||j|d�rqzt|�}Wntd|�Yq|�|�td|�qdS)Nrr,zcannot parse %s, skippingzsaved %s.fastmap)r�listdirrrrr(�printr6)�cmapdirr�files�filer�rrr�precalculate�s

�r�cCs�td�}|�dd�|�ddd�t�tdd��t�td	d��|�d
d�d}|�dd
|�|��td�d}t|�}t|d|�	|��tdd�}td|�
|d��dS)Nztest_japanese.pdf�	Helvetica��di�zJapanese Font SupportzHeiseiMin-W3z90ms-RKSJ-HzHeiseiKakuGo-W5zHeiseiMin-W3-90ms-RKSJ-HrGu'‚±‚ê‚Í•½¬–¾’©‚Å‚·Bi�zsaved test_japanese.pdfz->z
width = %0.2f�
)r	�setFont�
drawStringr�registerFontr��saver�r(rnr�)�c�message1�encNamer�rurrr�test�s

r��__main__)�cidfonts)*�__version__r�rrqrw�hashlibr�ImportError�reportlab.pdfbaser�reportlab.pdfbase._cidfontdatarrrrr�reportlab.pdfgen.canvasr	r
�reportlab.lib.rl_accelr�reportlab.rl_configr
r3rrr2rrr�r(r�r��Fontr�r�r�r�r��doctestr��testmodrrrr�<module>s@�	)B@[2�

Youez - 2016 - github.com/yon3zu
LinuXploit