code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def readBytesFromPath(self, path): """ 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. """ try: return self.fs.readbytes(fsdecode(path)) except fs.errors....
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.
readBytesFromPath
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def getReadFileForPath(self, path, encoding=None): """ 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 e...
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)...
getReadFileForPath
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def _readMetaInfo(self, validate=None): """ 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. """ if validate is None: v...
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.
_readMetaInfo
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def readMetaInfo(self, validate=None): """ 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. """ data = self._readMetaInfo(validat...
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.
readMetaInfo
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def readGroups(self, validate=None): """ 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. """ if validate is None: validate = self._validate # handle up ...
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.
readGroups
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def getKerningGroupConversionRenameMaps(self, validate=None): """ 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 n...
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 n...
getKerningGroupConversionRenameMaps
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def readInfo(self, info, validate=None): """ 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...
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...
readInfo
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def readKerning(self, validate=None): """ 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. """ if validate is None: validate = self._validate # hand...
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.
readKerning
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def readLib(self, validate=None): """ 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. """ if validate is None: validate = self._validate data = self._getPlist(...
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.
readLib
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def readFeatures(self): """ Read features.fea. Return a string. The returned string is empty if the file is missing. """ try: with self.fs.open(FEATURES_FILENAME, "r", encoding="utf-8-sig") as f: return f.read() except fs.errors.ResourceNotFoun...
Read features.fea. Return a string. The returned string is empty if the file is missing.
readFeatures
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def _readLayerContents(self, validate): """ Rebuild the layer contents list by checking what glyphsets are available on disk. ``validate`` will validate the layer contents. """ if self._formatVersion < UFOFormatVersion.FORMAT_3_0: return [(DEFAULT_LAYER_NAME,...
Rebuild the layer contents list by checking what glyphsets are available on disk. ``validate`` will validate the layer contents.
_readLayerContents
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def getLayerNames(self, validate=None): """ 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. """ if validate is None: validate = self._validate ...
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.
getLayerNames
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def getDefaultLayerName(self, validate=None): """ 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. """ if validate is None: validate = self._valida...
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.
getDefaultLayerName
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def getGlyphSet(self, layerName=None, validateRead=None, validateWrite=None): """ 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. ``va...
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 val...
getGlyphSet
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def getCharacterMapping(self, layerName=None, validate=None): """ Return a dictionary that maps unicode values (ints) to lists of glyph names. """ if validate is None: validate = self._validate glyphSet = self.getGlyphSet( layerName, validateRead=v...
Return a dictionary that maps unicode values (ints) to lists of glyph names.
getCharacterMapping
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def getDataDirectoryListing(self): """ 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. """ try: self._dataF...
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.
getDataDirectoryListing
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def getImageDirectoryListing(self, validate=None): """ 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 ...
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.
getImageDirectoryListing
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def readData(self, fileName): """ Return bytes for the file named 'fileName' inside the 'data/' directory. """ fileName = fsdecode(fileName) try: try: dataFS = self._dataFS except AttributeError: # in case readData is called...
Return bytes for the file named 'fileName' inside the 'data/' directory.
readData
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def readImage(self, fileName, validate=None): """ 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. """ if validate is None: validate = self._validate ...
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.
readImage
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def copyFromReader(self, reader, sourcePath, destPath): """ 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. """ if not isinstance(reader, UFOReader): r...
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.
copyFromReader
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def writeBytesToPath(self, path, data): """ 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 pre...
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 t...
writeBytesToPath
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def getFileObjectForPath(self, path, mode="w", encoding=None): """ 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...
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 responsi...
getFileObjectForPath
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def removePath(self, path, force=False, removeEmptyParents=True): """ 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 loc...
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 'removeE...
removePath
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def setModificationTime(self): """ 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. """ path = self._path if path is not None and os.path.exists(path): ...
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.
setModificationTime
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def setKerningGroupConversionRenameMaps(self, maps): """ 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 f...
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" : {"gro...
setKerningGroupConversionRenameMaps
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def writeGroups(self, groups, validate=None): """ 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. """ if validate is None: ...
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.
writeGroups
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def writeInfo(self, info, validate=None): """ 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. ``val...
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 ...
writeInfo
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def writeKerning(self, kerning, validate=None): """ 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 pa...
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 ...
writeKerning
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def writeLib(self, libDict, validate=None): """ 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. """ if validate is None: valid...
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.
writeLib
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def writeFeatures(self, features, validate=None): """ Write features.fea. This method requires a features string as an argument. """ if validate is None: validate = self._validate if self._formatVersion == UFOFormatVersion.FORMAT_1_0: raise UFOLibE...
Write features.fea. This method requires a features string as an argument.
writeFeatures
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def writeLayerContents(self, layerOrder=None, validate=None): """ Write the layercontents.plist file. This method *must* be called after all glyph sets have been written. """ if validate is None: validate = self._validate if self._formatVersion < UFOFormatVer...
Write the layercontents.plist file. This method *must* be called after all glyph sets have been written.
writeLayerContents
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def getGlyphSet( self, layerName=None, defaultLayer=True, glyphNameToFileNameFunc=None, validateRead=None, validateWrite=None, expectContentsFile=False, ): """ Return the GlyphSet object associated with the appropriate glyph directory i...
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`` wi...
getGlyphSet
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def renameGlyphSet(self, layerName, newLayerName, defaultLayer=False): """ 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. """ if s...
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.
renameGlyphSet
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def deleteGlyphSet(self, layerName): """ Remove the glyph set matching layerName. """ if self._formatVersion < UFOFormatVersion.FORMAT_3_0: # ignore deleting glyph sets for UFO1 UFO2 as there are no layers # just write the data from the default layer r...
Remove the glyph set matching layerName.
deleteGlyphSet
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def writeImage(self, fileName, data, validate=None): """ Write data to fileName in the images directory. The data must be a valid PNG. """ if validate is None: validate = self._validate if self._formatVersion < UFOFormatVersion.FORMAT_3_0: raise UF...
Write data to fileName in the images directory. The data must be a valid PNG.
writeImage
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def removeImage(self, fileName, validate=None): # XXX remove unused 'validate'? """ Remove the file named fileName from the images directory. """ if self._formatVersion < UFOFormatVersion.FORMAT_3_0: raise UFOLibError( f"Images are not allowed in UFO ...
Remove the file named fileName from the images directory.
removeImage
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def copyImageFromReader(self, reader, sourceFileName, destFileName, validate=None): """ 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. """ if validate is ...
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.
copyImageFromReader
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def _sniffFileStructure(ufo_path): """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. """ if zipfile.is_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.
_sniffFileStructure
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def makeUFOPath(path): """ 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 ...
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
makeUFOPath
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def validateFontInfoVersion2ValueForAttribute(attr, value): """ 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 ...
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 de...
validateFontInfoVersion2ValueForAttribute
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def validateInfoVersion2Data(infoData): """ 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...
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 d...
validateInfoVersion2Data
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def validateInfoVersion3Data(infoData): """ 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...
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 d...
validateInfoVersion3Data
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def convertFontInfoValueForAttributeFromVersion1ToVersion2(attr, value): """ 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. """ # convert floats to ints if possible if is...
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.
convertFontInfoValueForAttributeFromVersion1ToVersion2
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def convertFontInfoValueForAttributeFromVersion2ToVersion1(attr, value): """ 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. """ if value is not None: if attr == "styl...
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.
convertFontInfoValueForAttributeFromVersion2ToVersion1
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def convertFontInfoValueForAttributeFromVersion2ToVersion3(attr, value): """ 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. """ if attr in _ufo2To3FloatToInt: try: ...
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.
convertFontInfoValueForAttributeFromVersion2ToVersion3
python
fonttools/fonttools
Lib/fontTools/ufoLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/ufoLib/__init__.py
MIT
def script(char): """Return the four-letter script code assigned to the Unicode character 'char' as string. >>> script("a") 'Latn' >>> script(",") 'Zyyy' >>> script(chr(0x10FFFF)) 'Zzzz' """ code = byteord(char) # 'bisect_right(a, x, lo=0, hi=len(a))' returns an insertion po...
Return the four-letter script code assigned to the Unicode character 'char' as string. >>> script("a") 'Latn' >>> script(",") 'Zyyy' >>> script(chr(0x10FFFF)) 'Zzzz'
script
python
fonttools/fonttools
Lib/fontTools/unicodedata/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/unicodedata/__init__.py
MIT
def script_extension(char): """Return the script extension property assigned to the Unicode character 'char' as a set of string. >>> script_extension("a") == {'Latn'} True >>> script_extension(chr(0x060C)) == {'Nkoo', 'Arab', 'Rohg', 'Thaa', 'Syrc', 'Gara', 'Yezi'} True >>> script_extension...
Return the script extension property assigned to the Unicode character 'char' as a set of string. >>> script_extension("a") == {'Latn'} True >>> script_extension(chr(0x060C)) == {'Nkoo', 'Arab', 'Rohg', 'Thaa', 'Syrc', 'Gara', 'Yezi'} True >>> script_extension(chr(0x10FFFF)) == {'Zzzz'} Tru...
script_extension
python
fonttools/fonttools
Lib/fontTools/unicodedata/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/unicodedata/__init__.py
MIT
def script_name(code, default=KeyError): """Return the long, human-readable script name given a four-letter Unicode script code. If no matching name is found, a KeyError is raised by default. You can use the 'default' argument to return a fallback value (e.g. 'Unknown' or None) instead of throwing...
Return the long, human-readable script name given a four-letter Unicode script code. If no matching name is found, a KeyError is raised by default. You can use the 'default' argument to return a fallback value (e.g. 'Unknown' or None) instead of throwing an error.
script_name
python
fonttools/fonttools
Lib/fontTools/unicodedata/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/unicodedata/__init__.py
MIT
def script_code(script_name, default=KeyError): """Returns the four-letter Unicode script code from its long name If no matching script code is found, a KeyError is raised by default. You can use the 'default' argument to return a fallback string (e.g. 'Zzzz' or None) instead of throwing an error. ...
Returns the four-letter Unicode script code from its long name If no matching script code is found, a KeyError is raised by default. You can use the 'default' argument to return a fallback string (e.g. 'Zzzz' or None) instead of throwing an error.
script_code
python
fonttools/fonttools
Lib/fontTools/unicodedata/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/unicodedata/__init__.py
MIT
def script_horizontal_direction( script_code: str, default: T | type[KeyError] = KeyError ) -> HorizDirection | T: """Return "RTL" for scripts that contain right-to-left characters according to the Bidi_Class property. Otherwise return "LTR". """ if script_code not in Scripts.NAMES: if isins...
Return "RTL" for scripts that contain right-to-left characters according to the Bidi_Class property. Otherwise return "LTR".
script_horizontal_direction
python
fonttools/fonttools
Lib/fontTools/unicodedata/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/unicodedata/__init__.py
MIT
def block(char): """Return the block property assigned to the Unicode character 'char' as a string. >>> block("a") 'Basic Latin' >>> block(chr(0x060C)) 'Arabic' >>> block(chr(0xEFFFF)) 'No_Block' """ code = byteord(char) i = bisect_right(Blocks.RANGES, code) return Block...
Return the block property assigned to the Unicode character 'char' as a string. >>> block("a") 'Basic Latin' >>> block(chr(0x060C)) 'Arabic' >>> block(chr(0xEFFFF)) 'No_Block'
block
python
fonttools/fonttools
Lib/fontTools/unicodedata/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/unicodedata/__init__.py
MIT
def ot_tags_from_script(script_code): """Return a list of OpenType script tags associated with a given Unicode script code. Return ['DFLT'] script tag for invalid/unknown script codes. """ if script_code in OTTags.SCRIPT_EXCEPTIONS: return [OTTags.SCRIPT_EXCEPTIONS[script_code]] if scri...
Return a list of OpenType script tags associated with a given Unicode script code. Return ['DFLT'] script tag for invalid/unknown script codes.
ot_tags_from_script
python
fonttools/fonttools
Lib/fontTools/unicodedata/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/unicodedata/__init__.py
MIT
def ot_tag_to_script(tag): """Return the Unicode script code for the given OpenType script tag, or None for "DFLT" tag or if there is no Unicode script associated with it. Raises ValueError if the tag is invalid. """ tag = tostr(tag).strip() if not tag or " " in tag or len(tag) > 4: rais...
Return the Unicode script code for the given OpenType script tag, or None for "DFLT" tag or if there is no Unicode script associated with it. Raises ValueError if the tag is invalid.
ot_tag_to_script
python
fonttools/fonttools
Lib/fontTools/unicodedata/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/unicodedata/__init__.py
MIT
def main(args=None): """Add `avar` table from designspace file to variable font.""" if args is None: import sys args = sys.argv[1:] from fontTools import configLogger from fontTools.ttLib import TTFont from fontTools.designspaceLib import DesignSpaceDocument import argparse ...
Add `avar` table from designspace file to variable font.
main
python
fonttools/fonttools
Lib/fontTools/varLib/avar.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/avar.py
MIT
def normalizeLog(value, rangeMin, rangeMax): """Logarithmically normalize value in [rangeMin, rangeMax] to [0, 1], with extrapolation.""" logMin = math.log(rangeMin) logMax = math.log(rangeMax) return (math.log(value) - logMin) / (logMax - logMin)
Logarithmically normalize value in [rangeMin, rangeMax] to [0, 1], with extrapolation.
normalizeLog
python
fonttools/fonttools
Lib/fontTools/varLib/avarPlanner.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/avarPlanner.py
MIT
def interpolateLog(t, a, b): """Logarithmic interpolation between a and b, with t typically in [0, 1].""" logA = math.log(a) logB = math.log(b) return math.exp(logA + t * (logB - logA))
Logarithmic interpolation between a and b, with t typically in [0, 1].
interpolateLog
python
fonttools/fonttools
Lib/fontTools/varLib/avarPlanner.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/avarPlanner.py
MIT
def normalizeDegrees(value, rangeMin, rangeMax): """Angularly normalize value in [rangeMin, rangeMax] to [0, 1], with extrapolation.""" tanMin = math.tan(math.radians(rangeMin)) tanMax = math.tan(math.radians(rangeMax)) return (math.tan(math.radians(value)) - tanMin) / (tanMax - tanMin)
Angularly normalize value in [rangeMin, rangeMax] to [0, 1], with extrapolation.
normalizeDegrees
python
fonttools/fonttools
Lib/fontTools/varLib/avarPlanner.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/avarPlanner.py
MIT
def measureWeight(glyphset, glyphs=None): """Measure the perceptual average weight of the given glyphs.""" if isinstance(glyphs, dict): frequencies = glyphs else: frequencies = {g: 1 for g in glyphs} wght_sum = wdth_sum = 0 for glyph_name in glyphs: if frequencies is not Non...
Measure the perceptual average weight of the given glyphs.
measureWeight
python
fonttools/fonttools
Lib/fontTools/varLib/avarPlanner.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/avarPlanner.py
MIT
def measureWidth(glyphset, glyphs=None): """Measure the average width of the given glyphs.""" if isinstance(glyphs, dict): frequencies = glyphs else: frequencies = {g: 1 for g in glyphs} wdth_sum = 0 freq_sum = 0 for glyph_name in glyphs: if frequencies is not None: ...
Measure the average width of the given glyphs.
measureWidth
python
fonttools/fonttools
Lib/fontTools/varLib/avarPlanner.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/avarPlanner.py
MIT
def measureSlant(glyphset, glyphs=None): """Measure the perceptual average slant angle of the given glyphs.""" if isinstance(glyphs, dict): frequencies = glyphs else: frequencies = {g: 1 for g in glyphs} slnt_sum = 0 freq_sum = 0 for glyph_name in glyphs: if frequencies ...
Measure the perceptual average slant angle of the given glyphs.
measureSlant
python
fonttools/fonttools
Lib/fontTools/varLib/avarPlanner.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/avarPlanner.py
MIT
def planWeightAxis( glyphSetFunc, axisLimits, weights=None, samples=None, glyphs=None, designLimits=None, pins=None, sanitize=False, ): """Plan a weight (`wght`) axis. weights: A list of weight values to plan for. If None, the default values are used. This function simp...
Plan a weight (`wght`) axis. weights: A list of weight values to plan for. If None, the default values are used. This function simply calls planAxis with values=weights, and the appropriate arguments. See documenation for planAxis for more information.
planWeightAxis
python
fonttools/fonttools
Lib/fontTools/varLib/avarPlanner.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/avarPlanner.py
MIT
def planWidthAxis( glyphSetFunc, axisLimits, widths=None, samples=None, glyphs=None, designLimits=None, pins=None, sanitize=False, ): """Plan a width (`wdth`) axis. widths: A list of width values (percentages) to plan for. If None, the default values are used. This func...
Plan a width (`wdth`) axis. widths: A list of width values (percentages) to plan for. If None, the default values are used. This function simply calls planAxis with values=widths, and the appropriate arguments. See documenation for planAxis for more information.
planWidthAxis
python
fonttools/fonttools
Lib/fontTools/varLib/avarPlanner.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/avarPlanner.py
MIT
def planSlantAxis( glyphSetFunc, axisLimits, slants=None, samples=None, glyphs=None, designLimits=None, pins=None, sanitize=False, ): """Plan a slant (`slnt`) axis. slants: A list slant angles to plan for. If None, the default values are used. This function simply calls...
Plan a slant (`slnt`) axis. slants: A list slant angles to plan for. If None, the default values are used. This function simply calls planAxis with values=slants, and the appropriate arguments. See documenation for planAxis for more information.
planSlantAxis
python
fonttools/fonttools
Lib/fontTools/varLib/avarPlanner.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/avarPlanner.py
MIT
def planOpticalSizeAxis( glyphSetFunc, axisLimits, sizes=None, samples=None, glyphs=None, designLimits=None, pins=None, sanitize=False, ): """Plan a optical-size (`opsz`) axis. sizes: A list of optical size values to plan for. If None, the default values are used. This ...
Plan a optical-size (`opsz`) axis. sizes: A list of optical size values to plan for. If None, the default values are used. This function simply calls planAxis with values=sizes, and the appropriate arguments. See documenation for planAxis for more information.
planOpticalSizeAxis
python
fonttools/fonttools
Lib/fontTools/varLib/avarPlanner.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/avarPlanner.py
MIT
def makeDesignspaceSnippet(axisTag, axisName, axisLimit, mapping): """Make a designspace snippet for a single axis.""" designspaceSnippet = ( ' <axis tag="%s" name="%s" minimum="%g" default="%g" maximum="%g"' % ((axisTag, axisName) + axisLimit) ) if mapping: designspaceSnippe...
Make a designspace snippet for a single axis.
makeDesignspaceSnippet
python
fonttools/fonttools
Lib/fontTools/varLib/avarPlanner.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/avarPlanner.py
MIT
def addEmptyAvar(font): """Add an empty `avar` table to the font.""" font["avar"] = avar = newTable("avar") for axis in fvar.axes: avar.segments[axis.axisTag] = {}
Add an empty `avar` table to the font.
addEmptyAvar
python
fonttools/fonttools
Lib/fontTools/varLib/avarPlanner.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/avarPlanner.py
MIT
def main(args=None): """Plan the standard axis mappings for a variable font""" if args is None: import sys args = sys.argv[1:] from fontTools import configLogger from fontTools.ttLib import TTFont import argparse parser = argparse.ArgumentParser( "fonttools varLib.ava...
Plan the standard axis mappings for a variable font
main
python
fonttools/fonttools
Lib/fontTools/varLib/avarPlanner.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/avarPlanner.py
MIT
def merge_PrivateDicts(top_dicts, vsindex_dict, var_model, fd_map): """ I step through the FontDicts in the FDArray of the varfont TopDict. For each varfont FontDict: * step through each key in FontDict.Private. * For each key, step through each relevant source font Private dict, and build a ...
I step through the FontDicts in the FDArray of the varfont TopDict. For each varfont FontDict: * step through each key in FontDict.Private. * For each key, step through each relevant source font Private dict, and build a list of values to blend. The 'relevant' source fonts are selected by f...
merge_PrivateDicts
python
fonttools/fonttools
Lib/fontTools/varLib/cff.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/cff.py
MIT
def getfd_map(varFont, fonts_list): """Since a subset source font may have fewer FontDicts in their FDArray than the default font, we have to match up the FontDicts in the different fonts . We do this with the FDSelect array, and by assuming that the same glyph will reference matching FontDicts in ...
Since a subset source font may have fewer FontDicts in their FDArray than the default font, we have to match up the FontDicts in the different fonts . We do this with the FDSelect array, and by assuming that the same glyph will reference matching FontDicts in each source font. We return a mapping from ...
getfd_map
python
fonttools/fonttools
Lib/fontTools/varLib/cff.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/cff.py
MIT
def reorder_blend_args(self, commands, get_delta_func): """ We first re-order the master coordinate values. For a moveto to lineto, the args are now arranged as:: [ [master_0 x,y], [master_1 x,y], [master_2 x,y] ] We re-arrange this to:: [ [master_0 x, ...
We first re-order the master coordinate values. For a moveto to lineto, the args are now arranged as:: [ [master_0 x,y], [master_1 x,y], [master_2 x,y] ] We re-arrange this to:: [ [master_0 x, master_1 x, master_2 x], [master_0 y, maste...
reorder_blend_args
python
fonttools/fonttools
Lib/fontTools/varLib/cff.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/cff.py
MIT
def overlayBox(top, bot): """Overlays ``top`` box on top of ``bot`` box. Returns two items: * Box for intersection of ``top`` and ``bot``, or None if they don't intersect. * Box for remainder of ``bot``. Remainder box might not be exact (since the remainder might not be a simple box), but is in...
Overlays ``top`` box on top of ``bot`` box. Returns two items: * Box for intersection of ``top`` and ``bot``, or None if they don't intersect. * Box for remainder of ``bot``. Remainder box might not be exact (since the remainder might not be a simple box), but is inclusive of the exact remain...
overlayBox
python
fonttools/fonttools
Lib/fontTools/varLib/featureVars.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/featureVars.py
MIT
def addFeatureVariationsRaw(font, table, conditionalSubstitutions, featureTag="rvrn"): """Low level implementation of addFeatureVariations that directly models the possibilities of the FeatureVariations table.""" featureTags = [featureTag] if isinstance(featureTag, str) else sorted(featureTag) processL...
Low level implementation of addFeatureVariations that directly models the possibilities of the FeatureVariations table.
addFeatureVariationsRaw
python
fonttools/fonttools
Lib/fontTools/varLib/featureVars.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/featureVars.py
MIT
def makeSubstitutionsHashable(conditionalSubstitutions): """Turn all the substitution dictionaries in sorted tuples of tuples so they are hashable, to detect duplicates so we don't write out redundant data.""" allSubstitutions = set() condSubst = [] for conditionSet, substitutionMaps in conditio...
Turn all the substitution dictionaries in sorted tuples of tuples so they are hashable, to detect duplicates so we don't write out redundant data.
makeSubstitutionsHashable
python
fonttools/fonttools
Lib/fontTools/varLib/featureVars.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/featureVars.py
MIT
def buildSubstitutionLookups(gsub, allSubstitutions, processLast=False): """Build the lookups for the glyph substitutions, return a dict mapping the substitution to lookup indices.""" # Insert lookups at the beginning of the lookup vector # https://github.com/googlefonts/fontmake/issues/950 firstI...
Build the lookups for the glyph substitutions, return a dict mapping the substitution to lookup indices.
buildSubstitutionLookups
python
fonttools/fonttools
Lib/fontTools/varLib/featureVars.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/featureVars.py
MIT
def findFeatureVariationRecord(featureVariations, conditionTable): """Find a FeatureVariationRecord that has the same conditionTable.""" if featureVariations.Version != 0x00010000: raise VarLibError( "Unsupported FeatureVariations table version: " f"0x{featureVariations.Version:0...
Find a FeatureVariationRecord that has the same conditionTable.
findFeatureVariationRecord
python
fonttools/fonttools
Lib/fontTools/varLib/featureVars.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/featureVars.py
MIT
def sortFeatureList(table): """Sort the feature list by feature tag, and remap the feature indices elsewhere. This is needed after the feature list has been modified. """ # decorate, sort, undecorate, because we need to make an index remapping table tagIndexFea = [ (fea.FeatureTag, index, fe...
Sort the feature list by feature tag, and remap the feature indices elsewhere. This is needed after the feature list has been modified.
sortFeatureList
python
fonttools/fonttools
Lib/fontTools/varLib/featureVars.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/featureVars.py
MIT
def remapFeatures(table, featureRemap): """Go through the scripts list, and remap feature indices.""" for scriptIndex, script in enumerate(table.ScriptList.ScriptRecord): defaultLangSys = script.Script.DefaultLangSys if defaultLangSys is not None: _remapLangSys(defaultLangSys, featur...
Go through the scripts list, and remap feature indices.
remapFeatures
python
fonttools/fonttools
Lib/fontTools/varLib/featureVars.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/featureVars.py
MIT
def main(args=None): """Add `HVAR` table to variable font.""" if args is None: import sys args = sys.argv[1:] from fontTools import configLogger from fontTools.designspaceLib import DesignSpaceDocument import argparse parser = argparse.ArgumentParser( "fonttools varLi...
Add `HVAR` table to variable font.
main
python
fonttools/fonttools
Lib/fontTools/varLib/hvar.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/hvar.py
MIT
def main(args=None): """Test for interpolatability issues between fonts""" import argparse import sys parser = argparse.ArgumentParser( "fonttools varLib.interpolatable", description=main.__doc__, ) parser.add_argument( "--glyphs", action="store", help="S...
Test for interpolatability issues between fonts
main
python
fonttools/fonttools
Lib/fontTools/varLib/interpolatable.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/interpolatable.py
MIT
def sort_problems(problems): """Sort problems by severity, then by glyph name, then by problem message.""" return dict( sorted( problems.items(), key=lambda _: -min( ( (InterpolatableProblem.severity[p["type"]] + p.get("tolerance", 0)) ...
Sort problems by severity, then by glyph name, then by problem message.
sort_problems
python
fonttools/fonttools
Lib/fontTools/varLib/interpolatableHelpers.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/interpolatableHelpers.py
MIT
def interpolate_layout(designspace, loc, master_finder=lambda s: s, mapped=False): """ Interpolate GPOS from a designspace file and location. If master_finder is set, it should be a callable that takes master filename as found in designspace file and map it to master font binary as to be opened (eg...
Interpolate GPOS from a designspace file and location. If master_finder is set, it should be a callable that takes master filename as found in designspace file and map it to master font binary as to be opened (eg. .ttf or .otf). If mapped is False (default), then location is mapped using the ...
interpolate_layout
python
fonttools/fonttools
Lib/fontTools/varLib/interpolate_layout.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/interpolate_layout.py
MIT
def main(args=None): """Interpolate GDEF/GPOS/GSUB tables for a point on a designspace""" from fontTools import configLogger import argparse import sys parser = argparse.ArgumentParser( "fonttools varLib.interpolate_layout", description=main.__doc__, ) parser.add_argument( ...
Interpolate GDEF/GPOS/GSUB tables for a point on a designspace
main
python
fonttools/fonttools
Lib/fontTools/varLib/interpolate_layout.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/interpolate_layout.py
MIT
def iup_segment( coords: _PointSegment, rc1: _Point, rd1: _Delta, rc2: _Point, rd2: _Delta ): # -> _DeltaSegment: """Given two reference coordinates `rc1` & `rc2` and their respective delta vectors `rd1` & `rd2`, returns interpolated deltas for the set of coordinates `coords`.""" # rc1 = reference...
Given two reference coordinates `rc1` & `rc2` and their respective delta vectors `rd1` & `rd2`, returns interpolated deltas for the set of coordinates `coords`.
iup_segment
python
fonttools/fonttools
Lib/fontTools/varLib/iup.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/iup.py
MIT
def iup_contour(deltas: _DeltaOrNoneSegment, coords: _PointSegment) -> _DeltaSegment: """For the contour given in `coords`, interpolate any missing delta values in delta vector `deltas`. Returns fully filled-out delta vector.""" assert len(deltas) == len(coords) if None not in deltas: retu...
For the contour given in `coords`, interpolate any missing delta values in delta vector `deltas`. Returns fully filled-out delta vector.
iup_contour
python
fonttools/fonttools
Lib/fontTools/varLib/iup.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/iup.py
MIT
def iup_delta( deltas: _DeltaOrNoneSegment, coords: _PointSegment, ends: _Endpoints ) -> _DeltaSegment: """For the outline given in `coords`, with contour endpoints given in sorted increasing order in `ends`, interpolate any missing delta values in delta vector `deltas`. Returns fully filled-out de...
For the outline given in `coords`, with contour endpoints given in sorted increasing order in `ends`, interpolate any missing delta values in delta vector `deltas`. Returns fully filled-out delta vector.
iup_delta
python
fonttools/fonttools
Lib/fontTools/varLib/iup.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/iup.py
MIT
def can_iup_in_between( deltas: _DeltaSegment, coords: _PointSegment, i: Integral, j: Integral, tolerance: Real, ): # -> bool: """Return true if the deltas for points at `i` and `j` (`i < j`) can be successfully used to interpolate deltas for points in between them within provided error...
Return true if the deltas for points at `i` and `j` (`i < j`) can be successfully used to interpolate deltas for points in between them within provided error tolerance.
can_iup_in_between
python
fonttools/fonttools
Lib/fontTools/varLib/iup.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/iup.py
MIT
def _iup_contour_bound_forced_set( deltas: _DeltaSegment, coords: _PointSegment, tolerance: Real = 0 ) -> set: """The forced set is a conservative set of points on the contour that must be encoded explicitly (ie. cannot be interpolated). Calculating this set allows for significantly speeding up the dyn...
The forced set is a conservative set of points on the contour that must be encoded explicitly (ie. cannot be interpolated). Calculating this set allows for significantly speeding up the dynamic-programming, as well as resolve circularity in DP. The set is precise; that is, if an index is in the returned s...
_iup_contour_bound_forced_set
python
fonttools/fonttools
Lib/fontTools/varLib/iup.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/iup.py
MIT
def _iup_contour_optimize_dp( deltas: _DeltaSegment, coords: _PointSegment, forced=set(), tolerance: Real = 0, lookback: Integral = None, ): """Straightforward Dynamic-Programming. For each index i, find least-costly encoding of points 0 to i where i is explicitly encoded. We find this by ...
Straightforward Dynamic-Programming. For each index i, find least-costly encoding of points 0 to i where i is explicitly encoded. We find this by considering all previous explicit points j and check whether interpolation can fill points between j and i. Note that solution always encodes last point explic...
_iup_contour_optimize_dp
python
fonttools/fonttools
Lib/fontTools/varLib/iup.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/iup.py
MIT
def _rot_list(l: list, k: int): """Rotate list by k items forward. Ie. item at position 0 will be at position k in returned list. Negative k is allowed.""" n = len(l) k %= n if not k: return l return l[n - k :] + l[: n - k]
Rotate list by k items forward. Ie. item at position 0 will be at position k in returned list. Negative k is allowed.
_rot_list
python
fonttools/fonttools
Lib/fontTools/varLib/iup.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/iup.py
MIT
def iup_contour_optimize( deltas: _DeltaSegment, coords: _PointSegment, tolerance: Real = 0.0 ) -> _DeltaOrNoneSegment: """For contour with coordinates `coords`, optimize a set of delta values `deltas` within error `tolerance`. Returns delta vector that has most number of None items instead of the ...
For contour with coordinates `coords`, optimize a set of delta values `deltas` within error `tolerance`. Returns delta vector that has most number of None items instead of the input delta.
iup_contour_optimize
python
fonttools/fonttools
Lib/fontTools/varLib/iup.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/iup.py
MIT
def iup_delta_optimize( deltas: _DeltaSegment, coords: _PointSegment, ends: _Endpoints, tolerance: Real = 0.0, ) -> _DeltaOrNoneSegment: """For the outline given in `coords`, with contour endpoints given in sorted increasing order in `ends`, optimize a set of delta values `deltas` within err...
For the outline given in `coords`, with contour endpoints given in sorted increasing order in `ends`, optimize a set of delta values `deltas` within error `tolerance`. Returns delta vector that has most number of None items instead of the input delta.
iup_delta_optimize
python
fonttools/fonttools
Lib/fontTools/varLib/iup.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/iup.py
MIT
def _merge_GlyphOrders(font, lst, values_lst=None, default=None): """Takes font and list of glyph lists (must be sorted by glyph id), and returns two things: - Combined glyph list, - If values_lst is None, return input glyph lists, but padded with None when a glyph was missing in a list. Otherwis...
Takes font and list of glyph lists (must be sorted by glyph id), and returns two things: - Combined glyph list, - If values_lst is None, return input glyph lists, but padded with None when a glyph was missing in a list. Otherwise, return values_lst list-of-list, padded with None to match combin...
_merge_GlyphOrders
python
fonttools/fonttools
Lib/fontTools/varLib/merger.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/merger.py
MIT
def _Lookup_PairPos_subtables_canonicalize(lst, font): """Merge multiple Format1 subtables at the beginning of lst, and merge multiple consecutive Format2 subtables that have the same Class2 (ie. were split because of offset overflows). Returns new list.""" lst = list(lst) l = len(lst) i = 0 ...
Merge multiple Format1 subtables at the beginning of lst, and merge multiple consecutive Format2 subtables that have the same Class2 (ie. were split because of offset overflows). Returns new list.
_Lookup_PairPos_subtables_canonicalize
python
fonttools/fonttools
Lib/fontTools/varLib/merger.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/merger.py
MIT
def expandPaintColrLayers(colr): """Rebuild LayerList without PaintColrLayers reuse. Each base paint graph is fully DFS-traversed (with exception of PaintColrGlyph which are irrelevant for this); any layers referenced via PaintColrLayers are collected into a new LayerList and duplicated...
Rebuild LayerList without PaintColrLayers reuse. Each base paint graph is fully DFS-traversed (with exception of PaintColrGlyph which are irrelevant for this); any layers referenced via PaintColrLayers are collected into a new LayerList and duplicated when reuse is detected, to ensure t...
expandPaintColrLayers
python
fonttools/fonttools
Lib/fontTools/varLib/merger.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/merger.py
MIT
def normalizeValue(v, triple, extrapolate=False): """Normalizes value based on a min/default/max triple. >>> normalizeValue(400, (100, 400, 900)) 0.0 >>> normalizeValue(100, (100, 400, 900)) -1.0 >>> normalizeValue(650, (100, 400, 900)) 0.5 """ lower, default, upper = triple if ...
Normalizes value based on a min/default/max triple. >>> normalizeValue(400, (100, 400, 900)) 0.0 >>> normalizeValue(100, (100, 400, 900)) -1.0 >>> normalizeValue(650, (100, 400, 900)) 0.5
normalizeValue
python
fonttools/fonttools
Lib/fontTools/varLib/models.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/models.py
MIT
def normalizeLocation(location, axes, extrapolate=False, *, validate=False): """Normalizes location based on axis min/default/max values from axes. >>> axes = {"wght": (100, 400, 900)} >>> normalizeLocation({"wght": 400}, axes) {'wght': 0.0} >>> normalizeLocation({"wght": 100}, axes) {'wght': -...
Normalizes location based on axis min/default/max values from axes. >>> axes = {"wght": (100, 400, 900)} >>> normalizeLocation({"wght": 400}, axes) {'wght': 0.0} >>> normalizeLocation({"wght": 100}, axes) {'wght': -1.0} >>> normalizeLocation({"wght": 900}, axes) {'wght': 1.0} >>> normal...
normalizeLocation
python
fonttools/fonttools
Lib/fontTools/varLib/models.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/models.py
MIT
def supportScalar(location, support, ot=True, extrapolate=False, axisRanges=None): """Returns the scalar multiplier at location, for a master with support. If ot is True, then a peak value of zero for support of an axis means "axis does not participate". That is how OpenType Variation Font technology ...
Returns the scalar multiplier at location, for a master with support. If ot is True, then a peak value of zero for support of an axis means "axis does not participate". That is how OpenType Variation Font technology works. If extrapolate is True, axisRanges must be a dict that maps axis names to ...
supportScalar
python
fonttools/fonttools
Lib/fontTools/varLib/models.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/models.py
MIT
def getSubModel(self, items): """Return a sub-model and the items that are not None. The sub-model is necessary for working with the subset of items when some are None. The sub-model is cached.""" if None not in items: return self, items key = tuple(v is not...
Return a sub-model and the items that are not None. The sub-model is necessary for working with the subset of items when some are None. The sub-model is cached.
getSubModel
python
fonttools/fonttools
Lib/fontTools/varLib/models.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/models.py
MIT
def getScalars(self, loc): """Return scalars for each delta, for the given location. If interpolating many master-values at the same location, this function allows speed up by fetching the scalars once and using them with interpolateFromMastersAndScalars().""" return [ ...
Return scalars for each delta, for the given location. If interpolating many master-values at the same location, this function allows speed up by fetching the scalars once and using them with interpolateFromMastersAndScalars().
getScalars
python
fonttools/fonttools
Lib/fontTools/varLib/models.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/models.py
MIT
def getMasterScalars(self, targetLocation): """Return multipliers for each master, for the given location. If interpolating many master-values at the same location, this function allows speed up by fetching the scalars once and using them with interpolateFromValuesAndScalars(). ...
Return multipliers for each master, for the given location. If interpolating many master-values at the same location, this function allows speed up by fetching the scalars once and using them with interpolateFromValuesAndScalars(). Note that the scalars used in interpolateFromMastersAnd...
getMasterScalars
python
fonttools/fonttools
Lib/fontTools/varLib/models.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/varLib/models.py
MIT