Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 Nebïtã@s^dZdZddlZddlZddlZddlmZddlmZddl m Z m Z m Z m Z mZmZmZmZddlmZmZddlmZmZdd lmZd ZejjƒejZejZiZiZiZ iZ!Gd d „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ƒZdPd7d8„Z?dQd9d:„Z@d;d<„ZAdRd>d?„ZBd@dA„ZCdBdC„ZDdDdE„ZEdFdG„ZFeGejHƒejHƒe jHƒe!jHƒdH�fdIdJ„ZIddKlmJZJeJeIƒ[JeKdLk�rZeFƒeEƒdS)Sz3.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@s eZdZdS)Ú FontErrorN)Ú__name__Ú __module__Ú __qualname__©rrú=/tmp/tmp4i9tl1d3/lib64/python/reportlab/pdfbase/pdfmetrics.pyr'src@s eZdZdS)ÚFontNotFoundErrorN)rrrrrrrr)srcCs6t|dƒ}t|ƒdkr@|r(|djdƒ}t|ƒdkr@td|ƒ‚i}g}dd„|Dƒ}dd„|Dƒ}d}�x|D�] }|dd …d krŒd}qp|dd …d kr¢d}qp|rp|jd ƒ}dd„|Dƒ}|dd…\}}} |jƒ\} } | dksðtd|ƒ‚t| ƒ} |jƒ\} } | dk�std|ƒ‚y t| ƒ} Wntk �rDt| ƒ} YnX| jƒ\} } | dk�shtd|ƒ‚| }|j| | |fƒqpWd}x¨|D] }|dd …dk�r¤d}|dd …d k�r¼d}nl|�rŠ|dd…dk�rÔy|jddƒ\}}Wntd||fƒ‚YnXy t|ƒ}Wn YnX|||<�qŠW||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 datacSsg|] }|jƒ‘qSr)Ústrip)Ú.0Úlrrrú =sz parseAFMFile..cSsg|]}|jƒjdƒs|‘qS)Úcomment)ÚlowerÚ startswith)rrrrrr>séZStartCharMetricséZEndCharMetricsú;cSsg|] }|jƒ‘qSr)r)rÚchunkrrrrHséÚCzbad line in font file %sZWXÚNZStartFontMetricséÚCommentú z-Header information error in afm %s: line='%s')rÚlenÚsplitÚ ValueErrorÚAssertionErrorÚintÚfloatÚappend)Ú afmFileNameÚlinesÚtopLevelZ glyphLevelZ inMetricsÚlineÚchunksZcidChunkZ widthChunkZ nameChunkrrÚcidÚwidthÚnameZinHeaderÚleftÚrightrrrÚ parseAFMFile,sf           r>c@s.eZdZdd„Zdd„Zdd„Zd dd „Zd S) ÚTypeFacecCsz||_g|_i|_d|_d|_d|_d|_d|_|dkr@d|_n|dkrPd|_nd|_|t krpd|_ |j |ƒnd|_ dS)NrÚ ZapfDingbatsZZapfDingbatsEncodingÚSymbolZSymbolEncodingr) r;Ú glyphNamesÚ glyphWidthsÚascentÚdescentÚ familyNameÚboldÚitalicÚrequiredEncodingÚ standardFontsÚbuiltInÚ_loadBuiltInData)Úselfr;rrrÚ__init__vs" zTypeFace.__init__cCs:t|ƒ}tj||_t|jjƒƒ|_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) ÚstrrZwidthsByFontGlyphrCÚlistÚkeysrBZascent_descentrDrE)rMr;rrrrL�s zTypeFace._loadBuiltInDatacCsgS)z=Info function, return list of the font files this depends on.r)rMrrrÚ getFontFiles˜szTypeFace.getFontFilesú.pfbc Csð|jƒ|jƒf}t|dƒrNtjj|jƒd}x |D]}t||ƒr2||Sq2Wytj |j ƒ}Wnrt |j ƒ}|rÈ|jƒdkr¶xD|D]*}tjj|ƒd|}t|ƒr¬|}q†d}q†WqÌ|jƒdkrÌ|}nd}YnX|dkrìt d||j fƒ|S)NÚ pfbFileNamerz.pfbz.afmzCan't find %s for face '%s') r!ÚupperÚhasattrÚosÚpathÚsplitextrTrrÚ findT1Filer;ÚbruteForceSearchForAFMr)rMÚextZ possible_extsZ r_basenameÚerÚafmÚpfbrrrrZœs.          zTypeFace.findT1FileN)rS)rrrrNrLrRrZrrrrr?usr?cCsb|dkrddlm}t|ƒr |Stjj|ƒ}x0|D](}t|ƒs@q2tjj||ƒ}t|ƒr2|Sq2W|S)Nr)r )Úreportlab.rl_configr rrWrXÚbasenamerÚjoin)ÚfnZ searchPathZbfnÚdirnameZtfnrrrÚbruteForceSearchForFile·s   rec Cs¤ddlm}x’|D]Š}t|ƒs qt|tjdƒ}xh|D]`}y t|ƒ\}}|d|krZ|SWq8tjƒ\}}} dj t t |j ƒƒd|f|_ ‚Yq8Xq8WqWdS)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 rrrWÚsepr>ÚsysÚexc_inforbÚmaprOÚargs) ÚfaceNamer rdZ possiblesÚpossibleZtopDictZ glyphDictÚtÚvÚbrrrr[Ás     r[c@sReZdZdZddd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dS)ÚEncodingz1Object to help you create and refer to encodings.NcCsÂ||_d|_|tkr8|dks$tdƒ‚||_tj||_n†|dkrTt|_tjt|_njt |ƒr~t |ƒ}|j|_|jdd…|_n@t |ƒrœt|_|dd…|_n"t |t ƒr¾|j|_|jdd…|_dS)Nrz2Can't have a base encoding for a standard encoding)r;ÚfrozenÚstandardEncodingsr0ÚbaseEncodingNamerÚ encodingsÚvectorr r Ú getEncodingr Ú isinstancerq)rMr;ÚbaseÚbaseEncrrrrNÛs& zEncoding.__init__cCs |j|S)z.Return glyph name for that code point, or None)rv)rMÚindexrrrÚ __getitem__òszEncoding.__getitem__cCs@|jdkstdƒ‚|j||kr}|j|dƒx*|dd…D]}|dk rd|jd|ƒqdWqDW|j|ƒ|d<|d krª|j|ƒ|d <|jd ƒ|d <|j|ƒ} | SdS)z&Returns a PDF Object representing selfr)ÚpdfdocrNú/Z DifferencesÚMacRomanEncodingÚMacExpertEncodingÚWinAnsiEncodingZ BaseEncodingrqÚType)r‹rŒr�) Úreportlab.pdfbaser‰rtrwrˆÚPDFNamer3ÚPDFArrayÚ PDFDictionary) rMr‰ÚDrtrzZ differencesZ diffArrayr†Ú glyphNameZPDrrrÚ makePDFObject,s&     zEncoding.makePDFObject)N) rrrÚ__doc__rNr|r€r�rƒr…rˆr•rrrrrqÙs rqc@sLeZdZdZdZdZddd„Zddd„Zd d „Zd d „Z d d„Z dd„Z dS)Ú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|ƒ|_||_|jr8|jdkr8tn|p>g|_ |j ƒt |_ |dkr\|p^t |_ dS)Nr@) ÚfontNameÚ getTypeFaceÚfacerwÚencodingÚencNamerKrIÚstandardT1SubstitutionFontsÚsubstitutionFontsÚ _calcWidthsÚ _notdefCharÚ _notdefFont)rMr;rlrœržršrrrrN]s  z Font.__init__Úutf8cCst||||d�S)N)r›)r)rMÚtextÚsizer›rrrÚ stringWidthiszFont.stringWidthcCsd|jj|jjfS)Nz<%s %s>)Ú __class__rršr;)rMrrrÚ__repr__lsz Font.__repr__c Cs–dgd}|jj}|jj}xptdƒD]d}||}|dk r$y||}|||<Wq$tk r†ddl}|jjr‚t d|jj |fƒnYq$Xq$W||_ dS)z)Vector of widths for stringWidth functionréNz3typeface "%s" does not have a glyph "%s", bad font!) ršrCr›rvr†ÚKeyErrorr`Z rl_configZwarnOnMissingFontGlyphsÚprintr;Úwidths)rMÚwZgwZvecr‡r”r:Ú reportlabrrrrŸos   zFont._calcWidthscCsZd}xPtdƒD]D}|dtt|j|ƒdƒ}|dkr>|d}|ddkr|d }qW|S) z||dd>B||dBd>||B}|d}||t|ƒkrÌtd|||t|ƒfƒ‚|||fS)NrzGBad 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_MARKERr/ÚordÚPFB_EOFr-)ÚpÚdÚmrcrrrrÚ _pfbCheckµs$,8rÍ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.cCsZtj|dƒt|tƒ}t|tƒ}tjj|ƒ|_tjj|ƒ|_d|_ |j |ƒ|j |ƒdS)N) r?rNr r rWrXÚabspathr4rTrIÚ _loadGlyphsÚ _loadMetrics)rMr4rTrrrrNÅs    zEmbeddedType1Face.__init__cCs |j|jgS)N)r4rT)rMrrrrRÒszEmbeddedType1Face.getFontFilesc Cs¾t|ƒ}t|ƒstd|ƒ‚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 foundrprN)rerr0rrÍÚ PFB_ASCIIÚ PFB_BINARYrÉÚ _binaryDatar-Z_lengthÚ_length1Ú_length2Ú_length3) rMrTrËÚs1Úl1Ús2Úl2Zs3Úl3rrrrÐÕs &   zEmbeddedType1Face._loadGlyphsc Csôt|ƒ}t|ƒ\}}|d|_|d|_|jddƒ|_|jddƒ|_|jddƒ|_|jddƒ|_|jd dƒ|_ |jd dƒ|_ |jd ddddgƒ}|j ƒ}g|_ x|D]}|j j t|ƒƒq¤Wi}x|D]\}} } | || <qÆW||_t|jƒƒ|_|jjƒ|jd d ƒdk�rðtd k�rFyddlm} | a~ Wniatdƒ‚YnXd gd} i} i}x^|D]V\}} } d|k�o|dkn�r^| | |<tj| d ƒ}|d k �r^|||<|| |<�q^Wtjd|jƒ}tjj|| |ƒ||_t|| ƒ}t|ƒd S)z Loads in and parses font metricsrfZ FamilyNameZAscenderièZ DescenderrÚ CapHeightÚ ItalicAngleÚstemVÚXHeightÚFontBBoxZEncodingSchemeNZ 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) rer>r;rFÚgetrDrEÚ capHeightÚ italicAnglerßÚxHeightr.Úbboxr3r1rCrPrQrBÚsortÚ_postScriptNames2UnicodeZreportlab.pdfbase._glyphlistrâr/ruÚnormalize_encodingrÚ RL_CodecsZadd_dynamic_codecrIrqÚregisterEncoding)rMr4r6Z glyphDataZstrBboxÚtokensÚtokrCr9r:r;râÚnamesÚexZrexÚcodeÚurœÚencrrrrÑçs\             zEmbeddedType1Face._loadMetricsc Cs¦ddlm}|jƒ}|j|_|j|jd<|j|jd<|j|jd<|j |d|j ƒ}|j d|j |j |jd|j|jƒ|j|jƒ|j|j|j|d œ ƒ}|j |d |jƒ}|S) zFAdd whatever needed to PDF file, and return a FontDescriptor referencer)r‰ZLength1ZLength2ZLength3z fontFile:z/FontDescriptoré") rŽZAscentrÝZDescentZFlagsrárfrÞZStemVràZFontFilezfontDescriptor:)r�r‰Z PDFStreamrÔÚcontentrÕÚ dictionaryrÖr×r¼rTr’rDrärEr‘rçr�r;rårßræ)rMr¾r‰ZfontFileZ fontFileRefZfontDescriptorZfontDescriptorRefrrrr»$s*       zEmbeddedType1Face.addObjectsN) rrrr–rNrRrÐrÑr»rrrrrÎÁs  =rÎcCs8t|tƒstd|ƒ‚|t|j<|jtkr4t|jƒdS)NzNot a TypeFace: %s)rxr?r0Ú _typefacesr;rJÚregisterFontFamily)ršrrrÚregisterTypeFaceBs  rùcCs`t|tƒstd|ƒ‚|jtkrJ|jt|jƒr:|jƒq\td|jƒ‚n|t|j<|jƒdS)NzNot an Encoding: %sz>Encoding "%s" already registered with a different name vector!)rxrqr0r;Ú _encodingsrƒr�r)rórrrrìJs   rìcCs€ddlm}|s|}|jƒ}|s,|p*|p*|}|s4|}|s<|}|j|dd|ƒ|j|dd|ƒ|j|dd|ƒ|j|dd|ƒdS)Nr)Úfontsr)Z reportlab.librûr!Z addMapping)ÚfamilyZnormalrGrHZ boldItalicrûrrrrøWs  røcCs~|j}|jrb|jj}|tkrj|tkrPt|}|jsFtd|||fƒ‚q`|t|<qj|t|<t|<n|t|<|jrzt|jƒdS)zGRegisters a font, including setting up info for accelerated stringWidthz+Attempt to register fonts %r %r for face %rN) r˜rÁršr;Ú_fontsÚ _dynFaceNamesr/rÀrø)Úfontr˜rlZofontrrrÚ registerFontcs rc Cs¸yt|Stk r²|tkrJt|ƒ}tj|\|_|_|_t |ƒ|St |ƒ}|r¬x*dD]"}t j j |ƒd|}t|ƒr\Pq\Wt|ƒs–td|ƒ‚t||ƒ}t |ƒ|S‚YnXdS)z-Lazily construct known typefaces if not foundú.pfbú.PFBrzfile %s not found!N)rr)r÷r©rJr?rZstandardFontAttributesrFrGrHrùr[rWrXrYrr0rÎ)rlršr^r]r_rrrr™{s&  r™c Cs@yt|Stk r:|tkr4t|ƒ}t|ƒ|S‚YnXdS)z-Lazily construct known encodings if not foundN)rúr©rsrqrì)rœrórrrrw–srwcCsZt|ƒ}t|ƒtks$tdt|ƒƒ‚t|ƒ}|jrBt|||jƒ}n t||tƒ}t|ƒ|S)z-search for and register a font given its namez$fontName=%s is not required type str) rOÚtyper0Úasciir™rIr—r r)r˜ršrÿrrrÚfindFontAndRegister£s rc Cs&yt|Stk r t|ƒSXdS)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.N)rýr©r)r˜rrrÚgetFont±srr@rAc Cs^t|ƒ}y|j}|j}Wn|jj}|jj}YnX|rR|d}||||fS||fSdS)Ng@�@)rrDrErš)r˜ÚfontSizerÿrDrEZnormrrrÚgetAscentDescentÀs rcCst||ƒdS)Nr)r)r˜rrrrÚ getAscentÎsr cCst||ƒdS)Nr)r)r˜rrrrÚ getDescentÑsr cCsttjƒƒ}|jƒ|S)zReturns what's in there)rPrýrQrè)ÚregrrrÚgetRegisteredFontNamesÔs r r¢cCst|ƒj|||d�S)zjCompute width of string in points; not accelerated as fast enough because of instanceStringWidthT1/TTF)r›)rr¥)r£r˜rr›rrrr¥Úsr¥cCsÆtdƒttjƒƒ}|jƒx|D]}td|ƒq"Wtƒtdƒttjƒƒ}|jƒx|D]}td|ƒq\Wtƒtdƒttjƒƒ}|jƒx0|D](}t|}td|j|jj |j j fƒq–WdS)NzRegistered Encodings:z zRegistered Typefaces:zRegistered Fonts:z %s (%s/%s)) rªrPrúrQrèr÷rýr˜ršr;r›)rQrœZfacesrlÚkÚkeyrÿrrrÚ dumpFontDataßs$      rc CsÀddl}x²tdd…D]¢}|jƒ}t|ƒj}x.|D]&}d}x|D]}||t|ƒ}q@Wq2W|jƒ}td||ƒ|jƒ}x|D]}t|ƒj|dƒ} q‚W|jƒ}td||ƒtƒqWdS)Nrrzslow stringWidth took %0.4fé z'class lookup and stringWidth took %0.4f)ÚtimerJrr«rÈrªr¥) Ztextsrr˜Út0r¬r£rÛÚchÚt1rÜrrrÚ test3widthsös     rcCsltdƒjƒ}tdt|ƒƒtdƒt|gƒtƒ|jƒ}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ªr-rr.)ÚrawdataÚwordsrrrÚtestStringWidthAlgorithmss  $rcCsFtdƒ}t|ƒt|jdd…ƒtdƒ}t|jƒt|ƒtƒdS)NZ HelveticaréZWombat)r?rùrªrBr)ZhelvZwombatrrrÚtests r)r÷rúrýrþcCs@x0|jƒD]$\}}tƒ|}|jƒ|j|ƒq WtjjƒdS)N)ÚitemsÚglobalsÚclearÚupdaterrëZreset_dynamic_codecs)Z initial_dictsr rorËrrrÚ_reset's  r!)Úregister_resetÚ__main__)N)NNNN)N)N)N)r¢)LÚ __version__r–rWrhrur�rZreportlab.lib.loggerrZreportlab.lib.utilsrrrrrr r r r`r r Zreportlab.lib.rl_accelrrrr rëÚregisterrJrsr÷rúrýrþÚ Exceptionrrr>r?rer[rqr�r—rÆrÇrÒrÓrÉrÍrérÎrùrìrørr™rwrrr¡Úextendrr r r r¥rrrrr½Úcopyr!r"rrrrrÚs~  (  IB w_