Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 2øªj4ã`@s¢ ddlZddlmZddlmZddlZddlZddlZddlmZddl Z ddl Z ddl Z ddl Z ddl Z ddlZ ddlZ ddlZ ddlZ ddlmZddlTddlmZddlmZdd lmZdd lmZmZd d d dddddddddddgZdZej e!ƒZ"dZ#dZ$dZ%dZ&dZ'dZ(d Z)d!Z*d"Z+d#Z,d$Z-d%Z.Gd&d'„d'e/eej0ƒZ1Gd(d„dej0ƒZ2Gd)d*„d*ƒZ3Gd+d „d e3ƒZ4Gd,d„de4ƒZ5e5Z6d-d.„Z7d/d „Z8d0d„Z9d1d2„Z:d3d„Z;d4d5„Zdd6ƒƒZ?d7d8d9d:d;ddd>ƒƒZAe=e>dd?ƒƒZBdd7d8d9d/tmp/pip-build-_d5lkt3n/fonttools/fontTools/ufoLib/__init__.pyr`src@seZdZdZdZdS)rÚzipÚpackageN)rrr ÚZIPÚPACKAGEr$r$r$r%rfsc@s&eZdZdd„Zddd„Zdd„ZdS) Ú _UFOBaseIOc CsJy|jjt|ƒdgd�j}Wn tjjtjjfk r<dSX|jƒSdS)zæ 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ÚerrorsZMissingInfoNamespaceÚResourceNotFoundÚ timestamp)ÚselfÚpathÚdtr$r$r%ÚgetFileModificationTimers z"_UFOBaseIO.getFileModificationTimeNcCsžy$|jj|dƒ� }tj|ƒSQRXWnttjjk r\|dkrTtd||jfƒ‚n|SYn>tk r˜}z"td|›d|j›d|›�ƒ‚WYdd}~XnXdS)al 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. ÚrbNz,'%s' is missing on %s. This file is requiredú'z' could not be read on z: )r-ÚopenrÚloadr0r1r Ú Exception)r3ÚfileNameÚdefaultÚfÚer$r$r%Ú _getPlist€s z_UFOBaseIO._getPlistcCsä|jr|ytj|ƒ}Wn6tk rJ}ztd||j|fƒ‚WYdd}~XnX|jj|ƒrl||jj|ƒkrldS|jj||ƒnd|jj |dd��N}ytj ||ƒWn6tk rÔ}ztd||j|fƒ‚WYdd}~XnXWdQRXdS)aO 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. zN'%s' could not be written on %s because the data is not properly formatted: %sNÚw)Úmode) Ú_havePreviousFilerÚdumpsr;r r-ÚexistsÚ readbytesÚ writebytesÚopenbinÚdump)r3r<Úobjrr?Úfpr$r$r%Ú _writePlist›s""z_UFOBaseIO._writePlist)N)rrr r6r@rLr$r$r$r%r*ps r*c@sNeZdZdZdFdd„Zdd„Zeedd�Zd d „Zeed d�Z ed d „ƒZ dd„Z ee dd�Z dd„Z dd„ZdGdd„ZdHdd„ZdIdd„Zdd„ZdJdd„ZdKd d!„Zd"d#„ZdLd$d%„Zd&d'„ZdMd(d)„ZdNd*d+„Zd,d-„Zd.d/„ZdOd0d1„ZdPd2d3„ZdQd4d5„ZdRd6d7„Zd8d9„Z dSd:d;„Z!dd?„Z#d@dA„Z$dBdC„Z%dDdE„Z&dS)Ur zŠ Read the various components of the .ufo. By default read data is validated. Set ``validate`` to ``False`` to not validate the data. TcCsæt|dƒr|jƒ}t|tƒrøt|ƒ}y.|tjkrDtjj |ddd�}n tj j |ƒ}Wn:tj j k rŒ}ztd|›d|›�ƒ‚WYdd}~XnX|tjkrädd„|jd ƒDƒ}t|ƒd krÒ|j|d tjjd �|_qêtd t|ƒƒ‚n||_d|_||_n¢t|tjjƒ�rˆ|}y |jƒWn&tj jk �r>td|ƒ‚YnX||_y|jd ƒ}Wn"tj jk �rvt|ƒ}YnXd|_tj|_ntdt|ƒjƒ‚t |ƒ|_!||_"d|_#y|j$|d�Wn tk �rà|j%ƒ‚YnXdS)NÚ __fspath__Fzutf-8)ÚwriteÚencodingzunable to open 'z': cSs"g|]}|jr|jdkr|j‘qS)Ú__MACOSX)Úis_dirÚname)Ú.0Úpr$r$r%ú àsz&UFOReader.__init__..ú/rr)Úfactoryz+Expected exactly 1 root directory, found %dTzthe filesystem '%s' is closedz7Expected a path string or fs.base.FS object, found '%s')Úvalidate)&ÚhasattrrMÚ isinstanceÚstrÚ_sniffFileStructurerr(r-ÚzipfsÚZipFSÚosfsÚOSFSr0Z CreateFailedr ÚscandirÚlenÚopendirÚsubfsÚ ClosingSubFSÚ _shouldCloseÚ_fileStructureÚbaseÚFSÚcheckÚFilesystemClosedÚ getsyspathÚ NoSysPathr)Ú TypeErrorÚtyperrÚ_pathÚ _validateÚ_upConvertedKerningDataÚ readMetaInfoÚclose)r3r4rXÚ structureÚparentFSr?ÚrootDirsÚ filesystemr$r$r%Ú__init__ÎsX   &     zUFOReader.__init__cCsddl}|jdtdd�|jS)NrzBThe 'path' attribute is deprecated; use the 'fs' attribute insteadr)Ú stacklevel)ÚwarningsÚwarnÚDeprecationWarningrp)r3r{r$r$r%Ú _get_paths zUFOReader._get_pathz!The path of the UFO (DEPRECATED).)ÚdoccCs ddl}|jdtdd�|jjS)NrzIThe 'formatVersion' attribute is deprecated; use the 'formatVersionTuple'r)rz)r{r|r}Ú_formatVersionÚmajor)r3r{r$r$r%Ú_get_formatVersion$s zUFOReader._get_formatVersionzIThe (major) format version of the UFO. DEPRECATED: Use formatVersionTuplecCs|jS)zpThe (major, minor) format version of the UFO. This is determined by reading metainfo.plist during __init__. )r€)r3r$r$r%ÚformatVersionTuple3szUFOReader.formatVersionTuplecCs|jS)N)rg)r3r$r$r%Ú_get_fileStructure:szUFOReader._get_fileStructurezVThe file structure of the UFO: either UFOFileStructure.ZIP or UFOFileStructure.PACKAGEc Cs |jrD|jƒ}||jdkr$tdƒ‚|jƒ}||jdkrBtdƒ‚nØ|jƒ}|rÂd}t|tƒsft|ƒ‚xZ|jƒD]N\}}t|tƒsŒt|ƒ‚nt|tƒsžt|ƒ‚x|D]}t|tƒs¤t|ƒ‚q¤WqpWti|jƒi|d�|_t |jdt |jdƒ|j ƒƒ\} }} | |jd<||jd<| |jd <d S) aF 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) rrÚ _readKerningr Ú _readGroupsrZÚdictÚitemsr[ÚlistrrÚ getGlyphSet) r3rXZ testKerningZ testGroupsrˆÚinvalidFormatMessageÚ groupNameÚ glyphListÚ glyphNamer‡ZconversionMapsr$r$r%Ú_upConvertKerningGs@            zUFOReader._upConvertKerningc Cs.y|jjt|ƒƒStjjk r(dSXdS)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)r-rFrr0r1)r3r4r$r$r%ÚreadBytesFromPathyszUFOReader.readBytesFromPathNc CsPt|ƒ}y*|dkr|jj|ƒS|jj|d|d�SWntjjk rJdSXdS)ad 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)rBrO)rr-rHr9r0r1)r3r4rOr$r$r%ÚgetReadFileForPath„s  zUFOReader.getReadFileForPathc Cs|dkr|j}|jtƒ}|r0t|tƒ r0tdƒ‚y |d}Wn*tk rftdt›d|j›�ƒ‚YnX|jddƒ}yt ||fƒ}Wnpt k rô}zTd|›d |›d t›d|j›�}|rÎdd l m }||ƒ|‚t j ƒ}tjd ||ƒWYdd}~XnX||d <|S)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 'z' on ÚformatVersionMinorrzUnsupported UFO format (Ú.z) in ')ÚUnsupportedUFOFormatz^%s. Assuming the latest supported version (%s). Some data may be skipped or parsed incorrectlyrƒ)rqr@ÚMETAINFO_FILENAMErZrŒr ÚKeyErrorr-Ú setdefaultrÚ ValueErrorÚfontTools.ufoLib.errorsr›r=ÚloggerÚwarning) r3rXrZformatVersionMajorr™r˜r?ZunsupportedMsgr›r$r$r%Ú _readMetaInfo˜s0     zUFOReader._readMetaInfocCs|j|d�}|d|_dS)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. )rXrƒN)r£r€)r3rXrr$r$r%rsÁs zUFOReader.readMetaInfocCsB|jtiƒ}x0|jƒD]$\}}|jdƒrttj|ƒƒ||<qW|S)Nú public.kern1.ú public.kern2.)r¤r¥)r@ÚGROUPS_FILENAMEr�Ú startswithrŽrÚfromkeys)r3rˆr‘r’r$r$r%r‹Ís   zUFOReader._readGroupscCsX|dkr|j}|jtjkr0|j|ƒ|jd}n|jƒ}|rTt|ƒ\}}|sTt|ƒ‚|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. Nrˆ) rqr€rr#r”rrr‹ÚgroupsValidatorr )r3rXrˆÚvalidÚmessager$r$r%Ú readGroupsÕs    zUFOReader.readGroupscCs<|dkr|j}|jtjkr&tiid�S|j|d�|jdS)aÔ 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. N)Úside1Úside2)rXr‰)rqr€rr#rŒr¬rr)r3rXr$r$r%Ú#getKerningGroupConversionRenameMapsês    z-UFOReader.getKerningGroupConversionRenameMapscCs(|jtiƒ}|r$t|tƒ r$tdƒ‚|S)Nz)fontinfo.plist is not properly formatted.)r@ÚFONTINFO_FILENAMErZrŒr )r3rXrr$r$r%Ú _readInfos zUFOReader._readInfoc Csb|dkr|j}|j|ƒ}i}|jtjkrbx&tD]}|j|ƒ}|dk r.|||<q.Wt|ƒ}t|ƒ}nž|jtj kr®x4t t j ƒƒD]$\}}|j|ƒ}|dkr˜q||||<q|Wt|ƒ}nR|jj tjj kröx@t tj ƒƒD]$\}}|j|ƒ}|dkrèqÌ|||<qÌWn t|jƒ‚|�rt|ƒ}xNt |j ƒƒD]>\}}yt|||ƒWn"tk �rVtd|ƒ‚YnX�qWdS)aR 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).)rqr±r€rr!rÚgetÚ&_convertFontInfoDataVersion1ToVersion2Ú&_convertFontInfoDataVersion2ToVersion3r"rŽÚ#fontInfoAttributesVersion2ValueDatar�r�r#Ú#fontInfoAttributesVersion3ValueDataÚNotImplementedErrorÚvalidateInfoVersion3DataÚsetattrÚAttributeErrorr )r3ÚinforXZinfoDictZ infoDataToSetÚattrÚvalueÚdataValidationDictr$r$r%ÚreadInfo s@             zUFOReader.readInfocCs|jtiƒ}|S)N)r@ÚKERNING_FILENAME)r3rr$r$r%rŠ@s zUFOReader._readKerningc Cs”|dkr|j}|jtjkr0|j|ƒ|jd}n|jƒ}|rTt|ƒ\}}|sTt|ƒ‚i}x6|D].}x(||D]}|||}||||f<qlWq^W|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. Nr‡) rqr€rr#r”rrrŠZkerningValidatorr ) r3rXZ kerningNestedrªr«r‡ÚleftÚrightr½r$r$r%Ú readKerningDs       zUFOReader.readKerningcCs:|dkr|j}|jtiƒ}|r6t|ƒ\}}|s6t|ƒ‚|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. N)rqr@Ú LIB_FILENAMEÚfontLibValidatorr )r3rXrrªr«r$r$r%ÚreadLibbs  zUFOReader.readLibcCsDy&|jjtddd�� }|jƒSQRXWntjjk r>dSXdS)z` Read features.fea. Return a string. The returned string is empty if the file is missing. r–zutf-8)rONÚ)r-r9ÚFEATURES_FILENAMEÚreadr0r1)r3r>r$r$r%Ú readFeaturests zUFOReader.readFeaturescCsD|jtjkrttfgS|jtƒ}|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€rr#ÚDEFAULT_LAYER_NAMEÚDEFAULT_GLYPHS_DIRNAMEr@ÚLAYERCONTENTS_FILENAMEZlayerContentsValidatorr-r )r3rXÚcontentsrªÚerrorr$r$r%Ú_readLayerContents�s   zUFOReader._readLayerContentscCs*|dkr|j}|j|ƒ}dd„|Dƒ}|S)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. NcSsg|] \}}|‘qSr$r$)rSÚ layerNameÚ directoryNamer$r$r%rU›sz+UFOReader.getLayerNames..)rqrÐ)r3rXÚ layerContentsZ layerNamesr$r$r%Ú getLayerNames‘s  zUFOReader.getLayerNamescCsB|dkr|j}|j|ƒ}x|D]\}}|tkr|SqWtdƒ‚dS)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. Nz8The default layer is not defined in layercontents.plist.)rqrÐrÌr )r3rXrÓrÑZlayerDirectoryr$r$r%ÚgetDefaultLayerNamežs zUFOReader.getDefaultLayerNamec CsÒddlm}|dkr|j}|dkr(|j}|dkr<|j|d�}d}|j|ƒ}x|D]\}}||krP|}PqPW|dkr~td|ƒ‚y|jj|ƒ} Wn.tjj k r¼td|›d|›d�ƒ‚YnX|| |j ||d d �S) 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)ÚGlyphSetN)rXz&No glyphs directory is mapped to "%s".zNo 'z' directory for layer 'r8T)ÚufoFormatVersionÚ validateReadÚ validateWriteÚexpectContentsFile) ÚfontTools.ufoLib.glifLibrÖrqrÕrÐr r-rcr0r1r€) r3rÑrØrÙrÖÚ directoryrÓZstoredLayerNameZstoredLayerDirectoryÚ glyphSubFSr$r$r%r�®s4    zUFOReader.getGlyphSetc Cst|dkr|j}|j||dd�}|jƒ}i}xD|jƒD]8\}}x.|D]&}||kr^||j|ƒqB|g||<qBWq4W|S)zT Return a dictionary that maps unicode values (ints) to lists of glyph names. NT)rØrÙ)rqr�Z getUnicodesr�Úappend) r3rÑrXZglyphSetZ allUnicodesZcmapr“ZunicodesÚcoder$r$r%ÚgetCharacterMappingÙs zUFOReader.getCharacterMappingcCs~y|jjtƒ|_Wn6tjjk r*gStjjk rHtdƒ‚YnXydd„|jjj ƒDƒStjj k rxgSXdS)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.cSsg|]}|jdƒ‘qS)rV)Úlstrip)rSrTr$r$r%rUÿsz5UFOReader.getDataDirectoryListing..N) r-rcÚ DATA_DIRNAMEÚ_dataFSr0r1ÚDirectoryExpectedr ÚwalkÚfilesÚ ResourceError)r3r$r$r%ÚgetDataDirectoryListingísz!UFOReader.getDataDirectoryListingcCsØ|jtjkrgS|dkr|j}y|jjtƒ|_}Wn6tjj k rLgStjj k rjt dƒ‚YnXg}xb|j dƒD]T}|j rˆq||rÄ|j|jƒ�}t|d�\}}WdQRX|rÐ|j|jƒq||j|jƒq|W|S)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.rV)ZfileObj)r€rr#rqr-rcÚIMAGES_DIRNAMEÚ _imagesFSr0r1rär rarQrHrRÚ pngValidatorrÞ)r3rXÚimagesFSÚresultr4rKrªrÏr$r$r%ÚgetImageDirectoryListings* z"UFOReader.getImageDirectoryListingcCsvt|ƒ}y:y |j}Wn tk r4|jjtƒ}YnX|j|ƒ}Wn.tjjk rpt d|›d|j›�ƒ‚YnX|S)zN Return bytes for the file named 'fileName' inside the 'data/' directory. zNo data file named 'z' on ) rrãrºr-rcrârFr0r1r )r3r<ZdataFSrr$r$r%ÚreadData&s zUFOReader.readDatacCsÂ|dkr|j}|jtjkr.td|jj›d�ƒ‚t|ƒ}y:y |j}Wn tk rb|j j t ƒ}YnX|j |ƒ}Wn.t j jk ržtd|›d|j ›�ƒ‚YnX|r¾t|d�\}}|s¾t|ƒ‚|S)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. Nz%Reading images is not allowed in UFO ršzNo image file named 'z' on )r)rqr€rr#r r�rrêrºr-rcrérFr0r1rë)r3r<rXrìrrªrÏr$r$r%Ú readImage6s&  zUFOReader.readImagecCs|jr|jjƒdS)N)rfr-rt)r3r$r$r%rtSszUFOReader.closecCs|S)Nr$)r3r$r$r%Ú __enter__WszUFOReader.__enter__cCs |jƒdS)N)rt)r3Úexc_typeÚ exc_valueÚexc_tbr$r$r%Ú__exit__ZszUFOReader.__exit__)T)N)N)N)N)N)N)N)N)N)N)NNN)NN)N)N)'rrr Ú__doc__ryr~Úpropertyr4r‚r˜rƒr„Z fileStructurer”r•r—r£rsr‹r¬r¯r±r¿rŠrÃrÆrÊrÐrÔrÕr�ràrèrîrïrðrtrñrõr$r$r$r%r ÅsN J   2  )    4     +  " cs eZdZdZd?dd„Zdd„Zeed d �Zd d „Zd d„Z d@dd„Z dAdd„Z e Z dd„Z dd„Zdd„ZdBdd„ZdCdd„ZdDdd „ZdEd!d"„ZdFd#d$„ZdGd%d&„Zd'd(„ZdHd)d*„ZdId+d,„ZdJd-d.„ZdKd/d0„Zd1d2„Zd3d4„Zd5d6„ZdLd7d8„ZdMd9d:„ZdNd;d<„Z ‡fd=d>„Z!‡Z"S)OraŽ Write the various components of the .ufo. 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. The ``formatVersion`` argument allows to specify the UFO format version as a tuple of integers (major, minor), or as a single integer for the major digit only (minor is implied as 0). By default the latest formatVersion will be used; currently it's 3.0, which is equivalent to formatVersion=(3, 0). An UnsupportedUFOFormat exception is raised if the requested UFO formatVersion is not supported. Núcom.github.fonttools.ufoLibTc$CsÀy t|ƒ}Wn>tk rJ}z"ddlm}|d|›�ƒ|‚WYdd}~XnXt|dƒr^|jƒ}t|tƒ�r(tj j |ƒ}tj j |ƒ}|rät |ƒ} |dk rÞy t |ƒ}Wn tk rÂtd|ƒ‚YnX|| k râtd| |fƒ‚n| }n<|dkròt j}tj j|ƒ} | �r tj j| ƒ �r td|ƒ‚|t jk�r|�r´tjjƒ} tjj|dd ��} tjj| | ƒWdQRXd d „| jd ƒDƒ} t| ƒd k�rštdt| ƒƒ‚n| j| dtjjd�|_nLtj jtj j |ƒƒdd}tjj|ddd�} | j!|ƒ| j|tjjd�|_ntj"j#|dd�|_||_$||_%d|_&nØt|tj'j(ƒ�rî|}y |j)ƒWn&tj*j+k �rntd|ƒ‚YnX||_y|j,d ƒ}Wn"tj*j-k �r¦t|ƒ}YnX|�rÒ|t jk �rÒddl.}|j/dt0dd�t j|_$|j t1ƒ|_%d|_&nt2dt3|ƒj4ƒ‚t5|ƒ|_6||_7||_8d|_9||_:d}|j%�rn|j;|d�}|d}||k�rnddlm}|d|›d|›d�ƒ‚i|_<|dk �rœ|j=dk�rœt>|j?|ƒƒ|_.rVrz+Expected exactly 1 root directory, found %d)rWz.ufoT)rNrO)Úcreatezthe filesystem '%s' is closedz?The 'structure' argument is not used when input is an FS objectr)rzFz-Expected a path string or fs object, found %s)rXrƒ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)CrrŸr r›rYrMrZr[Úosr4ÚnormpathrEr\rr r)ÚdirnameÚisdirr(r-ZtempfsZTempFSr]r^ÚcopyÚcopy_fsrarbrcrdreÚsplitextÚbasenameÚmakedirr_r`rgrCrfrhrirjr0rkrlrmr{r|Ú UserWarningrœrnrorrrpr€Ú _fileCreatorÚ_downConversionKerningDatarqr£rÓr�rrÐrÌrËÚ_writeMetaInfo)r3r4r˜Ú fileCreatorrurXr?r›ZhavePreviousFileZexistingStructureÚdirNamervZorigFSrwÚrootDirrxr{ZpreviousFormatVersionÚmetaInfor$r$r%ryts´  "                 zUFOWriter.__init__cCs|jS)N)r)r3r$r$r%Ú_get_fileCreatorszUFOWriter._get_fileCreatorzMThe file creator of the UFO. This is set into metainfo.plist during __init__.)rcCs¨t|tƒstdƒ‚t|ƒ}t|ƒ}|jj|ƒs:td|ƒ‚|jj|ƒrRtd|ƒ‚|jjtjj|ƒdd�|jj |ƒrŽtj j |j||j|ƒntj j |j||j|ƒdS)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) rZr r rr-rEÚmakedirsr4rürýrþZcopy_dirÚ copy_file)r3ÚreaderÚ sourcePathÚdestPathr$r$r%ÚcopyFromReaders      zUFOWriter.copyFromReaderc Cs¦t|ƒ}|jr.|jj|ƒr.||jj|ƒkr.dSy|jj||ƒWn`tjjk rdtd|ƒ‚Yn>tjj k r |jj tj j |ƒdd�|jj||ƒYnXdS)aA 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. NzA directory exists at '%s'T)r ) rrCr-ÚisfilerFrGr0Ú FileExpectedr r1r r4rü)r3r4rr$r$r%ÚwriteBytesToPath+szUFOWriter.writeBytesToPathrAcCsÖt|ƒ}y|jj|||d�Stjjk r–}z\|d}|dkrDdS|dks\|dks\|dkr†|jjtjj|ƒdd �|jj|||d�SWYdd}~Xn<tjjk rÐ}zt d |›d |j›d |›�ƒSd}~XnXdS) 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 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. )rBrOrr–NrAÚaÚxT)r zunable to open 'z' on z: ) rr-r9r0r1r r4rürçr )r3r4rBrOr?Úmr$r$r%ÚgetFileObjectForPath?s "zUFOWriter.getFileObjectForPathFc Cs–t|ƒ}y|jj|ƒWnTtjjk r<|jj|ƒYn2tjjk rl|shtd|›d|j›�ƒ‚YnX|r’tjj |ƒ}|r’tj j |j|ƒdS)a5 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. r8z' does not exist on N) rr-Úremover0rZ removetreer1r r4rüÚtoolsZ remove_empty)r3r4ÚforceÚremoveEmptyParentsÚparentr$r$r%Ú removePathZs  zUFOWriter.removePathcCs^|j}|dk rZtjj|ƒrZytj|dƒWn.tk rX}ztjd|ƒWYdd}~XnXdS)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. NzFailed to set modified time: %s)rprúr4rEÚutimeÚOSErrorr¡r¢)r3r4r?r$r$r%ÚsetModificationTimews zUFOWriter.setModificationTimecCs:t|j|jjd�}|jjdkr*|jj|d<|jt|ƒdS)N)Zcreatorr˜rr™)rŒrr€r�ÚminorrLrœ)r3r r$r$r%r‡s    zUFOWriter._writeMetaInfocCsX|jtjkrdSi}x2dD]*}x$t||jƒƒD]\}}|||<q0WqWt|d�|_dS)aä 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­r®)ÚgroupRenameMap)r­r®)r€rr#rŽr�rŒr)r3ÚmapsÚremapZsideZ writeNameZdataNamer$r$r%Ú#setKerningGroupConversionRenameMaps’s  z-UFOWriter.setKerningGroupConversionRenameMapsc Cs|dkr|j}|r*t|ƒ\}}|s*t|ƒ‚|jtjkr²|jdk r²|jd}i}x*t|jƒƒD]\}}||krnq\|||<q\Wx2t|jƒƒD]"\}}||kršqˆ||}|||<qˆW|}i} x |jƒD]\} } t| ƒ| | <qÀW| rê|j t | ƒn|j �r|j t ddd�dS)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)rr) rqr©r r€rr#rrŽr�rLr¦rCr) r3rˆrXrªr«r&ZremappedGroupsrRrÎZ groupsNewÚkeyr½r$r$r%Ú writeGroups«s6       zUFOWriter.writeGroupsc Csì|dkr|j}i}x`ttjƒƒD]P}t||ƒr yt||ƒ}Wn tk r\td|ƒ‚YnX|dkrhq |||<q W|jt j krŽ|rØt |ƒ}nJ|jt j kr°t |ƒ}|rØt|ƒ}n(|jt jkrØt |ƒ}|rÐt|ƒ}t|ƒ}|rè|jt|ƒdS)aR 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).)rqrŽr¶ÚkeysrYÚgetattrrºr r€rr#r¸r"Ú&_convertFontInfoDataVersion3ToVersion2ÚvalidateInfoVersion2Datar!Ú&_convertFontInfoDataVersion2ToVersion1rLr°)r3r»rXÚinfoDatar¼r½r$r$r%Ú writeInfoâs4        zUFOWriter.writeInfoc CsŠ|dkr|j}|r¨d}t|ƒs&t|ƒ‚x€t|jƒƒD]p\}}t|ttfƒsRt|ƒ‚t|ƒdksft|ƒ‚t|dtƒs|t|ƒ‚t|dtƒs’t|ƒ‚t|t ƒs4t|ƒ‚q4W|j t j ko¼|j dk �r|j d}i}x@t|jƒƒD]0\\}} }|j||ƒ}|j| | ƒ} |||| f<qÜW|}i} x@|jƒD]4\} } || | f}| | k�rHi| | <|| | | <�q"W| �rn|jt| ƒn|j�r†|jtddd �dS) 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.rrrr$TF)rr)rqZ isDictEnoughr rŽr�rZÚtuplerbr[r r€rr#rr²r*rLrÀrCr) r3r‡rXr�Úpairr½r&ZremappedKerningr­r®Z kerningDictrÁrÂr$r$r%Ú writeKerning sH           zUFOWriter.writeKerningcCsV|dkr|j}|r*t|ƒ\}}|s*t|ƒ‚|r<|jt|ƒn|jrR|jtddd�dS)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. NTF)rr)rqrÅr rLrÄrCr)r3ZlibDictrXrªr«r$r$r%ÚwriteLibFs zUFOWriter.writeLibcCsj|dkr|j}|jtjkr"tdƒ‚|r8t|tƒs8tdƒ‚|rP|jt|j dƒƒn|j rf|j tddd�dS)zR Write features.fea. This method requires a features string as an argument. Nz4features.fea is not allowed in UFO Format Version 1.zThe features are not text.Úutf8TF)rr) rqr€rr!r rZr[rrÈÚencoderCr)r3ÚfeaturesrXr$r$r%Ú writeFeatures[s  zUFOWriter.writeFeaturescs¦|dkrˆj}ˆjtjkrdS|dk rTg}x"|D]}|dkr@t}|j|ƒq0W|}ntˆjjƒƒ}|r„t |ƒt ˆjjƒƒkr„t dƒ‚‡fdd„|Dƒ}ˆj t |ƒdS)zq 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.csg|]}|ˆj|f‘qSr$)rÓ)rSrÑ)r3r$r%rU‚sz0UFOWriter.writeLayerContents..) rqr€rr#rËrÞrŽrÓr*Úsetr rLrÍ)r3Z layerOrderrXZnewOrderrÑrÓr$)r3r%ÚwriteLayerContentsns   zUFOWriter.writeLayerContentscCsZd}x@t|jjƒƒD].\}}|dkr4|tkr4|}Pq||kr|}PqW|sVtd|ƒ‚|S)Nz>Could not locate a glyph set directory for the layer named %s.)rŽrÓr�rÌr )r3rÑÚfoundDirectoryÚexistingLayerNamerÒr$r$r%Ú_findDirectoryForLayerName…s z$UFOWriter._findDirectoryForLayerNamec Csð|dkr|j}|dkr|j}|jtjkrJ| s6|dk rJtd|jj›d�ƒ‚|dkrˆ|rˆx"|jjƒD]\}}|tkrb|}qbW|dkržt }n|dkrž| ržtdƒ‚|jtjkr¼|j ||||d�S|jjtjjkrâ|j ||||||d�St |jƒ‚dS)aý 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. Nz,Only the default layer can be writen in UFO ršz5A layer name must be provided for non-default layers.)ÚglyphNameToFileNameFuncrÚ)rÑÚ defaultLayerr>rÚ) rqr€rr#r r�rÓr�rÌrËÚ_getDefaultGlyphSetÚ_getGlyphSetFormatVersion3r·) r3rÑr?r>rØrÙrÚr<rÜr$r$r%r�’s>   zUFOWriter.getGlyphSetcCs2ddlm}|jjtdd�}||||j|||d�S)Nr)rÖT)r )r>r×rØrÙrÚ)rÛrÖr-rrÌr€)r3rØrÙr>rÚrÖrÝr$r$r%r@Õs zUFOWriter._getDefaultGlyphSetc CsÈddlm}|rVxD|jjƒD]6\}} | tkrB||krRtd|ƒ‚q||krtdƒ‚qW||jkrl|j|} n,|rvt} n"dd„|jjƒDƒ} t|| dd�} |jj | d d �} | |j|<|| ||j |||d �S) Nr)rÖz@Another layer ('%s') is already mapped to the default directory.z8The layer name is already mapped to a non-default layer.cSsh|] }|jƒ’qSr$)Úlower)rSÚdr$r$r%ú sz7UFOWriter._getGlyphSetFormatVersion3..zglyphs.)ÚexistingÚprefixT)r )r>r×rØrÙrÚ) rÛrÖrÓr�rÌr Úvaluesrr-rr€) r3rØrÙrÑr?r>rÚrÖr<rÜrErÝr$r$r%rAès2      z$UFOWriter._getGlyphSetFormatVersion3cCsâ|jtjkrdS||krH|j|tkr0| r0dS|j|tkr„|r„dSn<|dkrTt}||jkrjtd|ƒ‚|r„t|jjƒkr„tdƒ‚|j|ƒ}|r˜t}n"dd„|jjƒDƒ}t ||dd�}|j|=||j|<|j j ||dd �dS) 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.zA default layer already exists.cSsh|] }|jƒ’qSr$)rB)rSrRr$r$r%rD=sz+UFOWriter.renameGlyphSet..zglyphs.)rErFT)rù) r€rr#rÓrÌrËr rGr=rr-Zmovedir)r3rÑZ newLayerNamer?Z oldDirectoryZ newDirectoryrEr$r$r%ÚrenameGlyphSets*     zUFOWriter.renameGlyphSetcCs4|jtjkrdS|j|ƒ}|j|dd�|j|=dS)z. Remove the glyph set matching layerName. NF)r)r€rr#r=rrÓ)r3rÑr;r$r$r%ÚdeleteGlyphSetEs   zUFOWriter.deleteGlyphSetcCs|jt›dt|ƒ›�|ƒdS)zX Write data to fileName in the 'data' directory. The data must be a bytes string. rVN)rrâr)r3r<rr$r$r%Ú writeDataQszUFOWriter.writeDatacCs|jt›dt|ƒ›�ƒdS)z= Remove the file named fileName from the data directory. rVN)rrâr)r3r<r$r$r%Ú removeDataXszUFOWriter.removeDatacCsn|dkr|j}|jtjkr.td|jj›d�ƒ‚t|ƒ}|rTt|d�\}}|sTt|ƒ‚|jt ›d|›�|ƒdS)zU Write data to fileName in the images directory. The data must be a valid PNG. NzImages are not allowed in UFO rš)rrV) rqr€rr#r r�rrërré)r3r<rrXrªrÏr$r$r%Ú writeImage`s zUFOWriter.writeImagecCs<|jtjkr td|jj›d�ƒ‚|jt›dt|ƒ›�ƒdS)zA Remove the file named fileName from the images directory. zImages are not allowed in UFO ršrVN)r€rr#r r�rrér)r3r<rXr$r$r%Ú removeImagers zUFOWriter.removeImagecCsd|dkr|j}|jtjkr.td|jj›d�ƒ‚t›dt|ƒ›�}t›dt|ƒ›�}|j|||ƒdS)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. NzImages are not allowed in UFO ršrV) rqr€rr#r r�rérr)r3rZsourceFileNameZ destFileNamerXrrr$r$r%ÚcopyImageFromReader}s zUFOWriter.copyImageFromReaderc st|jrf|jtjkrftjjtjj|jƒƒdd}t j j |jddd��}t j j |j |j|ƒƒWdQRXtƒjƒdS)Nrz.ufoTzutf-8)rNrO)rCrgrr(rúr4rrrpr-r]r^rþrÿrÚsuperrt)r3r ZdestFS)Ú __class__r$r%rt�s  zUFOWriter.close)NrøNT)rAN)FT)N)N)N)N)N)NN)NTNNNF)NF)NTNF)F)N)N)N)#rrr röryr r÷rrrrrZremoveFileForPathr"rr'r)r0r3r4r8r:r=r�r@rArHrIrJrKrLrMrNrtÚ __classcell__r$r$)rPr%rbsV      7 + 9    @  + +   cCsLtj|ƒrtjStjj|ƒr"tjStjj|ƒr>> 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šNrZufoéÿÿÿÿ)rúr4ÚsplitÚjoin)r4ÚdirrRr$r$r%r ³s "cCsZt|}|jdƒ}|jdƒ}|jdƒ}|dk r:|||ƒ}n|tkrN|||ƒ}n||ƒ}|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. roÚvalueValidatorÚ valueOptionsN)rµr²ÚgenericTypeValidator)r¼r½r¾Ú valueTypeÚ validatorrYÚ isValidValuer$r$r%rÌs      cCsPi}xFt|jƒƒD]6\}}t||ƒ}|s@td|›d|›d�ƒ‚q|||<qW|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. zInvalid value for attribute z (z).)rŽr�rr )r/Ú validInfoDatar¼r½r]r$r$r%r-ås   r-cCsZt|}|jdƒ}|jdƒ}|jdƒ}|dk r:|||ƒ}n|tkrN|||ƒ}n||ƒ}|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. rorXrYN)r¶r²rZ)r¼r½r¾r[r\rYr]r$r$r%røs      cCsPi}xFt|jƒƒD]6\}}t||ƒ}|s@td|›d|›d�ƒ‚q|||<qW|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. zInvalid value for attribute z (z).)rŽr�rr )r/r^r¼r½r]r$r$r%r¸s   r¸érrréééé é€é@Ú familyNameÚ styleNameÚfullNameÚfontNameÚmenuNameÚ fontStyleÚnoteÚ versionMajorÚ versionMinorÚyearÚ copyrightÚnoticeÚ trademarkÚlicenseÚ licenseURLÚ createdByÚdesignerÚ designerURLÚ vendorURLÚ unitsPerEmÚascenderÚ descenderÚ capHeightÚxHeightÚ defaultWidthÚ slantAngleÚ italicAngleÚ widthNameÚ weightNameÚ weightValueÚfondNameÚ otFamilyNameÚ otStyleNameÚ otMacNameÚ msCharSetÚfondIDÚuniqueIDÚttVendorÚ ttUniqueIDÚ ttVersion)ro)rorXZ integerList)rorXrY)^rfrgÚstyleMapFamilyNameÚstyleMapStyleNamermrnrorprrryr{r}r|rzr€rlZopenTypeHeadCreatedÚopenTypeHeadLowestRecPPEMZopenTypeHeadFlagsÚopenTypeHheaAscenderÚopenTypeHheaDescenderÚopenTypeHheaLineGapZopenTypeHheaCaretSlopeRiseZopenTypeHheaCaretSlopeRunÚopenTypeHheaCaretOffsetÚopenTypeNameDesignerÚopenTypeNameDesignerURLÚopenTypeNameManufacturerÚopenTypeNameManufacturerURLÚopenTypeNameLicenseÚopenTypeNameLicenseURLÚopenTypeNameVersionÚopenTypeNameUniqueIDÚopenTypeNameDescriptionÚopenTypeNamePreferredFamilyNameÚ"openTypeNamePreferredSubfamilyNameÚopenTypeNameCompatibleFullNameZopenTypeNameSampleTextZopenTypeNameWWSFamilyNameZopenTypeNameWWSSubfamilyNameÚopenTypeOS2WidthClassÚopenTypeOS2WeightClassZopenTypeOS2SelectionÚopenTypeOS2VendorIDÚopenTypeOS2PanoseZopenTypeOS2FamilyClassZopenTypeOS2UnicodeRangesZopenTypeOS2CodePageRangesÚopenTypeOS2TypoAscenderÚopenTypeOS2TypoDescenderÚopenTypeOS2TypoLineGapÚopenTypeOS2WinAscentÚopenTypeOS2WinDescentZopenTypeOS2TypeÚopenTypeOS2SubscriptXSizeÚopenTypeOS2SubscriptYSizeÚopenTypeOS2SubscriptXOffsetÚopenTypeOS2SubscriptYOffsetÚopenTypeOS2SuperscriptXSizeÚopenTypeOS2SuperscriptYSizeÚopenTypeOS2SuperscriptXOffsetÚopenTypeOS2SuperscriptYOffsetÚopenTypeOS2StrikeoutSizeÚopenTypeOS2StrikeoutPositionÚopenTypeVheaVertTypoAscenderÚopenTypeVheaVertTypoDescenderÚopenTypeVheaVertTypoLineGapZopenTypeVheaCaretSlopeRiseZopenTypeVheaCaretSlopeRunÚopenTypeVheaCaretOffsetÚpostscriptFontNameÚpostscriptFullNameÚpostscriptSlantAngleÚpostscriptUniqueIDZpostscriptUnderlineThicknessZpostscriptUnderlinePositionZpostscriptIsFixedPitchZpostscriptBlueValuesZpostscriptOtherBluesZpostscriptFamilyBluesZpostscriptFamilyOtherBluesZpostscriptStemSnapHZpostscriptStemSnapVZpostscriptBlueFuzzZpostscriptBlueShiftZpostscriptBlueScaleZpostscriptForceBoldÚpostscriptDefaultWidthXZpostscriptNominalWidthXÚpostscriptWeightNameZpostscriptDefaultCharacterÚpostscriptWindowsCharacterSetÚmacintoshFONDFamilyIDÚmacintoshFONDNameZdictList))rnryr�r‘r’r“r”r¤r¥r¦r§r¨r©rªr«r¬r­r®r¯r°r±r²r³ZopenTypeGaspRangeRecordsZopenTypeNameRecordsr´rµr¶r·ZwoffMajorVersionZwoffMinorVersionZwoffMetadataUniqueIDZwoffMetadataVendorZwoffMetadataCreditsZwoffMetadataDescriptionZwoffMetadataLicenseZwoffMetadataCopyrightZwoffMetadataTrademarkZwoffMetadataLicenseeZwoffMetadataExtensionsZ guidelinesrXcCs*i}x t|jƒƒD]\}}|||<qW|S)N)rŽr�)rCZflippedr(r½r$r$r%Ú _flipDictús rÁrŽr•r–r—r˜r™ršr›rœr�ržrŸr r½r¢r£r»r¸r¿rÀr¼rºr¹r�r¡r¾)rjrvrwrurxrsrtr�rŒrqr…r†r‡r‚rƒr‹rŠrir‰r„r~rrhrkr�rˆZregularZitalicZboldz bold italic)reré é!éé) zUltra-condensedzExtra-condensedZ CondensedzSemi-condensedzMedium (normal)z Semi-expandedZExpandedzExtra-expandedzUltra-expandedZNormalZAllZmediumZMediumé é é é éééééé)rrréMrdé�é‚é†éˆé¡é¢é£é±é²éºéÈéÌéÞéîéÿcCsÚt|tƒrt|ƒ|krt|ƒ}|dk rÆ|dkr\tj|ƒ}|dkrVtd|›d|›d�ƒ‚|}nj|dkr’tj|ƒ}|dkrŒtd|›d|›d�ƒ‚|}n4|dkrÆtj|ƒ}|dkrÂtd|›d|›d�ƒ‚|}tj||ƒ}||fS)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. NrkzCannot convert value (z) for attribute ršr�rˆ) rZÚfloatÚintÚ_fontStyle1To2r²r Ú_widthName1To2Ú_msCharSet1To2ÚfontInfoAttributesVersion1To2)r¼r½Úvr$r$r%r[s*      cCsV|dk rB|dkrtj|ƒ}n&|dkr0tj|ƒ}n|dkrBtj|ƒ}tj||ƒ}||fS)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. Nr�r¡r¾)Ú_fontStyle2To1r²Ú_widthName2To1Ú_msCharSet2To1ÚfontInfoAttributesVersion2To1)r¼r½r$r$r%rxs    cCsri}xht|jƒƒD]X\}}|dkr,|dkr,qt||ƒ\}}|tkrDq|dkrbtd|›d|›d�ƒ‚|||<qW|S)NrƒrzCannot convert value (z) for attribute ršrT)rŽr�rrr )rÚ convertedr¼r½ÚnewAttrÚnewValuer$r$r%r³ˆs r³cCs`i}xVt|jƒƒD]F\}}t||ƒ\}}|tkr2q|dkrPtd|›d|›d�ƒ‚|||<qW|S)NzCannot convert value (z) for attribute rš)rŽr�rrr )rrër¼r½rìrír$r$r%r.›s r.r�r¨r©r‘r’r“r”r¥r¦r§rªr«r¬r­r®r¯r°r±r²r³r´rµr¶r·cCsà|tkr:y t|ƒ}Wn$ttfk r8td|ƒ‚YnX|tkrzytt|ƒƒ}WqØttfk rvtd|ƒ‚YqØXn^|tkrØyt t|ƒƒ}Wn$ttfk r¶td|ƒ‚YnX|t|ƒkrÌt|ƒ}||krØ|}||fS)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. zCould not convert value for %s.) Ú_ufo2To3FloatToIntÚroundrŸrnr Ú_ufo2To3NonNegativeIntráÚabsÚ_ufo2To3NonNegativeIntOrFloatrà)r¼r½rær$r$r%Ú6convertFontInfoValueForAttributeFromVersion2ToVersion3Ïs(  rócCs||fS)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¼r½r$r$r%Ú6convertFontInfoValueForAttributeFromVersion3ToVersion2êsrôcCsBi}x8t|jƒƒD](\}}t||ƒ\}}|tkr2q|||<qW|S)N)rŽr�rôr)rrër¼r½rìrír$r$r%r,òs r,cCs8i}x.t|jƒƒD]\}}t||ƒ\}}|||<qW|S)N)rŽr�ró)rrër¼r½r$r$r%r´ûs  r´Ú__main__)†rúrþrrÚloggingrRÚenumÚ collectionsrr-Zfs.baseZfs.subfsZ fs.errorsZfs.copyZfs.osfsZfs.zipfsZ fs.tempfsZfs.toolsZfontTools.miscrZfontTools.ufoLib.validatorsZfontTools.ufoLib.filenamesrZfontTools.ufoLib.convertersrr r ZfontTools.ufoLib.utilsr r Ú__all__Ú __version__Ú getLoggerrr¡rÌrârérœr°rÄr¦rÀrÈrÍZLAYERINFO_FILENAMErËr1ÚEnumrrr*r rrr\r rr-rr¸rŽÚrangeZ fontInfoOpenTypeHeadFlagsOptionsZ#fontInfoOpenTypeOS2SelectionOptionsZ'fontInfoOpenTypeOS2UnicodeRangesOptionsZ(fontInfoOpenTypeOS2CodePageRangesOptionsZfontInfoOpenTypeOS2TypeOptionsrrŒr[Z"fontInfoStyleMapStyleNameValidatorráràZ$fontInfoOpenTypeHeadCreatedValidatorZgenericIntListValidatorZ&fontInfoOpenTypeOS2WidthClassValidatorZ'fontInfoOpenTypeOS2WeightClassValidatorZ*fontInfoVersion2OpenTypeOS2PanoseValidatorZ'fontInfoOpenTypeOS2FamilyClassValidatorÚboolZ fontInfoPostscriptBluesValidatorZ%fontInfoPostscriptOtherBluesValidatorZ fontInfoPostscriptStemsValidatorZ.fontInfoPostscriptWindowsCharacterSetValidatorrµr9r*rr¶ÚupdateZgenericNonNegativeIntValidatorZ!genericNonNegativeNumberValidatorZ*fontInfoVersion3OpenTypeOS2PanoseValidatorZ)fontInfoOpenTypeGaspRangeRecordsValidatorZ$fontInfoOpenTypeNameRecordsValidatorZ%fontInfoWOFFMetadataUniqueIDValidatorZ#fontInfoWOFFMetadataVendorValidatorZ$fontInfoWOFFMetadataCreditsValidatorZ(fontInfoWOFFMetadataDescriptionValidatorZ$fontInfoWOFFMetadataLicenseValidatorZ&fontInfoWOFFMetadataCopyrightValidatorZ&fontInfoWOFFMetadataTrademarkValidatorZ%fontInfoWOFFMetadataLicenseeValidatorZ'fontInfoWOFFMetadataExtensionsValidatorZguidelinesValidatorrr�r¼ZdataDictrZrÁrårêrrârçrãrèrärérrr³r.rðròrîrórôr,r´ÚdoctestÚtestmodr$r$r$r%Úsè       !  U"<