Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 2øªji+ã@s*dZddlZejdƒZejdƒZejdƒZejdƒZejdƒZdd d d d d ddddddddddgZGdd„de ƒZ Gdd„de ƒZ dd„Z d%dd „Zed!k�r&ddlZejƒZe�r&e eƒZd"ZejeƒrÖeeeƒd&Zejeƒrðeeeƒeejƒeejƒeejƒƒeeƒejed$ƒdS)'a Module for reading and writing AFM (Adobe Font Metrics) files. Note that this has been designed to read in AFM files generated by Fontographer and has not been tested on many other files. In particular, it does not implement the whole Adobe AFM specification [#f1]_ but, it should read most "common" AFM files. Here is an example of using `afmLib` to read, modify and write an AFM file: >>> from fontTools.afmLib import AFM >>> f = AFM("Tests/afmLib/data/TestAFM.afm") >>> >>> # Accessing a pair gets you the kern value >>> f[("V","A")] -60 >>> >>> # Accessing a glyph name gets you metrics >>> f["A"] (65, 668, (8, -25, 660, 666)) >>> # (charnum, width, bounding box) >>> >>> # Accessing an attribute gets you metadata >>> f.FontName 'TestFont-Regular' >>> f.FamilyName 'TestFont' >>> f.Weight 'Regular' >>> f.XHeight 500 >>> f.Ascender 750 >>> >>> # Attributes and items can also be set >>> f[("A","V")] = -150 # Tighten kerning >>> f.FontName = "TestFont Squished" >>> >>> # And the font written out again (remove the # in front) >>> #f.write("testfont-squished.afm") .. rubric:: Footnotes .. [#f1] `Adobe Technote 5004 `_, Adobe Font Metrics File Format Specification. éNz^([A-Za-z]+).*zl(-?\d+)\s*;\s*WX\s+(-?\d+)\s*;\s*N\s+([.A-Za-z0-9_]+)\s*;\s*B\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)\s*;\s*z0([.A-Za-z0-9_]+)\s+([.A-Za-z0-9_]+)\s+(-?\d+)\s*z([.A-Za-z0-9_]+)\s+(\d+)\s*;\s*z1PCC\s+([.A-Za-z0-9_]+)\s+(-?\d+)\s+(-?\d+)\s*;\s*ZFontNameÚFullNameZ FamilyNameÚWeightZ ItalicAngleZ IsFixedPitchÚFontBBoxZUnderlinePositionZUnderlineThicknessÚVersionZNoticeZEncodingSchemeZ CapHeightZXHeightZAscenderZ Descenderc@s eZdZdS)ÚerrorN)Ú__name__Ú __module__Ú __qualname__©r r ú5/tmp/pip-build-_d5lkt3n/fonttools/fontTools/afmLib.pyrxsrc @sÔeZdZdZdddddddd d d g Zd7d d „Zdd„Zdd„Zdd„Zdd„Z dd„Z d8dd„Z dd„Z dd„Z dd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„Zd3d4„Zd5d6„ZdS)9ÚAFMNZStartFontMetricsÚEndFontMetricsZStartCharMetricsÚEndCharMetricsÚ StartKernDataZStartKernPairsÚ EndKernPairsÚ EndKernDataZStartCompositesÚ EndCompositescCs:i|_i|_i|_i|_g|_i|_|dk r6|j|ƒdS)záAFM file reader. Instantiating an object with a path name will cause the file to be opened, read, and parsed. Alternatively the path can be left unspecified, and a file can be parsed later with the :meth:`read` method.N)Ú_attrsÚ_charsÚ_kerningÚ_indexÚ _commentsÚ _compositesÚread)ÚselfÚpathr r r Ú__init__Œsz AFM.__init__cCsÄt|ƒ}x¶|D]®}|jƒsqtj|ƒ}|dkr>tdt|ƒƒ‚|jdd}|d|…}||d…jƒ}||jkrtq|dkrˆ|j|ƒq|dkrœ|j |ƒq|dkr°|j |ƒq|j ||ƒqWdS)zOpens, reads and parses a file.Nzsyntax error in AFM file: éÚCZKPXÚCC) Ú readlinesÚstripÚ identifierREÚmatchrÚreprÚregsÚ _keywordsÚ parsecharÚ parsekernpairÚparsecompositeÚ parseattr)rrÚlinesÚlineÚmÚposÚwordÚrestr r r r›s&       zAFM.readc Cs˜tj|ƒ}|dkr"tdt|ƒƒ‚g}x,|jdd…D]\}}|j|||…ƒq6W|d}|d=dd„|Dƒ\}}} } } } ||| | | | ff|j|<dS)Nzsyntax error in AFM file: récss|]}t|ƒVqdS)N)Úint)Ú.0Úthingr r r ú ¼sz AFM.parsechar..)ÚcharREr#rr$r%Úappendr) rr0r-ÚthingsÚfrÚtoÚcharnameÚcharnumÚwidthÚlÚbÚrÚtr r r r'³s z AFM.parsecharc Csxtj|ƒ}|dkr"tdt|ƒƒ‚g}x,|jdd…D]\}}|j|||…ƒq6W|\}}}t|ƒ}||j||f<dS)Nzsyntax error in AFM file: r)ÚkernREr#rr$r%r7r2r) rr0r-r8r9r:ÚleftcharÚ rightcharÚvaluer r r r(¿s  zAFM.parsekernpairc CsŠ|dkr6dd„|jƒDƒ\}}}}||||f|j|<nP|dkrL|jj|ƒn:y t|ƒ}Wn"ttfk rz||j|<Yn X||j|<dS)NrcSsg|] }t|ƒ‘qSr )r2)r3r4r r r ú Ìsz!AFM.parseattr..ÚComment)Úsplitrrr7r2Ú ValueErrorÚ OverflowError)rr/r0r>r?r@rArEr r r r*Ês z AFM.parseattrc Csìtj|ƒ}|dkr"tdt|ƒƒ‚|jdƒ}t|jdƒƒ}||jddd…}g}xxtj|ƒ}|dkrxtdt|ƒƒ‚|jdƒ}t|jdƒƒ}t|jdƒƒ}|j|||fƒ||jddd…}|sVPqVWt |ƒ|ksÞt ‚||j |<dS)Nzsyntax error in AFM file: rr1ré) Ú compositeREr#rr$Úgroupr2r%Ú componentREr7ÚlenÚAssertionErrorr) rr0r-r;Z ncomponentsÚ componentsÚbasecharÚxoffsetÚyoffsetr r r r)Øs(    zAFM.parsecompositeú c Cshddl}dd|jd|j|jƒƒƒg}x|jD]}|jd|ƒq.W|j}xBtD]:}||krP||}|dkrtd|}|j|d t|ƒƒqPWt|j ƒƒ} x0| D](\}}|tkr²q |j|d t|ƒƒq W|jd t t |j ƒƒƒd d „|j j ƒDƒ} d d„} | j | d�x<| D]4\} \} } \}}}}|jd| | | ||||fƒ�qW|jdƒ|jdƒ|jdt t |jƒƒƒt|jj ƒƒ} x*| D]"\\}}}|jd|||fƒ�qŠW|jdƒ|jdƒ|j�rNt|jj ƒƒ}|jdt |jƒƒxT|D]L\} }d| t |ƒf}x&|D]\}}}|d|||f}�qW|j|ƒ�qôW|jdƒ|jdƒt|||ƒdS)z)Writes out an AFM font to the given path.rNzStartFontMetrics 2.0z"Comment Generated by afmLib; at %sz%m/%d/%Y %H:%M:%SzComment rz %s %s %s %sú zStartCharMetrics cSs$g|]\}\}}}||||ff‘qSr r )r3r;r<r=Zboxr r r rFszAFM.write..cSs |ddkrd|dd…}|S)zeCustom key function to make sure unencoded chars (-1) end up at the end of the list after sorting.rréÿÿNéÿÿÿÿ)rWr )Úar r r ÚmyKeys zAFM.write..myKey)Úkeyz%C %d ; WX %d ; N %s ; B %d %d %d %d ;rrzStartKernPairs z KPX %s %s %drrzStartComposites %sz CC %s %s ;z PCC %s %s %s ;rr )ÚtimeÚstrftimeÚ localtimerr7rÚpreferredAttributeOrderÚstrÚsortedÚitemsr$rOrÚsortrrÚ writelines)rrÚsepr\r+ÚcommentÚattrsÚattrrErbrZr<r;r=r>r?r@rArCrDZ compositesrQr,rRrSrTr r r ÚwriteîsZ          z AFM.writecCs ||jkS)zaReturns `True` if the given glyph pair (specified as a tuple) exists in the kerning dictionary.)r)rÚpairr r r Ú has_kernpair4szAFM.has_kernpaircCst|jjƒƒS)z;Returns a list of all kern pairs in the kerning dictionary.)ÚlistrÚkeys)rr r r Ú kernpairs9sz AFM.kernpairscCs ||jkS)z5Returns `True` if the given glyph exists in the font.)r)rÚcharr r r Úhas_char=sz AFM.has_charcCst|jjƒƒS)z.Returns a list of all glyph names in the font.)rlrrm)rr r r ÚcharsAsz AFM.charscCs|jS)z#Returns all comments from the file.)r)rr r r ÚcommentsEsz AFM.commentscCs|jj|ƒdS)zAdds a new comment to the file.N)rr7)rrfr r r Ú addCommentIszAFM.addCommentcCs||j|<dS)z¼Specifies that the glyph `glyphName` is made up of the given components. The components list should be of the following form:: [ (glyphname, xOffset, yOffset), ... ] N)r)rZ glyphNamerQr r r Ú addCompositeMs zAFM.addCompositecCs ||jkr|j|St|ƒ‚dS)N)rÚAttributeError)rrhr r r Ú __getattr__Ys  zAFM.__getattr__cCs*|dd…dkr||j|<n ||j|<dS)NrÚ_)Ú__dict__r)rrhrEr r r Ú __setattr___s zAFM.__setattr__c Csj|dd…dkrz)ÚhasattrrÚid)rr r r Ú__repr__‹s  z AFM.__repr__)N)rU)rrr rr&rrr'r(r*r)rirkrnrprqrrrsrtrvryr{r~rr€rƒr r r r r |s@    F  r c Cs*t|ddd��}|jƒ}WdQRX|jƒS)Nr@Úascii)Úencoding)ÚopenrÚ splitlines)rÚfÚdatar r r r ’sr rUc Cs4t|dd|d��}|jdj|ƒdƒWdQRXdS)NÚwr„)r…ÚnewlineÚ )r†riÚjoin)rr+rerˆr r r rd—srdÚ__main__ÚAÚVz.muck)rU)r�r�)Ú__doc__ÚreÚcompiler"r6rBrLrNr_Ú ExceptionrÚobjectr r rdrZ EasyDialogsZAskFileForOpenrZafmrorpÚprintrjrkrrrrrir r r r Ú.s`