Ë
    £eh® ã                  ó:  — d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl	Z	ddl
Z	ddlZ	ddlZ	ddlZ	ddlmZ ddlmZ ddlmZmZ dd	lmZ dd
lmZ ddlmZmZmZmZmZmZm Z  ddlm!Z! ddl"m#Z#m$Z$ ddl%m&Z&m'Z' g d¢Z( ejR                  e*«      Z+dZ,dZ- G d„ de.e'ej^                  «      Z0e'jb                  e0_1         G d„ d«      Z2 G d„ de#«      Z3d„ Z4	 	 	 	 dVd„Z5	 	 	 	 	 dWd„Z6	 	 	 	 dVd„Z7d„ Z8d„ Z9d„ Z:d „ Z;d!„ Z<d"„ Z=d#„ Z>d$„ Z? e@eAe¬%«       e@e@e¬%«      d&œZBd'„ ZCd(„ ZDd)„ ZEd*„ ZFdde0j�                  «       dfd+„ZH	 dXd,„ZI	 dYd-„ZJe0j–                  eIe0j˜                  eJiZMd.„ ZNd/„ ZOd0„ ZPd1„ ZQd2„ ZRd3hZSh d4£ZTeTd3hz  ZUh d5£ZVeVd3hz  ZWd6d7hZXh d8£ZYd9„ ZZd:„ Z[d;„ Z\d<„ Z]d=„ Z^d>„ Z_d?„ Z`d@„ ZadA„ Zb	 dZdB„ZcdC„ ZddD„ Ze G dE„ dFef«      Zg G dG„ dH«      ZhdI„ Zi G dJ„ dKeh«      ZjdL„ Zk G dM„ dNeh«      ZldO„ Zm G dP„ dQeh«      Zng dR¢Zo G dS„ dTe«      Zpe*dUk(  rddlqZq eqjä                  «        yy)[a|  
glifLib.py -- Generic module for reading and writing the .glif format.

More info about the .glif format (GLyphInterchangeFormat) can be found here:

	http://unifiedfontobject.org

The main class in this module is GlyphSet. It manages a set of .glif files
in a folder. It offers two ways to read glyph data, and one way to write
glyph data. See the class doc string for details.
é    )ÚannotationsN)Úwarn)ÚOrderedDict)Útobytes)Úplistlib)ÚAbstractPointPenÚPointToSegmentPen)ÚGlifLibError)ÚuserNameToFileName)ÚgenericTypeValidatorÚcolorValidatorÚguidelinesValidatorÚanchorsValidatorÚidentifierValidatorÚimageValidatorÚglyphLibValidator)Úetree)Ú
_UFOBaseIOÚUFOFormatVersion)ÚnumberTypesÚ_VersionTupleEnumMixin)ÚGlyphSetr
   ÚreadGlyphFromStringÚwriteGlyphToStringÚglyphNameToFileNamezcontents.plistzlayerinfo.plistc                  óH   ‡ — e Zd ZdZdZedˆ fd„	«       Zedˆ fd„	«       Zˆ xZS )ÚGLIFFormatVersion)é   r   )é   r   c                óX   •— |�t        | j                  |«      «      S t        ‰| �  «       S ©N)ÚmaxÚsupported_versionsÚsuperÚdefault)ÚclsÚufoFormatVersionÚ	__class__s     €úV/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/fontTools/ufoLib/glifLib.pyr%   zGLIFFormatVersion.defaultB   s-   ø€ àÐ'Ü�s×-Ñ-Ð.>Ó?Ó@Ð@Ü‰w‰Ó Ð ó    c                ó°   •— |€t         ‰| �  «       S | j                  h}|t        j                  k\  r|j                  | j                  «       t        |«      S r!   )r$   r#   Ú
FORMAT_1_0r   Ú
FORMAT_3_0ÚaddÚ
FORMAT_2_0Ú	frozenset)r&   r'   Úversionsr(   s      €r)   r#   z$GLIFFormatVersion.supported_versionsH   sM   ø€ àÐ#ä‘7Ñ-Ó/Ð/à—N‘NÐ#ˆØÔ/×:Ñ:Ò:Ø�L‰L˜Ÿ™Ô(Ü˜Ó"Ð"r*   r!   )	Ú__name__Ú
__module__Ú__qualname__r,   r/   Úclassmethodr%   r#   Ú__classcell__©r(   s   @r)   r   r   >   s3   ø„ Ø€JØ€Jàô!ó ð!ð
 ô#ó ô#r*   r   c                  ó$   — e Zd ZdZd„ Zdd„Zd„ Zy)ÚGlyphz‚
    Minimal glyph object. It has no glyph attributes until either
    the draw() or the drawPoints() method has been called.
    c                ó    — || _         || _        y r!   )Ú	glyphNameÚglyphSet)Úselfr;   r<   s      r)   Ú__init__zGlyph.__init__c   s   € Ø"ˆŒØ ˆ�r*   c                ó@   — t        ||¬«      }| j                  |«       y)z9
        Draw this glyph onto a *FontTools* Pen.
        )ÚoutputImpliedClosingLineN)r	   Ú
drawPoints)r=   Úpenr@   ÚpointPens       r)   Údrawz
Glyph.drawg   s"   € ô %ØÐ*Bô
ˆð 	�‰˜Õ!r*   c                óR   — | j                   j                  | j                  | |«       y)z2
        Draw this glyph onto a PointPen.
        N)r<   Ú	readGlyphr;   )r=   rC   s     r)   rA   zGlyph.drawPointsp   s   € ð 	�‰×Ñ §¡°°hÕ?r*   N)F)r2   r3   r4   Ú__doc__r>   rD   rA   © r*   r)   r9   r9   ]   s   „ ñò
!ó"ó@r*   r9   c                  óº   — e Zd ZdZeZ	 	 	 	 	 dd„Zdd„Zd„ Zd„ Z	dd„Z
dd„Zd	„ Zd
„ Zdd„Z	 	 	 	 dd„Zd„ Zd„ Zd„ ZeZd„ Zd„ Zdd„Zdd„Zdd„Zd„ Zd„ Zd„ Zy)r   aL  
    GlyphSet manages a set of .glif files inside one directory.

    GlyphSet's constructor takes a path to an existing directory as it's
    first argument. Reading glyph data can either be done through the
    readGlyph() method, or by using GlyphSet's dictionary interface, where
    the keys are glyph names and the values are (very) simple glyph objects.

    To write a glyph to the glyph set, you use the writeGlyph() method.
    The simple glyph objects returned through the dict interface do not
    support writing, they are just a convenient way to get at the glyph data.
    Nc                ó~  — 	 t        |«      }t	        |d«      r|j                  «       }t        |t        «      r(	 t        j                  j                  |«      }	d| _        n`t        |t        j                  j                   «      r|}		 |	j#                  «        d	| _        n!t'        d
t)        |«      j*                  z  «      ‚	 |	j-                  d«      }t        j0                  j3                  |«      d   | _        |	| _        |	j7                  t8        «      | _        |r| j:                  st        t8        › d�«      ‚|j<                  | _        || _         |€tB        }|| _!        || _"        || _#        d| _$        d| _%        | jM                  «        y# t        $ r}ddlm}  |d|›�«      |‚d}~ww xY w# t        j                  j                  $ r t        d|z  «      ‚w xY w# t        j                  j$                  $ r t        d|	z  «      ‚w xY w# t        j                  j.                  $ r t        |	«      }Y �Œhw xY w)a“  
        'path' should be a path (string) to an existing local directory, or
        an instance of fs.base.FS class.

        The optional 'glyphNameToFileNameFunc' argument must be a callback
        function that takes two arguments: a glyph name and a list of all
        existing filenames (if any exist). It should return a file name
        (including the .glif extension). The glyphNameToFileName function
        is called whenever a file name is created for a given glyph name.

        ``validateRead`` will validate read operations. Its default is ``True``.
        ``validateWrite`` will validate write operations. Its default is ``True``.
        ``expectContentsFile`` will raise a GlifLibError if a contents.plist file is
        not found on the glyph set file system. This should be set to ``True`` if you
        are reading an existing UFO and ``False`` if you create a fresh	glyph set.
        r   )ÚUnsupportedUFOFormatzUnsupported UFO format: NÚ
__fspath__zNo glyphs directory '%s'Tzthe filesystem '%s' is closedFz-Expected a path string or fs object, found %sú/éÿÿÿÿz is missing.)'r   Ú
ValueErrorÚfontTools.ufoLib.errorsrK   ÚhasattrrL   Ú
isinstanceÚstrÚfsÚosfsÚOSFSÚerrorsÚCreateFailedr
   Ú_shouldCloseÚbaseÚFSÚcheckÚFilesystemClosedÚ	TypeErrorÚtyper2   Ú
getsyspathÚ	NoSysPathÚpathÚpartsÚdirNameÚexistsÚCONTENTS_FILENAMEÚ_havePreviousFileÚmajorr'   ÚufoFormatVersionTupler   Ú_validateReadÚ_validateWriteÚ_existingFileNamesÚ_reverseContentsÚrebuildContents)
r=   rb   ÚglyphNameToFileNameFuncr'   ÚvalidateReadÚvalidateWriteÚexpectContentsFileÚerK   Ú
filesystems
             r)   r>   zGlyphSet.__init__Œ   s  € ð2	Ü/Ð0@ÓAÐô �4˜Ô&Ø—?‘?Ó$ˆDä�dœCÔ ðFÜŸW™WŸ\™\¨$Ó/�
ð !%ˆDÕÜ˜œbŸg™gŸj™jÔ)ØˆJðQØ× Ñ Ô"ð !&ˆDÕäØ?Ä$ÀtÃ*×BUÑBUÑUóð ð	#Ø×(Ñ(¨Ó-ˆDô —w‘w—}‘} TÓ*¨2Ñ.ˆŒØˆŒà!+×!2Ñ!2Ô3DÓ!EˆÔÙ d×&<Ò&<ÜÔ"3Ð!4°LÐAÓBÐBà 0× 6Ñ 6ˆÔØ%5ˆÔ"Ø"Ð*Ü&9Ð#Ø#:ˆÔ Ø)ˆÔØ+ˆÔØ37ˆÔØ $ˆÔà×ÑÕøôi ò 	ÝDá&Ø*Ð+;Ð*>Ð?óàðûð	ûô —9‘9×)Ñ)ò FÜ"Ð#=ÀÑ#DÓEÐEðFûô —9‘9×-Ñ-ò QÜ"Ð#BÀZÑ#OÓPÐPðQûô �y‰y×"Ñ"ò 	#ä�z“?‹Dð	#ús@   ‚F ºF2 ÂG! ÃH Æ	F/ÆF*Æ*F/Æ2,GÇ!,HÈ(H<È;H<c                ó¤  — |€| j                   }| j                  t        i «      }|r•d}t        |t        «      sd}nl|j                  «       D ]Y  \  }}t        |t        «      sd}t        |t        «      sd}Œ+| j                  j                  |«      rŒGt        t        ›d|›�«      ‚ |rt        dt        z  «      ‚|| _
        d| _        d| _        y)zÏ
        Rebuild the contents dict by loading contents.plist.

        ``validateRead`` will validate the data, by default it is set to the
        class's ``validateRead`` value, can be overridden.
        NFTz( references a file that does not exist: z%s is not properly formatted)rj   Ú	_getPlistrf   rR   ÚdictÚitemsrS   rT   re   r
   Úcontentsrl   rm   )r=   rp   ry   ÚinvalidFormatÚnameÚfileNames         r)   rn   zGlyphSet.rebuildContentsÝ   sÊ   € ð ÐØ×-Ñ-ˆLØ—>‘>Ô"3°RÓ8ˆáØ!ˆMÜ˜h¬Ô-Ø $‘à&.§n¡nÓ&6ò 	‘N�D˜(Ü% d¬CÔ0Ø(,˜Ü% h´Ô4Ø(,™Ø!ŸW™WŸ^™^¨HÕ5Ü*æ0±(ð<óð ð	ñ Ü"Ð#AÔDUÑ#UÓVÐVØ ˆŒØ"&ˆÔØ $ˆÕr*   c                ó®   — | j                   €>i }| j                  j                  «       D ]  \  }}|||j                  «       <   Œ || _         | j                   S )a¬  
        Return a reversed dict of self.contents, mapping file names to
        glyph names. This is primarily an aid for custom glyph name to file
        name schemes that want to make sure they don't generate duplicate
        file names. The file names are converted to lowercase so we can
        reliably check for duplicates that only differ in case, which is
        important for case-insensitive file systems.
        )rm   ry   rx   Úlower)r=   ÚdÚkÚvs       r)   ÚgetReverseContentszGlyphSet.getReverseContentsý   sX   € ð × Ñ Ð(ØˆAØŸ™×+Ñ+Ó-ò !‘��1Ø ��!—'‘'“)’ð!à$%ˆDÔ!Ø×$Ñ$Ð$r*   c                óD   — | j                  t        | j                  «       y)zv
        Write the contents.plist file out to disk. Call this method when
        you're done writing glyphs.
        N)Ú_writePlistrf   ry   ©r=   s    r)   ÚwriteContentszGlyphSet.writeContents  s   € ð
 	×ÑÔ*¨D¯M©MÕ:r*   c                ó  — |€| j                   }| j                  t        i «      }|r&t        |t        «      st        d«      ‚t        |«      }|j                  «       D ]  \  }}	 t        |||«       Œ y# t        $ r t        d|z  «      ‚w xY w)z‘
        ``validateRead`` will validate the data, by default it is set to the
        class's ``validateRead`` value, can be overridden.
        Nz*layerinfo.plist is not properly formatted.zSThe supplied layer info object does not support setting a necessary attribute (%s).)
rj   rv   ÚLAYERINFO_FILENAMErR   rw   r
   ÚvalidateLayerInfoVersion3Datarx   ÚsetattrÚAttributeError)r=   Úinforp   ÚinfoDictÚattrÚvalues         r)   ÚreadLayerInfozGlyphSet.readLayerInfo  s�   € ð
 ÐØ×-Ñ-ˆLØ—>‘>Ô"4°bÓ9ˆÙÜ˜h¬Ô-Ü"Ð#OÓPÐPÜ4°XÓ>ˆHà#Ÿ>™>Ó+ò 	‰KˆD�%ðÜ˜˜d EÕ*ñ	øô "ò Ü"ØiØñóð ðús   Á$A4Á4Bc                ó8  — |€| j                   }| j                  j                  dk  r"t        d| j                  j                  z  «      ‚i }t        j                  «       D ]+  }t        ||«      sŒ	 t        ||«      }|�|dk(  r|sŒ'|||<   Œ- |r$|rt        |«      }| j                  t        |«       y| j                  r@| j                  j                  t        «      r | j                  j                  t        «       yyy# t        $ r t        d|z  «      ‚w xY w)z“
        ``validateWrite`` will validate the data, by default it is set to the
        class's ``validateWrite`` value, can be overridden.
        Né   z)layerinfo.plist is not allowed in UFO %d.zMThe supplied info object does not support getting a necessary attribute (%s).Úlib)rk   ri   rh   r
   ÚlayerInfoVersion3ValueDataÚkeysrQ   Úgetattrr‹   r‰   r„   rˆ   rg   rT   re   Úremove)r=   rŒ   rq   ÚinfoDatarŽ   r�   s         r)   ÚwriteLayerInfozGlyphSet.writeLayerInfo,  s!  € ð
 Ð Ø ×/Ñ/ˆMØ×%Ñ%×+Ñ+¨aÒ/ÜØ;Ø×,Ñ,×2Ñ2ñ3óð ð
 ˆÜ.×3Ñ3Ó5ò 	'ˆDÜ�t˜TÕ"ðÜ# D¨$Ó/�Eð �= T¨U¢]¹5ØØ!&�˜’ð	'ñ áÜ8¸ÓB�à×ÑÔ/°Õ:Ø×#Ò#¨¯©¯©Ô7IÔ(Jà�G‰G�N‰NÔ-Õ.ð )KÐ#øô &ò Ü&ØgØñóð ðús   Á1DÄDc           	     óÖ   — | j                   |   }	 | j                  j                  |«      S # t        j                  j                  $ r t        d|›d|›d| j                  ›�«      ‚w xY w)aØ  
        Get the raw GLIF text for a given glyph name. This only works
        for GLIF files that are already on disk.

        This method is useful in situations when the raw XML needs to be
        read from a glyph set for a particular glyph before fully parsing
        it into an object structure via the readGlyph method.

        Raises KeyError if 'glyphName' is not in contents.plist, or
        GlifLibError if the file associated with can't be found.
        z
The file 'z' associated with glyph 'z&' in contents.plist does not exist on )ry   rT   Ú	readbytesrW   ÚResourceNotFoundr
   ©r=   r;   r|   s      r)   ÚgetGLIFzGlyphSet.getGLIFP  sc   € ð —=‘= Ñ+ˆð	Ø—7‘7×$Ñ$ XÓ.Ð.øÜ�y‰y×)Ñ)ò 	Ýâ*2²I¸t¿wºwðHóð ð	ús	   ‘, ¬<A(c                óB   — | j                   |   }| j                  |«      S )ao  
        Returns the modification time for the GLIF file with 'glyphName', as
        a floating point number giving the number of seconds since the epoch.
        Return None if the associated file does not exist or the underlying
        filesystem does not support getting modified times.
        Raises KeyError if the glyphName is not in contents.plist.
        )ry   ÚgetFileModificationTimer�   s      r)   ÚgetGLIFModificationTimez GlyphSet.getGLIFModificationTimee  s#   € ð —=‘= Ñ+ˆØ×+Ñ+¨HÓ5Ð5r*   c                óê  — |€| j                   }| j                  |«      }	 t        |«      }t        j	                  | j
                  «      }t        |||||¬«       y# t        $ r�}| j                  |   }		 d| j                  j                  |	«      › d�}
n?# t        j                  j                  $ r d|	› dt        | j                  «      › d�}
Y nw xY w|j                  d|› d|
› d�«       ‚ d}~ww xY w)a`  
        Read a .glif file for 'glyphName' from the glyph set. The
        'glyphObject' argument can be any kind of object (even None);
        the readGlyph() method will attempt to set the following
        attributes on it:

        width
                the advance width of the glyph
        height
                the advance height of the glyph
        unicodes
                a list of unicode values for this glyph
        note
                a string
        lib
                a dictionary containing custom data
        image
                a dictionary containing image data
        guidelines
                a list of guideline data dictionaries
        anchors
                a list of anchor data dictionaries

        All attributes are optional, in two ways:

        1) An attribute *won't* be set if the .glif file doesn't
           contain data for it. 'glyphObject' will have to deal
           with default values itself.
        2) If setting the attribute fails with an AttributeError
           (for example if the 'glyphObject' attribute is read-
           only), readGlyph() will not propagate that exception,
           but ignore that attribute.

        To retrieve outline information, you need to pass an object
        conforming to the PointPen protocol as the 'pointPen' argument.
        This argument may be None if you don't need the outline data.

        readGlyph() will raise KeyError if the glyph is not present in
        the glyph set.

        ``validate`` will validate the data, by default it is set to the
        class's ``validateRead`` value, can be overridden.
        N©ÚformatVersionsÚvalidateú'z' from 'zThe issue is in glyph 'z', located in ú.)rj   rž   Ú_glifTreeFromStringr   r#   ri   Ú_readGlyphFromTreer
   ry   rT   r`   rW   ra   rS   Ú	_add_note)r=   r;   ÚglyphObjectrC   r¥   ÚtextÚtreer¤   ÚglifLibErrorr|   ÚglifLocations              r)   rF   zGlyphSet.readGlyphr  s  € ðX ÐØ×)Ñ)ˆHØ�|‰|˜IÓ&ˆð	Ü& tÓ,ˆDÜ.×AÑAØ×*Ñ*óˆNô ØØØØ-Ø!öøô ò 	ð —}‘} YÑ/ˆHðEØ!" 4§7¡7×#5Ñ#5°hÓ#?Ð"@ÀÐB‘øÜ—9‘9×&Ñ&ò Eð "# 8 *¨H´S¸¿¹³\°NÀ!ÐD’ðEúð
 ×"Ñ"Ø)¨)¨°NÀ<À.ÐPQÐRôð ûð	ús;   ¡:A Á	C2Á%C-Á5BÂC-Â9CÃC-ÃCÃC-Ã-C2c                óò  — |€ t         j                  | j                  «      }n	 t        |«      }|t         j                  | j                  «      vrddlm}  |d|›d| j                  ›d�«      ‚|€| j                  }| j                  j                  |«      }|€Ä| j                  €;| j                  j                  «       D �ch c]  }|j                  «       ’Œ c}| _
        | j                  || j                  «      }|| j                  |<   | j                  j                  |j                  «       «       | j                  �|| j                  |j                  «       <   t!        |||||¬«      }	| j"                  r:| j$                  j'                  |«      r|	| j$                  j)                  |«      k(  ry| j$                  j+                  ||	«       y# t        $ r}ddlm}  |d|›�«      |‚d}~ww xY wc c}w )	aV  
        Write a .glif file for 'glyphName' to the glyph set. The
        'glyphObject' argument can be any kind of object (even None);
        the writeGlyph() method will attempt to get the following
        attributes from it:

        width
                the advance width of the glyph
        height
                the advance height of the glyph
        unicodes
                a list of unicode values for this glyph
        note
                a string
        lib
                a dictionary containing custom data
        image
                a dictionary containing image data
        guidelines
                a list of guideline data dictionaries
        anchors
                a list of anchor data dictionaries

        All attributes are optional: if 'glyphObject' doesn't
        have the attribute, it will simply be skipped.

        To write outline data to the .glif file, writeGlyph() needs
        a function (any callable object actually) that will take one
        argument: an object that conforms to the PointPen protocol.
        The function will be called by writeGlyph(); it has to call the
        proper PointPen methods to transfer the outline to the .glif file.

        The GLIF format version will be chosen based on the ufoFormatVersion
        passed during the creation of this object. If a particular format
        version is desired, it can be passed with the formatVersion argument.
        The formatVersion argument accepts either a tuple of integers for
        (major, minor), or a single integer for the major digit only (with
        minor digit implied as 0).

        An UnsupportedGLIFFormat exception is raised if the requested GLIF
        formatVersion is not supported.

        ``validate`` will validate the data, by default it is set to the
        class's ``validateWrite`` value, can be overridden.
        Nr   ©ÚUnsupportedGLIFFormatz!Unsupported GLIF format version: z!Unsupported GLIF format version (z) for UFO format version r§   )ÚformatVersionr¥   )r   r%   ri   rO   rP   r²   r#   rk   ry   Úgetrl   Úvaluesr~   r   r.   rm   Ú_writeGlyphToBytesrg   rT   re   r›   Ú
writebytes)
r=   r;   r«   ÚdrawPointsFuncr³   r¥   rs   r²   r|   Údatas
             r)   Ú
writeGlyphzGlyphSet.writeGlyph½  sè  € ðj Ð Ü-×5Ñ5°d×6PÑ6PÓQ‰MðÜ 1°-Ó @�ð Ô 1× DÑ DØ×&Ñ&ó!
ñ 
õ Fá'Ø3°MÐ3Dð E*Ø*.×*DÑ*DÐ)GÀqðJóð ð ÐØ×*Ñ*ˆHØ—=‘=×$Ñ$ YÓ/ˆØÐØ×&Ñ&Ð.à59·]±]×5IÑ5IÓ5Kö+Ø)1�H—N‘NÕ$ò+�Ô'ð ×/Ñ/°	¸4×;RÑ;RÓSˆHØ'/ˆD�M‰M˜)Ñ$Ø×#Ñ#×'Ñ'¨¯©Ó(8Ô9Ø×$Ñ$Ð0Ø:C�×%Ñ% h§n¡nÓ&6Ñ7Ü!ØØØØ'Øô
ˆð ×"Ò"Ø—‘—‘˜xÔ(Ø˜Ÿ™×)Ñ)¨(Ó3Ò3àØ�‰×Ñ˜8 TÕ*øôS ò ÝIá+Ø7¸Ð7HÐIóàðûðüò(+s   ¤G ÃG4Ç	G1ÇG,Ç,G1c                ó*  — | j                   |   }| j                  j                  |«       | j                  �)| j                  j                  |j	                  «       «       | j
                  �| j
                  |j	                  «       = | j                   |= y)z‹Permanently delete the glyph from the glyph set on disk. Will
        raise KeyError if the glyph is not present in the glyph set.
        N)ry   rT   r—   rl   r~   rm   r�   s      r)   ÚdeleteGlyphzGlyphSet.deleteGlyph"  sv   € ð —=‘= Ñ+ˆØ�‰�‰�xÔ Ø×"Ñ"Ð.Ø×#Ñ#×*Ñ*¨8¯>©>Ó+;Ô<Ø× Ñ Ð,Ø×%Ñ% h§n¡nÓ&6Ð7Ø�M‰M˜)Ñ$r*   c                óH   — t        | j                  j                  «       «      S r!   )Úlistry   r•   r…   s    r)   r•   zGlyphSet.keys0  s   € Ü�D—M‘M×&Ñ&Ó(Ó)Ð)r*   c                ó   — || j                   v S r!   )ry   ©r=   r;   s     r)   Úhas_keyzGlyphSet.has_key3  s   € Ø˜DŸM™MÐ)Ð)r*   c                ó,   — t        | j                  «      S r!   )Úlenry   r…   s    r)   Ú__len__zGlyphSet.__len__8  s   € Ü�4—=‘=Ó!Ð!r*   c                óX   — || j                   vrt        |«      ‚| j                  || «      S r!   )ry   ÚKeyErrorÚ
glyphClassrÀ   s     r)   Ú__getitem__zGlyphSet.__getitem__;  s*   € Ø˜DŸM™MÑ)Ü˜9Ó%Ð%Ø�‰˜y¨$Ó/Ð/r*   c                óŽ   — i }|€| j                   j                  «       }|D ]!  }| j                  |«      }t        |«      ||<   Œ# |S )aC  
        Return a dictionary that maps glyph names to lists containing
        the unicode value[s] for that glyph, if any. This parses the .glif
        files partially, so it is a lot faster than parsing all files completely.
        By default this checks all glyphs, but a subset can be passed with glyphNames.
        )ry   r•   rž   Ú_fetchUnicodes)r=   Ú
glyphNamesÚunicodesr;   r¬   s        r)   ÚgetUnicodeszGlyphSet.getUnicodesB  sT   € ð ˆØÐØŸ™×+Ñ+Ó-ˆJØ#ò 	7ˆIØ—<‘< 	Ó*ˆDÜ"0°Ó"6ˆH�YÒð	7ð ˆr*   c                óŽ   — i }|€| j                   j                  «       }|D ]!  }| j                  |«      }t        |«      ||<   Œ# |S )aF  
        Return a dictionary that maps glyph names to lists containing the
        base glyph name of components in the glyph. This parses the .glif
        files partially, so it is a lot faster than parsing all files completely.
        By default this checks all glyphs, but a subset can be passed with glyphNames.
        )ry   r•   rž   Ú_fetchComponentBases)r=   rË   Ú
componentsr;   r¬   s        r)   ÚgetComponentReferenceszGlyphSet.getComponentReferencesQ  sU   € ð ˆ
ØÐØŸ™×+Ñ+Ó-ˆJØ#ò 	?ˆIØ—<‘< 	Ó*ˆDÜ$8¸Ó$>ˆJ�yÒ!ð	?ð Ðr*   c                óŽ   — i }|€| j                   j                  «       }|D ]!  }| j                  |«      }t        |«      ||<   Œ# |S )a9  
        Return a dictionary that maps glyph names to the file name of the image
        referenced by the glyph. This parses the .glif files partially, so it is a
        lot faster than parsing all files completely.
        By default this checks all glyphs, but a subset can be passed with glyphNames.
        )ry   r•   rž   Ú_fetchImageFileName)r=   rË   Úimagesr;   r¬   s        r)   ÚgetImageReferenceszGlyphSet.getImageReferences`  sT   € ð ˆØÐØŸ™×+Ñ+Ó-ˆJØ#ò 	:ˆIØ—<‘< 	Ó*ˆDÜ 3°DÓ 9ˆF�9Òð	:ð ˆr*   c                óR   — | j                   r| j                  j                  «        y y r!   )rY   rT   Úcloser…   s    r)   r×   zGlyphSet.closeo  s   € Ø×ÒØ�G‰G�M‰M�Oð r*   c                ó   — | S r!   rH   r…   s    r)   Ú	__enter__zGlyphSet.__enter__s  s   € Øˆr*   c                ó$   — | j                  «        y r!   )r×   )r=   Úexc_typeÚ	exc_valueÚexc_tbs       r)   Ú__exit__zGlyphSet.__exit__v  s   € Ø�
‰
�r*   )NNTTFr!   ©NNN©NNNN)r2   r3   r4   rG   r9   rÇ   r>   rn   r‚   r†   r�   r™   rž   r¡   rF   rº   r¼   r•   rÁ   Ú__contains__rÄ   rÈ   rÍ   rÑ   rÕ   r×   rÙ   rÞ   rH   r*   r)   r   r   |   s¥   „ ñð €Jð
 !%ØØØØ óOób%ò@%ò ;óó,"/òHò*	6óIð\ ØØØóc+òJ
%ò*ò*ð €Lò"ò0óóóòòór*   r   c                ó6   — |€
t        «       }t        | |d¬«      S )z­
    Wrapper around the userNameToFileName function in filenames.py

    Note that existingFileNames should be a set for large glyphsets
    or performance will suffer.
    z.glif)ÚexistingÚsuffix)Úsetr   )r;   ÚexistingFileNamess     r)   r   r     s"   € ð Ð Ü›EÐÜ˜iÐ2CÈGÔTÐTr*   Tc                ó8  — t        | «      }|€t        j                  «       }nHt        «       t        «       }}|D ]  }	 t        |«      }	|j	                  |	«       Œ! |st        d|›�«      ‚t        |||||¬«       y# t
        $ r |j	                  |«       Y Œ_w xY w)a/  
    Read .glif data from a string into a glyph object.

    The 'glyphObject' argument can be any kind of object (even None);
    the readGlyphFromString() method will attempt to set the following
    attributes on it:

    width
            the advance width of the glyph
    height
            the advance height of the glyph
    unicodes
            a list of unicode values for this glyph
    note
            a string
    lib
            a dictionary containing custom data
    image
            a dictionary containing image data
    guidelines
            a list of guideline data dictionaries
    anchors
            a list of anchor data dictionaries

    All attributes are optional, in two ways:

    1) An attribute *won't* be set if the .glif file doesn't
       contain data for it. 'glyphObject' will have to deal
       with default values itself.
    2) If setting the attribute fails with an AttributeError
       (for example if the 'glyphObject' attribute is read-
       only), readGlyphFromString() will not propagate that
       exception, but ignore that attribute.

    To retrieve outline information, you need to pass an object
    conforming to the PointPen protocol as the 'pointPen' argument.
    This argument may be None if you don't need the outline data.

    The formatVersions optional argument define the GLIF format versions
    that are allowed to be read.
    The type is Optional[Iterable[Tuple[int, int], int]]. It can contain
    either integers (for the major versions to be allowed, with minor
    digits defaulting to 0), or tuples of integers to specify both
    (major, minor) versions.
    By default when formatVersions is None all the GLIF format versions
    currently defined are allowed to be read.

    ``validate`` will validate the read data. It is set to ``True`` by default.
    Nz9None of the requested GLIF formatVersions are supported: r£   )r¨   r   r#   rå   r.   rO   r©   )
ÚaStringr«   rC   r¤   r¥   r­   ÚvalidFormatVersionsÚinvalidFormatVersionsr�   r³   s
             r)   r   r   �  s¹   € ôp ˜wÓ'€DàÐÜ/×BÑBÓDÑä58³U¼C»EÐ2ÐØò 	7ˆAð7Ü 1°!Ó 4�ð $×'Ñ'¨Õ6ð	7ñ #ÜØKØ!Ð$ð&óð ô
 ØØØØ*Øöøô ò -Ø%×)Ñ)¨!Ö,ð-ús   ½A<Á<BÂBc                ó<  — 	 t        |«      }|rt	        | t
        «      st        d«      ‚|rt        | «      dk(  rt        d«      ‚t        d| fdt        |j                  «      fg«      }|j                  dk7  rt        |j                  «      |d<   t        j                  d	|«      }t        «       }	t        |||«       t!        |d
d«      rt#        |||«       t!        |dd«      rt%        |||«       |j                  dk\  rt!        |dd«      rt'        |||«       |j                  dk\  rt!        |dd«      rt)        |||	|«       t!        |dd«      }
|j                  dk\  r|
rt+        |||	|«       |�\t        j,                  |d«      }t/        ||	|¬«      } ||«       |j                  dk(  r|
rt1        ||
|«       t        |«      sd|_        t!        |dd«      rt5        |||«       t        j6                  |ddd¬«      }|S # t        $ r ddlm}  |d«      ‚w xY w)z>Return .glif data for a glyph as a UTF-8 encoded bytes string.r   r±   z2Unsupported GLIF format version: {formatVersion!r}z)The glyph name is not properly formatted.zThe glyph name is empty.r{   ÚformatÚformatMinorÚglyphrÌ   NÚnoter   ÚimageÚ
guidelinesÚanchorsÚoutline)Úidentifiersr¥   r   ú
  r“   zUTF-8T)ÚencodingÚxml_declarationÚpretty_print)r   rO   rP   r²   rR   rS   r
   rÃ   r   Úreprrh   Úminorr   ÚElementrå   Ú_writeAdvancer–   Ú_writeUnicodesÚ
_writeNoteÚ_writeImageÚ_writeGuidelinesÚ_writeAnchorsÚ
SubElementÚGLIFPointPenÚ_writeAnchorsFormat1r¬   Ú	_writeLibÚtostring)r;   r«   r¸   Úwriterr³   r¥   r²   Ú
glyphAttrsÚrootrô   rò   ró   rB   r¹   s                 r)   r¶   r¶   ä  s  € ð
Ü)¨-Ó8ˆñ œ
 9¬cÔ2ÜÐFÓGÐGÙ”C˜	“N aÒ'ÜÐ5Ó6Ð6ÜØ
�)Ð	˜x¬¨m×.AÑ.AÓ)BÐCÐDó€Jð ×Ñ˜aÒÜ$(¨×)<Ñ)<Ó$=ˆ
�=Ñ!Ü�=‰=˜ *Ó-€DÜ“%€Kä�+˜t XÔ.äˆ{˜J¨Ô-Ü�{ D¨(Ô3äˆ{˜F DÔ)Ü�;  hÔ/à×Ñ˜aÒ¤G¨K¸À$Ô$GÜ�K  xÔ0à×Ñ˜aÒ¤G¨K¸ÀtÔ$LÜ˜ d¨K¸ÔBä�k 9¨dÓ3€GØ×Ñ˜aÒ¡GÜ�k 4¨°hÔ?àÐ!Ü×"Ñ" 4¨Ó3ˆÜ˜7°ÀhÔOˆÙ�sÔØ×Ñ !Ò#©Ü   g¨xÔ8ä�7Œ|Ø!ˆGŒLäˆ{˜E 4Ô(Ü�+˜t XÔ.ä�>‰>Ø�w°À4ô€Dð €Køôk ò 
ÝAá#Ø@ó
ð 	
ð
ús   ‚H ÈHc                óD   — t        | ||||¬«      }|j                  d«      S )aÔ  
    Return .glif data for a glyph as a string. The XML declaration's
    encoding is always set to "UTF-8".
    The 'glyphObject' argument can be any kind of object (even None);
    the writeGlyphToString() method will attempt to get the following
    attributes from it:

    width
            the advance width of the glyph
    height
            the advance height of the glyph
    unicodes
            a list of unicode values for this glyph
    note
            a string
    lib
            a dictionary containing custom data
    image
            a dictionary containing image data
    guidelines
            a list of guideline data dictionaries
    anchors
            a list of anchor data dictionaries

    All attributes are optional: if 'glyphObject' doesn't
    have the attribute, it will simply be skipped.

    To write outline data to the .glif file, writeGlyphToString() needs
    a function (any callable object actually) that will take one
    argument: an object that conforms to the PointPen protocol.
    The function will be called by writeGlyphToString(); it has to call the
    proper PointPen methods to transfer the outline to the .glif file.

    The GLIF format version can be specified with the formatVersion argument.
    This accepts either a tuple of integers for (major, minor), or a single
    integer for the major digit only (with minor digit implied as 0).
    By default when formatVesion is None the latest GLIF format version will
    be used; currently it's 2.0, which is equivalent to formatVersion=(2, 0).

    An UnsupportedGLIFFormat exception is raised if the requested UFO
    formatVersion is not supported.

    ``validate`` will validate the written data. It is set to ``True`` by default.
    )r«   r¸   r³   r¥   úutf-8)r¶   Údecode)r;   r«   r¸   r³   r¥   r¹   s         r)   r   r   '  s/   € ôf ØØØ%Ø#Øô€Dð �;‰;�wÓÐr*   c                óþ  — t        | dd «      }|�$|rt        |t        «      st        d«      ‚|dk(  rd }t        | dd «      }|�$|rt        |t        «      st        d«      ‚|dk(  rd }|�;|�9t	        j
                  |dt        dt        |«      fdt        |«      fg«      «       y |�+t	        j
                  |dt        t        |«      ¬«      «       y |�+t	        j
                  |dt        t        |«      ¬«      «       y y )	NÚwidthz$width attribute must be int or floatr   Úheightz%height attribute must be int or floatÚadvance)r  )r  )	r–   rR   r   r
   r   r  r   rù   rw   )r«   Úelementr¥   r  r  s        r)   rü   rü   d  sù   € Ü�K ¨$Ó/€EØÐÙœJ u¬kÔ:ÜÐEÓFÐFØ�AŠ:ØˆEÜ�[ (¨DÓ1€FØÐÙœJ v¬{Ô;ÜÐFÓGÐGØ�QŠ;ØˆFØÐ˜VÐ/Ü×ÑØØÜ˜(¤D¨£LÐ1°G¼TÀ%»[Ð3IÐJÓKõ	
ð
 
Ð	Ü×Ñ˜ )¬T¼¸U»Ô-DÕEØ	Ð	Ü×Ñ˜ )¬T¼¸f»Ô-FÕGð 
r*   c                ó  — t        | dd «      }|rt        |t        «      r|g}t        «       }|D ][  }|rt        |t        «      st	        d«      ‚||v rŒ%|j                  |«       d|z  }t        j                  |dt        |¬«      «       Œ] y )NrÌ   zunicode values must be intz%04XÚunicode)Úhex)	r–   rR   Úintrå   r
   r.   r   r  rw   )r«   r  r¥   rÌ   ÚseenÚcodeÚhexCodes          r)   rý   rý   }  sˆ   € Ü�{ J°Ó5€HÙ”J˜x¬Ô-Ø�:ˆÜ‹5€DØò @ˆÙœJ t¬SÔ1ÜÐ;Ó<Ð<Ø�4‰<ØØ�‰�ŒØ˜4‘-ˆÜ×Ñ˜ )¬T°gÔ->Õ?ñ@r*   c                ó¾   — t        | dd «      }|rt        |t        «      st        d«      ‚|j	                  «       }d|z   dz   }|t        j                  |d«      _        y )Nrï   znote attribute must be strú
)r–   rR   rS   r
   Ústripr   r  r¬   )r«   r  r¥   rï   s       r)   rþ   rþ   Œ  sV   € Ü�; ¨Ó-€DÙœ
 4¬Ô-ÜÐ7Ó8Ð8Ø�:‰:‹<€DØ�$‰;˜Ñ€DØ-1„E×Ñ�W˜fÓ%Õ*r*   c                ó6  — t        | dd «      }|rt        |«      st        d«      ‚t        d|d   fg«      }t        D ]+  \  }}|j                  ||«      }||k7  sŒt        |«      ||<   Œ- |j                  d«      }|�||d<   t        j                  |d|«       y )Nrð   zMimage attribute must be a dict or dict-like object with the proper structure.r|   Úcolor)	r–   r   r
   r   Ú_transformationInfor´   rù   r   r  )	r«   r  r¥   rð   ÚattrsrŽ   r%   r�   r  s	            r)   rÿ   rÿ   •  s¬   € Ü�K ¨$Ó/€EÙœ uÔ-ÜØ[ó
ð 	
ô ˜* e¨JÑ&7Ð8Ð9Ó:€EÜ,ò &‰ˆˆgØ—	‘	˜$ Ó(ˆØ�GÓÜ˜u›+ˆE�$ŠKð&ð �I‰I�gÓ€EØÐØˆˆg‰Ü	×Ñ�W˜g uÕ-r*   c                ó>  — t        | dg «      }|rt        |«      st        d«      ‚|D ]ó  }t        «       }|j	                  d«      }|�t        |«      |d<   |j	                  d«      }|�t        |«      |d<   |j	                  d«      }	|	�t        |	«      |d<   |j	                  d«      }
|
�|
|d<   |j	                  d«      }|�||d<   |j	                  d«      }|�*|r||v rt        d	|z  «      ‚||d<   |j                  |«       t        j                  |d
|«       Œõ y )Nrñ   z8guidelines attribute does not have the proper structure.ÚxÚyÚangler{   r  Ú
identifierú"identifier used more than once: %sÚ	guideline)	r–   r   r
   r   r´   rù   r.   r   r  )r«   r  rô   r¥   rñ   r&  r  r!  r"  r#  r{   r  r$  s                r)   r   r   ¦  s/  € Ü˜ l°BÓ7€JÙÔ+¨JÔ7ÜÐUÓVÐVØò 6ˆ	Ü“ˆØ�M‰M˜#ÓˆØˆ=Ü˜a›ˆE�#‰JØ�M‰M˜#ÓˆØˆ=Ü˜a›ˆE�#‰JØ—‘˜gÓ&ˆØÐÜ! %›[ˆE�'‰NØ�}‰}˜VÓ$ˆØÐØ ˆE�&‰MØ—‘˜gÓ&ˆØÐØ"ˆE�'‰NØ—]‘] <Ó0ˆ
ØÐ!Ù˜J¨+Ñ5Ü"Ð#GÈ*Ñ#TÓUÐUØ",ˆE�,ÑØ�O‰O˜JÔ'Ü×Ñ˜ +¨uÕ5ñ/6r*   c                ó.  — |rt        |«      st        d«      ‚|D ]x  }i }|d   }t        |«      |d<   |d   }t        |«      |d<   |j                  d«      }|�||d<   | j	                  «        | j                  ||fd|¬«       | j                  «        Œz y )Nú5anchors attribute does not have the proper structure.r!  r"  r{   Úmove)ÚsegmentTyper{   )r   r
   rù   r´   Ú	beginPathÚaddPointÚendPath)rB   rò   r¥   Úanchorr  r!  r"  r{   s           r)   r  r  Ä  sž   € ÙÔ(¨Ô1ÜÐRÓSÐSØò ˆØˆØ�3‰KˆÜ˜!“Wˆˆc‰
Ø�3‰KˆÜ˜!“Wˆˆc‰
Ø�z‰z˜&Ó!ˆØÐØ ˆE�&‰MØ�‰ŒØ�‰�a˜�V¨°dˆÔ;Ø�‰�ñr*   c                óÄ  — t        | dg «      }|rt        |«      st        d«      ‚|D ]¶  }t        «       }|d   }t	        |«      |d<   |d   }t	        |«      |d<   |j                  d«      }	|	�|	|d<   |j                  d«      }
|
�|
|d<   |j                  d«      }|�*|r||v rt        d|z  «      ‚||d<   |j                  |«       t        j                  |d	|«       Œ¸ y )
Nrò   r(  r!  r"  r{   r  r$  r%  r.  )	r–   r   r
   r   rù   r´   r.   r   r  )r«   r  rô   r¥   rò   r.  r  r!  r"  r{   r  r$  s               r)   r  r  Õ  sú   € Ü�k 9¨bÓ1€GÙÔ(¨Ô1ÜÐRÓSÐSØò 3ˆÜ“ˆØ�3‰KˆÜ˜!“Wˆˆc‰
Ø�3‰KˆÜ˜!“Wˆˆc‰
Ø�z‰z˜&Ó!ˆØÐØ ˆE�&‰MØ—
‘
˜7Ó#ˆØÐØ"ˆE�'‰NØ—Z‘Z Ó-ˆ
ØÐ!Ù˜J¨+Ñ5Ü"Ð#GÈ*Ñ#TÓUÐUØ",ˆE�,ÑØ�O‰O˜JÔ'Ü×Ñ˜ (¨EÕ2ñ%3r*   c                ó  — t        | dd «      }|sy |rt        |«      \  }}|st        |«      ‚t        |t        «      st	        |«      }t        j                  |d¬«      }t        j                  |d«      j                  |«       y )Nr“   r   )Úindent_level)
r–   r   r
   rR   rw   r   Útotreer   r  Úappend)r«   r  r¥   r“   ÚvalidÚmessagers   s          r)   r  r  î  ss   € Ü
�+˜u dÓ
+€CÙàÙÜ*¨3Ó/‰ˆˆwÙÜ˜wÓ'Ð'Ü�cœ4Ô Ü�3‹iˆä�‰˜¨!Ô,€AÜ	×Ñ�W˜eÓ$×+Ñ+¨AÕ.r*   )r_   ÚvalueValidator)r  r“   c                óâ   — | t         vryt         |    }|j                  d«      }|j                  d«      }|j                  d«      }|� |||«      }|S |t        k(  r |||«      }|S  ||«      }|S )a¬  
    This performs very basic validation of the value for attribute
    following the UFO 3 fontinfo.plist specification. The results
    of this should not be interpretted as *correct* for the font
    that they are part of. This merely indicates that the value
    is of the proper type and, where the specification defines
    a set range of possible values for an attribute, that the
    value is in the accepted range.
    Fr_   r6  ÚvalueOptions)r”   r´   r   )rŽ   r�   ÚdataValidationDictÚ	valueTypeÚ	validatorr8  ÚisValidValues          r)   Ú*validateLayerInfoVersion3ValueForAttributer=    s—   € ð Ô-Ñ-ØÜ3°DÑ9ÐØ"×&Ñ& vÓ.€IØ"×&Ñ&Ð'7Ó8€IØ%×)Ñ)¨.Ó9€LàÐÙ  ¨Ó5ˆð Ðð	 Ô,Ò,Ù$ U¨IÓ6ˆLð Ðñ % UÓ+ˆLØÐr*   c                ó¢   — | j                  «       D ];  \  }}|t        vrt        d|z  «      ‚t        ||«      }|rŒ+t        d|› d|›d�«      ‚ | S )a®  
    This performs very basic validation of the value for infoData
    following the UFO 3 layerinfo.plist specification. The results
    of this should not be interpretted as *correct* for the font
    that they are part of. This merely indicates that the values
    are of the proper type and, where the specification defines
    a set range of possible values for an attribute, that the
    value is in the accepted range.
    zUnknown attribute %s.zInvalid value for attribute z (z).)rx   r”   r
   r=  )r˜   rŽ   r�   r<  s       r)   r‰   r‰   $  sk   € ð  —~‘~Ó'ò S‰ˆˆeØÔ1Ñ1ÜÐ6¸Ñ=Ó>Ð>ÜAÀ$ÈÓNˆÚÜÐ!=¸d¸VÀ2ÀeÀYÈbÐQÓRÐRðSð €Or*   c                ód  — t         j                  r,t        j                  | t        j                  d¬«      ¬«      }nt        j                  | «      }|j	                  «       }|j
                  dk7  rt        d«      ‚|j                  r(|j                  j                  «       dk7  rt        d«      ‚|S )NT©Úremove_comments©Úparserrî   ú#The GLIF is not properly formatted.Ú úInvalid GLIF structure.)	r   Ú
_have_lxmlÚparseÚ	XMLParserÚgetrootÚtagr
   r¬   r  )ÚaFiler­   r	  s      r)   Ú_glifTreeFromFilerM  <  s   € Ü×ÒÜ�{‰{˜5¬¯©ÈÔ)NÔO‰ä�{‰{˜5Ó!ˆØ�<‰<‹>€DØ‡x�x�7ÒÜÐ@ÓAÐAØ‡y‚y�T—Y‘Y—_‘_Ó&¨"Ò,ÜÐ4Ó5Ð5Ø€Kr*   c                óš  — t        | d¬«      }	 t        j                  r,t        j                  |t        j                  d¬«      ¬«      }nt        j                  |«      }|j                  dk7  rt        d«      ‚|j                  r(|j                  j                  «       d	k7  rt        d
«      ‚|S # t
        $ r}t        d«      |‚d }~ww xY w)Nr  )rö   Tr@  rB  zGLIF contains invalid XML.rî   rD  rE  rF  )
r   r   rG  Ú
fromstringrI  Ú	Exceptionr
   rK  r¬   r  )rè   r¹   r	  Úetree_exceptions       r)   r¨   r¨   I  s¯   € Ü�7 WÔ-€DðNÜ×ÒÜ×#Ñ# D´·±ÐQUÔ1VÔW‰Dä×#Ñ# DÓ)ˆDð ‡x�x�7ÒÜÐ@ÓAÐAØ‡y‚y�T—Y‘Y—_‘_Ó&¨"Ò,ÜÐ4Ó5Ð5Ø€Køô ò NÜÐ7Ó8¸oÐMûðNús   �AB0 Â0	C
Â9CÃC
c                óö  — | j                  d«      }|r|€t        d«      ‚| j                  dd«      }	 t        t        |«      t        |«      f«      }|r||vrt        d	|›�«      ‚	 t        |   } || ||||j                  ¬
«       y # t        $ rN}d|›d|›�}	|rddlm}
  |
|	«      |‚t        j                  «       }t        j                  d|	|«       Y d }~Œˆd }~ww xY w# t        $ r t        |«      ‚w xY w)Nrì   z#Unspecified format version in GLIF.rí   r   zUnsupported GLIF format: r§   r±   z_%s. Assuming the latest supported version (%s). Some data may be skipped or parsed incorrectly.zForbidden GLIF format version: )r­   r«   rC   r¥   rí   )r´   r
   r   r  rO   rP   r²   r%   ÚloggerÚwarningÚ_READ_GLYPH_FROM_TREE_FUNCSrÆ   ÚNotImplementedErrorrú   )r­   r«   rC   r¤   r¥   ÚformatVersionMajorÚformatVersionMinorr³   rs   Úmsgr²   ÚreadGlyphFromTrees               r)   r©   r©   Z  s$  € ð Ÿ™ (Ó+ÐÙÐ&Ð.ÜÐ@ÓAÐAØŸ™ -°Ó3Ðð
Ü)ÜÐ#Ó$¤cÐ*<Ó&=Ð>ó
ˆñ* �M¨Ñ7ÜÐ<¸]Ð<MÐNÓOÐOð1Ü7¸ÑFÐñ ØØØØØ!×'Ñ'öøô5 ó 
âÙð
ˆñ ÝEá'¨Ó,°!Ð3ä)×1Ñ1Ó3ˆÜ�‰ð>àØ÷		
ñ 	
ûð
ûô. ò 1Ü! -Ó0Ð0ð1ús$   ´B	 Á(	C# Â		C ÂACÃC Ã#C8c                óZ  — t        || |«       g }dx}x}x}}	| D �]f  }
|
j                  dk(  rk|rX|rt        d«      ‚|
j                  rt        d«      ‚|
j                  r(|
j                  j                  «       dk7  rt        d«      ‚d}t        |||
|«       Œ~|€Œ�|
j                  dk(  r|r|rt        d	«      ‚d}t        ||
«       Œ®|
j                  d
k(  rA|
j                  d«      }|€t        d«      ‚	 t        |d«      }||vr|j                  |«       Œþ|
j                  dk(  r|r|	rt        d«      ‚d}	t        ||
«       �Œ,|
j                  dk(  r |r|rt        d«      ‚d}t        ||
|«       �Œ[t        d|
z  «      ‚ |rt        |d|«       y y # t        $ r t        d«      ‚w xY w)NFró   ú*The outline element occurs more than once.ú0The outline element contains unknown attributes.rE  úInvalid outline structure.Tr  ú*The advance element occurs more than once.r  r  ú8A unicode element is missing its required hex attribute.é   ú3Illegal value for hex attribute of unicode element.rï   ú'The note element occurs more than once.r“   ú&The lib element occurs more than once.úUnknown element in GLIF: %srÌ   )Ú	_readNamerK  r
   Úattribr¬   r  ÚbuildOutlineFormat1Ú_readAdvancer´   r  r3  rO   Ú	_readNoteÚ_readLibÚ_relaxedSetattr)r­   r«   rC   r¥   ÚkwargsrÌ   ÚhaveSeenAdvanceÚhaveSeenOutlineÚhaveSeenLibÚhaveSeenNoter  r�   s               r)   Ú_readGlyphFromTreeFormat1rr  �  sÚ  € ô ˆk˜4 Ô*à€HØEJÐJ€OÐJ�oÐJ¨°lØó -HˆØ�;‰;˜)Ò#ÙÙ"Ü&Ð'SÓTÐTØ—>’>Ü&ØJóð ð —<’< G§L¡L×$6Ñ$6Ó$8¸BÒ$>Ü&Ð'CÓDÐDØ"ˆOÜ ¨X°wÀÕIØÐ ØØ�[‰[˜IÒ%Ù™OÜ"Ð#OÓPÐPØ"ˆOÜ˜ gÕ.Ø�[‰[˜IÒ%Ø—‘˜EÓ"ˆAØˆyÜ"ØNóð ðÜ˜˜2“J�Ø˜HÑ$Ø—O‘O AÔ&øð
 �[‰[˜FÒ"Ù™LÜ"Ð#LÓMÐMØˆLÜ�k 7Ö+Ø�[‰[˜EÒ!Ù™KÜ"Ð#KÓLÐLØˆKÜ�[ '¨8Ö4äÐ<¸wÑFÓGÐGð[-Hñ^ Ü˜ Z°Õ:ð øô# ò Ü"ØIóð ðús   Ã6!FÆF*c                ór  — t        || |«       g }g }g }dx}x}	x}
x}}t        «       }| D �]’  }|j                  dk(  ro|rX|
rt        d«      ‚|j                  rt        d«      ‚|j
                  r(|j
                  j                  «       dk7  rt        d«      ‚d}
|€Œrt        |||||«       Œ‚|€Œ…|j                  dk(  r|r|rt        d	«      ‚d}t        ||«       Œ²|j                  d
k(  rB|j                  d«      }|€t        d«      ‚	 t        |d«      }||vr|j                  |«       �Œ|j                  dk(  r]|rt        |«      rt        d«      ‚t        |j                  «      }dD ]  }||v sŒt        ||   «      ||<   Œ |j                  |«       �Œo|j                  dk(  rg|rt        |«      rt        d«      ‚t        |j                  «      }dD ]"  }||j                  v sŒt        ||   «      ||<   Œ$ |j                  |«       �Œå|j                  dk(  r6|r#|	rt        d«      ‚t        |«      rt        d«      ‚d}	t!        |||«       �Œ*|j                  dk(  r|r|rt        d«      ‚d}t#        ||«       �ŒX|j                  dk(  r |r|rt        d«      ‚d}t%        |||«       �Œ‡t        d|z  «      ‚ |rt'        |d|«       |r&|rt)        ||«      st        d«      ‚t'        |d|«       |r'|rt+        ||«      st        d «      ‚t'        |d!|«       y y # t        $ r t        d«      ‚w xY w)"NFró   r\  r]  rE  r^  Tr  r_  r  r  r`  ra  rb  r&  z&Unknown children in guideline element.)r!  r"  r#  r.  z#Unknown children in anchor element.©r!  r"  rð   z(The image element occurs more than once.z"Unknown children in image element.rï   rc  r“   rd  re  rÌ   z(The guidelines are improperly formatted.rñ   z%The anchors are improperly formatted.rò   )rf  rå   rK  r
   rg  r¬   r  ÚbuildOutlineFormat2ri  r´   r  r3  rO   rÃ   rw   Ú_numberÚ
_readImagerj  rk  rl  r   r   )r­   r«   rC   r¥   rí   rÌ   rñ   rò   rn  ÚhaveSeenImagero  rp  rq  rô   r  r�   rg  rŽ   s                     r)   Ú_readGlyphFromTreeFormat2ry  È  sm  € ô ˆk˜4 Ô*à€HØ€JØ€Gàð€Oð �mð  oð ¸Àlô “%€KØó HHˆØ�;‰;˜)Ò#ÙÙ"Ü&Ð'SÓTÐTØ—>’>Ü&ØJóð ð —<’< G§L¡L×$6Ñ$6Ó$8¸BÒ$>Ü&Ð'CÓDÐDØ"ˆOØÑ#Ü#Ø ¨7°KÀõð Ð ØØ�[‰[˜IÒ%Ù™OÜ"Ð#OÓPÐPØ"ˆOÜ˜ gÕ.Ø�[‰[˜IÒ%Ø—‘˜EÓ"ˆAØˆyÜ"ØNóð ðÜ˜˜2“J�Ø˜HÑ$Ø—O‘O AÔ&ùð
 �[‰[˜KÒ'ÙœC œLÜ"Ð#KÓLÐLÜ˜'Ÿ.™.Ó)ˆFØ+ò 9�Ø˜6’>Ü#*¨6°$©<Ó#8�F˜4’Lð9ð ×Ñ˜fÖ%Ø�[‰[˜HÒ$ÙœC œLÜ"Ð#HÓIÐIÜ˜'Ÿ.™.Ó)ˆFØ"ò 9�Ø˜7Ÿ>™>Ò)Ü#*¨6°$©<Ó#8�F˜4’Lð9ð �N‰N˜6Ö"Ø�[‰[˜GÒ#ÙÙ Ü&Ð'QÓRÐRÜ�w”<Ü&Ð'KÓLÐLØ ˆMÜ�{ G¨XÖ6Ø�[‰[˜FÒ"Ù™LÜ"Ð#LÓMÐMØˆLÜ�k 7Ö+Ø�[‰[˜EÒ!Ù™KÜ"Ð#KÓLÐLØˆKÜ�[ '¨8Ö4äÐ<¸wÑFÓGÐGðQHHñT Ü˜ Z°Ô:áÙÔ/°
¸KÔHÜÐIÓJÐJÜ˜ \°:Ô>áÙÔ,¨W°kÔBÜÐFÓGÐGÜ˜ Y°Õ8ð øôc ò Ü"ØIóð ðús   Ä
!L!Ì!L6c                ój   — |j                  d«      }|r|st        d«      ‚|r| �t        | d|«       y y y )Nr{   zEmpty glyph name in GLIF.)r´   r
   rl  )r«   r	  r¥   r;   s       r)   rf  rf  3  s<   € Ø—‘˜Ó €IÙ™	ÜÐ6Ó7Ð7Ù�[Ð,Ü˜ V¨YÕ7ð -€yr*   c                ó¤   — t        |j                  dd«      «      }t        | d|«       t        |j                  dd«      «      }t        | d|«       y )Nr  r   r  )rv  r´   rl  )r«   r  r  r  s       r)   ri  ri  ;  sD   € Ü�G—K‘K ¨Ó+Ó,€EÜ�K ¨%Ô0Ü�W—[‘[ ¨1Ó-Ó.€FÜ�K ¨6Õ2r*   c                ó„   — |j                   j                  d«      }dj                  d„ |D «       «      }t        | d|«       y )Nr  c              3  ó^   K  — | ]%  }|j                  «       sŒ|j                  «       –— Œ' y ­wr!   )r  )Ú.0Úlines     r)   ú	<genexpr>z_readNote.<locals>.<genexpr>D  s   è ø€ ÒD d°t·z±zµ|�T—Z‘Z—\ÑDùs   ‚-˜-rï   )r¬   ÚsplitÚjoinrl  )r«   rï   Úliness      r)   rj  rj  B  s4   € Ø�I‰I�O‰O˜DÓ!€EØ�9‰9ÑD¨eÔDÓD€DÜ�K ¨Õ.r*   c                ó¬   — t        |«      dk(  sJ ‚|d   }t        j                  |«      }|rt        |«      \  }}|st	        |«      ‚t        | d|«       y )Nr   r   r“   )rÃ   r   Úfromtreer   r
   rl  )r«   r“   r¥   ÚchildÚplistr4  r5  s          r)   rk  rk  H  sV   € Üˆs‹8�qŠ=Ðˆ=Ø�‰F€EÜ×Ñ˜eÓ$€EÙÜ*¨5Ó1‰ˆˆwÙÜ˜wÓ'Ð'Ü�K ¨Õ.r*   c                óÔ   — t        |j                  «      }t        D ]%  \  }}|j                  ||«      }t	        |«      ||<   Œ' |rt        |«      st        d«      ‚t        | d|«       y )Nz,The image element is not properly formatted.rð   )rw   rg  r  r´   rv  r   r
   rl  )r«   rð   r¥   Ú	imageDatarŽ   r%   r�   s          r)   rw  rw  S  sd   € Ü�U—\‘\Ó"€IÜ,ò )‰ˆˆgØ—‘˜d GÓ,ˆÜ! %›.ˆ	�$Šð)ñ œ yÔ1ÜÐIÓJÐJÜ�K ¨)Õ4r*   r$  >   rZ   ÚxScaleÚyScaleÚxOffsetÚxyScaleÚyOffsetÚyxScale>   r!  r"  r{   r_   ÚsmoothÚnoÚyes>   r  r)  ÚcurveÚqcurveÚoffcurvec                óŠ  — g }|D ]‘  }|j                   dk(  rSt        |«      dk(  r4|d   }|j                   dk(  r t        ||«      }|�|j                  |«       ŒT|€ŒWt	        |||«       Œe|j                   dk(  r|€Œwt        |||«       Œ…t        d|z  «      ‚ | �)|r&|rt        |«      st        d«      ‚t        | d|«       y y y )	NÚcontourr   r   ÚpointÚ	componentú&Unknown element in outline element: %sz*GLIF 1 anchors are not properly formatted.rò   )	rK  rÃ   Ú_buildAnchorFormat1r3  Ú_buildOutlineContourFormat1Ú_buildOutlineComponentFormat1r
   r   rl  )r«   rB   ró   r¥   rò   r  r˜  r.  s           r)   rh  rh  t  sÚ   € Ø€GØò SˆØ�;‰;˜)Ò#Ü�7‹|˜qÒ Ø ™
�Ø—9‘9 Ò'Ü0°¸ÓA�FØÐ)ØŸ™ vÔ.Ø Ø‰Ü+¨C°¸(ÕCØ�[‰[˜KÒ'Ø‰Ü-¨c°7¸HÕEäÐGÈ'ÑQÓRÐRðSð  Ð¡7ÙÔ,¨WÔ5ÜÐKÓLÐLÜ˜ Y°Õ8ð $+Ðr*   c                ó   — | j                  d«      dk7  ry | j                  d«      }|€y | j                  d«      }| j                  d«      }|r|€t        d«      ‚|r|€t        d«      ‚t        |«      }t        |«      }t        |||¬«      }|S )	Nr_   r)  r{   r!  r"  z1Required x attribute is missing in point element.z1Required y attribute is missing in point element.)r!  r"  r{   )r´   r
   rv  rw   )r˜  r¥   r{   r!  r"  r.  s         r)   r›  r›  Œ  s‘   € Ø‡y�y�Ó˜FÒ"ØØ�9‰9�VÓ€DØ€|ØØ�	‰	�#‹€AØ�	‰	�#‹€AÙ�A�IÜÐNÓOÐOÙ�A�IÜÐNÓOÐOÜ�‹
€AÜ�‹
€AÜ�A˜ Ô&€FØ€Mr*   c                óÊ   — |r|j                   rt        d«      ‚| j                  «        t        |«      rt	        |t
        d|¬«      }t        | |«       | j                  «        y )Nz&Unknown attributes in contour element.T)ÚopenContourOffCurveLeniencyr¥   )rg  r
   r+  rÃ   Ú"_validateAndMassagePointStructuresÚpointAttributesFormat1Ú_buildOutlinePointsFormat1r-  )rB   r—  r¥   Úmassageds       r)   rœ  rœ  ž  sR   € Ù�G—N’NÜÐCÓDÐDØ‡M�M„OÜ
ˆ7„|Ü5ØÜ"Ø(,Øô	
ˆô 	# 3¨Ô1Ø‡K�K…Mr*   c                ór   — |D ]2  }|d   }|d   }|d   }|d   }|d   }| j                  ||f|||¬«       Œ4 y )Nr!  r"  r*  r�  r{   ©r*  r�  r{   )r,  )rB   r—  r˜  r!  r"  r*  r�  r{   s           r)   r£  r£  ­  sY   € Øò PˆØ�#‰JˆØ�#‰JˆØ˜MÑ*ˆØ�x‘ˆØ�V‰}ˆØ�‰�a˜�V¨¸VÈ$ˆÕOñPr*   c                ó˜  — |rKt        |«      rt        d«      ‚|j                  j                  «       D ]  }|t        vsŒt        d|z  «      ‚ |j                  d«      }|r|€t        d«      ‚g }t        D ]7  \  }}|j                  |«      }|€|}nt        |«      }|j                  |«       Œ9 | j                  |t        |«      «       y )Nú,Unknown child elements of component element.ú*Unknown attribute in component element: %srZ   ú3The base attribute is not defined in the component.)rÃ   r
   rg  r•   ÚcomponentAttributesFormat1r´   r  rv  r3  ÚaddComponentÚtuple)rB   r™  r¥   rŽ   ÚbaseGlyphNameÚtransformationr%   r�   s           r)   r�  r�  ·  sÕ   € ÙÜˆyŒ>ÜÐMÓNÐNØ×$Ñ$×)Ñ)Ó+ò 	XˆDØÔ5Ò5Ü"Ð#OÐRVÑ#VÓWÐWð	Xð —M‘M &Ó)€MÙ�MÐ)ÜÐPÓQÐQØ€NÜ,ò %‰ˆˆgØ—‘˜dÓ#ˆØˆ=Ø‰Eä˜E“NˆEØ×Ñ˜eÕ$ð%ð ×Ñ�]¤E¨.Ó$9Õ:r*   c                ó¸   — |D ]U  }|j                   dk(  rt        ||||«       Œ!|j                   dk(  rt        ||||«       Œ?t        d|j                   z  «      ‚ y )Nr—  r™  rš  )rK  Ú_buildOutlineContourFormat2Ú_buildOutlineComponentFormat2r
   )r«   rB   ró   rô   r¥   r  s         r)   ru  ru  Ï  s\   € Øò WˆØ�;‰;˜)Ò#Ü'¨¨W°kÀ8ÕLØ�[‰[˜KÒ'Ü)¨#¨w¸ÀXÕNäÐGÈ'Ï+É+ÑUÓVÐVñWr*   c                ó  — |r5|j                   j                  «       D ]  }|t        vsŒt        d|z  «      ‚ |j	                  d«      }|�>|r+||v rt        d|z  «      ‚t        |«      st        d|z  «      ‚|j                  |«       	 | j                  |¬«       t        |«      r t        |t        |¬«      }t        | |||«       | j                  «        y # t        $ r# | j                  «        t        dt        «       Y Œgw xY w)Nz(Unknown attribute in contour element: %sr$  ú)The identifier %s is used more than once.z'The contour identifier %s is not valid.©r$  zbThe beginPath method needs an identifier kwarg. The contour's identifier value has been discarded.)r¥   )rg  r•   ÚcontourAttributesFormat2r
   r´   r   r.   r+  r^   r   ÚDeprecationWarningrÃ   r¡  ÚpointAttributesFormat2Ú_buildOutlinePointsFormat2r-  )rB   r—  rô   r¥   rŽ   r$  r¤  s          r)   r±  r±  Ù  s  € ÙØ—N‘N×'Ñ'Ó)ò 	VˆDØÔ3Ò3Ü"Ð#MÐPTÑ#TÓUÐUð	Vð —‘˜\Ó*€JØÐÙØ˜[Ñ(Ü"Ø?À*ÑLóð ô ' zÔ2Ü"Ø=À
ÑJóð ð 	�‰˜
Ô#ð
Ø�‰ ˆÔ,ô ˆ7„|Ü5ØÔ+°hô
ˆô 	# 3¨°+¸xÔHØ‡K�K…Møô ò 
Ø�‰ŒÜØpÜö	
ð
ús   Â
C Ã)DÄDc                ó„  — |D ]…  }|d   }|d   }|d   }|d   }|d   }	|j                  d«      }
|
�>|r+|
|v rt        d|
z  «      ‚t        |
«      st        d|
z  «      ‚|j                  |
«       	 | j	                  ||f|||	|
¬	«       Œ‡ y # t
        $ r* | j	                  ||f|||	¬
«       t        dt        «       Y Œ»w xY w)Nr!  r"  r*  r�  r{   r$  r´  úThe identifier %s is not valid.)r*  r�  r{   r$  r¦  z_The addPoint method needs an identifier kwarg. The point's identifier value has been discarded.)r´   r
   r   r.   r,  r^   r   r·  )rB   r—  rô   r¥   r˜  r!  r"  r*  r�  r{   r$  s              r)   r¹  r¹  ú  sú   € Øò ˆØ�#‰JˆØ�#‰JˆØ˜MÑ*ˆØ�x‘ˆØ�V‰}ˆØ—Y‘Y˜|Ó,ˆ
ØÐ!ÙØ Ñ,Ü&ØCÀjÑPóð ô +¨:Ô6Ü&Ð'HÈ:Ñ'UÓVÐVØ�O‰O˜JÔ'ð	Ø�L‰LØ�A�Ø'ØØØ%ð õ ñ#øô0 ò 	Ø�L‰L˜!˜Q˜¨[ÀÈdˆLÔSÜØqÜ"öð	ús   Á1BÂ0B?Â>B?c                ó¸  — |rKt        |«      rt        d«      ‚|j                  j                  «       D ]  }|t        vsŒt        d|z  «      ‚ |j                  d«      }|r|€t        d«      ‚g }t        D ]7  \  }}|j                  |«      }|€|}nt        |«      }|j                  |«       Œ9 |j                  d«      }	|	�@|r-|	|v rt        d|	z  «      ‚|rt        |	«      st        d|	z  «      ‚|j                  |	«       	 | j                  |t        |«      |	¬«       y # t        $ r. | j                  |t        |«      «       t        d	t        «       Y y w xY w)
Nr¨  r©  rZ   rª  r$  r´  r»  rµ  zgThe addComponent method needs an identifier kwarg. The component's identifier value has been discarded.)rÃ   r
   rg  r•   ÚcomponentAttributesFormat2r´   r  rv  r3  r   r.   r¬  r­  r^   r   r·  )
rB   r™  rô   r¥   rŽ   r®  r¯  r%   r�   r$  s
             r)   r²  r²    so  € ÙÜˆyŒ>ÜÐMÓNÐNØ×$Ñ$×)Ñ)Ó+ò 	XˆDØÔ5Ò5Ü"Ð#OÐRVÑ#VÓWÐWð	Xð —M‘M &Ó)€MÙ�MÐ)ÜÐPÓQÐQØ€NÜ,ò %‰ˆˆgØ—‘˜dÓ#ˆØˆ=Ø‰Eä˜E“NˆEØ×Ñ˜eÕ$ð%ð —‘˜|Ó,€JØÐÙØ˜[Ñ(Ü"Ø?À*ÑLóð ñ Ô 3°JÔ ?Ü"Ð#DÀzÑ#QÓRÐRØ�‰˜
Ô#ð
Ø×Ñ˜¬¨nÓ(=È*ÐÕUøÜò 
Ø×Ñ˜¬¨nÓ(=Ô>ÜØuÜö	
ð
ús   ÄD" Ä"4EÅEc                ó|  — t        | «      sy d }d}g }t        | «      D �][  \  }}|j                  dk7  rt        d|j                  z  «      ‚t	        |j
                  «      }	|j                  |	«       |r=|	j                  «       D ]  }
|
|vsŒt        d|
z  «      ‚ t        |«      rt        d«      ‚dD ]  }
	 t        |	|
   «      |	|
<   Œ |	j                  d	d
«      }|r|t        vrt        d|z  «      ‚|d
k(  rd }||	d<   |€d}n|}|r|dk(  r|dk7  rt        d«      ‚|	j                  dd«      }|r|�|t        vrt        d|z  «      ‚|dk(  }||	d<   |r|r|€t        d«      ‚d|j
                  vs�ŒWd |	d<   �Œ^ |r1|d   d   dk(  r&d}t        |«      D ]  }	|	d   €|dz  }Œ n |r|d |  }|ri|rg|�et        |«      dz
  |z
  }|D ]O  }	|	d   }|€|dz  }Œ|r<|dk(  rt        d«      ‚|dk(  rt        d«      ‚|dk(  r|dkD  rt        d«      ‚|dk(  rn	 d}ŒQ |S # t        $ r}t        d|
› d�«      |‚d }~ww xY w)NFr˜  z.Unknown child element (%s) of contour element.z&Unknown attribute in point element: %sz(Unknown child elements in point element.rt  z	Required z' attribute is missing in point element.r_   r•  zUnknown point type: %sr*  Tr)  r   z9A move point occurs after the first point in the contour.r�  r‘  zUnknown point smooth value: %sr’  z*smooth attribute set in an offcurve point.r{   r   zmove can not have an offcurve.r  zline can not have an offcurve.r“  r   z%Too many offcurves defined for curve.r”  )rÃ   Ú	enumeraterK  r
   rw   rg  r3  r•   rv  rÆ   ÚpopÚpointTypeOptionsr´   ÚpointSmoothOptionsÚreversed)r—  ÚpointAttributesr   r¥   ÚlastOnCurvePointÚhaveOffCurvePointr¤  Úindexr  r˜  rŽ   rs   Ú	pointTyper�  ÚcountÚoffCurvesCountr*  s                    r)   r¡  r¡  D  s
  € ô ˆwŒ<ØàÐØÐà€HÜ# GÓ,ó 4!‰ˆˆwà�;‰;˜'Ò!ÜØ@À7Ç;Á;ÑNóð ô �W—^‘^Ó$ˆØ�‰˜ÔÙàŸ
™
›ò X�Ø˜Ò.Ü&Ð'OÐRVÑ'VÓWÐWðXô �7Œ|Ü"Ð#MÓNÐNàò 	ˆDðÜ% e¨D¡kÓ2��d’ð	ð —I‘I˜f jÓ1ˆ	Ù˜	Ô)9Ñ9ÜÐ7¸)ÑCÓDÐDØ˜
Ò"ØˆIØ(ˆˆmÑØÐØ $Ñà$Ðá˜	 VÒ+°¸²
ÜØKóð ð —‘˜8 TÓ*ˆÙ˜Ð*ØÔ/Ñ/Ü"Ð#CÀfÑ#LÓMÐMØ˜5‘ˆØ ˆˆh‰á™ 9Ð#4ÜÐKÓLÐLà˜Ÿ™Ó'Ø ˆE�&‹Mði4!ñj #ð �A‰;�}Ñ%¨Ò/ØˆEÜ! (Ó+ò �Ø˜Ñ'Ð/Ø˜Q‘J‘Eáð	ñ
 Ø# G e VÐ,�áÑ%Ð*:Ð*Fô ˜X›¨Ñ*Ð-=Ñ=ˆØò 	#ˆEØ Ñ.ˆKØÐ"Ø !Ñ#‘á!à" fÒ,ä*Ð+KÓLÐLØ$¨Ò.Ü*Ð+KÓLÐLØ$¨Ò/Ø)¨AÒ-Ü".Ð/VÓ"WÐWØ$¨Ò0Øð Ø!"‘ð)	#ð* €OøôO ò Ü"Ø ˜vÐ%LÐMóàðûðús   Â7HÈ	H;È&H6È6H;c                ó>   — 	 t        | ||«       y # t        $ r Y y w xY wr!   )rŠ   r‹   )ÚobjectrŽ   r�   s      r)   rl  rl  ±  s%   € ðÜ�˜˜eÕ$øÜò Ùðús   ‚ �	›c                óŽ   — 	 t        | «      }|S # t        $ r Y nw xY w	 t        | «      }|S # t        $ r t        d| z  «      ‚w xY w)a›  
    Given a numeric string, return an integer or a float, whichever
    the string indicates. _number("1") will return the integer 1,
    _number("1.0") will return the float 1.0.

    >>> _number("1")
    1
    >>> _number("1.0")
    1.0
    >>> _number("a")  # doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
        ...
    GlifLibError: Could not convert a to an int or float.
    z(Could not convert %s to an int or float.)r  rO   Úfloatr
   )ÚsÚns     r)   rv  rv  ¸  s]   € ðÜ�‹FˆØˆøÜò ÙðúðKÜ�!‹HˆØˆøÜò KÜÐEÈÑIÓJÐJðKús   ‚ �	šŸ, ¬Ac                  ó   — e Zd Zy)Ú_DoneParsingN)r2   r3   r4   rH   r*   r)   rÒ  rÒ  Ú  s   „ Ør*   rÒ  c                  ó$   — e Zd Zd„ Zd„ Zd„ Zd„ Zy)Ú_BaseParserc                ó   — g | _         y r!   )Ú_elementStackr…   s    r)   r>   z_BaseParser.__init__ß  s
   € ØˆÕr*   c                ó†   — ddl m}  |«       }| j                  |_        | j                  |_        |j                  |d«       y )Nr   )ÚParserCreater   )Úxml.parsers.expatrØ  ÚstartElementHandlerÚStartElementHandlerÚendElementHandlerÚEndElementHandlerÚParse)r=   r¬   rØ  rC  s       r)   rH  z_BaseParser.parseâ  s6   € Ý2á“ˆØ%)×%=Ñ%=ˆÔ"Ø#'×#9Ñ#9ˆÔ Ø�‰�T˜1Õr*   c                ó:   — | j                   j                  |«       y r!   )rÖ  r3  )r=   r{   r  s      r)   rÚ  z_BaseParser.startElementHandlerê  s   € Ø×Ñ×!Ñ! $Õ'r*   c                óH   — | j                   j                  d«      }||k(  sJ ‚y )NrN   )rÖ  rÀ  )r=   r{   Úothers      r)   rÜ  z_BaseParser.endElementHandlerí  s$   € Ø×"Ñ"×&Ñ& rÓ*ˆØ˜Š}Ð‰}r*   N)r2   r3   r4   r>   rH  rÚ  rÜ  rH   r*   r)   rÔ  rÔ  Þ  s   „ ò òò(ór*   rÔ  c                óP   — t        «       }|j                  | «       |j                  S )z0
    Get a list of unicodes listed in glif.
    )Ú_FetchUnicodesParserrH  rÌ   ©ÚglifrC  s     r)   rÊ   rÊ   õ  s"   € ô "Ó#€FØ
‡L�L�ÔØ�?‰?Ðr*   c                  ó(   ‡ — e Zd Zˆ fd„Zˆ fd„Zˆ xZS )rã  c                ó0   •— g | _         t        ‰| �	  «        y r!   )rÌ   r$   r>   ©r=   r(   s    €r)   r>   z_FetchUnicodesParser.__init__ÿ  s   ø€ ØˆŒÜ‰ÑÕr*   c                ó  •— |dk(  rg| j                   r[| j                   d   dk(  rI|j                  d«      }|�6	 t        |d«      }|| j                  vr| j                  j	                  |«       t        ‰| �  ||«       y # t
        $ r Y Œw xY w)Nr  rN   rî   r  ra  )rÖ  r´   r  rÌ   r3  rO   r$   rÚ  )r=   r{   r  r�   r(   s       €r)   rÚ  z(_FetchUnicodesParser.startElementHandler  sŽ   ø€ à�IÒØ×"Ò"Ø×"Ñ" 2Ñ&¨'Ò1à—I‘I˜eÓ$ˆEØÐ ðÜ  r›N�EØ D§M¡MÑ1ØŸ™×,Ñ,¨UÔ3ô 	‰Ñ# D¨%Õ0øô "ò Ùðús   ¹5A? Á?	BÂ
B©r2   r3   r4   r>   rÚ  r6   r7   s   @r)   rã  rã  þ  s   ø„ ô÷1ð 1r*   rã  c                ó†   — t        «       }	 |j                  | «       |j                  S # t        $ r Y |j                  S w xY w)z1
    The image file name (if any) from glif.
    )Ú_FetchImageFileNameParserrH  rÒ  r|   rä  s     r)   rÓ   rÓ     sG   € ô 'Ó(€FðØ�‰�TÔð �?‰?Ðøô ò ØØ�?‰?Ððús   Œ) ©	A ¿A c                  ó(   ‡ — e Zd Zˆ fd„Zˆ fd„Zˆ xZS )rì  c                ó0   •— d | _         t        ‰| �	  «        y r!   )r|   r$   r>   rè  s    €r)   r>   z"_FetchImageFileNameParser.__init__$  s   ø€ ØˆŒÜ‰ÑÕr*   c                ó¤   •— |dk(  r:| j                   r.| j                   d   dk(  r|j                  d«      | _        t        ‚t        ‰| �  ||«       y )Nrð   rN   rî   r|   )rÖ  r´   r|   rÒ  r$   rÚ  )r=   r{   r  r(   s      €r)   rÚ  z-_FetchImageFileNameParser.startElementHandler(  sJ   ø€ Ø�7Š?˜t×1Ò1°d×6HÑ6HÈÑ6LÐPWÒ6WØ!ŸI™I jÓ1ˆDŒMÜÐÜ‰Ñ# D¨%Õ0r*   rê  r7   s   @r)   rì  rì  #  s   ø„ ô÷1ð 1r*   rì  c                ó‚   — t        «       }	 |j                  | «       t        |j                  «      S # t        $ r Y Œ w xY w)z=
    Get a list of component base glyphs listed in glif.
    )Ú_FetchComponentBasesParserrH  rÒ  r¾   Úbasesrä  s     r)   rÏ   rÏ   2  sB   € ô (Ó)€FðØ�‰�TÔô �—‘ÓÐøô ò Ùðús   Œ2 ²	>½>c                  ó2   ‡ — e Zd Zˆ fd„Zˆ fd„Zˆ fd„Zˆ xZS )rñ  c                ó0   •— g | _         t        ‰| �	  «        y r!   )rò  r$   r>   rè  s    €r)   r>   z#_FetchComponentBasesParser.__init__?  s   ø€ ØˆŒ
Ü‰ÑÕr*   c                óÈ   •— |dk(  rL| j                   r@| j                   d   dk(  r.|j                  d«      }|�| j                  j                  |«       t        ‰| �  ||«       y )Nr™  rN   ró   rZ   )rÖ  r´   rò  r3  r$   rÚ  )r=   r{   r  rZ   r(   s       €r)   rÚ  z._FetchComponentBasesParser.startElementHandlerC  s\   ø€ à�KÒØ×"Ò"Ø×"Ñ" 2Ñ&¨)Ò3à—9‘9˜VÓ$ˆDØÐØ—
‘
×!Ñ! $Ô'Ü‰Ñ# D¨%Õ0r*   c                ó:   •— |dk(  rt         ‚t        ‰| �	  |«       y )Nró   )rÒ  r$   rÜ  )r=   r{   r(   s     €r)   rÜ  z,_FetchComponentBasesParser.endElementHandlerN  s   ø€ Ø�9ÒÜÐÜ‰Ñ! $Õ'r*   )r2   r3   r4   r>   rÚ  rÜ  r6   r7   s   @r)   rñ  rñ  >  s   ø„ ôô	1÷(ð (r*   rñ  ))rŠ  r   )r�  r   )r�  r   )r‹  r   )rŒ  r   )rŽ  r   c                  ó8   — e Zd ZdZdd„Zd	d„Zd„ Z	 d
d„Zd	d„Zy)r  zb
    Helper class using the PointPen protocol to write the <outline>
    part of .glif files.
    Nc                ó�   — |€
t        «       }t        |«      | _        || _        || _        d | _        d| _        g | _        || _        y )Nr   )	rå   r   r³   rô   ró   r—  ÚprevOffCurveCountÚprevPointTypesr¥   )r=   r  r³   rô   r¥   s        r)   r>   zGLIFPointPen.__init__i  sI   € ØÐÜ›%ˆKÜ.¨}Ó=ˆÔØ&ˆÔØˆŒØˆŒØ!"ˆÔØ ˆÔØ ˆ�r*   c                ój  — t        «       }|�z| j                  j                  dk\  ra| j                  r5|| j                  v rt        d|z  «      ‚t        |«      st        d|z  «      ‚||d<   | j                  j                  |«       t        j                  | j                  d|«      | _        d| _        y )Nr   r%  ú%identifier not formatted properly: %sr$  r—  r   )r   r³   rh   r¥   rô   r
   r   r.   r   r  ró   r—  rù  )r=   r$  rm  r  s       r)   r+  zGLIFPointPen.beginPatht  s­   € Ü“ˆØÐ! d×&8Ñ&8×&>Ñ&>À!Ò&CØ�}Š}Ø ×!1Ñ!1Ñ1Ü&Ø<¸zÑIóð ô +¨:Ô6Ü&Ø?À*ÑLóð ð #-ˆE�,ÑØ×Ñ× Ñ  Ô,Ü×'Ñ'¨¯©°iÀÓGˆŒØ!"ˆÕr*   c                ó  — | j                   r;| j                   d   dk(  r)| j                  r| j                   d   dk(  rt        d«      ‚t        | j                  «      sd| j                  _        d | _        d | _        d| _        g | _         y )Nr   r)  rN   r•  z%open contour has loose offcurve pointrõ   )rú  r¥   r
   rÃ   r—  r¬   ÚprevPointTyperù  r…   s    r)   r-  zGLIFPointPen.endPath…  sy   € Ø×Ò 4×#6Ñ#6°qÑ#9¸VÒ#CØ�}Š} ×!4Ñ!4°RÑ!8¸JÒ!FÜ"Ð#JÓKÐKä�4—<‘<Ô Ø &ˆD�L‰LÔØˆŒØ!ˆÔØ!"ˆÔØ ˆÕr*   c                óÔ  — t        «       }|�P| j                  r"|D ]  }t        |t        «      rŒt	        d«      ‚ t        |d   «      |d<   t        |d   «      |d<   |dk(  rd }| j                  rk|dk(  r| j                  rt	        d«      ‚|d	v r,| j                  r | j                  d
   dk(  rt	        d|z  «      ‚|dk(  r| j                  dkD  rt	        d«      ‚|�||d<   nd}|dk(  r| xj                  dz  c_        nd| _        | j                  j                  |«       |r!| j                  r|dk(  rt	        d«      ‚d|d<   |�||d<   |�z| j                  j                  dk\  ra| j                  r5|| j                  v rt	        d|z  «      ‚t        |«      st	        d|z  «      ‚||d<   | j                  j                  |«       t        j                  | j                   d|«       y )Nz coordinates must be int or floatr   r!  r   r"  r•  r)  z@move occurs after a point has already been added to the contour.)r)  r  rN   z offcurve occurs before %s point.r“  r   z,too many offcurve points before curve point.r_   z&can't set smooth in an offcurve point.r’  r�  r{   r%  rü  r$  r˜  )r   r¥   rR   r   r
   rù   rú  rù  r3  r³   rh   rô   r   r.   r   r  r—  )	r=   Úptr*  r�  r{   r$  rm  r  Úcoords	            r)   r,  zGLIFPointPen.addPoint‘  s  € ô “ˆàˆ>Ø�}Š}Øò O�EÜ% e¬[Õ9Ü*Ð+MÓNÐNðOô ˜b ™e›ˆE�#‰JÜ˜b ™e›ˆE�#‰Jà˜*Ò$ØˆKØ�=Š=Ø˜fÒ$¨×)<Ò)<Ü"ØVóð ð Ð/Ñ/Ø×'Ò'Ø×'Ñ'¨Ñ+¨zÒ9ä"Ð#EÈÑ#SÓTÐTØ˜gÒ%¨$×*@Ñ*@À1Ò*DÜ"Ð#QÓRÐRØÐ"Ø'ˆE�&ŠMà$ˆKØ˜*Ò$Ø×"Ò" aÑ'Ö"à%&ˆDÔ"Ø×Ñ×"Ñ" ;Ô/áØ�}Š} °
Ò!:Ü"Ð#KÓLÐLØ#ˆE�(‰OàÐØ ˆE�&‰MàÐ! d×&8Ñ&8×&>Ñ&>À!Ò&CØ�}Š}Ø ×!1Ñ!1Ñ1Ü&Ø<¸zÑIóð ô +¨:Ô6Ü&Ø?À*ÑLóð ð #-ˆE�,ÑØ×Ñ× Ñ  Ô,Ü×Ñ˜Ÿ™ w°Õ6r*   c                ó  — t        d|fg«      }t        t        |«      D ]C  \  \  }}}| j                  rt	        |t
        «      st        d«      ‚||k7  sŒ6t        |«      ||<   ŒE |�†| j                  j                  dk\  rm| j                  rA|| j                  v rt        d|z  «      ‚| j                  rt        |«      st        d|z  «      ‚||d<   | j                  j                  |«       t        j                  | j                  d|«       y )NrZ   z*transformation values must be int or floatr   r%  rü  r$  r™  )r   Úzipr  r¥   rR   r   r
   rù   r³   rh   rô   r   r.   r   r  ró   )	r=   r;   r¯  r$  rm  r  rŽ   r%   r�   s	            r)   r¬  zGLIFPointPen.addComponentÍ  s  € Ü˜f iÐ0Ð1Ó2ˆÜ&)Ô*=¸~Ó&Nò 	*Ñ"‰OˆT�7˜UØ�}Š}¤Z°´{Ô%CÜ"Ð#OÓPÐPØ˜ÓÜ" 5›k��d’ð		*ð
 Ð! d×&8Ñ&8×&>Ñ&>À!Ò&CØ�}Š}Ø ×!1Ñ!1Ñ1Ü&Ø<¸zÑIóð ð —=’=Ô)<¸ZÔ)HÜ&Ø?À*ÑLóð ð #-ˆE�,ÑØ×Ñ× Ñ  Ô,Ü×Ñ˜Ÿ™ {°EÕ:r*   )NNTr!   rà   )	r2   r3   r4   rG   r>   r+  r-  r,  r¬  rH   r*   r)   r  r  c  s(   „ ñó
	!ó#ò"
!ð HLó:7ôx;r*   r  Ú__main__)NNNT)NNNNTrß   )NNNr   )FT)srG   Ú
__future__r   ÚloggingÚenumÚwarningsr   Úcollectionsr   rT   Úfs.baseÚ	fs.errorsÚfs.osfsÚfs.pathÚfontTools.misc.textToolsr   ÚfontTools.miscr   ÚfontTools.pens.pointPenr   r	   rP   r
   ÚfontTools.ufoLib.filenamesr   ÚfontTools.ufoLib.validatorsr   r   r   r   r   r   r   r   ÚfontTools.ufoLibr   r   ÚfontTools.ufoLib.utilsr   r   Ú__all__Ú	getLoggerr2   rS  rf   rˆ   r­  ÚEnumr   Ú__str__r9   r   r   r   r¶   r   rü   rý   rþ   rÿ   r   r  r  r  rw   rS   r”   r=  r‰   rM  r¨   r#   r©   rr  ry  r,   r/   rU  rf  ri  rj  rk  rw  r¶  r«  r½  r¢  r¸  rÂ  rÁ  rh  r›  rœ  r£  r�  ru  r±  r¹  r²  r¡  rl  rv  rP  rÒ  rÔ  rÊ   rã  rÓ   rì  rÏ   rñ  r  r  ÚdoctestÚtestmodrH   r*   r)   ú<module>r     sá  ðñ
õ #ã Û Ý Ý #Û 	Û Û Û Û Ý ,Ý #ß GÝ 0Ý 9÷÷ ñ õ !ß 9ß Fò€ð 
ˆ×	Ñ	˜8Ó	$€ð %Ð Ø&Ð ô#˜Ð5°t·y±yô #ð. 3×:Ñ:Ð Ô ÷@ñ @ô>{ˆzô {òF	Uð& ØØØóQðl ØØØØó@ðJ ØØØó: òzHò2@ò2ò.ò"6ò<ò"3ò2/ñ* �s¨>Ô:Ù�TÐ*>Ô?ñÐ òò8ò0
òð& ØØ$×7Ñ7Ó9Øó0ðh 59ó8;ðx GHób9ðL × Ñ Ð";Ø× Ñ Ð";ðÐ ò8ò3ò/ò/ò5ð )˜>Ð òÐ ð 8¸<¸.ÑHÐ Ú=Ð Ø/°<°.Ñ@Ð Ø˜E�]Ð ÚBÐ ò
9ò0ò$òPò;ò0WòòBòB#
ðT KOóeòZòKôD	�9ô 	÷ñ ò.ô1˜;ô 1ò2	ô	1 ô 	1ò	ô( ô (ò4Ð ô};Ð#ô };ð@ ˆzÒÛà€G‡O�OÕð r*   