Ë
    £ehÍp ã                   ó^  — d 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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Z
ddlZ
ddlZ
ddlZ
ddlmZ ddl­ ddlmZ dd	lmZ dd
lmZ ddlmZmZ g d¢ZdZ  ejB                  e"«      Z#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/ G d„ de0eejb                  «      Z2ejf                  e2_3         G d„ dejb                  «      Z4 G d„ d«      Z5 G d „ d!e5«      Z6 G d"„ d#e6«      Z7e7Z8d$„ Z9d%„ Z:d&„ Z;d'„ Z<d(„ Z=d)„ Z> e? e@dd*«      «      ZAg d+¢ZB e? e@dd,«      «      ZC e? e@dd-«      «      ZDg d.¢ZEh d/£ZFi d0 eGeH¬1«      “d2 eGeH¬1«      “d3 eGeH¬1«      “d4 eGeHeI¬5«      “d6 eGeJ¬1«      “d7 eGeJ¬1«      “d8 eGeJ¬1«      “d9 eGeH¬1«      “d: eGeH¬1«      “d; eGeJeKf¬1«      “d< eGeJeKf¬1«      “d= eGeJeKf¬1«      “d> eGeJeKf¬1«      “d? eGeJeKf¬1«      “d@ eGeKeJf¬1«      “dA eGeH¬1«      “dB eGeHeL¬5«      “i dC eGeJeKf¬1«      “dD eGdEeMeA¬F«      “dG eGeJeKf¬1«      “dH eGeJeKf¬1«      “dI eGeJeKf¬1«      “dJ eGeJ¬1«      “dK eGeJ¬1«      “dL eGeJeKf¬1«      “dM eGeH¬1«      “dN eGeH¬1«      “dO eGeH¬1«      “dP eGeH¬1«      “dQ eGeH¬1«      “dR eGeH¬1«      “dS eGeH¬1«      “dT eGeH¬1«      “dU eGeH¬1«      “¥i dV eGeH¬1«      “dW eGeH¬1«      “dX eGeH¬1«      “dY eGeH¬1«      “dZ eGeH¬1«      “d[ eGeH¬1«      “d\ eGeJeN¬5«      “d] eGeJeO¬5«      “d^ eGdEeMeB¬F«      “d_ eGeH¬1«      “d` eGdEeP¬5«      “da eGdEeQ¬5«      “db eGdEeMeC¬F«      “dc eGdEeMeD¬F«      “dd eGeJeKf¬1«      “de eGeJeKf¬1«      “df eGeJeKf¬1«      “¥i dg eGeJeKf¬1«      “dh eGeJeKf¬1«      “di eGdEeMeE¬F«      “dj eGeJeKf¬1«      “dk eGeJeKf¬1«      “dl eGeJeKf¬1«      “dm eGeJeKf¬1«      “dn eGeJeKf¬1«      “do eGeJeKf¬1«      “dp eGeJeKf¬1«      “dq eGeJeKf¬1«      “dr eGeJeKf¬1«      “ds eGeJeKf¬1«      “dt eGeJeKf¬1«      “du eGeJeKf¬1«      “dv eGeJeKf¬1«      “dw eGeJ¬1«      “¥i dx eGeJ¬1«      “dy eGeJeKf¬1«      “dz eGeH¬1«      “d{ eGeH¬1«      “d| eGeKeJf¬1«      “d} eGeJ¬1«      “d~ eGeJeKf¬1«      “d eGeJeKf¬1«      “d€ eGeR¬1«      “d� eGdEeS¬5«      “d‚ eGdEeT¬5«      “dƒ eGdEeS¬5«      “d„ eGdEeT¬5«      “d… eGdEeU¬5«      “d† eGdEeU¬5«      “d‡ eGeJeKf¬1«      “dˆ eGeJeKf¬1«      “¥ eGeKeJf¬1«       eGeR¬1«       eGeJeKf¬1«       eGeJeKf¬1«       eGeH¬1«       eGeH¬1«       eGeJeV¬5«       eGeJ¬1«       eGeH¬1«      d‰œ	¥ZW eXeWj³                  «       «      ZZ eeW«      Z[e[j¹                  i d7 eGeJe]¬5«      “d; eGeJeKfe^¬5«      “dC eGeJe^¬5«      “dG eGeJ¬1«      “dH eGeJ¬1«      “dI eGeJ¬1«      “dL eGeJ¬1«      “d` eGdEe_¬5«      “dd eGeJ¬1«      “de eGeJ¬1«      “df eGeJ¬1«      “dg eGeJe^¬5«      “dh eGeJe^¬5«      “dj eGeJ¬1«      “dk eGeJ¬1«      “dl eGeJ¬1«      “dm eGeJ¬1«      “i dn eGeJ¬1«      “do eGeJ¬1«      “dp eGeJ¬1«      “dq eGeJ¬1«      “dr eGeJ¬1«      “ds eGeJ¬1«      “dŠ eGd‹e`¬5«      “dŒ eGd‹ea¬5«      “dt eGeJ¬1«      “du eGeJ¬1«      “dv eGeJ¬1«      “dy eGeJ¬1«      “d� eGeJe]¬5«      “dŽ eGeJe]¬5«      “d� eGeGeb¬5«      “d� eGeGec¬5«      “d‘ eGeGed¬5«      “¥ eGeGee¬5«       eGeGef¬5«       eGeGeg¬5«       eGeGeh¬5«       eGeGei¬5«       eGe?ej¬5«       eGe?ek¬5«      d’œ¥«        eXe[j³                  «       «      Zl e?eWjÛ                  «       «      D ]  \  ZnZod“eovsŒepeod“<   Œ  e?e[jÛ                  «       «      D ]  \  ZnZod“eovsŒepeod“<   Œ d”„ Zqi d•d3“d–dM“d—dN“d˜dO“d™dP“dšdQ“d›dR“dœdS“d�dT“dždU“dŸdV“d dW“d¡dX“d¢d£“d¤d]“d¥d_“d¦d}“dzd§d¨d©d|d{d4d\dªd«œ	¥Zr eqer«      Zs eXerj³                  «       «      Ztd¬d­d®d¯d°œZu eqeu«      Zvd¬eud<   d±d²d³d´dµd¶d·d¸d¹dºœ	Zw eqew«      Zxdµewd»<   dµewd¼<   dµewd½<   dµewd¾<   i dd±“d±d²“d²d³“d¿d´“d,dµ“dÀd¶“dÁd·“dÂd¸“dÃd¹“dÄdÅ“dÆdÇ“dÈdÉ“dÊdË“dÌdÍ“dÎd*“dÏdÐ“dÑdÒ“dÓdÔdÕdÖœ¥Zy eqey«      Zzd×„ Z{dØ„ Z|dÙ„ Z}dÚ„ Z~h dÛ£Zd;hZ€h dÜ£Z�dÝ„ Z‚dÞ„ Zƒdß„ Z„dà„ Z…e"dák(  rddl†Z† e†�j                  «        yy)âaö  
A library for importing .ufo files and their descendants.
Refer to http://unifiedfontobject.org for the UFO specification.

The main interfaces are the :class:`.UFOReader` and :class:`.UFOWriter`
classes, which support versions 1, 2, and 3 of the UFO specification.

Set variables are available for external use that list the font
info attribute names for the `fontinfo.plist` formats. These are:

- :obj:`.fontInfoAttributesVersion1`
- :obj:`.fontInfoAttributesVersion2`
- :obj:`.fontInfoAttributesVersion3`

A set listing the `fontinfo.plist` attributes that were deprecated
in version 2 is available for external use:

- :obj:`.deprecatedFontInfoAttributesVersion2`

Functions that do basic validation on values for `fontinfo.plist`
are available for external use. These are

- :func:`.validateFontInfoVersion2ValueForAttribute`
- :func:`.validateFontInfoVersion3ValueForAttribute`

Value conversion functions are available for converting
`fontinfo.plist` values between the possible format versions.

- :func:`.convertFontInfoValueForAttributeFromVersion1ToVersion2`
- :func:`.convertFontInfoValueForAttributeFromVersion2ToVersion1`
- :func:`.convertFontInfoValueForAttributeFromVersion2ToVersion3`
- :func:`.convertFontInfoValueForAttributeFromVersion3ToVersion2`
é    N)Údeepcopy)Úfsdecode)ÚOrderedDict)Úplistlib)Ú*)ÚuserNameToFileName)Ú%convertUFO1OrUFO2KerningToUFO3Kerning)ÚUFOLibError)ÚnumberTypesÚ_VersionTupleEnumMixin)ÚmakeUFOPathr
   Ú	UFOReaderÚ	UFOWriterÚUFOReaderWriterÚUFOFileStructureÚfontInfoAttributesVersion1ÚfontInfoAttributesVersion2ÚfontInfoAttributesVersion3Ú$deprecatedFontInfoAttributesVersion2Ú)validateFontInfoVersion2ValueForAttributeÚ)validateFontInfoVersion3ValueForAttributeÚ6convertFontInfoValueForAttributeFromVersion1ToVersion2Ú6convertFontInfoValueForAttributeFromVersion2ToVersion1z3.0.0ÚglyphsÚdataÚimageszmetainfo.plistzfontinfo.plistz	lib.plistzgroups.plistzkerning.plistzfeatures.feazlayercontents.plistzlayerinfo.plistzpublic.defaultc                   ó   — e Zd ZdZdZdZy)ÚUFOFormatVersion)é   r   )é   r   )é   r   N)Ú__name__Ú
__module__Ú__qualname__Ú
FORMAT_1_0Ú
FORMAT_2_0Ú
FORMAT_3_0© ó    úW/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/fontTools/ufoLib/__init__.pyr   r   d   s   „ Ø€JØ€JØ�Jr)   r   c                   ó   — e Zd ZdZdZy)r   ÚzipÚpackageN)r"   r#   r$   ÚZIPÚPACKAGEr(   r)   r*   r   r   p   s   „ Ø
€CØ�Gr)   r   c                   ó    — e Zd Zd„ Zdd„Zd„ Zy)Ú
_UFOBaseIOc                 ó   — 	 | j                   j                  t        |«      dg¬«      j                  }|j	                  «       S # t         j
                  j                  t         j
                  j                  f$ r Y yw xY w)a  
        Returns the modification time for the file at the given path, as a
        floating point number giving the number of seconds since the epoch.
        The path must be relative to the UFO path.
        Returns None if the file does not exist.
        Údetails)Ú
namespacesN)ÚfsÚgetinfor   ÚmodifiedÚ	timestampÚerrorsÚMissingInfoNamespaceÚResourceNotFound)ÚselfÚpathÚdts      r*   ÚgetFileModificationTimez"_UFOBaseIO.getFileModificationTime{   sd   € ð	"Ø—‘—‘¤¨$£¸Y¸K�ÓH×QÑQˆBð —<‘<“>Ð!øô —	‘	×.Ñ.´·	±	×0JÑ0JÐKò 	Ùð	ús   ‚1A Á7A=Á<A=Nc           	      ól  — 	 | j                   j                  |d«      5 }t        j                  |«      cddd«       S # 1 sw Y   yxY w# t         j                  j
                  $ r# |€t        d|›d| j                   ›d�«      ‚|cY S t        $ r#}t        d|› d| j                   › d|› �«      ‚d}~ww xY w)a–  
        Read a property list relative to the UFO filesystem's root.
        Raises UFOLibError if the file is missing and default is None,
        otherwise default is returned.

        The errors that could be raised during the reading of a plist are
        unpredictable and/or too large to list, so, a blind try: except:
        is done. If an exception occurs, a UFOLibError will be raised.
        ÚrbNú'z' is missing on z. This file is requiredz' could not be read on ú: )r5   Úopenr   Úloadr9   r;   r
   Ú	Exception)r<   ÚfileNameÚdefaultÚfÚes        r*   Ú	_getPlistz_UFOBaseIO._getPlist‰   s«   € ð	SØ—‘—‘˜h¨Ó-ð (°Ü—}‘} QÓ'÷(÷ (ò (ûä�y‰y×)Ñ)ò 	ØˆÝ!ÚFNÐPT×PWÓPWÐXóð ð ’Üò 	Sä  ( Ð+BÀ4Ç7Á7À)È2ÈaÈSÐQÓRÐRûð	Sús7   ‚A	 ž=³	A	 ½AÁA	 ÁA	 Á	=B3ÂB3ÂB.Â.B3c           
      óF  — | j                   rm	 t        j                  |«      }| j
                  j                  |«      r|| j
                  j                  |«      k(  ry| j
                  j                  ||«       y| j
                  j                  |d¬«      5 }	 t        j                  ||«       	 ddd«       y# t        $ r#}t	        d|›d| j
                  ›d|›�«      ‚d}~ww xY w# t        $ r#}t	        d|›d| j
                  ›d|›�«      ‚d}~ww xY w# 1 sw Y   yxY w)a‹  
        Write a property list to a file relative to the UFO filesystem's root.

        Do this sort of atomically, making it harder to corrupt existing files,
        for example when plistlib encounters an error halfway during write.
        This also checks to see if text matches the text that is already in the
        file at path. If so, the file is not rewritten so that the modification
        date is preserved.

        The errors that could be raised during the writing of a plist are
        unpredictable and/or too large to list, so, a blind try: except: is done.
        If an exception occurs, a UFOLibError will be raised.
        rB   z' could not be written on z- because the data is not properly formatted: NÚw)Úmode)Ú_havePreviousFiler   ÚdumpsrF   r
   r5   ÚexistsÚ	readbytesÚ
writebytesÚopenbinÚdump)r<   rG   Úobjr   rJ   Úfps         r*   Ú_writePlistz_UFOBaseIO._writePlist¡   s  € ð ×!Ò!ðÜ—~‘~ cÓ*�ð �w‰w�~‰~˜hÔ'¨D°D·G±G×4EÑ4EÀhÓ4OÒ,OØØ�G‰G×Ñ˜x¨Õ.à—‘—‘ °�Ó4ð ¸ðÜ—M‘M # rÕ*÷ð øô ò Ý!â@HÈ$Ï'Ë'ÑSTðVóð ûðûô !ò Ý%ò $ T§W£W©að1óð ûðú÷ð úsA   ŽB9 ÂDÂC(Â9	C%ÃC Ã C%Ã(	DÃ1DÄDÄDÄD ©N)r"   r#   r$   r?   rK   rX   r(   r)   r*   r1   r1   z   s   „ ò"óSó0"r)   r1   c                   ó.  — e Zd ZdZd&d„Zd„ Z eed¬«      Zd„ Z eed¬«      Z	ed„ «       Z
d	„ Z eed
¬«      Zd„ Zd„ Zd'd„Zd'd„Zd'd„Zd„ Zd'd„Zd'd„Zd„ Zd'd„Zd„ Zd'd„Zd'd„Zd„ Zd„ Zd'd„Zd'd„Zd(d„Zd)d„Zd„ Z d'd „Z!d!„ Z"d'd"„Z#d#„ Z$d$„ Z%d%„ Z&y)*r   aG  Read the various components of a .ufo.

    Attributes:
        path: An `os.PathLike` object pointing to the .ufo.
        validate: A boolean indicating if the data read should be
          validated. Defaults to `True`.

    By default read data is validated. Set ``validate`` to
    ``False`` to not validate the data.
    c                 ó’  — t        |d«      r|j                  «       }t        |t        «      �r$t	        |«      }	 |t
        j                  u r#t        j                  j                  |dd¬«      }nt        j                  j                  |«      }|t
        j                  u rœ|j                  d«      D �cg c])  }|j                   r|j"                  dk7  r|j"                  ‘Œ+ }}t%        |«      d	k(  r4|j'                  |d
   t        j(                  j*                  ¬«      | _        nt        dt%        |«      z  «      ‚|| _        d| _        || _        nŽt        |t        j0                  j2                  «      rI|}	 |j5                  «        || _        	 |j9                  d«      }d| _        t
        j<                  | _        n!t?        dtA        |«      jB                  z  «      ‚tE        |«      | _#        || _$        d | _%        	 | jM                  |¬«       y # t        j                  j                  $ r}t        d|› d|› �«      ‚d }~ww xY wc c}w # t        j                  j6                  $ r t        d|z  «      ‚w xY w# t        j                  j:                  $ r t        |«      }Y �Œw xY w# t        $ r | jO                  «        ‚ w xY w)NÚ
__fspath__Fúutf-8©ÚwriteÚencodingúunable to open 'z': ú/Ú__MACOSXr   r   ©Úfactoryú+Expected exactly 1 root directory, found %dTúthe filesystem '%s' is closedz7Expected a path string or fs.base.FS object, found '%s'©Úvalidate)(Úhasattrr\   Ú
isinstanceÚstrÚ_sniffFileStructurer   r.   r5   ÚzipfsÚZipFSÚosfsÚOSFSr9   ÚCreateFailedr
   ÚscandirÚis_dirÚnameÚlenÚopendirÚsubfsÚClosingSubFSÚ_shouldCloseÚ_fileStructureÚbaseÚFSÚcheckÚFilesystemClosedÚ
getsyspathÚ	NoSysPathr/   Ú	TypeErrorÚtyper"   r   Ú_pathÚ	_validateÚ_upConvertedKerningDataÚreadMetaInfoÚclose)	r<   r=   ri   Ú	structureÚparentFSrJ   ÚpÚrootDirsÚ
filesystems	            r*   Ú__init__zUFOReader.__init__×   s‡  € Ü�4˜Ô&Ø—?‘?Ó$ˆDä�dœCÕ Ü+¨DÓ1ˆIðCØÔ 0× 4Ñ 4Ñ4Ü!Ÿx™xŸ~™~¨d¸%È'˜~ÓR‘Hä!Ÿw™wŸ|™|¨DÓ1�Hð Ô,×0Ñ0Ñ0ð
 &×-Ñ-¨cÓ2öàà—x’x A§F¡F¨jÒ$8ð —F“Fð�ð ô �x“= AÒ%ð '×.Ñ.Ø  ™¬R¯X©X×-BÑ-Bð /ó �D•Gô &ØEÌÈHËÑUóð ð
 #�”ð !%ˆDÔØ"+ˆDÕÜ˜œbŸg™gŸj™jÔ)ØˆJð%Ø× Ñ Ô"ð %�”ð'Ø!×,Ñ,¨SÓ1�ð !&ˆDÔä"2×":Ñ":ˆDÕäØIÜ�t“*×%Ñ%ñ&óð ô ˜d“^ˆŒ
Ø!ˆŒØ'+ˆÔ$ð	Ø×Ñ xÐÕ0øôs —9‘9×)Ñ)ò CÜ!Ð$4°T°F¸#¸a¸SÐ"AÓBÐBûðCüòøô6 —9‘9×-Ñ-ò JÜ!Ð"AÀDÑ"HÓIÐIðJûô —9‘9×&Ñ&ò 'ä˜:““ð'ûô& ò 	Ø�J‰JŒLØð	úsH   ºAH Â3.IÅ9I ÆI< Ç?J+ ÈIÈ/I É IÉ,I9É<(J(Ê'J(Ê+Kc                 óR   — dd l }|j                  dt        d¬«       | j                  S )Nr   zBThe 'path' attribute is deprecated; use the 'fs' attribute insteadr    ©Ú
stacklevel)ÚwarningsÚwarnÚDeprecationWarningr„   ©r<   r’   s     r*   Ú	_get_pathzUFOReader._get_path"  s+   € Ûà�‰ØPÜØð 	ô 	
ð
 �z‰zÐr)   z!The path of the UFO (DEPRECATED).©Údocc                 óf   — dd l }|j                  dt        d¬«       | j                  j                  S )Nr   zIThe 'formatVersion' attribute is deprecated; use the 'formatVersionTuple'r    r�   )r’   r“   r”   Ú_formatVersionÚmajorr•   s     r*   Ú_get_formatVersionzUFOReader._get_formatVersion.  s3   € Ûà�‰ØWÜØð 	ô 	
ð
 ×"Ñ"×(Ñ(Ð(r)   zIThe (major) format version of the UFO. DEPRECATED: Use formatVersionTuplec                 ó   — | j                   S )z|The (major, minor) format version of the UFO.
        This is determined by reading metainfo.plist during __init__.
        )rš   ©r<   s    r*   ÚformatVersionTuplezUFOReader.formatVersionTuple=  s   € ð
 ×"Ñ"Ð"r)   c                 ó   — | j                   S rY   )r{   rž   s    r*   Ú_get_fileStructurezUFOReader._get_fileStructureD  s   € Ø×"Ñ"Ð"r)   zVThe file structure of the UFO: either UFOFileStructure.ZIP or UFOFileStructure.PACKAGEc                 ó2  — | j                   r[| j                  «       }|| j                   d   k7  rt        d«      ‚| j                  «       }|| j                   d   k7  rt        d«      ‚y
| j                  «       }|r�d}t	        |t
        «      st        |«      ‚|j                  «       D ]]  \  }}t	        |t        «      st        |«      ‚t	        |t        «      st        |«      ‚|D ]  }t	        |t        «      rŒt        |«      ‚ Œ_ t        i | j                  «       i |¬«      | _         t        | j                   d   t        | j                   d   «      | j                  «       «      \  }	}}
|	| j                   d<   || j                   d<   |
| j                   d	<   y
)ap  
        Up convert kerning and groups in UFO 1 and 2.
        The data will be held internally until each bit of data
        has been retrieved. The conversion of both must be done
        at once, so the raw data is cached and an error is raised
        if one bit of data becomes obsolete before it is called.

        ``validate`` will validate the data.
        ÚoriginalKerningzSThe data in kerning.plist has been modified since it was converted to UFO 3 format.ÚoriginalGroupszRThe data in groups.plist has been modified since it was converted to UFO 3 format.z'groups.plist is not properly formatted.)Úkerningr£   Úgroupsr¤   r¥   r¦   ÚgroupRenameMapsN)r†   Ú_readKerningr
   Ú_readGroupsrk   ÚdictÚitemsrl   Úlistr	   r   ÚgetGlyphSet)r<   ri   ÚtestKerningÚ
testGroupsr¦   ÚinvalidFormatMessageÚ	groupNameÚ	glyphListÚ	glyphNamer¥   ÚconversionMapss              r*   Ú_upConvertKerningzUFOReader._upConvertKerningQ  s±  € ð ×'Ò'Ø×+Ñ+Ó-ˆKØ˜d×:Ñ:Ð;LÑMÒMÜ!Øióð ð ×)Ñ)Ó+ˆJØ˜T×9Ñ9Ð:JÑKÒKÜ!Øhóð ð Lð
 ×%Ñ%Ó'ˆFÙØ'PÐ$Ü! &¬$Ô/Ü%Ð&:Ó;Ð;Ø,2¯L©L«Nò DÑ(�I˜yÜ% i´Ô5Ü)Ð*>Ó?Ð?Ü'¨	´4Ô8Ü)Ð*>Ó?Ð?Ø%.ò D˜	Ü)¨)´SÕ9Ü"-Ð.BÓ"CÐCñDðDô ,0ØØ $× 1Ñ 1Ó 3ØØ%ô	,ˆDÔ(ô /TØ×,Ñ,Ð->Ñ?Ü˜×5Ñ5Ð6FÑGÓHØ× Ñ Ó"ó/Ñ+ˆG�V˜^ð 7>ˆD×(Ñ(¨Ñ3Ø5;ˆD×(Ñ(¨Ñ2Ø>LˆD×(Ñ(Ð):Ò;r)   c                 ó’   — 	 | j                   j                  t        |«      «      S # t         j                  j                  $ r Y yw xY w)z³
        Returns the bytes in the file at the given path.
        The path must be relative to the UFO's filesystem root.
        Returns None if the file does not exist.
        N)r5   rR   r   r9   r;   )r<   r=   s     r*   ÚreadBytesFromPathzUFOReader.readBytesFromPath‡  s<   € ð	Ø—7‘7×$Ñ$¤X¨d£^Ó4Ð4øÜ�y‰y×)Ñ)ò 	Ùð	ús   ‚#& ¦AÁANc                 óÖ   — t        |«      }	 |€| j                  j                  |«      S | j                  j                  |d|¬«      S # t        j                  j
                  $ r Y yw xY w)aŽ  
        Returns a file (or file-like) object for the file at the given path.
        The path must be relative to the UFO path.
        Returns None if the file does not exist.
        By default the file is opened in binary mode (reads bytes).
        If encoding is passed, the file is opened in text mode (reads str).

        Note: The caller is responsible for closing the open file.
        NÚr©rN   r`   )r   r5   rT   rD   r9   r;   )r<   r=   r`   s      r*   ÚgetReadFileForPathzUFOReader.getReadFileForPath’  s`   € ô ˜‹~ˆð	ØÐØ—w‘w—‘ tÓ,Ð,à—w‘w—|‘| D¨s¸X�|ÓFÐFøÜ�y‰y×)Ñ)ò 	Ùð	ús   �A ªA ÁA(Á'A(c           	      ó  — |€| j                   }| j                  t        «      }|rt        |t        «      st        d«      ‚	 |d   }|j                  dd«      }	 t        ||f«      }||d<   |S # t        $ r  t        dt        › d| j                  › �«      ‚w xY w# t        $ rb}d|› d	|› d
t        › d| j                  › �}|rddlm}  ||«      |‚t        j                  «       }t        j                  d||«       Y d}~Œ™d}~ww xY w)zß
        Read metainfo.plist and return raw data. Only used for internal operations.

        ``validate`` will validate the read data, by default it is set
        to the class's validate value, can be overridden.
        Nz)metainfo.plist is not properly formatted.ÚformatVersionz#Missing required formatVersion in 'ú' on ÚformatVersionMinorr   zUnsupported UFO format (ú.z) in '©ÚUnsupportedUFOFormatz^%s. Assuming the latest supported version (%s). Some data may be skipped or parsed incorrectlyrŸ   )r…   rK   ÚMETAINFO_FILENAMErk   rª   r
   ÚKeyErrorr5   Ú
setdefaultr   Ú
ValueErrorÚfontTools.ufoLib.errorsrÂ   rH   ÚloggerÚwarning)	r<   ri   r   ÚformatVersionMajorr¿   r½   rJ   ÚunsupportedMsgrÂ   s	            r*   Ú_readMetaInfozUFOReader._readMetaInfo§  s<  € ð ÐØ—~‘~ˆHØ�~‰~Ô/Ó0ˆÙœJ t¬TÔ2ÜÐIÓJÐJð	Ø!% oÑ!6Ðð
 "Ÿ_™_Ð-AÀ1ÓEÐð	Ü,Ð.@ÐBTÐ-UÓVˆMð$ &3ˆÐ!Ñ"Øˆøô5 ò 	ÜØ5Ô6GÐ5HÈÈdÏgÉgÈYÐWóð ð	ûô ò 	à*Ð+=Ð*>¸aÐ@RÐ?Sð TÜ(Ð)¨¨t¯w©w¨ið9ð ñ ÝHá*¨>Ó:ÀÐAä,×4Ñ4Ó6ˆMÜ�N‰NðAàØ÷	ñ ûð	ús%   ÁA. ÁB Á.)BÂ	DÂ#AD Ä Dc                 ó<   — | j                  |¬«      }|d   | _        y)zá
        Read metainfo.plist and set formatVersion. Only used for internal operations.

        ``validate`` will validate the read data, by default it is set
        to the class's validate value, can be overridden.
        rh   rŸ   N)rÌ   rš   ©r<   ri   r   s      r*   r‡   zUFOReader.readMetaInfoÑ  s%   € ð ×!Ñ!¨8Ð!Ó4ˆØ"Ð#7Ñ8ˆÕr)   c                 óÈ   — | j                  t        i «      }|j                  «       D ]8  \  }}|j                  d«      sŒt	        t        j                  |«      «      ||<   Œ: |S )N)zpublic.kern1.zpublic.kern2.)rK   ÚGROUPS_FILENAMEr«   Ú
startswithr¬   r   Úfromkeys)r<   r¦   r±   r²   s       r*   r©   zUFOReader._readGroupsÝ  s^   € Ø—‘¤°Ó4ˆà$*§L¡L£Nò 	JÑ ˆI�yØ×#Ñ#Ð$FÕGÜ$(¬×)=Ñ)=¸iÓ)HÓ$I��yÒ!ð	Jð ˆr)   c                 óø   — |€| j                   }| j                  t        j                  k  r!| j	                  |«       | j
                  d   }n| j                  «       }|rt        |«      \  }}|st        |«      ‚|S )zµ
        Read groups.plist. Returns a dict.
        ``validate`` will validate the read data, by default it is set to the
        class's validate value, can be overridden.
        r¦   )	r…   rš   r   r'   rµ   r†   r©   ÚgroupsValidatorr
   )r<   ri   r¦   ÚvalidÚmessages        r*   Ú
readGroupszUFOReader.readGroupså  sz   € ð ÐØ—~‘~ˆHà×ÑÔ!1×!<Ñ!<Ò<Ø×"Ñ" 8Ô,Ø×1Ñ1°(Ñ;‰Fð ×%Ñ%Ó'ˆFÙÜ,¨VÓ4‰NˆE�7ÙÜ! 'Ó*Ð*Øˆr)   c                 ó´   — |€| j                   }| j                  t        j                  k\  rt	        i i ¬«      S | j                  |¬«       | j                  d   S )aG  
        Get maps defining the renaming that was done during any
        needed kerning group conversion. This method returns a
        dictionary of this form::

                {
                        "side1" : {"old group name" : "new group name"},
                        "side2" : {"old group name" : "new group name"}
                }

        When no conversion has been performed, the side1 and side2
        dictionaries will be empty.

        ``validate`` will validate the groups, by default it is set to the
        class's validate value, can be overridden.
        ©Úside1Úside2rh   r§   )r…   rš   r   r'   rª   r×   r†   )r<   ri   s     r*   Ú#getKerningGroupConversionRenameMapsz-UFOReader.getKerningGroupConversionRenameMapsú  sW   € ð" ÐØ—~‘~ˆHØ×ÑÔ"2×"=Ñ"=Ò=Ü˜b¨Ô+Ð+ð 	�‰ ˆÔ*Ø×+Ñ+Ð,=Ñ>Ð>r)   c                 ól   — | j                  t        i «      }|rt        |t        «      st	        d«      ‚|S )Nz)fontinfo.plist is not properly formatted.)rK   ÚFONTINFO_FILENAMErk   rª   r
   rÎ   s      r*   Ú	_readInfozUFOReader._readInfo  s0   € Ø�~‰~Ô/°Ó4ˆÙœJ t¬TÔ2ÜÐIÓJÐJØˆr)   c                 ó|  — |€| j                   }| j                  |«      }i }| j                  t        j                  k(  r;t
        D ]  }|j                  |«      }|€Œ|||<   Œ t        |«      }t        |«      }nì| j                  t        j                  k(  rJt        t        j                  «       «      D ]  \  }}|j                  |«      }|€Œ|||<   Œ  t        |«      }n…| j                  j                  t        j                  j                  k(  r?t        t        j                  «       «      D ]  \  }}|j                  |«      }|€Œ|||<   Œ  nt!        | j                  «      ‚|rt#        |«      }t        |j                  «       «      D ]  \  }}	 t%        |||«       Œ y# t&        $ r t)        d|z  «      ‚w xY w)a|  
        Read fontinfo.plist. It requires an object that allows
        setting attributes with names that follow the fontinfo.plist
        version 3 specification. This will write the attributes
        defined in the file into the object.

        ``validate`` will validate the read data, by default it is set to the
        class's validate value, can be overridden.
        NzMThe supplied info object does not support setting a necessary attribute (%s).)r…   rß   rš   r   r%   r   ÚgetÚ&_convertFontInfoDataVersion1ToVersion2Ú&_convertFontInfoDataVersion2ToVersion3r&   r¬   Ú#fontInfoAttributesVersion2ValueDatar«   r›   r'   Ú#fontInfoAttributesVersion3ValueDataÚNotImplementedErrorÚvalidateInfoVersion3DataÚsetattrÚAttributeErrorr
   )r<   Úinfori   ÚinfoDictÚinfoDataToSetÚattrÚvalueÚdataValidationDicts           r*   ÚreadInfozUFOReader.readInfo  sÍ  € ð ÐØ—~‘~ˆHØ—>‘> (Ó+ˆØˆà×ÑÔ"2×"=Ñ"=Ò=Ü2ò 0�Ø Ÿ™ TÓ*�ØÑ$Ø*/�M $Ò'ð0ô CÀ=ÓQˆMÜBÀ=ÓQ‰Mà× Ñ Ô$4×$?Ñ$?Ò?Ü,0Ü3×9Ñ9Ó;ó-ò ,Ñ(�Ð(ð !Ÿ™ TÓ*�Ø�=ØØ&+�˜dÒ#ð,ô CÀ=ÓQ‰Mà× Ñ ×&Ñ&Ô*:×*EÑ*E×*KÑ*KÒKÜ,0Ü3×9Ñ9Ó;ó-ò ,Ñ(�Ð(ð !Ÿ™ TÓ*�Ø�=ØØ&+�˜dÒ#ñ,ô & d×&9Ñ&9Ó:Ð:áÜ4°]ÓCˆMä × 3Ñ 3Ó 5Ó6ò 	‰KˆD�%ðÜ˜˜d EÕ*ñ	øô "ò Ü!ØcØñóð ðús   ÆF#Æ#F;c                 ó2   — | j                  t        i «      }|S rY   )rK   ÚKERNING_FILENAME)r<   r   s     r*   r¨   zUFOReader._readKerningW  s   € Ø�~‰~Ô.°Ó3ˆØˆr)   c                 ó<  — |€| j                   }| j                  t        j                  k  r!| j	                  |«       | j
                  d   }n| j                  «       }|rt        |«      \  }}|st        |«      ‚i }|D ]  }||   D ]  }||   |   }||||f<   Œ Œ |S )zº
        Read kerning.plist. Returns a dict.

        ``validate`` will validate the kerning data, by default it is set to the
        class's validate value, can be overridden.
        r¥   )	r…   rš   r   r'   rµ   r†   r¨   ÚkerningValidatorr
   )	r<   ri   ÚkerningNestedrÕ   rÖ   r¥   ÚleftÚrightrî   s	            r*   ÚreadKerningzUFOReader.readKerning[  sÁ   € ð ÐØ—~‘~ˆHà×ÑÔ!1×!<Ñ!<Ò<Ø×"Ñ" 8Ô,Ø ×8Ñ8¸ÑC‰Mð !×-Ñ-Ó/ˆMÙÜ-¨mÓ<‰NˆE�7ÙÜ! 'Ó*Ð*àˆØ!ò 	-ˆDØ& tÑ,ò -�Ø% dÑ+¨EÑ2�Ø',�˜˜e˜Ò$ñ-ð	-ð ˆr)   c                 óˆ   — |€| j                   }| j                  t        i «      }|rt        |«      \  }}|st	        |«      ‚|S )z®
        Read lib.plist. Returns a dict.

        ``validate`` will validate the data, by default it is set to the
        class's validate value, can be overridden.
        )r…   rK   ÚLIB_FILENAMEÚfontLibValidatorr
   )r<   ri   r   rÕ   rÖ   s        r*   ÚreadLibzUFOReader.readLiby  sG   € ð ÐØ—~‘~ˆHØ�~‰~œl¨BÓ/ˆÙÜ-¨dÓ3‰NˆE�7ÙÜ! 'Ó*Ð*Øˆr)   c                 óÚ   — 	 | j                   j                  t        dd¬«      5 }|j                  «       cddd«       S # 1 sw Y   yxY w# t         j                  j
                  $ r Y yw xY w)zr
        Read features.fea. Return a string.
        The returned string is empty if the file is missing.
        r¹   r]   ©r`   NÚ )r5   rD   ÚFEATURES_FILENAMEÚreadr9   r;   )r<   rI   s     r*   ÚreadFeatureszUFOReader.readFeatures‹  sY   € ð
	Ø—‘—‘Ô/°¸w�ÓGð  È1Ø—v‘v“x÷ ÷  ò  ûä�y‰y×)Ñ)ò 	Ùð	ús+   ‚"A
 ¤>´	A
 ¾AÁA
 ÁA
 Á
A*Á)A*c                 óÔ   — | j                   t        j                  k  rt        t        fgS | j                  t        «      }|r&t        || j                  «      \  }}|st        |«      ‚|S )z£
        Rebuild the layer contents list by checking what glyphsets
        are available on disk.

        ``validate`` will validate the layer contents.
        )
rš   r   r'   ÚDEFAULT_LAYER_NAMEÚDEFAULT_GLYPHS_DIRNAMErK   ÚLAYERCONTENTS_FILENAMEÚlayerContentsValidatorr5   r
   )r<   ri   ÚcontentsrÕ   Úerrors        r*   Ú_readLayerContentszUFOReader._readLayerContents˜  sa   € ð ×ÑÔ!1×!<Ñ!<Ò<Ü'Ô)?Ð@ÐAÐAØ—>‘>Ô"8Ó9ˆÙÜ1°(¸D¿G¹GÓD‰LˆE�5ÙÜ! %Ó(Ð(Øˆr)   c                 óx   — |€| j                   }| j                  |«      }|D ��cg c]  \  }}|‘Œ	 }}}|S c c}}w )zÄ
        Get the ordered layer names from layercontents.plist.

        ``validate`` will validate the data, by default it is set to the
        class's validate value, can be overridden.
        )r…   r
  )r<   ri   ÚlayerContentsÚ	layerNameÚdirectoryNameÚ
layerNamess         r*   ÚgetLayerNameszUFOReader.getLayerNames¨  sG   € ð ÐØ—~‘~ˆHØ×/Ñ/°Ó9ˆØ@M×NÑ$< I¨}’iÐNˆ
ÑNØÐùó Os   ¥6c                 ó„   — |€| j                   }| j                  |«      }|D ]  \  }}|t        k(  sŒ|c S  t        d«      ‚)zÃ
        Get the default layer name from layercontents.plist.

        ``validate`` will validate the data, by default it is set to the
        class's validate value, can be overridden.
        z8The default layer is not defined in layercontents.plist.)r…   r
  r  r
   )r<   ri   r  r  ÚlayerDirectorys        r*   ÚgetDefaultLayerNamezUFOReader.getDefaultLayerNameµ  sT   € ð ÐØ—~‘~ˆHØ×/Ñ/°Ó9ˆØ)6ò 	!Ñ%ˆI�~ØÔ!7Ó7Ø Ò ð	!ô ÐTÓUÐUr)   c                 ó¦  — ddl m} |€| j                  }|€| j                  }|€| j                  |¬«      }d}| j	                  |«      }|D ]  \  }}||k(  sŒ|} n |€t        d|z  «      ‚	 | j                  j                  |«      }	 ||	| j                  ||d	¬
«      S # t        j                  j                  $ r t        d|› d|› d�«      ‚w xY w)añ  
        Return the GlyphSet associated with the
        glyphs directory mapped to layerName
        in the UFO. If layerName is not provided,
        the name retrieved with getDefaultLayerName
        will be used.

        ``validateRead`` will validate the read data, by default it is set to the
        class's validate value, can be overridden.
        ``validateWrite`` will validate the written data, by default it is set to the
        class's validate value, can be overridden.
        r   ©ÚGlyphSetNrh   z&No glyphs directory is mapped to "%s".zNo 'z' directory for layer 'rB   T)ÚufoFormatVersionÚvalidateReadÚvalidateWriteÚexpectContentsFile)ÚfontTools.ufoLib.glifLibr  r…   r  r
  r
   r5   rw   r9   r;   rš   )
r<   r  r  r  r  Ú	directoryr  ÚstoredLayerNameÚstoredLayerDirectoryÚ
glyphSubFSs
             r*   r­   zUFOReader.getGlyphSetÅ  s  € õ 	6àÐØŸ>™>ˆLØÐ Ø ŸN™NˆMØÐØ×0Ñ0¸,Ð0ÓGˆIØˆ	Ø×/Ñ/°Ó=ˆØ5Bò 	Ñ1ˆOÐ1Ø˜OÓ+Ø0�	Ùð	ð ÐÜÐFÈÑRÓSÐSð	UØŸ™Ÿ™¨Ó3ˆJñ ØØ!×0Ñ0Ø%Ø'Ø#ô
ð 	
øô �y‰y×)Ñ)ò 	UÜ  Y KÐ/FÀyÀkÐQRÐSÓTÐTð	Uús   Á.B  Â 0Cc                 óê   — |€| j                   }| j                  ||d¬«      }|j                  «       }i }|j                  «       D ]+  \  }}|D ]!  }||v r||   j	                  |«       Œ|g||<   Œ# Œ- |S )zf
        Return a dictionary that maps unicode values (ints) to
        lists of glyph names.
        T)r  r  )r…   r­   ÚgetUnicodesr«   Úappend)	r<   r  ri   ÚglyphSetÚallUnicodesÚcmapr³   ÚunicodesÚcodes	            r*   ÚgetCharacterMappingzUFOReader.getCharacterMappingî  s›   € ð
 ÐØ—~‘~ˆHØ×#Ñ#Ø H¸Dð $ó 
ˆð ×*Ñ*Ó,ˆØˆØ#.×#4Ñ#4Ó#6ò 	-ÑˆI�xØ ò -�Ø˜4‘<Ø˜‘J×%Ñ% iÕ0à"+ �D˜’Jñ	-ð	-ð ˆr)   c                 ó¼  — 	 | j                   j                  t        «      | _        	 | j                  j                  j                  «       D �cg c]  }|j                  d«      ‘Œ c}S # t         j                  j
                  $ r g cY S t         j                  j                  $ r t        d«      ‚w xY wc c}w # t         j                  j                  $ r g cY S w xY w)zê
        Returns a list of all files in the data directory.
        The returned paths will be relative to the UFO.
        This will not list directory names, only file names.
        Thus, empty directories will be skipped.
        z6The UFO contains a "data" file instead of a directory.rb   )r5   rw   ÚDATA_DIRNAMEÚ_dataFSr9   r;   ÚDirectoryExpectedr
   ÚwalkÚfilesÚlstripÚResourceError)r<   r‹   s     r*   ÚgetDataDirectoryListingz!UFOReader.getDataDirectoryListing  s²   € ð	XØŸ7™7Ÿ?™?¬<Ó8ˆDŒLð
	ð ,0¯<©<×+<Ñ+<×+BÑ+BÓ+DÖE a�A—H‘H˜S•MÒEÐEøô �y‰y×)Ñ)ò 	ØŠIÜ�y‰y×*Ñ*ò 	XÜÐVÓWÐWð	Xüò FøÜ�y‰y×&Ñ&ò 	ØŠIð	ús4   ‚$A( §&B9 ÁB4Á%B9 Á(B1Â	(B1Â4B9 Â9CÃCc                 ó†  — | j                   t        j                  k  rg S |€| j                  }	 | j                  j                  t        «      x| _        }g }|j                  d«      D ]~  }|j                  rŒ|rR|j                  |j                  «      5 }t!        |¬«      \  }}ddd«       sŒH|j#                  |j                  «       Œd|j#                  |j                  «       Œ€ |S # t        j                  j                  $ r g cY S t        j                  j                  $ r t        d«      ‚w xY w# 1 sw Y   Œ“xY w)a$  
        Returns a list of all image file names in
        the images directory. Each of the images will
        have been verified to have the PNG signature.

        ``validate`` will validate the data, by default it is set to the
        class's validate value, can be overridden.
        Nz9The UFO contains an "images" file instead of a directory.rb   )ÚfileObj)rš   r   r'   r…   r5   rw   ÚIMAGES_DIRNAMEÚ	_imagesFSr9   r;   r,  r
   rs   rt   rT   ru   ÚpngValidatorr"  )r<   ri   ÚimagesFSÚresultr=   rW   rÕ   r	  s           r*   ÚgetImageDirectoryListingz"UFOReader.getImageDirectoryListing  s  € ð ×ÑÔ!1×!<Ñ!<Ò<ØˆIØÐØ—~‘~ˆHð	Ø(,¯©¯©¼Ó(GÐGˆDŒN˜Xð ˆØ×$Ñ$ SÓ)ò 	)ˆDØ�{Š{ð ÙØ×%Ñ% d§i¡iÓ0ð <°BÜ#/¸Ô#;‘L�E˜5÷<âØ—M‘M $§)¡)Õ,à—‘˜dŸi™iÕ(ð	)ð ˆøô' �y‰y×)Ñ)ò 	ØŠIÜ�y‰y×*Ñ*ò 	ÜØKóð ð	ú÷<ð <ús   ¯&C+ ÂD7Ã+D4Ä(D4Ä7E 	c                 ó.  — t        |«      }	 	 | j                  }|j                  |«      }|S # t        $ r" | j                  j	                  t
        «      }Y Œ=w xY w# t        j                  j                  $ r t        d|› d| j                  › �«      ‚w xY w)zZ
        Return bytes for the file named 'fileName' inside the 'data/' directory.
        zNo data file named 'r¾   )
r   r+  ré   r5   rw   r*  rR   r9   r;   r
   )r<   rG   ÚdataFSr   s       r*   ÚreadDatazUFOReader.readData=  s—   € ô ˜HÓ%ˆð	Oð7ØŸ™�ð ×#Ñ# HÓ-ˆDð ˆøô "ò 7àŸ™Ÿ™¬Ó6’ð7ûô �y‰y×)Ñ)ò 	OÜÐ 4°X°J¸eÀDÇGÁGÀ9ÐMÓNÐNð	Oús&   Ž- šA ­(AÁA ÁAÁA Á9Bc                 ó  — |€| j                   }| j                  t        j                  k  r#t	        d| j                  j
                  › d�«      ‚t        |«      }	 	 | j                  }|j                  |«      }|rt        |¬«      \  }}|st	        |«      ‚|S # t        $ r" | j                  j                  t        «      }Y Œ[w xY w# t        j                  j                  $ r t	        d|› d| j                  › �«      ‚w xY w)z½
        Return image data for the file named fileName.

        ``validate`` will validate the data, by default it is set to the
        class's validate value, can be overridden.
        z%Reading images is not allowed in UFO rÀ   zNo image file named 'r¾   ©r   )r…   rš   r   r'   r
   r›   r   r5  ré   r5   rw   r4  rR   r9   r;   r6  )r<   rG   ri   r7  r   rÕ   r	  s          r*   Ú	readImagezUFOReader.readImageM  s  € ð ÐØ—~‘~ˆHØ×ÑÔ!1×!<Ñ!<Ò<ÜØ7¸×8KÑ8K×8QÑ8QÐ7RÐRSÐTóð ô ˜HÓ%ˆð	Pð;ØŸ>™>�ð ×%Ñ% hÓ/ˆDñ Ü'¨TÔ2‰LˆE�5ÙÜ! %Ó(Ð(Øˆøô "ò ;àŸ7™7Ÿ?™?¬>Ó:’ð;ûô �y‰y×)Ñ)ò 	PÜÐ 5°h°Z¸uÀTÇWÁWÀIÐNÓOÐOð	Pús*   ÁB Á(C Â(CÃC ÃCÃC Ã9D c                 óR   — | j                   r| j                  j                  «        y y rY   )rz   r5   rˆ   rž   s    r*   rˆ   zUFOReader.closej  s   € Ø×ÒØ�G‰G�M‰M�Oð r)   c                 ó   — | S rY   r(   rž   s    r*   Ú	__enter__zUFOReader.__enter__n  s   € Øˆr)   c                 ó$   — | j                  «        y rY   )rˆ   )r<   Úexc_typeÚ	exc_valueÚexc_tbs       r*   Ú__exit__zUFOReader.__exit__q  s   € Ø�
‰
�r)   )TrY   )NNN©NN)'r"   r#   r$   Ú__doc__rŽ   r–   Úpropertyr=   rœ   r½   rŸ   r¡   ÚfileStructurerµ   r·   r»   rÌ   r‡   r©   r×   rÜ   rß   rð   r¨   rø   rü   r  r
  r  r  r­   r(  r1  r9  r<  r?  rˆ   rB  rG  r(   r)   r*   r   r   Ë   sð   „ ñ	óGòVñ �IÐ#FÔG€Dò)ñ ØØWô€Mð
 ñ#ó ð#ò#ñ ØðFô€Mò2Mòl	óó*(óT9òóó*?ò8ó7òvóó<ò$	òó óVó '
óRò,ó*"òHó ò:òór)   r   c                   ó  ‡ — e Zd ZdZ	 	 	 	 dd„Zd„ Z eed¬«      Zd„ Zd„ Z	d d„Z
d!d	„ZeZd
„ Zd„ Zd„ Zd"d„Zd"d„Zd"d„Zd"d„Zd"d„Zd#d„Zd„ Z	 	 	 	 	 	 d$d„Z	 	 d%d„Z	 	 	 	 d&d„Zd'd„Zd„ Zd„ Zd„ Zd"d„Zd"d„Zd"d„Z ˆ fd„Z!ˆ xZ"S )(r   a=  Write the various components of a .ufo.

    Attributes:
        path: An `os.PathLike` object pointing to the .ufo.
        formatVersion: the UFO format version as a tuple of integers (major, minor),
            or as a single integer for the major digit only (minor is implied to be 0).
            By default, the latest formatVersion will be used; currently it is 3.0,
            which is equivalent to formatVersion=(3, 0).
        fileCreator: The creator of the .ufo file. Defaults to
            `com.github.fonttools.ufoLib`.
        structure: The internal structure of the .ufo file: either `ZIP` or `PACKAGE`.
        validate: A boolean indicating if the data read should be validated. Defaults
            to `True`.

    By default, the written data will be validated before writing. Set ``validate`` to
    ``False`` if you do not want to validate the data. Validation can also be overriden
    on a per-method level if desired.

    Raises:
        UnsupportedUFOFormat: An exception indicating that the requested UFO
            formatVersion is not supported.
    c                 óä
  — 	 t        |«      }t	        |d«      r|j                  «       }t        |t        «      �rÎt        j                  j                  |«      }t        j                  j                  |«      }|r2t        |«      }	|�"	 t        |«      }||	urut        d|	›d|›d�«      ‚|	}n`|€t        j                  }t        j                  j!                  |«      }
|
r-t        j                  j#                  |
«      st        d	|z  «      ‚|t        j$                  u �r­|�rt&        j(                  j+                  «       }t&        j,                  j/                  |d
¬«      5 }t&        j0                  j3                  ||«       d d d «       |j5                  d«      D �cg c])  }|j6                  r|j8                  dk7  r|j8                  ‘Œ+ }}t;        |«      dk7  rt        dt;        |«      z  «      ‚|j=                  |d   t&        j>                  j@                  ¬«      | _        nÌt        j                  jC                  t        j                  jE                  |«      «      d   dz   }t&        j,                  j/                  |dd
¬«      }|jG                  |«       |j=                  |t&        j>                  j@                  ¬«      | _        n&t&        jH                  jK                  |d¬«      | _        || _&        || _'        d| _(        nØt        |t&        jR                  jT                  «      r“|}	 |jW                  «        || _        	 |j]                  d«      }|r.|t        j                  urdd l0}|jc                  dtd        d¬«       t        j                  | _&        |j                  tf        «      | _'        d| _(        n!ti        dtk        |«      jl                  z  «      ‚to        |«      | _8        || _9        || _:        d | _;        || _<        d }| jN                  r1| j{                  |¬«      }|d   }||kD  rddlm}  |d|› d|› d�«      ‚i | _>        |�/|j~                  d k\  r t�        | jƒ                  |«      «      | _>        n0| j&                  j                  t„        «      rt†        t„        i| _>        | j‰                  «        y # t        $ r}ddlm}  |d|›�«      |‚d }~ww xY w# t        $ r t        d|z  «      ‚w xY w# 1 sw Y   �Œ‚xY wc c}w # t&        jX                  jZ                  $ r t        d|z  «      ‚w xY w# t&        jX                  j^                  $ r t        |«      }Y �Œw xY w)!Nr   rÁ   zUnsupported UFO format: r\   z&Invalid or unsupported structure: '%s'z"A UFO with a different structure (z%) already exists at the given path: 'rB   z.Cannot write to '%s': directory does not existr]   rþ   rb   rc   r   rf   rd   ú.ufoTr^   ©Úcreaterg   z?The 'structure' argument is not used when input is an FS objectr    r�   Fz-Expected a path string or fs object, found %srh   rŸ   z2The UFO located at this path is a higher version (z) than the version (z6) that is trying to be written. This is not supported.r!   )Er   rÆ   rÇ   rÂ   rj   r\   rk   rl   Úosr=   ÚnormpathrQ   rm   r   r
   r/   ÚdirnameÚisdirr.   r5   ÚtempfsÚTempFSrn   ro   ÚcopyÚcopy_fsrs   rt   ru   rv   rw   rx   ry   ÚsplitextÚbasenameÚmakedirrp   rq   r{   rO   rz   r|   r}   r~   r9   r   r€   r�   r’   r“   ÚUserWarningrÃ   r‚   rƒ   r"   r   r„   rš   Ú_fileCreatorÚ_downConversionKerningDatar…   rÌ   r  r›   r   r
  r  r  Ú_writeMetaInfo)r<   r=   r½   ÚfileCreatorr‰   ri   rJ   rÂ   ÚhavePreviousFileÚexistingStructureÚdirNamerŠ   ÚorigFSr‹   rŒ   ÚrootDirr�   r’   ÚpreviousFormatVersionÚmetaInfos                       r*   rŽ   zUFOWriter.__init__’  sø  € ð	Ü,¨]Ó;ˆMô �4˜Ô&Ø—?‘?Ó$ˆDä�dœCÕ ä—7‘7×#Ñ# DÓ)ˆDÜ!Ÿw™wŸ~™~¨dÓ3ÐÙä$7¸Ó$=Ð!ØÐ(ðÜ$4°YÓ$?˜	ð
 !Ð(9Ñ9Ý)â9JÊDðRóð ð
 !2‘Ið Ð$Ü 0× 8Ñ 8�IÜŸ'™'Ÿ/™/¨$Ó/�Ù¤2§7¡7§=¡=°Ô#9Ü%ØHÈ4ÑOóð ð Ô,×0Ñ0Ò0Ú#ô  "Ÿy™y×/Ñ/Ó1�HÜŸ™Ÿ™¨°w˜Ó?ð :À6ÜŸ™Ÿ™¨°Ô9÷:ð "*×!1Ñ!1°#Ó!6ö ààŸ8š8¨¯©°*Ò(<ð Ÿ›ð �Hð  ô ˜8“}¨Ò)Ü)ØIÜ! (›mñ,óð ð #+×"2Ñ"2Ø$ Q™K´·±×1FÑ1Fð #3ó #˜�ô !Ÿg™g×.Ñ.¬r¯w©w×/?Ñ/?ÀÓ/EÓFÀqÑIÈFÑR�GÜ!Ÿx™xŸ~™~¨d¸$È˜~ÓQ�HØ×$Ñ$ WÔ-Ø&×.Ñ.¨wÄÇÁ×@UÑ@UÐ.ÓV�D•GäŸ'™'Ÿ,™, t°D˜,Ó9�”Ø"+ˆDÔØ%5ˆDÔ"Ø $ˆDÕÜ˜œbŸg™gŸj™jÔ)ØˆJð%Ø× Ñ Ô"ð %�”ð'Ø!×,Ñ,¨SÓ1�ñ
 ˜YÔ.>×.FÑ.FÑFÛà—‘ØUÜØ ð ô ô
 #3×":Ñ":ˆDÔà%/×%6Ñ%6Ô7HÓ%IˆDÔ"à %ˆDÕäØ?Ä$ÀtÃ*×BUÑBUÑUóð ô
 ˜d“^ˆŒ
Ø+ˆÔØ'ˆÔØ*.ˆÔ'Ø!ˆŒð !%ÐØ×!Ò!Ø×)Ñ)°8Ð)Ó<ˆHØ$,Ð-AÑ$BÐ!à$ }Ò4ÝHá*ðØ-Ð.Ð.BÀ=À/ð RKðKóð ð  ˆÔØ Ð,Ð1F×1LÑ1LÐPQÒ1Qä!,¨T×-DÑ-DÀXÓ-NÓ!OˆDÕð �w‰w�~‰~Ô4Ô5Ü&8Ô:PÐ%Q�Ô"à×ÑÕøôa ò 	ÝDá&Ø*¨=Ð*;Ð<óàðûð	ûô( &ò Ü)ØDÀyÑPóð ðú÷4:ñ :üò
 øôB —9‘9×-Ñ-ò JÜ!Ð"AÀDÑ"HÓIÐIðJûô —9‘9×&Ñ&ò 'ä˜:““ð'úsS   ‚S ÂS' Å!!TÆ.TÌ/T ÍU Ó	S$ÓSÓS$Ó'S?ÔTÔ,U Õ(U/Õ.U/c                 ó   — | j                   S rY   )r]  rž   s    r*   Ú_get_fileCreatorzUFOWriter._get_fileCreator0  s   € Ø× Ñ Ð r)   zMThe file creator of the UFO. This is set into metainfo.plist during __init__.r—   c                 óŽ  — t        |t        «      st        d«      ‚t        |«      }t        |«      }|j                  j                  |«      st        d|z  «      ‚| j                  j                  |«      rt        d|z  «      ‚| j                  j                  t        j                  j                  |«      d¬«       |j                  j                  |«      r7t        j                  j                  |j                  || j                  |«       yt        j                  j                  |j                  || j                  |«       y)z¾
        Copy the sourcePath in the provided UFOReader to destPath
        in this writer. The paths must be relative. This works with
        both individual files and directories.
        z,The reader must be an instance of UFOReader.z.The reader does not have data located at "%s".z!A file named "%s" already exists.T©ÚrecreateN)rk   r   r
   r   r5   rQ   Úmakedirsr=   rS  rT  rW  Úcopy_dirÚ	copy_file)r<   ÚreaderÚ
sourcePathÚdestPaths       r*   ÚcopyFromReaderzUFOWriter.copyFromReader:  sì   € ô ˜&¤)Ô,ÜÐLÓMÐMÜ˜jÓ)ˆ
Ü˜HÓ%ˆØ�y‰y×Ñ 
Ô+ÜØ@À:ÑMóð ð �7‰7�>‰>˜(Ô#ÜÐAÀHÑLÓMÐMà�‰×ÑœŸ™Ÿ™¨Ó2¸TÐÔBØ�9‰9�?‰?˜:Ô&Ü�G‰G×Ñ˜VŸY™Y¨
°D·G±G¸XÕFä�G‰G×Ñ˜fŸi™i¨°T·W±W¸hÕGr)   c                 ó&  — t        |«      }| j                  r:| j                  j                  |«      r|| j                  j	                  |«      k(  ry	 | j                  j                  ||«       y# t        j                  j                  $ r t        d|z  «      ‚t        j                  j                  $ rY | j                  j                  t        j                  j                  |«      d¬«       | j                  j                  ||«       Y yw xY w)ae  
        Write bytes to a path relative to the UFO filesystem's root.
        If writing to an existing UFO, check to see if data matches the data
        that is already in the file at path; if so, the file is not rewritten
        so that the modification date is preserved.
        If needed, the directory tree for the given path will be built.
        NzA directory exists at '%s'Trk  )r   rO   r5   ÚisfilerR   rS   r9   ÚFileExpectedr
   r;   rm  r=   rS  )r<   r=   r   s      r*   ÚwriteBytesToPathzUFOWriter.writeBytesToPathQ  sÍ   € ô ˜‹~ˆØ×!Ò!Ø�w‰w�~‰~˜dÔ#¨°·±×0AÑ0AÀ$Ó0GÒ(GØð	+Ø�G‰G×Ñ˜t TÕ*øÜ�y‰y×%Ñ%ò 	CÜÐ:¸TÑAÓBÐBÜ�y‰y×)Ñ)ò 	+Ø�G‰G×ÑœRŸW™WŸ_™_¨TÓ2¸TÐÔBØ�G‰G×Ñ˜t TÖ*ð	+ús   ÁA0 Á0BDÄDc           	      ó&  — t        |«      }	 | j                  j                  |||¬«      S # t        j                  j                  $ r…}|d   }|dk(  rY d}~y|dk(  s
|dk(  s|dk(  r]| j                  j                  t        j                  j                  |«      d¬	«       | j                  j                  |||¬«      cY d}~S Y d}~yd}~wt        j                  j                  $ r(}t        d
|› d| j                  › d|› �«      cY d}~S d}~ww xY w)ag  
        Returns a file (or file-like) object for the
        file at the given path. The path must be relative
        to the UFO path. Returns None if the file does
        not exist and the mode is "r" or "rb.
        An encoding may be passed if the file is opened in text mode.

        Note: The caller is responsible for closing the open file.
        rº   r   r¹   NrM   ÚaÚxTrk  ra   r¾   rC   )
r   r5   rD   r9   r;   rm  r=   rS  r0  r
   )r<   r=   rN   r`   rJ   Úms         r*   ÚgetFileObjectForPathzUFOWriter.getFileObjectForPathe  së   € ô ˜‹~ˆð	MØ—7‘7—<‘< ¨4¸(�<ÓCÐCøÜ�y‰y×)Ñ)ò 	HØ�Q‘ˆAØ�CŠxô Ø�c’˜Q #šX¨¨cªØ—‘× Ñ ¤§¡§¡°Ó!6ÀÐ ÔFØ—w‘w—|‘| D¨t¸h�|ÓGÕGô *2ûô �y‰y×&Ñ&ò 	MÜÐ!1°$°°u¸T¿W¹W¸IÀRÈÀsÐKÓLÕLûð	Mús4   �+ «DÁ
CÁA&CÂ=DÃ DÃ(DÄDÄDc                 óâ  — t        |«      }	 | j                  j                  |«       |rMt        j                  j                  |«      }|r+t        j                  j                  | j                  |«       yyy# t        j                  j                  $ r | j                  j                  |«       Y ŒŠt        j                  j                  $ r  |st        d|› d| j                  › �«      ‚Y ŒÅw xY w)a_  
        Remove the file (or directory) at path. The path
        must be relative to the UFO.
        Raises UFOLibError if the path doesn't exist.
        If force=True, ignore non-existent paths.
        If the directory where 'path' is located becomes empty, it will
        be automatically removed, unless 'removeEmptyParents' is False.
        rB   z' does not exist on N)r   r5   Úremover9   rv  Ú
removetreer;   r
   r=   rS  ÚtoolsÚremove_empty)r<   r=   ÚforceÚremoveEmptyParentsÚparents        r*   Ú
removePathzUFOWriter.removePath~  sÅ   € ô ˜‹~ˆð	KØ�G‰G�N‰N˜4Ô ñ Ü—W‘W—_‘_ TÓ*ˆFÙÜ—‘×%Ñ% d§g¡g¨vÕ6ð ð øô �y‰y×%Ñ%ò 	%Ø�G‰G×Ñ˜tÖ$Ü�y‰y×)Ñ)ò 	KÙÜ! A d VÐ+?ÀÇÁ¸yÐ"IÓJÐJñ ð	Kús   �A8 Á88C.Â29C.Ã-C.c                 óè   — | j                   }|�8t        j                  j                  |«      r	 t        j                  |d«       yyy# t
        $ r }t        j                  d|«       Y d}~yd}~ww xY w)z¾
        Set the UFO modification time to the current time.
        This is never called automatically. It is up to the
        caller to call this when finished working on the UFO.
        NzFailed to set modified time: %s)r„   rQ  r=   rQ   ÚutimeÚOSErrorrÈ   rÉ   )r<   r=   rJ   s      r*   ÚsetModificationTimezUFOWriter.setModificationTime™  sd   € ð �z‰zˆØÐ¤§¡§¡¨tÔ 4ðEä—‘˜˜tÕ$ð !5Ðøô ò EÜ—‘Ð@À!×DÑDûðEús   ¯A Á	A1ÁA,Á,A1c                 óê   — t        | j                  | j                  j                  ¬«      }| j                  j                  dk7  r| j                  j                  |d<   | j                  t        |«       y )N)Úcreatorr½   r   r¿   )rª   r]  rš   r›   ÚminorrX   rÃ   )r<   rg  s     r*   r_  zUFOWriter._writeMetaInfo©  sb   € ÜØ×%Ñ%Ø×-Ñ-×3Ñ3ô
ˆð ×Ñ×$Ñ$¨Ò)Ø-1×-@Ñ-@×-FÑ-FˆHÐ)Ñ*Ø×ÑÔ*¨HÕ5r)   c                 óÆ   — | j                   t        j                  k\  ryi }dD ]+  }t        ||   j	                  «       «      D ]
  \  }}|||<   Œ Œ- t        |¬«      | _        y)aW  
        Set maps defining the renaming that should be done
        when writing groups and kerning in UFO 1 and UFO 2.
        This will effectively undo the conversion done when
        UFOReader reads this data. The dictionary should have
        this form::

                {
                        "side1" : {"group name to use when writing" : "group name in data"},
                        "side2" : {"group name to use when writing" : "group name in data"}
                }

        This is the same form returned by UFOReader's
        getKerningGroupConversionRenameMaps method.
        NrÙ   )ÚgroupRenameMap)rš   r   r'   r¬   r«   rª   r^  )r<   ÚmapsÚremapÚsideÚ	writeNameÚdataNames         r*   Ú#setKerningGroupConversionRenameMapsz-UFOWriter.setKerningGroupConversionRenameMaps´  sn   € ð  ×ÑÔ"2×"=Ñ"=Ò=ØàˆØ&ò 	,ˆDÜ'+¨D°©J×,<Ñ,<Ó,>Ó'?ò ,Ñ#�	˜8Ø"+��h’ñ,ð	,ô +/¸eÔ*DˆÕ'r)   c                 óT  — |€| j                   }|rt        |«      \  }}|st        |«      ‚| j                  t        j
                  k  rz| j                  �n| j                  d   }i }t        |j                  «       «      D ]  \  }}||v rŒ|||<   Œ t        |j                  «       «      D ]  \  }}||vrŒ||   }|||<   Œ |}i }	|j                  «       D ]  \  }
}t        |«      |	|
<   Œ |	r| j                  t        |	«       y| j                  r| j                  t        dd¬«       yy)zæ
        Write groups.plist. This method requires a
        dict of glyph groups as an argument.

        ``validate`` will validate the data, by default it is set to the
        class's validate value, can be overridden.
        NrŽ  TF©r‚  rƒ  )r…   rÔ   r
   rš   r   r'   r^  r¬   r«   rX   rÐ   rO   r…  )r<   r¦   ri   rÕ   rÖ   r�  ÚremappedGroupsru   r  Ú	groupsNewÚkeyrî   s               r*   ÚwriteGroupszUFOWriter.writeGroupsÍ  sB  € ð ÐØ—~‘~ˆHáÜ,¨VÓ4‰NˆE�7ÙÜ! 'Ó*Ð*ð ×ÑÔ"2×"=Ñ"=Ò=Ø×/Ñ/Ð;à×3Ñ3Ð4DÑEˆEØˆNô #' v§|¡|£~Ó"6ò 0‘��hØ˜5‘=ØØ'/�˜tÒ$ð0ô #' v§|¡|£~Ó"6ò 0‘��hØ˜uÑ$ØØ˜T‘{�Ø'/�˜tÒ$ð	0ð
 $ˆFàˆ	Ø Ÿ,™,›.ò 	)‰JˆC�Ü! %›[ˆI�cŠNð	)áØ×Ñœ_¨iÕ8Ø×#Ò#Ø�O‰OœO°4ÈEˆOÕRð $r)   c                 óV  — |€| j                   }i }t        t        j                  «       «      D ]$  }t	        ||«      sŒ	 t        ||«      }|€Œ |||<   Œ& | j                  t        j                  k(  r|r‚t        |«      }nv| j                  t        j                  k(  rt        |«      }|rLt        |«      }n@| j                  t        j                  k(  r#t        |«      }|rt        |«      }t!        |«      }|r| j#                  t$        |«       yy# t        $ r t        d|z  «      ‚w xY w)a‚  
        Write info.plist. This method requires an object
        that supports getting attributes that follow the
        fontinfo.plist version 2 specification. Attributes
        will be taken from the given object and written
        into the file.

        ``validate`` will validate the data, by default it is set to the
        class's validate value, can be overridden.
        NzMThe supplied info object does not support getting a necessary attribute (%s).)r…   r¬   rå   Úkeysrj   Úgetattrré   r
   rš   r   r'   rç   r&   Ú&_convertFontInfoDataVersion3ToVersion2ÚvalidateInfoVersion2Datar%   Ú&_convertFontInfoDataVersion2ToVersion1rX   rÞ   )r<   rê   ri   ÚinfoDatarí   rî   s         r*   Ú	writeInfozUFOWriter.writeInfo  s,  € ð ÐØ—~‘~ˆHàˆÜÔ<×AÑAÓCÓDò 	'ˆDÜ�t˜TÕ"ðÜ# D¨$Ó/�Eð �=ØØ!&�˜’ð	'ð ×ÑÔ"2×"=Ñ"=Ò=ÙÜ3°HÓ=‘Ø× Ñ Ô$4×$?Ñ$?Ò?Ü=¸hÓGˆHÙÜ3°HÓ=‘Ø× Ñ Ô$4×$?Ñ$?Ò?Ü=¸hÓGˆHÙÜ3°HÓ=�Ü=¸hÓGˆHáØ×ÑÔ.°Õ9ð øô- &ò Ü%ØgØñóð ðús   ¿DÄD(c                 ó®  — |€| j                   }|rÊd}t        |«      st        |«      ‚t        |j	                  «       «      D ]–  \  }}t        |t        t        f«      st        |«      ‚t        |«      dk(  st        |«      ‚t        |d   t        «      st        |«      ‚t        |d   t        «      st        |«      ‚t        |t        «      rŒ�t        |«      ‚ | j                  t        j                  k  rn| j                  �b| j                  d   }i }t        |j	                  «       «      D ]3  \  \  }}	}|j                  ||«      }|j                  |	|	«      }	||||	f<   Œ5 |}i }
|j                  «       D ]  \  }}|||f   }||
vri |
|<   ||
|   |<   Œ |
r| j!                  t"        |
«       y| j$                  r| j'                  t"        dd¬	«       yy)
aä  
        Write kerning.plist. This method requires a
        dict of kerning pairs as an argument.

        This performs basic structural validation of the kerning,
        but it does not check for compliance with the spec in
        regards to conflicting pairs. The assumption is that the
        kerning data being passed is standards compliant.

        ``validate`` will validate the data, by default it is set to the
        class's validate value, can be overridden.
        Nz&The kerning is not properly formatted.r    r   r   rŽ  TFr–  )r…   ÚisDictEnoughr
   r¬   r«   rk   Útuplerv   rl   r   rš   r   r'   r^  rá   rœ  rX   rò   rO   r…  )r<   r¥   ri   r°   Úpairrî   r�  ÚremappedKerningrÚ   rÛ   ÚkerningDictrö   r÷   s                r*   ÚwriteKerningzUFOWriter.writeKerning2  sÞ  € ð ÐØ—~‘~ˆHáØ#KÐ Ü Ô(Ü!Ð"6Ó7Ð7Ü# G§M¡M£OÓ4ò 
<‘��eÜ! $¬¬u¨Ô6Ü%Ð&:Ó;Ð;Ü˜4“y A’~Ü%Ð&:Ó;Ð;Ü! $ q¡'¬3Ô/Ü%Ð&:Ó;Ð;Ü! $ q¡'¬3Ô/Ü%Ð&:Ó;Ð;Ü! %¬Õ5Ü%Ð&:Ó;Ð;ð
<ð ×ÑÔ"2×"=Ñ"=Ò=Ø×/Ñ/Ð;à×3Ñ3Ð4DÑEˆEØ ˆOÜ)-¨g¯m©m«oÓ)>ò 6Ñ%‘�˜ ØŸ	™	 %¨Ó/�ØŸ	™	 %¨Ó/�Ø05�  u Ò-ð6ð &ˆGàˆØ"Ÿ<™<›>ò 	-‰KˆD�%Ø˜D %˜KÑ(ˆEØ˜;Ñ&Ø$&�˜DÑ!Ø',ˆK˜Ñ˜eÒ$ð		-ñ
 Ø×ÑÔ-¨{Õ;Ø×#Ò#Ø�O‰OÔ,°DÈUˆOÕSð $r)   c                 óÖ   — |€| j                   }|rt        |«      \  }}|st        |«      ‚|r| j                  t        |«       y| j
                  r| j                  t        dd¬«       yy)z×
        Write lib.plist. This method requires a
        lib dict as an argument.

        ``validate`` will validate the data, by default it is set to the
        class's validate value, can be overridden.
        NTFr–  )r…   rû   r
   rX   rú   rO   r…  )r<   ÚlibDictri   rÕ   rÖ   s        r*   ÚwriteLibzUFOWriter.writeLibk  se   € ð ÐØ—~‘~ˆHÙÜ-¨gÓ6‰NˆE�7ÙÜ! 'Ó*Ð*ÙØ×Ñœ\¨7Õ3Ø×#Ò#Ø�O‰OœL°ÈˆOÕOð $r)   c                 óD  — |€| j                   }| j                  t        j                  k(  rt	        d«      ‚|rt        |t        «      st	        d«      ‚|r&| j                  t        |j                  d«      «       y| j                  r| j                  t        dd¬«       yy)zd
        Write features.fea. This method requires a
        features string as an argument.
        Nz4features.fea is not allowed in UFO Format Version 1.zThe features are not text.Úutf8TFr–  )r…   rš   r   r%   r
   rk   rl   rw  r   ÚencoderO   r…  )r<   Úfeaturesri   s      r*   ÚwriteFeatureszUFOWriter.writeFeatures€  s‹   € ð
 ÐØ—~‘~ˆHØ×ÑÔ"2×"=Ñ"=Ò=ÜÐTÓUÐUÙÜ˜h¬Ô,Ü!Ð">Ó?Ð?ÙØ×!Ñ!Ô"3°X·_±_ÀVÓ5LÕMØ×#Ò#Ø�O‰OÔ-°TÈeˆOÕTð $r)   c                 óÚ  — |€| j                   }| j                  t        j                  k  ry|�%g }|D ]  }|€t        }|j                  |«       Œ |}n#t        | j                  j                  «       «      }|r:t        |«      t        | j                  j                  «       «      k7  rt        d«      ‚|D �cg c]  }|| j                  |   f‘Œ }}| j                  t        |«       yc c}w )zƒ
        Write the layercontents.plist file. This method  *must* be called
        after all glyph sets have been written.
        NzMThe layer order content does not match the glyph sets that have been created.)r…   rš   r   r'   r  r"  r¬   r  rœ  Úsetr
   rX   r  )r<   Ú
layerOrderri   ÚnewOrderr  r  s         r*   ÚwriteLayerContentszUFOWriter.writeLayerContents“  sô   € ð
 ÐØ—~‘~ˆHØ×ÑÔ!1×!<Ñ!<Ò<ØØÐ!ØˆHØ'ò +�	ØÐ$Ü 2�IØ—‘ 	Õ*ð+ð "‰Jä˜d×0Ñ0×5Ñ5Ó7Ó8ˆJÙœ˜J›¬3¨t×/AÑ/A×/FÑ/FÓ/HÓ+IÒIÜØ_óð ð ISö
Ø;DˆY˜×*Ñ*¨9Ñ5Ò6ð
ˆð 
ð 	×ÑÔ/°Õ?ùò
s   Â7C(c                 ó°   — d }t        | j                  j                  «       «      D ]  \  }}|€|t        k(  r|} n||k(  sŒ|} n |st	        d|z  «      ‚|S )Nz>Could not locate a glyph set directory for the layer named %s.)r¬   r  r«   r  r
   )r<   r  ÚfoundDirectoryÚexistingLayerNamer  s        r*   Ú_findDirectoryForLayerNamez$UFOWriter._findDirectoryForLayerName®  s{   € ØˆÜ04°T×5GÑ5G×5MÑ5MÓ5OÓ0Pò 	Ñ,Ð˜}ØÐ  ]Ô6LÒ%LØ!.�ÙØ" iÓ/Ø!.�Ùð	ñ ÜØPØñóð ð Ðr)   c                 ót  — |€| j                   }|€| j                   }| j                  t        j                  k  r'|r|�#t	        d| j                  j
                  › d�«      ‚|€9|r7| j                  j                  «       D ]  \  }}|t        k(  sŒ|}Œ |€t        }n|€|st	        d«      ‚| j                  t        j                  k  r| j                  ||||¬«      S | j                  j
                  t        j                  j
                  k(  r| j                  ||||||¬«      S t        | j                  «      ‚)aW  
        Return the GlyphSet object associated with the
        appropriate glyph directory in the .ufo.
        If layerName is None, the default glyph set
        will be used. The defaultLayer flag indictes
        that the layer should be saved into the default
        glyphs directory.

        ``validateRead`` will validate the read data, by default it is set to the
        class's validate value, can be overridden.
        ``validateWrte`` will validate the written data, by default it is set to the
        class's validate value, can be overridden.
        ``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 use ``getGlyphSet`` to create
        a fresh	glyph set.
        z,Only the default layer can be writen in UFO rÀ   z5A layer name must be provided for non-default layers.)ÚglyphNameToFileNameFuncr  )r  ÚdefaultLayerr¼  r  )r…   rš   r   r'   r
   r›   r  r«   r  r  Ú_getDefaultGlyphSetÚ_getGlyphSetFormatVersion3ræ   )	r<   r  r½  r¼  r  r  r  r¹  r  s	            r*   r­   zUFOWriter.getGlyphSet¾  s\  € ð4 ÐØŸ>™>ˆLØÐ Ø ŸN™NˆMà×ÑÔ!1×!<Ñ!<Ò<Ù 	Ð 5äØ>¸t×?RÑ?R×?XÑ?XÐ>YÐYZÐ[óð ð Ð¡Ø04×0BÑ0B×0HÑ0HÓ0Jò 2Ñ,Ð! 9ØÔ 6Ó6Ø 1‘Ið2ð Ð Ü.‘	ØÐ¡|ÜÐUÓVÐVà×ÑÔ!1×!<Ñ!<Ò<Ø×+Ñ+ØØØ(?Ø#5ð	 ,ó ð ð × Ñ ×&Ñ&Ô*:×*EÑ*E×*KÑ*KÒKØ×2Ñ2ØØØ#Ø)Ø(?Ø#5ð 3ó ð ô & d×&9Ñ&9Ó:Ð:r)   c                 ó€   — ddl m} | j                  j                  t        d¬«      } |||| j
                  |||¬«      S )Nr   r  Trk  ©r¼  r  r  r  r  )r  r  r5   r[  r  rš   )r<   r  r  r¼  r  r  r  s          r*   r¾  zUFOWriter._getDefaultGlyphSet   sC   € õ 	6à—W‘W—_‘_Ô%;Àd�_ÓKˆ
ÙØØ$;Ø!×0Ñ0Ø%Ø'Ø1ô
ð 	
r)   c                 ó  — ddl m} |rO| j                  j                  «       D ]2  \  }}	|	t        k(  r||k7  sŒt        d|z  «      ‚||k(  sŒ)t        d«      ‚ || j                  v r| j                  |   }	nL|rt        }	nC| j                  j                  «       D �
ch c]  }
|
j                  «       ’Œ }}
t        ||d¬«      }	| j                  j                  |	d¬«      }|	| j                  |<    |||| j                  |||¬	«      S c c}
w )
Nr   r  z@Another layer ('%s') is already mapped to the default directory.z8The layer name is already mapped to a non-default layer.úglyphs.©ÚexistingÚprefixTrk  rÁ  )r  r  r  r«   r  r
   ÚvaluesÚlowerr   r5   r[  rš   )r<   r  r  r  r½  r¼  r  r  r¹  r  ÚdrÅ  r  s                r*   r¿  z$UFOWriter._getGlyphSetFormatVersion3  s+  € õ 	6ñ
 Ø04×0BÑ0B×0HÑ0HÓ0Jò 
Ñ,Ð! 9ØÔ 6Ò6Ø(¨IÓ5Ü)Ø^Ø/ñ0óð ð '¨)Ó3Ü%ØRóð ð
ð ˜×*Ñ*Ñ*Ø×*Ñ*¨9Ñ5‰Iñ Ü2‘	ð 04×/AÑ/A×/HÑ/HÓ/JÖK¨!˜AŸG™G�IÐK�ÐKÜ.Ø¨¸ô�	ð —W‘W—_‘_ Y¸�_Ó>ˆ
à(1ˆ×Ñ˜9Ñ%áØØ$;Ø!×0Ñ0Ø%Ø'Ø1ô
ð 	
ùò Ls   ÂDc                 óˆ  — | j                   t        j                  k  ry||k(  r2| j                  |   t        k7  r|sy| j                  |   t        k(  rT|rRy|€t
        }|| j                  v rt        d|z  «      ‚|r+t        | j                  j                  «       v rt        d«      ‚| j                  |«      }|rt        }nC| j                  j                  «       D �ch c]  }|j                  «       ’Œ }}t        ||d¬«      }| j                  |= || j                  |<   | j                  j                  ||d¬«       yc c}w )zÞ
        Rename a glyph set.

        Note: if a GlyphSet object has already been retrieved for
        layerName, it is up to the caller to inform that object that
        the directory it represents has changed.
        Nz A layer named %s already exists.zA default layer already exists.rÃ  rÄ  TrO  )rš   r   r'   r  r  r  r
   rÇ  rº  rÈ  r   r5   Úmovedir)r<   r  ÚnewLayerNamer½  ÚoldDirectoryÚnewDirectoryru   rÅ  s           r*   ÚrenameGlyphSetzUFOWriter.renameGlyphSetI  s<  € ð ×ÑÔ!1×!<Ñ!<Ò<ð ð ˜Ò$ð ×"Ñ" 9Ñ-Ô1GÒGÙ$àà×!Ñ! )Ñ,Ô0FÒFÉ<Øð Ð#Ü1�Ø˜t×1Ñ1Ñ1Ü!Ð"DÀ|Ñ"SÓTÐTáÔ 6¸$×:LÑ:L×:SÑ:SÓ:UÑ UÜ!Ð"CÓDÐDà×6Ñ6°yÓAˆÙÜ1‰Là15×1CÑ1C×1JÑ1JÓ1LÖM¨˜Ÿ
™
�ÐMˆHÐMÜ-Ø x¸	ôˆLð ×Ñ˜yÐ)Ø+7ˆ×Ñ˜<Ñ(à�‰�‰˜ l¸4ˆÕ@ùò Ns   ÃD?c                 ó¢   — | j                   t        j                  k  ry| j                  |«      }| j	                  |d¬«       | j
                  |= y)z:
        Remove the glyph set matching layerName.
        NF)rƒ  )rš   r   r'   rº  r…  r  )r<   r  r¸  s      r*   ÚdeleteGlyphSetzUFOWriter.deleteGlyphSety  sL   € ð ×ÑÔ!1×!<Ñ!<Ò<ð Ø×8Ñ8¸ÓCˆØ�‰˜¸5ˆÔAØ×Ñ˜yÑ)r)   c                 óL   — | j                  t        › dt        |«      › �|«       y)zj
        Write data to fileName in the 'data' directory.
        The data must be a bytes string.
        rb   N)rw  r*  r   )r<   rG   r   s      r*   Ú	writeDatazUFOWriter.writeData…  s%   € ð
 	×Ñ¤ ¨a´¸Ó0BÐ/CÐDÀdÕKr)   c                 óJ   — | j                  t        › dt        |«      › �«       y)zI
        Remove the file named fileName from the data directory.
        rb   N)r…  r*  r   )r<   rG   s     r*   Ú
removeDatazUFOWriter.removeDataŒ  s!   € ð 	�‰œ<˜.¨¬(°8Ó*<Ð)=Ð>Õ?r)   c                 ó(  — |€| j                   }| j                  t        j                  k  r#t	        d| j                  j
                  › d�«      ‚t        |«      }|rt        |¬«      \  }}|st	        |«      ‚| j                  t        › d|› �|«       y)zg
        Write data to fileName in the images directory.
        The data must be a valid PNG.
        NúImages are not allowed in UFO rÀ   r>  rb   )
r…   rš   r   r'   r
   r›   r   r6  rw  r4  )r<   rG   r   ri   rÕ   r	  s         r*   Ú
writeImagezUFOWriter.writeImage”  s•   € ð
 ÐØ—~‘~ˆHØ×ÑÔ!1×!<Ñ!<Ò<ÜØ0°×1DÑ1D×1JÑ1JÐ0KÈ1ÐMóð ô ˜HÓ%ˆÙÜ'¨TÔ2‰LˆE�5ÙÜ! %Ó(Ð(Ø×Ñ¤Ð 0°°(°Ð<¸dÕCr)   c                 óÊ   — | j                   t        j                  k  r#t        d| j                   j                  › d�«      ‚| j                  t        › dt        |«      › �«       y)zS
        Remove the file named fileName from the
        images directory.
        r×  rÀ   rb   N)rš   r   r'   r
   r›   r…  r4  r   )r<   rG   ri   s      r*   ÚremoveImagezUFOWriter.removeImage¦  s_   € ð
 ×ÑÔ!1×!<Ñ!<Ò<ÜØ0°×1DÑ1D×1JÑ1JÐ0KÈ1ÐMóð ð 	�‰œ>Ð*¨!¬H°XÓ,>Ð+?Ð@ÕAr)   c                 ó  — |€| j                   }| j                  t        j                  k  r#t	        d| j                  j
                  › d�«      ‚t        › dt        |«      › �}t        › dt        |«      › �}| j                  |||«       y)zÆ
        Copy the sourceFileName in the provided UFOReader to destFileName
        in this writer. This uses the most memory efficient method possible
        for copying the data possible.
        Nr×  rÀ   rb   )	r…   rš   r   r'   r
   r›   r4  r   rs  )r<   rp  ÚsourceFileNameÚdestFileNameri   rq  rr  s          r*   ÚcopyImageFromReaderzUFOWriter.copyImageFromReader±  s�   € ð ÐØ—~‘~ˆHØ×ÑÔ!1×!<Ñ!<Ò<ÜØ0°×1DÑ1D×1JÑ1JÐ0KÈ1ÐMóð ô 'Ð' q¬°.Ó)AÐ(BÐCˆ
Ü$Ð% Q¤x°Ó'=Ð&>Ð?ˆØ×Ñ˜F J°Õ9r)   c                 óþ  •— | j                   rÖ| j                  t        j                  u rºt        j
                  j                  t        j
                  j                  | j                  «      «      d   dz   }t        j                  j                  | j                  dd¬«      5 }t        j                  j                  | j                  |j                  |«      «       d d d «       t        ‰| �A  «        y # 1 sw Y   ŒxY w)Nr   rN  Tr]   r^   )rO   r{   r   r.   rQ  r=   rY  rZ  r„   r5   rn   ro   rW  rX  r[  Úsuperrˆ   )r<   re  ÚdestFSÚ	__class__s      €r*   rˆ   zUFOWriter.closeÁ  s°   ø€ Ø×!Ò! d×&9Ñ&9Ô=M×=QÑ=QÑ&Qô —g‘g×&Ñ&¤r§w¡w×'7Ñ'7¸¿
¹
Ó'CÓDÀQÑGÈ&ÑPˆGÜ—‘—‘ §
¡
°$À�ÓIð BÈVÜ—‘—‘ §¡¨¯©¸Ó)@ÔA÷Bä‰‰�÷Bð Bús   Â":C3Ã3C<)Nzcom.github.fonttools.ufoLibNT)rM   N)FTrY   rH  )NTNNNF)NF)NTNF)F)#r"   r#   r$   rI  rŽ   ri  rJ  r`  rs  rw  r|  r…  ÚremoveFileForPathr‰  r_  r”  rš  r¢  r©  r¬  r±  r¶  rº  r­   r¾  r¿  rÏ  rÑ  rÓ  rÕ  rØ  rÚ  rÞ  rˆ   Ú__classcell__)râ  s   @r*   r   r   z  sý   ø„ ñð4 Ø1ØØóZò|!ñ ØØ[ô€KòHò.+ó(Mó27ð. #ÐòEò 6òEó23Són*:ó\5TórPó*Uó&@ò6ð$ ØØ $ØØØ ó@;ðL !%Ø ó
ð. ØØ $Ø ó4
ól.Aò`
*òLò@óDó$	Bó:÷ ð r)   r   c                 ó   — t        j                  | «      rt        j                  S t        j
                  j                  | «      rt        j                  S t        j
                  j                  | «      rt        d| z  «      ‚t        d| z  «      ‚)zÿReturn UFOFileStructure.ZIP if the UFO at path 'ufo_path' (str)
    is a zip file, else return UFOFileStructure.PACKAGE if 'ufo_path' is a
    directory.
    Raise UFOLibError if it is a file with unknown structure, or if the path
    does not exist.
    z7The specified UFO does not have a known structure: '%s'zNo such file or directory: '%s')
ÚzipfileÚ
is_zipfiler   r.   rQ  r=   rT  r/   ru  r
   )Úufo_paths    r*   rm   rm   Ô  sr   € ô ×Ñ˜(Ô#Ü×#Ñ#Ð#Ü	�‰�‰�xÔ	 Ü×'Ñ'Ð'Ü	�‰�‰˜Ô	!ÜØEÈÑPó
ð 	
ô Ð;¸hÑFÓGÐGr)   c                 óî   — t         j                  j                  | «      \  }}dj                  dj                  |j                  d«      dd «      dg«      }t         j                  j                  ||«      S )a"  
    Return a .ufo pathname.

    >>> makeUFOPath("directory/something.ext") == (
    ... 	os.path.join('directory', 'something.ufo'))
    True
    >>> makeUFOPath("directory/something.another.thing.ext") == (
    ... 	os.path.join('directory', 'something.another.thing.ufo'))
    True
    rÀ   NéÿÿÿÿÚufo)rQ  r=   ÚsplitÚjoin)r=   Údirru   s      r*   r   r   ç  sZ   € ô —‘—‘˜dÓ#�I€CˆØ�8‰8�S—X‘X˜dŸj™j¨›o¨c¨rÐ2Ó3°UÐ;Ó<€DÜ�7‰7�<‰<˜˜TÓ"Ð"r)   c                 óÐ   — 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 2 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.
    rƒ   ÚvalueValidatorÚvalueOptions)rä   rá   ÚgenericTypeValidator©rí   rî   rï   Ú	valueTypeÚ	validatorrñ  ÚisValidValues          r*   r   r     ó‹   € ô =¸TÑBÐØ"×&Ñ& vÓ.€IØ"×&Ñ&Ð'7Ó8€IØ%×)Ñ)¨.Ó9€LàÐÙ  ¨Ó5ˆð Ðð	 Ô,Ò,Ù$ U¨IÓ6ˆLð Ðñ % UÓ+ˆLØÐr)   c                 ó–   — i }t        | j                  «       «      D ]*  \  }}t        ||«      }|st        d|› d|›d�«      ‚|||<   Œ, |S )a­  
    This performs very basic validation of the value for infoData
    following the UFO 2 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 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.
    úInvalid value for attribute ú (ú).)r¬   r«   r   r
   ©r¡  ÚvalidInfoDatarí   rî   rö  s        r*   rŸ  rŸ    ód   € ð €MÜ˜HŸN™NÓ,Ó-ò (‰ˆˆeÜ@ÀÀuÓMˆÙÜÐ <¸T¸FÀ"ÀUÀIÈRÐPÓQÐQà"'ˆM˜$Òð(ð Ðr)   c                 óÐ   — 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.
    rƒ   rð  rñ  )rå   rá   rò  ró  s          r*   r   r   0  r÷  r)   c                 ó–   — i }t        | j                  «       «      D ]*  \  }}t        ||«      }|st        d|› d|›d�«      ‚|||<   Œ, |S )a­  
    This performs very basic validation of the value for infoData
    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 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.
    rù  rú  rû  )r¬   r«   r   r
   rü  s        r*   rç   rç   J  rþ  r)   é   )r   r    r!   é   é   é   é	   é€   é@   )r   r   r    r!   r  r  >(   ÚnoteÚyearÚfondIDÚnoticeÚlicenseÚxHeightÚascenderÚdesignerÚfondNameÚfontNameÚfullNameÚmenuNameÚttVendorÚuniqueIDÚ	capHeightÚ	copyrightÚ	createdByÚ	descenderÚ	fontStyleÚ	msCharSetÚ	otMacNameÚ	styleNameÚ	trademarkÚ	ttVersionÚ	vendorURLÚ	widthNameÚ
familyNameÚ
licenseURLÚ
slantAngleÚ
ttUniqueIDÚ
unitsPerEmÚ
weightNameÚdesignerURLÚitalicAngleÚotStyleNameÚweightValueÚdefaultWidthÚotFamilyNameÚversionMajorÚversionMinorr"  )rƒ   r  ÚstyleMapFamilyNameÚstyleMapStyleName)rƒ   rð  r.  r/  r	  r  r  r&  r  r  r  r  r)  r  ÚopenTypeHeadCreatedÚopenTypeHeadLowestRecPPEMÚopenTypeHeadFlagsÚintegerList)rƒ   rð  rñ  ÚopenTypeHheaAscenderÚopenTypeHheaDescenderÚopenTypeHheaLineGapÚopenTypeHheaCaretSlopeRiseÚopenTypeHheaCaretSlopeRunÚopenTypeHheaCaretOffsetÚopenTypeNameDesignerÚopenTypeNameDesignerURLÚopenTypeNameManufacturerÚopenTypeNameManufacturerURLÚopenTypeNameLicenseÚopenTypeNameLicenseURLÚopenTypeNameVersionÚopenTypeNameUniqueIDÚopenTypeNameDescriptionÚopenTypeNamePreferredFamilyNameÚ"openTypeNamePreferredSubfamilyNameÚopenTypeNameCompatibleFullNameÚopenTypeNameSampleTextÚopenTypeNameWWSFamilyNameÚopenTypeNameWWSSubfamilyNameÚopenTypeOS2WidthClassÚopenTypeOS2WeightClassÚopenTypeOS2SelectionÚopenTypeOS2VendorIDÚopenTypeOS2PanoseÚopenTypeOS2FamilyClassÚopenTypeOS2UnicodeRangesÚopenTypeOS2CodePageRangesÚopenTypeOS2TypoAscenderÚopenTypeOS2TypoDescenderÚopenTypeOS2TypoLineGapÚopenTypeOS2WinAscentÚopenTypeOS2WinDescentÚopenTypeOS2TypeÚopenTypeOS2SubscriptXSizeÚopenTypeOS2SubscriptYSizeÚopenTypeOS2SubscriptXOffsetÚopenTypeOS2SubscriptYOffsetÚopenTypeOS2SuperscriptXSizeÚopenTypeOS2SuperscriptYSizeÚopenTypeOS2SuperscriptXOffsetÚopenTypeOS2SuperscriptYOffsetÚopenTypeOS2StrikeoutSizeÚopenTypeOS2StrikeoutPositionÚopenTypeVheaVertTypoAscenderÚopenTypeVheaVertTypoDescenderÚopenTypeVheaVertTypoLineGapÚopenTypeVheaCaretSlopeRiseÚopenTypeVheaCaretSlopeRunÚopenTypeVheaCaretOffsetÚpostscriptFontNameÚpostscriptFullNameÚpostscriptSlantAngleÚpostscriptUniqueIDÚpostscriptUnderlineThicknessÚpostscriptUnderlinePositionÚpostscriptIsFixedPitchÚpostscriptBlueValuesÚpostscriptOtherBluesÚpostscriptFamilyBluesÚpostscriptFamilyOtherBluesÚpostscriptStemSnapHÚpostscriptStemSnapVÚpostscriptBlueFuzzÚpostscriptBlueShift)	ÚpostscriptBlueScaleÚpostscriptForceBoldÚpostscriptDefaultWidthXÚpostscriptNominalWidthXÚpostscriptWeightNameÚpostscriptDefaultCharacterÚpostscriptWindowsCharacterSetÚmacintoshFONDFamilyIDÚmacintoshFONDNameÚopenTypeGaspRangeRecordsÚdictListÚopenTypeNameRecordsÚwoffMajorVersionÚwoffMinorVersionÚwoffMetadataUniqueIDÚwoffMetadataVendorÚwoffMetadataCredits)ÚwoffMetadataDescriptionÚwoffMetadataLicenseÚwoffMetadataCopyrightÚwoffMetadataTrademarkÚwoffMetadataLicenseeÚwoffMetadataExtensionsÚ
guidelinesrð  c                 óV   — i }t        | j                  «       «      D ]
  \  }}|||<   Œ |S rY   )r¬   r«   )rÉ  Úflippedr™  rî   s       r*   Ú	_flipDictr’  Š  s2   € Ø€GÜ˜1Ÿ7™7›9“oò ‰
ˆˆUØˆ�Šðà€Nr)   r  r  r(  r  r   r  r#  r  r%  r  r-  r*  r  r'  r|  r+  r  r  r  r€  rz  r~  )	r  r
  r  r,  r$  r  r  r!  r  ÚregularÚitalicÚboldzbold italic)r  r   é    é!   r   r    r!   r  é   é   r  r  r  )	zUltra-condensedzExtra-condensedÚ	CondensedzSemi-condensedzMedium (normal)zSemi-expandedÚExpandedzExtra-expandedzUltra-expandedÚNormalÚAllÚmediumÚMediuméM   é�   é‚   é†   éˆ   é¡   é
   é¢   é   é£   é   é±   é   é²   é   éº   éÈ   é   éÌ   é   é   é   é   )éÞ   éî   éÿ   c                 ó°  — t        |t        «      rt        |«      |k(  rt        |«      }|�’| dk(  r,t        j	                  |«      }|€t        d|›d| › d�«      ‚|}na| dk(  r,t        j	                  |«      }|€t        d|›d| › d�«      ‚|}n0| dk(  r+t        j	                  |«      }|€t        d|›d| › d�«      ‚|}t        j	                  | | «      } | |fS )zº
    Convert value from version 1 to version 2 format.
    Returns the new attribute name and the converted value.
    If the value is None, None will be returned for the new value.
    r  úCannot convert value (ú) for attribute rÀ   r!  r  )	rk   ÚfloatÚintÚ_fontStyle1To2rá   r
   Ú_widthName1To2Ú_msCharSet1To2ÚfontInfoAttributesVersion1To2©rí   rî   Úvs      r*   r   r   è  s  € ô �%œÔÜˆu‹:˜ÒÜ˜“JˆEØÐØ�;ÒÜ×"Ñ" 5Ó)ˆAØˆyÜ!Ø,¨U¨IÐ5EÀdÀVÈ1ÐMóð ð ‰EØ�[Ò Ü×"Ñ" 5Ó)ˆAØˆyÜ!Ø,¨U¨IÐ5EÀdÀVÈ1ÐMóð ð ‰EØ�[Ò Ü×"Ñ" 5Ó)ˆAØˆyÜ!Ø,¨U¨IÐ5EÀdÀVÈ1ÐMóð ð ˆEÜ(×,Ñ,¨T°4Ó8€DØ�ˆ;Ðr)   c                 óÚ   — |�P| dk(  rt         j                  |«      }n5| dk(  rt        j                  |«      }n| dk(  rt        j                  |«      }t        j                  | | «      } | |fS )zº
    Convert value from version 2 to version 1 format.
    Returns the new attribute name and the converted value.
    If the value is None, None will be returned for the new value.
    r1  rK  r~  )Ú_fontStyle2To1rá   Ú_widthName2To1Ú_msCharSet2To1ÚfontInfoAttributesVersion2To1©rí   rî   s     r*   r   r   	  sq   € ð ÐØÐ&Ò&Ü"×&Ñ& uÓ-‰EØÐ,Ò,Ü"×&Ñ& uÓ-‰EØÐ4Ò4Ü"×&Ñ& uÓ-ˆEÜ(×,Ñ,¨T°4Ó8€DØ�ˆ;Ðr)   c                 óÄ   — i }t        | j                  «       «      D ]A  \  }}|dk(  r|dk(  rŒt        ||«      \  }}|t        vrŒ)|€t	        d|›d|› d�«      ‚|||<   ŒC |S )Nr+  rê  r»  r¼  rÀ   )r¬   r«   r   r   r
   ©r   Ú	convertedrí   rî   ÚnewAttrÚnewValues         r*   râ   râ   	  s“   € Ø€IÜ˜DŸJ™J›LÓ)ò &‰ˆˆeð �=Ò  U¨b¢[ØÜRØ�%ó
Ñˆ�ð Ô4Ñ4Øàˆ=ÜØ(¨¨	Ð1AÀ'ÀÈ!ÐLóð ð &ˆ	�'Òð%&ð& Ðr)   c                 ó®   — i }t        | j                  «       «      D ]6  \  }}t        ||«      \  }}|t        vrŒ|€t	        d|›d|› d�«      ‚|||<   Œ8 |S )Nr»  r¼  rÀ   )r¬   r«   r   r   r
   rÌ  s         r*   r   r   5	  s€   € Ø€IÜ˜DŸJ™J›LÓ)ò &‰ˆˆeÜRØ�%ó
Ñˆ�ð Ô4Ñ4Øàˆ=ÜØ(¨¨	Ð1AÀ'ÀÈ!ÐLóð ð &ˆ	�'Òð&ð Ðr)   >   r/  rV  rW  r3  >   r8  r6  rV  r7  rW  rU  r;  rS  rh  ra  rT  r3  rY  rZ  r[  r\  r]  r^  re  rb  rc  r_  r`  rd  c                 ó´  — | t         v r	 t        |«      }| t
        v r	 t        t        |«      «      }| |fS | t        v r5	 t        t        |«      «      }|t        |«      k(  rt        |«      }||k7  r|}| |fS # t        t        f$ r t	        d| z  «      ‚w xY w# t        t        f$ r t	        d| z  «      ‚w xY w# t        t        f$ r t	        d| z  «      ‚w xY w)zº
    Convert value from version 2 to version 3 format.
    Returns the new attribute name and the converted value.
    If the value is None, None will be returned for the new value.
    zCould not convert value for %s.)
Ú_ufo2To3FloatToIntÚroundrÆ   r‚   r
   Ú_ufo2To3NonNegativeIntr¾  ÚabsÚ_ufo2To3NonNegativeIntOrFloatr½  rÃ  s      r*   Ú6convertFontInfoValueForAttributeFromVersion2ToVersion3r×  o	  s
  € ð Ô!Ñ!ð	HÜ˜%“LˆEð Ô%Ñ%ð	HÜœ˜E›
“OˆEð �ˆ;Ðð 
Ô.Ñ	.ð	HÜ”c˜%“jÓ!ˆAð ”�A“Š;Ü�A“ˆAØ�Š:ØˆEØ�ˆ;Ðøô! œIÐ&ò 	HÜÐ?À$ÑFÓGÐGð	Hûô
 œIÐ&ò 	HÜÐ?À$ÑFÓGÐGð	Hûô
 œIÐ&ò 	HÜÐ?À$ÑFÓGÐGð	Hús!   ŠA7 žB ¿B9 Á7BÂB6Â9Cc                 ó
   — | |fS )zº
    Convert value from version 3 to version 2 format.
    Returns the new attribute name and the converted value.
    If the value is None, None will be returned for the new value.
    r(   rÊ  s     r*   Ú6convertFontInfoValueForAttributeFromVersion3ToVersion2rÙ  ‹	  s   € ð �ˆ;Ðr)   c                 ó†   — i }t        | j                  «       «      D ]"  \  }}t        ||«      \  }}|t        vrŒ|||<   Œ$ |S rY   )r¬   r«   rÙ  r   rÌ  s         r*   rž  rž  ”	  sY   € Ø€IÜ˜DŸJ™J›LÓ)ò &‰ˆˆeÜRØ�%ó
Ñˆ�ð Ô4Ñ4ØØ%ˆ	�'Òð&ð Ðr)   c                 ót   — i }t        | j                  «       «      D ]  \  }}t        ||«      \  }}|||<   Œ |S rY   )r¬   r«   r×  )r   rÍ  rí   rî   s       r*   rã   rã    	  sK   € Ø€IÜ˜DŸJ™J›LÓ)ò  ‰ˆˆeÜLØ�%ó
‰ˆˆeð  ˆ	�$Šð	 ð
 Ðr)   Ú__main__)ˆrI  rQ  rW  r   r   Úloggingræ  ÚenumÚcollectionsr   r5   Úfs.baseÚfs.subfsÚ	fs.errorsÚfs.copyÚfs.osfsÚfs.zipfsÚ	fs.tempfsÚfs.toolsÚfontTools.miscr   ÚfontTools.ufoLib.validatorsÚfontTools.ufoLib.filenamesr   ÚfontTools.ufoLib.convertersr	   rÇ   r
   ÚfontTools.ufoLib.utilsr   r   Ú__all__Ú__version__Ú	getLoggerr"   rÈ   r  r*  r4  rÃ   rÞ   rú   rÐ   rò   r   r  ÚLAYERINFO_FILENAMEr  r¥  ÚEnumr   Ú__str__r   r1   r   r   r   rm   r   r   rŸ  r   rç   r¬   ÚrangeÚ fontInfoOpenTypeHeadFlagsOptionsÚ#fontInfoOpenTypeOS2SelectionOptionsÚ'fontInfoOpenTypeOS2UnicodeRangesOptionsÚ(fontInfoOpenTypeOS2CodePageRangesOptionsÚfontInfoOpenTypeOS2TypeOptionsr   rª   rl   Ú"fontInfoStyleMapStyleNameValidatorr¾  r½  Ú$fontInfoOpenTypeHeadCreatedValidatorÚgenericIntListValidatorÚ&fontInfoOpenTypeOS2WidthClassValidatorÚ'fontInfoOpenTypeOS2WeightClassValidatorÚ*fontInfoVersion2OpenTypeOS2PanoseValidatorÚ'fontInfoOpenTypeOS2FamilyClassValidatorÚboolÚ fontInfoPostscriptBluesValidatorÚ%fontInfoPostscriptOtherBluesValidatorÚ fontInfoPostscriptStemsValidatorÚ.fontInfoPostscriptWindowsCharacterSetValidatorrä   r³  rœ  r   rå   ÚupdateÚgenericNonNegativeIntValidatorÚ!genericNonNegativeNumberValidatorÚ*fontInfoVersion3OpenTypeOS2PanoseValidatorÚ)fontInfoOpenTypeGaspRangeRecordsValidatorÚ$fontInfoOpenTypeNameRecordsValidatorÚ%fontInfoWOFFMetadataUniqueIDValidatorÚ#fontInfoWOFFMetadataVendorValidatorÚ$fontInfoWOFFMetadataCreditsValidatorÚ(fontInfoWOFFMetadataDescriptionValidatorÚ$fontInfoWOFFMetadataLicenseValidatorÚ&fontInfoWOFFMetadataCopyrightValidatorÚ&fontInfoWOFFMetadataTrademarkValidatorÚ%fontInfoWOFFMetadataLicenseeValidatorÚ'fontInfoWOFFMetadataExtensionsValidatorÚguidelinesValidatorr   r«   rí   ÚdataDictrò  r’  rÂ  rÉ  r   r¿  rÆ  rÀ  rÇ  rÁ  rÈ  r   r   râ   r   rÔ  rÖ  rÒ  r×  rÙ  rž  rã   ÚdoctestÚtestmodr(   r)   r*   ú<module>r     s&  ðñ óD 
Ý Ý Û Û Û Ý #Û 	Û Û Û Û Û Û Û Û Ý #Ü )Ý 9Ý MÝ /ß Fò€ð" €ð 
ˆ×	Ñ	˜8Ó	$€ð "Ð Ø€Ø€Ø$Ð Ø$Ð Ø€Ø €Ø"Ð Ø"Ð Ø.Ð Ø&Ð à%Ð ô�uÐ4°d·i±iô ð 2×9Ñ9Ð Ô ô�t—y‘yô ÷Iñ Iôbg
�
ô g
ô^N�	ô Nðd €òHò&#ò6ò4ò(ò4ñ, $(©¨a°«Ó#5Ð  Ú&;Ð #Ù*.©u°Q¸«}Ó*=Ð 'Ù+/±°a¸³Ó+=Ð (Ú!3Ð ò)Ð ðVM'Ø‘$˜C”.ðM'à‘˜3”ðM'ð ™$ Cœ.ðM'ð ™ØÐ!Côð	M'ð ‘D˜c”NðM'ð ‘D˜c”NðM'ð ‰D�cŒNðM'ð ‘˜3”ðM'ð ‘˜3”ðM'ð ‘$˜S %˜LÔ)ðM'ð ‘˜C ˜<Ô(ðM'ð ‰t˜#˜u˜Ô&ðM'ð ‘˜C ˜<Ô(ðM'ð  ‘˜3 ˜,Ô'ð!M'ð" ‘4˜e S˜\Ô*ð#M'ð$ ‰D�cŒNð%M'ð& ™4ØÐ!Eôñ'M'ð,  ¡¨C°¨<Ô!8ð-M'ð. ™ØØ.Ø5ôð/M'ð8 ™D s¨E lÔ3ð9M'ð: ™T¨¨U |Ô4ð;M'ð< ™4 c¨5 \Ô2ð=M'ð> !¡$¨C¤.ð?M'ð@  ¡¨3¤ðAM'ðB ™t¨#¨u¨Ô6ðCM'ðD ™D cœNðEM'ðF ™t¨œ~ðGM'ðH ¡¨#¤ðIM'ðJ "¡4¨S¤>ðKM'ðL ™4 Sœ>ðMM'ðN ™d¨œnðOM'ðP ™4 Sœ>ðQM'ðR ™D cœNðSM'ðT ™t¨œ~òUM'ðV &¡t°¤~ðWM'ðX )©$°C¬.ðYM'ðZ %¡d°¤nð[M'ð\ ™d¨œnð]M'ð^  ¡¨3¤ð_M'ð` #¡D¨c¤NðaM'ðb ™TØÐ!GôðcM'ðh ™dØÐ!HôðiM'ðn ™DØØ.Ø8ôðoM'ðx ™4 Sœ>ðyM'ðz ™ØÐ+Uôð{M'ð@ ™dØÐ+RôðAM'ðF ¡ØØ.Ø<ô!ðGM'ðP  ¡ØØ.Ø=ô"ðQM'ðZ ™t¨#¨u¨Ô6ð[M'ð\ ¡¨3°¨,Ô 7ð]M'ð^ ™d¨¨e¨Ô5ò_M'ð` ™D s¨E lÔ3ðaM'ðb ™T¨¨U |Ô4ðcM'ðd ‘tØØ.Ø3ôðeM'ðn  ¡¨C°¨<Ô!8ðoM'ðp  ¡¨C°¨<Ô!8ðqM'ðr "¡4¨c°5¨\Ô#:ðsM'ðt "¡4¨c°5¨\Ô#:ðuM'ðv "¡4¨c°5¨\Ô#:ðwM'ðx "¡4¨c°5¨\Ô#:ðyM'ðz $¡T°°U¨|Ô%<ð{M'ð| $¡T°°U¨|Ô%<ð}M'ð~ ¡¨3°¨,Ô 7ðM'ð@ #¡D¨s°E¨lÔ$;ðAM'ðB #¡D¨s°E¨lÔ$;ðCM'ðD $¡T°°U¨|Ô%<ðEM'ðF "¡4¨c°5¨\Ô#:ðGM'ðH !¡$¨C¤.òIM'ðJ  ¡¨3¤ðKM'ðL ™t¨#¨u¨Ô6ðMM'ðN ™$ Cœ.ðOM'ðP ™$ Cœ.ðQM'ðR ™D u¨c lÔ3ðSM'ðT ™$ Cœ.ðUM'ðV #¡D¨s°E¨lÔ$;ðWM'ðX "¡4¨c°5¨\Ô#:ðYM'ðZ ™d¨œoð[M'ð\ ™DØÐ+Kôð]M'ðb ™DØÐ+PôðcM'ðh ™TØÐ+KôðiM'ðn !¡$ØÐ+Pô#ðoM'ðt ™4ØÐ+KôðuM'ðz ™4ØÐ+Kôð{M'ð@ ™$ S¨% LÔ1ðAM'ðB ™4 c¨5 \Ô2ñCM'ñD   e¨S \Ô2Ù Tœ?Ù#¨#¨u¨Ô6Ù#¨#¨u¨Ô6Ù  cœNÙ"&¨C¤.Ù%)ØÐ!Oô&ñ " sœ^Ù 3œòYM'Ð #ñ\ !Ð!D×!IÑ!IÓ!KÓLÐ á&.Ð/RÓ&SÐ #Ø #× *Ñ *ðOØ™ #Ð6TÔUðOà‘dØ�u�Ð.Oô
ðOð
 	$¡TØÐ%Fô&
ðOð 	¡¨#¤ðOð 	 ¡¨3¤ðOð 	™t¨œ~ðOð 	"¡4¨S¤>ðOð 	™TØØEô
ðOð  	"¡4¨S¤>ð!Oð" 	#¡D¨c¤Nð#Oð$ 	!¡$¨C¤.ð%Oð& 	¡ØÐ%Fô!
ð'Oð, 	 ¡ØÐ%Fô"
ð-Oð2 	$¡T¨s¤^ð3Oð4 	$¡T¨s¤^ð5Oð6 	&¡t°¤~ð7Oð8 	&¡t°¤~ñ9Oð: 	&¡t°¤~ð;Oð< 	&¡t°¤~ð=Oð> 	(©°3¬ð?Oð@ 	(©°3¬ðAOðB 	#¡D¨c¤NðCOðD 	'©°#¬ðEOðF 	#¡DØÐ,Uô%
ðGOðL 	™tØÐ,Pô 
ðMOðR 	'©°#¬ðSOðT 	(©°3¬ðUOðV 	&¡t°¤~ðWOðX 	"¡4¨S¤>ðYOðZ 	™DØÐ%Cô
ð[Oð` 	™DØÐ%Cô
ðaOðf 	¡ØÐ&Kô!
ðgOðl 	™dØÐ&Iô
ðmOðr 	™tØÐ&Jô 
ñsOñx $(ØÐ&Nô$
ñ  $ØÐ&Jô 
ñ "&ØÐ&Lô"
ñ "&ØÐ&Lô"
ñ !%ØÐ&Kô!
ñ #'ØÐ&Mô#
ñ  Ð5HÔIò]OôQñd !Ð!D×!IÑ!IÓ!KÓLÐ ñ Ð>×DÑDÓFÓGò :�N€Dˆ(Ø˜xÒ'Ø%9ˆÐ!Ò"ð:ñ Ð>×DÑDÓFÓGò :�N€Dˆ(Ø˜xÒ'Ø%9ˆÐ!Ò"ð:òð!ØÐ$ð!àÐ&ð!ð Ð,ð!ð Ð+ð	!ð
 Ð.ð!ð Ð$ð!ð Ð*ð!ð Ð&ð!ð Ð(ð!ð Ð'ð!ð Ð5ð!ð Ð7ð!ð Ð1ð!ð Ð(ð!ð Ð+ð!ð  Ð%ð!!ð" Ð$ð#!ð$ %Ø%Ø#Ø-Ø(Ø$à$Ø(Ø0ò7!Ð ñ: !*Ð*GÓ HÐ Ù'*Ð+H×+MÑ+MÓ+OÓ'PÐ $à H°&¸mÑL€Ù˜>Ó*€à€ˆqÑ ð ØØØØØØØØñ
€ñ ˜>Ó*€ð €ˆxÑ ð €ˆuÑ à€ˆxÑ à€ˆxÑ ðØ€qðà€qðð €qðð ˆð	ð
 ˆðð ˆðð ˆðð ˆðð ˆðð ˆðð ˆðð ˆðð ˆðð ˆðð ˆðð  ˆð!ð" ˆð#ð$ 
Ø	Ø	ò)€ñ, ˜>Ó*€ò
!òHò"ò0ò*Ð ð ð!Ð òÐ ò8ò8ò	òð ˆzÒÛà€G‡O‚OÕð r)   