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øªjW
ã @ s4 d dl Z d dlmZ d dlmZ G dd„ deƒZdS )é N)ÚMissingComponentError)ÚAbstractPointPenc @ sL e Zd ZdZddd„Zedd„ ƒZddd „Zd
d„ Zdd
d„Z ddd„Z
dS )ÚHashPointPena‰
This pen can be used to check if a glyph's contents (outlines plus
components) have changed.
Components are added as the original outline plus each composite's
transformation.
Example: You have some TrueType hinting code for a glyph which you want to
compile. The hinting code specifies a hash value computed with HashPointPen
that was valid for the glyph's outlines at the time the hinting code was
written. Now you can calculate the hash for the glyph's current outlines to
check if the outlines have changed, which would probably make the hinting
code invalid.
> glyph = ufo[name]
> hash_pen = HashPointPen(glyph.width, ufo)
> glyph.drawPoints(hash_pen)
> ttdata = glyph.lib.get("public.truetype.instructions", None)
> stored_hash = ttdata.get("id", None) # The hash is stored in the "id" key
> if stored_hash is None or stored_hash != hash_pen.hash:
> logger.error(f"Glyph hash mismatch, glyph '{name}' will have no instructions in font.")
> else:
> # The hash values are identical, the outline has not changed.
> # Compile the hinting code ...
> pass
r Nc C s || _ dt|dƒ g| _d S )Nzw%sé )ÚglyphsetÚroundÚdata)ÚselfZ
glyphWidthZglyphSet© r
ú@/tmp/pip-build-_d5lkt3n/fonttools/fontTools/pens/hashPointPen.pyÚ__init__$ s zHashPointPen.__init__c C s0 dj | jƒ}t|ƒdkr,tj|jdƒƒjƒ }|S )NÚ é€ Úascii)Újoinr ÚlenÚhashlibÚsha512ÚencodeÚ hexdigest)r r r
r
r Úhash( s zHashPointPen.hashc K s d S )Nr
)r Ú
identifierÚkwargsr
r
r Ú beginPath/ s zHashPointPen.beginPathc C s | j jdƒ d S )Nú|)r Úappend)r r
r
r ÚendPath2 s zHashPointPen.endPathFc K s> |d krd}n|d }| j j|› |d d›|d d›�ƒ d S )NÚor Úgé z+g)r r )r ÚptZsegmentTypeZsmoothÚnamer r Zpt_typer
r
r ÚaddPoint5 s zHashPointPen.addPointc K sj dj dd„ |D ƒƒ}| jjdƒ y| j| j| ƒ W n tk
rP t|ƒ‚Y nX | jjd|› d�ƒ d S )Nr
c S s g | ]}|d ›‘qS )ú+r
)Ú.0Útr
r
r ú
G s z-HashPointPen.addComponent..ú[ú(z)])r r r r Z
drawPointsÚKeyErrorr )r Z
baseGlyphNameZtransformationr r Útrr
r
r ÚaddComponentD s zHashPointPen.addComponent)r N)N)NFNN)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r Úpropertyr r r r" r+ r
r
r
r r s
r )r ZfontTools.pens.basePenr ZfontTools.pens.pointPenr r r
r
r
r Ú s