Files
intellecton/venv/lib/python3.12/site-packages/fontTools/__pycache__/afmLib.cpython-312.pyc
T

119 lines
16 KiB
Plaintext
Raw Normal View History

Ë
zRjl3ãóvdZddlZejd«Zejd«Zejd«Zejd«Zejd«Zgd¢ZGd „d
e «Z
Gd d e «Z d
Z
ddZedk(r³ddlZej"«Zere e«ZdZej+e«r eee«dZej1e«r eee«eej2«eej4«eej7««ee«ej9edz«yyy)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 <https://www.adobe.com/content/dam/acom/en/devnet/font/pdfs/5004.AFM_Spec.pdf>`_,
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*)ÚFontNameÚFullNameÚ
FamilyNameÚWeightÚ ItalicAngleÚ IsFixedPitchÚFontBBoxÚUnderlinePositionÚUnderlineThicknessÚVersionÚNoticeÚEncodingSchemeÚ CapHeightÚXHeightÚAscenderÚ Descendercó eZdZy)ÚerrorN)Ú__name__Ú
__module__Ú __qualname__©óúS/home/antigravity/intellecton/venv/lib/python3.12/site-packages/fontTools/afmLib.pyrrwsØrrcóšeZdZdZgd¢ZddZdZdZdZdZ dZ
dd „Z d
Z d Z
d Zd
ZdZdZdZdZdZdZdZdZdZdZy)ÚAFMN)
ÚStartFontMetricsÚEndFontMetricsÚStartCharMetricsÚEndCharMetricsÚ
StartKernDataÚStartKernPairsÚ EndKernPairsÚ EndKernDataÚStartCompositesÚ
EndCompositescó€i|_i|_i|_i|_g|_i|_||j
|«yy)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Úpaths rÚ__init__z AFM.__init__sE𠈌 ؈Œ ؈Œ
؈Œ ؈ŒØˆÔØ Ð Ø I‰Id rcóÆt|«}|D}|j«sŒtj|«}|t dt |«z«|j dd}|d|}||dj«}||jvrŒ{|dk(r|j|«Œ’|dk(r|j|«Œ©|dk(r|j|«ŒÀ|j||«ŒÓy)zOpens, reads and parses a file.Núsyntax error in AFM file: éÚKPXÚCC) Ú readlinesÚstripÚ identifierREÚmatchrÚreprÚregsÚ _keywordsÚ parsecharÚ
parsekernpairÚparsecompositeÚ parseattr)r/r0ÚlinesÚlineÚposÚwordÚrests rr.zAFM.readšä˜$“ˆØò +ˆDØ—::”<ØÜ×" (ˆˆÐ8¼4À»:Ñ—&&˜)˜A,ˆ˜˜:ˆDؘ˜%ˆDØt—~‘~ÑØsŠ{ؘtÕ˜Ø×" ˜Ø×# DÕ˜t *ñ' +rcótj|«}|tdt|«z«g}|jddD]\}}|j |||«Œ|d}|d=d|D«\}}} }
} } ||| |
| | ff|j |<y)Nr3r4éc3ó2K|]}t|«Œy­w©N)Úint)Ú.0Úthings rú <genexpr>z AFM.parsechar.<locals>.<genexpr>»sèø€Ò%E°U¤c¨%§jÑ%Eùs)ÚcharREr;rr<r=Úappendr))
r/rHrEÚthingsÚfrÚtoÚcharnameÚcharnumÚwidthÚts
rr?z
AFM.parsechar²Ü L‰L˜Ó ˆØ ˆ9ÜÐ4´t¸D³zÑ ˆØ—ff˜Q˜R '‰FˆBØ M‰M˜$˜r "˜ ˜!9ˆØ 1ˆIÙ%E¸fÔ%EÑ"ˆ˜˜1˜a Ø '¨°°A°q¸ Ð <ˆ rcóþtj|«}|tdt|«z«g}|jddD]\}}|j |||«Œ|\}}}t
|«}||j||f<y)Nr3r4)ÚkernREr;rr<r=rRrMr*) r/rHrErSrTrUÚleftcharÚ rightcharÚvalues rr@zAFM.parsekernpair¾s†Ü L‰L˜Ó ˆØ ˆ9ÜÐ4´t¸D³zÑ ˆØ—ff˜Q˜R '‰FˆBØ M‰M˜$˜r "˜  'à%+Ñ"ˆ)˜E“
ˆØ/4ˆ
x Ð,rcóX|dk(r@|j«Dcgc]
}t|«Œc}\}}}}||||f|j|<y|dk(r|jj |«y t|«}||j|<ycc}w#t
t f$r||j|<YywxYw)Nr ÚComment)ÚsplitrMr(r,rRÚ
ValueErrorÚ
OverflowError) r/rGrHrOrYrZr[r\ras rrBz
AFM.parseattrÉØ  Ø26·*±*³,Öœ#˜e?‰JˆAˆq!QØ ! 1  
ˆDK‰K˜Ò Ø

Ø N‰N× !  
˜D› ð%* ˜DÒ!ùò@øô¤
Ð
)Ø$( ˜
)ús˜BÁ( BÂB)Â(B)códtj|«}|tdt|«z«|j d«}t |j d««}||j ddd}g} tj|«}|tdt|«z«|j d«}t |j d««}t |j d««}|j|||f«||j ddd}|snŒ t|«|k(sJ||j|<y)Nr3r4rJré) Ú compositeREr;rr<ÚgrouprMr=Ú componentRErRÚlenr-) r/rHrErVÚ ncomponentsÚ
componentsÚbasecharÚxoffsetÚyoffsets rrAzAFM.parsecomposite×sÜ × Ñ ˜dÓ Ø ˆ9ÜÐ4´t¸D³zÑ —7‘7˜1“:ˆÜ˜!Ÿ'™' !*“oˆ ØA—FF˜1‘I˜a‘L؈
ØÜ×! $Ó'ˆA؈Ð8¼4À»:Ñ—w‘w˜q“zˆ˜!Ÿ'™' !*“oˆ˜!Ÿ'™' !*“oˆ × Ñ ˜°'Ð ˜Ÿ˜q™  !™ ˜Ð'ˆDÙØðô:‹ +Ò-Ø%/ˆ×јÒ"rc óbddl}dd|jd|j|j«««zg}|jD]}|j d|z«Œ|j
}t D]6}||vsŒ||}|dk(rd|z}|j |d zt|«z«Œ8t|j««} | D].\}}|t vrŒ|j |d zt|«z«Œ0|j d
tt|j««z«|jj«D
cgc]\}
\} } }
| |
| |
ffŒ} } } }
}
d }| j|¬ «| D])\} \}
} \}}}}|j d
| | |
||||fz«Œ+|j d«|j d«|j dtt|j««z«t|jj««} | D]\\}}}|j d|||fz«Œ!|j d«|j d«|jr¢t|jj««}|j dt|j«z«|D]B\}
}d|
d t|«d}|D]\}}}|d|d |d |dz}Œ|j |«ŒD|j d«|j d«t!|||«ycc}
} } }
w)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 r z %s %s %s %sú zStartCharMetrics có&|ddk(rd|ddz}|S)znCustom key function to make sure unencoded chars (-1)
end up at the end of the list after sorting.réÿÿÿÿ)iÿÿr4Nr)Úas rÚmyKeyzAFM.write.<locals>.myKeys$ð‰trŠzØ  ! " Ñ%؈Hr)Úkeyz%C %d ; WX %d ; N %s ; B %d %d %d %d ;r r!zStartKernPairs z KPX %s %s %dr#r$zStartComposites %szCC z ;z PCC r&r)ÚtimeÚstrftimeÚ localtimer,rRr(ÚpreferredAttributeOrderÚstrÚsortedÚitemsr<rlr)Úsortr*r-Ú
writelines)r/r0ÚsepryrCÚcommentÚattrsÚattrrarrVrWrXÚboxrwrYrZr[r\r_r`Ú
compositesrnrDrorprqs rÚwritez AFM.writeís'ãð
}‰}Ð0°$·.±.ÀÇÁÃÓ2MÓ
Pð
ˆð—~‘~ò /ˆGØ L‰L˜  
 ˆÜ 6ˆDØuŠ}ؘd™ ؘ:Ò)¨EÑ1 ˜T C™Z¬#¨e«*Ñ u—{‘{“}ÓØ ò 2‰KˆDÔØ L‰L˜ ¤c¨%£jÑ   Ð(¬4´°D·K±KÓ0@Ó+AÑ48·;±;×3DÑ3DÓ3F÷
ñ
á/Ñ/˜7 E¨3ðx ¨Ð 
ˆó
ò