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 curveLineIntersections(curve, line): """Finds intersections between a curve and a line. Args: curve: List of coordinates of the curve segment as 2D tuples. line: List of coordinates of the line segment as 2D tuples. Returns: A list of ``Intersection`` objects, each object havin...
Finds intersections between a curve and a line. Args: curve: List of coordinates of the curve segment as 2D tuples. line: List of coordinates of the line segment as 2D tuples. Returns: A list of ``Intersection`` objects, each object having ``pt``, ``t1`` and ``t2`` attributes c...
curveLineIntersections
python
fonttools/fonttools
Lib/fontTools/misc/bezierTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/bezierTools.py
MIT
def curveCurveIntersections(curve1, curve2): """Finds intersections between a curve and a curve. Args: curve1: List of coordinates of the first curve segment as 2D tuples. curve2: List of coordinates of the second curve segment as 2D tuples. Returns: A list of ``Intersection`` obje...
Finds intersections between a curve and a curve. Args: curve1: List of coordinates of the first curve segment as 2D tuples. curve2: List of coordinates of the second curve segment as 2D tuples. Returns: A list of ``Intersection`` objects, each object having ``pt``, ``t1`` and `...
curveCurveIntersections
python
fonttools/fonttools
Lib/fontTools/misc/bezierTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/bezierTools.py
MIT
def segmentSegmentIntersections(seg1, seg2): """Finds intersections between two segments. Args: seg1: List of coordinates of the first segment as 2D tuples. seg2: List of coordinates of the second segment as 2D tuples. Returns: A list of ``Intersection`` objects, each object having...
Finds intersections between two segments. Args: seg1: List of coordinates of the first segment as 2D tuples. seg2: List of coordinates of the second segment as 2D tuples. Returns: A list of ``Intersection`` objects, each object having ``pt``, ``t1`` and ``t2`` attributes contai...
segmentSegmentIntersections
python
fonttools/fonttools
Lib/fontTools/misc/bezierTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/bezierTools.py
MIT
def add(self, set_of_things): """ Add a set to the classifier. Any iterable is accepted. """ if not set_of_things: return self._dirty = True things, sets, mapping = self._things, self._sets, self._mapping s = set(set_of_things) intersection...
Add a set to the classifier. Any iterable is accepted.
add
python
fonttools/fonttools
Lib/fontTools/misc/classifyTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/classifyTools.py
MIT
def classify(list_of_sets, sort=True): """ Takes a iterable of iterables (list of sets from here on; but any iterable works.), and returns the smallest list of sets such that each set, is either a subset, or is disjoint from, each of the input sets. In other words, this function classifies all ...
Takes a iterable of iterables (list of sets from here on; but any iterable works.), and returns the smallest list of sets such that each set, is either a subset, or is disjoint from, each of the input sets. In other words, this function classifies all the things present in any of the input set...
classify
python
fonttools/fonttools
Lib/fontTools/misc/classifyTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/classifyTools.py
MIT
def register_option( cls, name: str, help: str, default: Any, parse: Callable[[str], Any], validate: Optional[Callable[[Any], bool]] = None, ) -> Option: """Register an available option in this config system.""" return cls.options.register( ...
Register an available option in this config system.
register_option
python
fonttools/fonttools
Lib/fontTools/misc/configTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/configTools.py
MIT
def set( self, option_or_name: Union[Option, str], value: Any, parse_values: bool = False, skip_unknown: bool = False, ): """Set the value of an option. Args: * `option_or_name`: an `Option` object or its name (`str`). * `value`: the v...
Set the value of an option. Args: * `option_or_name`: an `Option` object or its name (`str`). * `value`: the value to be assigned to given option. * `parse_values`: parse the configuration value from a string into its proper type, as per its `Option` object. ...
set
python
fonttools/fonttools
Lib/fontTools/misc/configTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/configTools.py
MIT
def get( self, option_or_name: Union[Option, str], default: Any = _USE_GLOBAL_DEFAULT ) -> Any: """ Get the value of an option. The value which is returned is the first provided among: 1. a user-provided value in the options's ``self._values`` dict 2. a caller-provid...
Get the value of an option. The value which is returned is the first provided among: 1. a user-provided value in the options's ``self._values`` dict 2. a caller-provided default value to this method call 3. the global default for the option provided in ``fontTools.config`` ...
get
python
fonttools/fonttools
Lib/fontTools/misc/configTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/configTools.py
MIT
def decrypt(cipherstring, R): r""" Decrypts a string using the Type 1 encryption algorithm. Args: cipherstring: String of ciphertext. R: Initial key. Returns: decryptedStr: Plaintext string. R: Output key for subsequent decryptions. Examples:: ...
Decrypts a string using the Type 1 encryption algorithm. Args: cipherstring: String of ciphertext. R: Initial key. Returns: decryptedStr: Plaintext string. R: Output key for subsequent decryptions. Examples:: >>> testStr = b"\0\0asdadads a...
decrypt
python
fonttools/fonttools
Lib/fontTools/misc/eexec.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/eexec.py
MIT
def encrypt(plainstring, R): r""" Encrypts a string using the Type 1 encryption algorithm. Note that the algorithm as described in the Type 1 specification requires the plaintext to be prefixed with a number of random bytes. (For ``eexec`` the number of random bytes is set to 4.) This routine does ...
Encrypts a string using the Type 1 encryption algorithm. Note that the algorithm as described in the Type 1 specification requires the plaintext to be prefixed with a number of random bytes. (For ``eexec`` the number of random bytes is set to 4.) This routine does *not* add the random prefix to it...
encrypt
python
fonttools/fonttools
Lib/fontTools/misc/eexec.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/eexec.py
MIT
def getEncoding(platformID, platEncID, langID, default=None): """Returns the Python encoding name for OpenType platformID/encodingID/langID triplet. If encoding for these values is not known, by default None is returned. That can be overriden by passing a value to the default argument. """ encodin...
Returns the Python encoding name for OpenType platformID/encodingID/langID triplet. If encoding for these values is not known, by default None is returned. That can be overriden by passing a value to the default argument.
getEncoding
python
fonttools/fonttools
Lib/fontTools/misc/encodingTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/encodingTools.py
MIT
def SubElement(parent, tag, attrib=_Attrib(), **extra): """Must override SubElement as well otherwise _elementtree.SubElement fails if 'parent' is a subclass of Element object. """ element = parent.__class__(tag, attrib, **extra) parent.append(element) return element
Must override SubElement as well otherwise _elementtree.SubElement fails if 'parent' is a subclass of Element object.
SubElement
python
fonttools/fonttools
Lib/fontTools/misc/etree.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/etree.py
MIT
def iterwalk(element_or_tree, events=("end",), tag=None): """A tree walker that generates events from an existing tree as if it was parsing XML data with iterparse(). Drop-in replacement for lxml.etree.iterwalk. """ if iselement(element_or_tree): element = element_or_...
A tree walker that generates events from an existing tree as if it was parsing XML data with iterparse(). Drop-in replacement for lxml.etree.iterwalk.
iterwalk
python
fonttools/fonttools
Lib/fontTools/misc/etree.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/etree.py
MIT
def tostring( element, encoding=None, xml_declaration=None, method=None, doctype=None, pretty_print=False, ): """Custom 'tostring' function that uses our ElementTree subclass, with pretty_print support. """ stream = io.StringIO() if enc...
Custom 'tostring' function that uses our ElementTree subclass, with pretty_print support.
tostring
python
fonttools/fonttools
Lib/fontTools/misc/etree.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/etree.py
MIT
def _tounicode(s): """Test if a string is valid user input and decode it to unicode string using ASCII encoding if it's a bytes string. Reject all bytes/unicode input that contains non-XML characters. Reject all bytes input that contains non-ASCII characters. """ try: ...
Test if a string is valid user input and decode it to unicode string using ASCII encoding if it's a bytes string. Reject all bytes/unicode input that contains non-XML characters. Reject all bytes input that contains non-ASCII characters.
_tounicode
python
fonttools/fonttools
Lib/fontTools/misc/etree.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/etree.py
MIT
def userNameToFileName(userName, existing=[], prefix="", suffix=""): """Converts from a user name to a file name. Takes care to avoid illegal characters, reserved file names, ambiguity between upper- and lower-case characters, and clashes with existing files. Args: userName (str): The inpu...
Converts from a user name to a file name. Takes care to avoid illegal characters, reserved file names, ambiguity between upper- and lower-case characters, and clashes with existing files. Args: userName (str): The input file name. existing: A case-insensitive list of all existing f...
userNameToFileName
python
fonttools/fonttools
Lib/fontTools/misc/filenames.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/filenames.py
MIT
def handleClash1(userName, existing=[], prefix="", suffix=""): """ existing should be a case-insensitive list of all existing file names. >>> prefix = ("0" * 5) + "." >>> suffix = "." + ("0" * 10) >>> existing = ["a" * 5] >>> e = list(existing) >>> handleClash1(userName="A" * 5, existi...
existing should be a case-insensitive list of all existing file names. >>> prefix = ("0" * 5) + "." >>> suffix = "." + ("0" * 10) >>> existing = ["a" * 5] >>> e = list(existing) >>> handleClash1(userName="A" * 5, existing=e, ... prefix=prefix, suffix=suffix) == ( ... '00000.AAAA...
handleClash1
python
fonttools/fonttools
Lib/fontTools/misc/filenames.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/filenames.py
MIT
def handleClash2(existing=[], prefix="", suffix=""): """ existing should be a case-insensitive list of all existing file names. >>> prefix = ("0" * 5) + "." >>> suffix = "." + ("0" * 10) >>> existing = [prefix + str(i) + suffix for i in range(100)] >>> e = list(existing) >>> handleClas...
existing should be a case-insensitive list of all existing file names. >>> prefix = ("0" * 5) + "." >>> suffix = "." + ("0" * 10) >>> existing = [prefix + str(i) + suffix for i in range(100)] >>> e = list(existing) >>> handleClash2(existing=e, prefix=prefix, suffix=suffix) == ( ... '...
handleClash2
python
fonttools/fonttools
Lib/fontTools/misc/filenames.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/filenames.py
MIT
def floatToFixedToFloat(value, precisionBits): """Converts a float to a fixed-point number and back again. By converting the float to fixed, rounding it, and converting it back to float again, this returns a floating point values which is exactly representable in fixed-point format. Note: this **i...
Converts a float to a fixed-point number and back again. By converting the float to fixed, rounding it, and converting it back to float again, this returns a floating point values which is exactly representable in fixed-point format. Note: this **is** equivalent to ``fixedToFloat(floatToFixed(value))`...
floatToFixedToFloat
python
fonttools/fonttools
Lib/fontTools/misc/fixedTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/fixedTools.py
MIT
def fixedToStr(value, precisionBits): """Converts a fixed-point number to a string representing a decimal float. This chooses the float that has the shortest decimal representation (the least number of fractional decimal digits). For example, to convert a fixed-point number in a 2.14 format, use `...
Converts a fixed-point number to a string representing a decimal float. This chooses the float that has the shortest decimal representation (the least number of fractional decimal digits). For example, to convert a fixed-point number in a 2.14 format, use ``precisionBits=14``:: >>> fixedT...
fixedToStr
python
fonttools/fonttools
Lib/fontTools/misc/fixedTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/fixedTools.py
MIT
def strToFixed(string, precisionBits): """Converts a string representing a decimal float to a fixed-point number. Args: string (str): A string representing a decimal float. precisionBits (int): Number of precision bits, *up to a maximum of 16*. Returns: int: Fixed-point...
Converts a string representing a decimal float to a fixed-point number. Args: string (str): A string representing a decimal float. precisionBits (int): Number of precision bits, *up to a maximum of 16*. Returns: int: Fixed-point representation. Examples:: ...
strToFixed
python
fonttools/fonttools
Lib/fontTools/misc/fixedTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/fixedTools.py
MIT
def strToFixedToFloat(string, precisionBits): """Convert a string to a decimal float with fixed-point rounding. This first converts string to a float, then turns it into a fixed-point number with ``precisionBits`` fractional binary digits, then back to a float again. This is simply a shorthand for...
Convert a string to a decimal float with fixed-point rounding. This first converts string to a float, then turns it into a fixed-point number with ``precisionBits`` fractional binary digits, then back to a float again. This is simply a shorthand for fixedToFloat(floatToFixed(float(s))). Args: ...
strToFixedToFloat
python
fonttools/fonttools
Lib/fontTools/misc/fixedTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/fixedTools.py
MIT
def floatToFixedToStr(value, precisionBits): """Convert float to string with fixed-point rounding. This uses the shortest decimal representation (ie. the least number of fractional decimal digits) to represent the equivalent fixed-point number with ``precisionBits`` fractional binary digits. It use...
Convert float to string with fixed-point rounding. This uses the shortest decimal representation (ie. the least number of fractional decimal digits) to represent the equivalent fixed-point number with ``precisionBits`` fractional binary digits. It uses nearestMultipleShortestRepr under the hood. >...
floatToFixedToStr
python
fonttools/fonttools
Lib/fontTools/misc/fixedTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/fixedTools.py
MIT
def ensureVersionIsLong(value): """Ensure a table version is an unsigned long. OpenType table version numbers are expressed as a single unsigned long comprising of an unsigned short major version and unsigned short minor version. This function detects if the value to be used as a version number loo...
Ensure a table version is an unsigned long. OpenType table version numbers are expressed as a single unsigned long comprising of an unsigned short major version and unsigned short minor version. This function detects if the value to be used as a version number looks too small (i.e. is less than ``0x100...
ensureVersionIsLong
python
fonttools/fonttools
Lib/fontTools/misc/fixedTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/fixedTools.py
MIT
def versionToFixed(value): """Ensure a table version number is fixed-point. Args: value (str): a candidate table version number. Returns: int: A table version number, possibly corrected to fixed-point. """ value = int(value, 0) if value.startswith("0") else float(value) ...
Ensure a table version number is fixed-point. Args: value (str): a candidate table version number. Returns: int: A table version number, possibly corrected to fixed-point.
versionToFixed
python
fonttools/fonttools
Lib/fontTools/misc/fixedTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/fixedTools.py
MIT
def configLogger(**kwargs): """A more sophisticated logging system configuation manager. This is more or less the same as :py:func:`logging.basicConfig`, with some additional options and defaults. The default behaviour is to create a ``StreamHandler`` which writes to sys.stderr, set a formatter us...
A more sophisticated logging system configuation manager. This is more or less the same as :py:func:`logging.basicConfig`, with some additional options and defaults. The default behaviour is to create a ``StreamHandler`` which writes to sys.stderr, set a formatter using the ``DEFAULT_FORMATS`` strings...
configLogger
python
fonttools/fonttools
Lib/fontTools/misc/loggingTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/loggingTools.py
MIT
def _resetExistingLoggers(parent="root"): """Reset the logger named 'parent' and all its children to their initial state, if they already exist in the current configuration. """ root = logging.root # get sorted list of all existing loggers existing = sorted(root.manager.loggerDict.keys()) if...
Reset the logger named 'parent' and all its children to their initial state, if they already exist in the current configuration.
_resetExistingLoggers
python
fonttools/fonttools
Lib/fontTools/misc/loggingTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/loggingTools.py
MIT
def reset(self, start=None): """Reset timer to 'start_time' or the current time.""" if start is None: self.start = self._time() else: self.start = start self.last = self.start self.elapsed = 0.0
Reset timer to 'start_time' or the current time.
reset
python
fonttools/fonttools
Lib/fontTools/misc/loggingTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/loggingTools.py
MIT
def split(self): """Split and return the lap time (in seconds) in between splits.""" current = self._time() self.elapsed = current - self.last self.last = current return self.elapsed
Split and return the lap time (in seconds) in between splits.
split
python
fonttools/fonttools
Lib/fontTools/misc/loggingTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/loggingTools.py
MIT
def formatTime(self, msg, time): """Format 'time' value in 'msg' and return formatted string. If 'msg' contains a '%(time)' format string, try to use that. Otherwise, use the predefined 'default_format'. If 'msg' is empty or None, fall back to 'default_msg'. """ if not ms...
Format 'time' value in 'msg' and return formatted string. If 'msg' contains a '%(time)' format string, try to use that. Otherwise, use the predefined 'default_format'. If 'msg' is empty or None, fall back to 'default_msg'.
formatTime
python
fonttools/fonttools
Lib/fontTools/misc/loggingTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/loggingTools.py
MIT
def __exit__(self, exc_type, exc_value, traceback): """End the current lap. If timer has a logger, log the time elapsed, using the format string in self.msg (or the default one). """ time = self.split() if self.logger is None or exc_type: # if there's no logger attach...
End the current lap. If timer has a logger, log the time elapsed, using the format string in self.msg (or the default one).
__exit__
python
fonttools/fonttools
Lib/fontTools/misc/loggingTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/loggingTools.py
MIT
def __call__(self, func_or_msg=None, **kwargs): """If the first argument is a function, return a decorator which runs the wrapped function inside Timer's context manager. Otherwise, treat the first argument as a 'msg' string and return an updated Timer instance, referencing the same logg...
If the first argument is a function, return a decorator which runs the wrapped function inside Timer's context manager. Otherwise, treat the first argument as a 'msg' string and return an updated Timer instance, referencing the same logger. A 'level' keyword can also be passed to overrid...
__call__
python
fonttools/fonttools
Lib/fontTools/misc/loggingTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/loggingTools.py
MIT
def deprecateFunction(msg, category=UserWarning): """Decorator to raise a warning when a deprecated function is called.""" def decorator(func): @wraps(func) def wrapper(*args, **kwargs): warnings.warn( "%r is deprecated; %s" % (func.__name__, msg), ca...
Decorator to raise a warning when a deprecated function is called.
deprecateFunction
python
fonttools/fonttools
Lib/fontTools/misc/loggingTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/loggingTools.py
MIT
def getMacCreatorAndType(path): """Returns file creator and file type codes for a path. Args: path (str): A file path. Returns: A tuple of two :py:class:`fontTools.textTools.Tag` objects, the first representing the file creator and the second representing the ...
Returns file creator and file type codes for a path. Args: path (str): A file path. Returns: A tuple of two :py:class:`fontTools.textTools.Tag` objects, the first representing the file creator and the second representing the file type.
getMacCreatorAndType
python
fonttools/fonttools
Lib/fontTools/misc/macCreatorType.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/macCreatorType.py
MIT
def setMacCreatorAndType(path, fileCreator, fileType): """Set file creator and file type codes for a path. Note that if the ``xattr`` module is not installed, no action is taken but no error is raised. Args: path (str): A file path. fileCreator: A four-character file creator ta...
Set file creator and file type codes for a path. Note that if the ``xattr`` module is not installed, no action is taken but no error is raised. Args: path (str): A file path. fileCreator: A four-character file creator tag. fileType: A four-character file type tag.
setMacCreatorAndType
python
fonttools/fonttools
Lib/fontTools/misc/macCreatorType.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/macCreatorType.py
MIT
def __init__(self, fileOrPath): """Open a file Args: fileOrPath: Either an object supporting a ``read`` method, an ``os.PathLike`` object, or a string. """ self._resources = OrderedDict() if hasattr(fileOrPath, "read"): self.fi...
Open a file Args: fileOrPath: Either an object supporting a ``read`` method, an ``os.PathLike`` object, or a string.
__init__
python
fonttools/fonttools
Lib/fontTools/misc/macRes.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/macRes.py
MIT
def countResources(self, resType): """Return the number of resources of a given type.""" try: return len(self[resType]) except KeyError: return 0
Return the number of resources of a given type.
countResources
python
fonttools/fonttools
Lib/fontTools/misc/macRes.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/macRes.py
MIT
def getIndices(self, resType): """Returns a list of indices of resources of a given type.""" numRes = self.countResources(resType) if numRes: return list(range(1, numRes + 1)) else: return []
Returns a list of indices of resources of a given type.
getIndices
python
fonttools/fonttools
Lib/fontTools/misc/macRes.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/macRes.py
MIT
def getIndResource(self, resType, index): """Return resource of given type located at an index ranging from 1 to the number of resources for that type, or None if not found. """ if index < 1: return None try: res = self[resType][index - 1] except (...
Return resource of given type located at an index ranging from 1 to the number of resources for that type, or None if not found.
getIndResource
python
fonttools/fonttools
Lib/fontTools/misc/macRes.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/macRes.py
MIT
def getNamedResource(self, resType, name): """Return the named resource of given type, else return None.""" name = tostr(name, encoding="mac-roman") for res in self.get(resType, []): if res.name == name: return res return None
Return the named resource of given type, else return None.
getNamedResource
python
fonttools/fonttools
Lib/fontTools/misc/macRes.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/macRes.py
MIT
def op_rrcurveto(self, index): """{dxa dya dxb dyb dxc dyc}+ rrcurveto""" args = self.popall() for i in range(0, len(args), 6): ( dxa, dya, dxb, dyb, dxc, dyc, ) = args[i : i +...
{dxa dya dxb dyb dxc dyc}+ rrcurveto
op_rrcurveto
python
fonttools/fonttools
Lib/fontTools/misc/psCharStrings.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/psCharStrings.py
MIT
def op_rcurveline(self, index): """{dxa dya dxb dyb dxc dyc}+ dxd dyd rcurveline""" args = self.popall() for i in range(0, len(args) - 2, 6): dxb, dyb, dxc, dyc, dxd, dyd = args[i : i + 6] self.rCurveTo((dxb, dyb), (dxc, dyc), (dxd, dyd)) self.rLineTo(args[-2:])
{dxa dya dxb dyb dxc dyc}+ dxd dyd rcurveline
op_rcurveline
python
fonttools/fonttools
Lib/fontTools/misc/psCharStrings.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/psCharStrings.py
MIT
def op_rlinecurve(self, index): """{dxa dya}+ dxb dyb dxc dyc dxd dyd rlinecurve""" args = self.popall() lineArgs = args[:-6] for i in range(0, len(lineArgs), 2): self.rLineTo(lineArgs[i : i + 2]) dxb, dyb, dxc, dyc, dxd, dyd = args[-6:] self.rCurveTo((dxb, dy...
{dxa dya}+ dxb dyb dxc dyc dxd dyd rlinecurve
op_rlinecurve
python
fonttools/fonttools
Lib/fontTools/misc/psCharStrings.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/psCharStrings.py
MIT
def op_vhcurveto(self, index): """dy1 dx2 dy2 dx3 {dxa dxb dyb dyc dyd dxe dye dxf}* dyf? vhcurveto (30) {dya dxb dyb dxc dxd dxe dye dyf}+ dxf? vhcurveto """ args = self.popall() while args: args = self.vcurveto(args) if args: args = self....
dy1 dx2 dy2 dx3 {dxa dxb dyb dyc dyd dxe dye dxf}* dyf? vhcurveto (30) {dya dxb dyb dxc dxd dxe dye dyf}+ dxf? vhcurveto
op_vhcurveto
python
fonttools/fonttools
Lib/fontTools/misc/psCharStrings.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/psCharStrings.py
MIT
def op_hvcurveto(self, index): """dx1 dx2 dy2 dy3 {dya dxb dyb dxc dxd dxe dye dyf}* dxf? {dxa dxb dyb dyc dyd dxe dye dxf}+ dyf? """ args = self.popall() while args: args = self.hcurveto(args) if args: args = self.vcurveto(args)
dx1 dx2 dy2 dy3 {dya dxb dyb dxc dxd dxe dye dyf}* dxf? {dxa dxb dyb dyc dyd dxe dye dxf}+ dyf?
op_hvcurveto
python
fonttools/fonttools
Lib/fontTools/misc/psCharStrings.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/psCharStrings.py
MIT
def op_seac(self, index): "asb adx ady bchar achar seac" from fontTools.encodings.StandardEncoding import StandardEncoding asb, adx, ady, bchar, achar = self.popall() baseGlyph = StandardEncoding[bchar] self.pen.addComponent(baseGlyph, (1, 0, 0, 1, 0, 0)) accentGlyph = S...
asb adx ady bchar achar seac
op_seac
python
fonttools/fonttools
Lib/fontTools/misc/psCharStrings.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/psCharStrings.py
MIT
def arg_blendList(self, name): """ There may be non-blend args at the top of the stack. We first calculate where the blend args start in the stack. These are the last numMasters*numBlends) +1 args. The blend args starts with numMasters relative coordinate values, the BlueValues ...
There may be non-blend args at the top of the stack. We first calculate where the blend args start in the stack. These are the last numMasters*numBlends) +1 args. The blend args starts with numMasters relative coordinate values, the BlueValues in the list from the default master font. ...
arg_blendList
python
fonttools/fonttools
Lib/fontTools/misc/psCharStrings.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/psCharStrings.py
MIT
def round2(number, ndigits=None): """ Implementation of Python 2 built-in round() function. Rounds a number to a given precision in decimal digits (default 0 digits). The result is a floating point number. Values are rounded to the closest multiple of 10 to the power minus ndigits; if two multip...
Implementation of Python 2 built-in round() function. Rounds a number to a given precision in decimal digits (default 0 digits). The result is a floating point number. Values are rounded to the closest multiple of 10 to the power minus ndigits; if two multiples are equally close, rounding is done a...
round2
python
fonttools/fonttools
Lib/fontTools/misc/py23.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/py23.py
MIT
def otRound(value): """Round float value to nearest integer towards ``+Infinity``. The OpenType spec (in the section on `"normalization" of OpenType Font Variations <https://docs.microsoft.com/en-us/typography/opentype/spec/otvaroverview#coordinate-scales-and-normalization>`_) defines the required method f...
Round float value to nearest integer towards ``+Infinity``. The OpenType spec (in the section on `"normalization" of OpenType Font Variations <https://docs.microsoft.com/en-us/typography/opentype/spec/otvaroverview#coordinate-scales-and-normalization>`_) defines the required method for converting floating poin...
otRound
python
fonttools/fonttools
Lib/fontTools/misc/roundTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/roundTools.py
MIT
def nearestMultipleShortestRepr(value: float, factor: float) -> str: """Round to nearest multiple of factor and return shortest decimal representation. This chooses the float that is closer to a multiple of the given factor while having the shortest decimal representation (the least number of fractional de...
Round to nearest multiple of factor and return shortest decimal representation. This chooses the float that is closer to a multiple of the given factor while having the shortest decimal representation (the least number of fractional decimal digits). For example, given the following: >>> nearestMu...
nearestMultipleShortestRepr
python
fonttools/fonttools
Lib/fontTools/misc/roundTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/roundTools.py
MIT
def parseXML(xmlSnippet): """Parses a snippet of XML. Input can be either a single string (unicode or UTF-8 bytes), or a a sequence of strings. The result is in the same format that would be returned by XMLReader, but the parser imposes no constraints on the root element so it can be called on...
Parses a snippet of XML. Input can be either a single string (unicode or UTF-8 bytes), or a a sequence of strings. The result is in the same format that would be returned by XMLReader, but the parser imposes no constraints on the root element so it can be called on small snippets of TTX files. ...
parseXML
python
fonttools/fonttools
Lib/fontTools/misc/testTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/testTools.py
MIT
def getXML(func, ttFont=None): """Call the passed toXML function and return the written content as a list of lines (unicode strings). Result is stripped of XML declaration and OS-specific newline characters. """ writer = makeXMLWriter() func(writer, ttFont) xml = writer.file.getvalue().decod...
Call the passed toXML function and return the written content as a list of lines (unicode strings). Result is stripped of XML declaration and OS-specific newline characters.
getXML
python
fonttools/fonttools
Lib/fontTools/misc/testTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/testTools.py
MIT
def stripVariableItemsFromTTX( string: str, ttLibVersion: bool = True, checkSumAdjustment: bool = True, modified: bool = True, created: bool = True, sfntVersion: bool = False, # opt-in only ) -> str: """Strip stuff like ttLibVersion, checksums, timestamps, etc. from TTX dumps.""" # ttli...
Strip stuff like ttLibVersion, checksums, timestamps, etc. from TTX dumps.
stripVariableItemsFromTTX
python
fonttools/fonttools
Lib/fontTools/misc/testTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/testTools.py
MIT
def deHexStr(hexdata): """Convert a hex string to binary data.""" hexdata = strjoin(hexdata.split()) if len(hexdata) % 2: hexdata = hexdata + "0" data = [] for i in range(0, len(hexdata), 2): data.append(bytechr(int(hexdata[i : i + 2], 16))) return bytesjoin(data)
Convert a hex string to binary data.
deHexStr
python
fonttools/fonttools
Lib/fontTools/misc/textTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/textTools.py
MIT
def hexStr(data): """Convert binary data to a hex string.""" h = string.hexdigits r = "" for c in data: i = byteord(c) r = r + h[(i >> 4) & 0xF] + h[i & 0xF] return r
Convert binary data to a hex string.
hexStr
python
fonttools/fonttools
Lib/fontTools/misc/textTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/textTools.py
MIT
def caselessSort(alist): """Return a sorted copy of a list. If there are only strings in the list, it will not consider case. """ try: return sorted(alist, key=lambda a: (a.lower(), a)) except TypeError: return sorted(alist)
Return a sorted copy of a list. If there are only strings in the list, it will not consider case.
caselessSort
python
fonttools/fonttools
Lib/fontTools/misc/textTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/textTools.py
MIT
def pad(data, size): r"""Pad byte string 'data' with null bytes until its length is a multiple of 'size'. >>> len(pad(b'abcd', 4)) 4 >>> len(pad(b'abcde', 2)) 6 >>> len(pad(b'abcde', 4)) 8 >>> pad(b'abcdef', 4) == b'abcdef\x00\x00' True """ data = tobytes(data) if si...
Pad byte string 'data' with null bytes until its length is a multiple of 'size'. >>> len(pad(b'abcd', 4)) 4 >>> len(pad(b'abcde', 2)) 6 >>> len(pad(b'abcde', 4)) 8 >>> pad(b'abcdef', 4) == b'abcdef\x00\x00' True
pad
python
fonttools/fonttools
Lib/fontTools/misc/textTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/textTools.py
MIT
def asctime(t=None): """ Convert a tuple or struct_time representing a time as returned by gmtime() or localtime() to a 24-character string of the following form: >>> asctime(time.gmtime(0)) 'Thu Jan 1 00:00:00 1970' If t is not provided, the current time as returned by localtime() is used. ...
Convert a tuple or struct_time representing a time as returned by gmtime() or localtime() to a 24-character string of the following form: >>> asctime(time.gmtime(0)) 'Thu Jan 1 00:00:00 1970' If t is not provided, the current time as returned by localtime() is used. Locale information is not...
asctime
python
fonttools/fonttools
Lib/fontTools/misc/timeTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/timeTools.py
MIT
def transformPoint(self, p): """Transform a point. :Example: >>> t = Transform() >>> t = t.scale(2.5, 5.5) >>> t.transformPoint((100, 100)) (250.0, 550.0) """ (x, y) = p xx, xy, yx, yy, dx, dy = self return...
Transform a point. :Example: >>> t = Transform() >>> t = t.scale(2.5, 5.5) >>> t.transformPoint((100, 100)) (250.0, 550.0)
transformPoint
python
fonttools/fonttools
Lib/fontTools/misc/transform.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/transform.py
MIT
def transformPoints(self, points): """Transform a list of points. :Example: >>> t = Scale(2, 3) >>> t.transformPoints([(0, 0), (0, 100), (100, 100), (100, 0)]) [(0, 0), (0, 300), (200, 300), (200, 0)] >>> """ xx, xy, yx, y...
Transform a list of points. :Example: >>> t = Scale(2, 3) >>> t.transformPoints([(0, 0), (0, 100), (100, 100), (100, 0)]) [(0, 0), (0, 300), (200, 300), (200, 0)] >>>
transformPoints
python
fonttools/fonttools
Lib/fontTools/misc/transform.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/transform.py
MIT
def transformVector(self, v): """Transform an (dx, dy) vector, treating translation as zero. :Example: >>> t = Transform(2, 0, 0, 2, 10, 20) >>> t.transformVector((3, -4)) (6, -8) >>> """ (dx, dy) = v xx, xy, yx, y...
Transform an (dx, dy) vector, treating translation as zero. :Example: >>> t = Transform(2, 0, 0, 2, 10, 20) >>> t.transformVector((3, -4)) (6, -8) >>>
transformVector
python
fonttools/fonttools
Lib/fontTools/misc/transform.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/transform.py
MIT
def transformVectors(self, vectors): """Transform a list of (dx, dy) vector, treating translation as zero. :Example: >>> t = Transform(2, 0, 0, 2, 10, 20) >>> t.transformVectors([(3, -4), (5, -6)]) [(6, -8), (10, -12)] >>> """ ...
Transform a list of (dx, dy) vector, treating translation as zero. :Example: >>> t = Transform(2, 0, 0, 2, 10, 20) >>> t.transformVectors([(3, -4), (5, -6)]) [(6, -8), (10, -12)] >>>
transformVectors
python
fonttools/fonttools
Lib/fontTools/misc/transform.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/transform.py
MIT
def scale(self, x: float = 1, y: float | None = None): """Return a new transformation, scaled by x, y. The 'y' argument may be None, which implies to use the x value for y as well. :Example: >>> t = Transform() >>> t.scale(5) <Transform [5 0 0 5 0...
Return a new transformation, scaled by x, y. The 'y' argument may be None, which implies to use the x value for y as well. :Example: >>> t = Transform() >>> t.scale(5) <Transform [5 0 0 5 0 0]> >>> t.scale(5, 6) <Transform ...
scale
python
fonttools/fonttools
Lib/fontTools/misc/transform.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/transform.py
MIT
def rotate(self, angle: float): """Return a new transformation, rotated by 'angle' (radians). :Example: >>> import math >>> t = Transform() >>> t.rotate(math.pi / 2) <Transform [0 1 -1 0 0 0]> >>> """ c = _n...
Return a new transformation, rotated by 'angle' (radians). :Example: >>> import math >>> t = Transform() >>> t.rotate(math.pi / 2) <Transform [0 1 -1 0 0 0]> >>>
rotate
python
fonttools/fonttools
Lib/fontTools/misc/transform.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/transform.py
MIT
def transform(self, other): """Return a new transformation, transformed by another transformation. :Example: >>> t = Transform(2, 0, 0, 3, 1, 6) >>> t.transform((4, 3, 2, 1, 5, 6)) <Transform [8 9 4 3 11 24]> >>> """ ...
Return a new transformation, transformed by another transformation. :Example: >>> t = Transform(2, 0, 0, 3, 1, 6) >>> t.transform((4, 3, 2, 1, 5, 6)) <Transform [8 9 4 3 11 24]> >>>
transform
python
fonttools/fonttools
Lib/fontTools/misc/transform.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/transform.py
MIT
def reverseTransform(self, other): """Return a new transformation, which is the other transformation transformed by self. self.reverseTransform(other) is equivalent to other.transform(self). :Example: >>> t = Transform(2, 0, 0, 3, 1, 6) >>> t.reverseTrans...
Return a new transformation, which is the other transformation transformed by self. self.reverseTransform(other) is equivalent to other.transform(self). :Example: >>> t = Transform(2, 0, 0, 3, 1, 6) >>> t.reverseTransform((4, 3, 2, 1, 5, 6)) <Tran...
reverseTransform
python
fonttools/fonttools
Lib/fontTools/misc/transform.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/transform.py
MIT
def inverse(self): """Return the inverse transformation. :Example: >>> t = Identity.translate(2, 3).scale(4, 5) >>> t.transformPoint((10, 20)) (42, 103) >>> it = t.inverse() >>> it.transformPoint((42, 103)) ...
Return the inverse transformation. :Example: >>> t = Identity.translate(2, 3).scale(4, 5) >>> t.transformPoint((10, 20)) (42, 103) >>> it = t.inverse() >>> it.transformPoint((42, 103)) (10.0, 20.0) >...
inverse
python
fonttools/fonttools
Lib/fontTools/misc/transform.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/transform.py
MIT
def Scale(x: float, y: float | None = None) -> Transform: """Return the identity transformation scaled by x, y. The 'y' argument may be None, which implies to use the x value for y as well. :Example: >>> Scale(2, 3) <Transform [2 0 0 3 0 0]> >>> """ if y is None:...
Return the identity transformation scaled by x, y. The 'y' argument may be None, which implies to use the x value for y as well. :Example: >>> Scale(2, 3) <Transform [2 0 0 3 0 0]> >>>
Scale
python
fonttools/fonttools
Lib/fontTools/misc/transform.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/transform.py
MIT
def fromTransform(self, transform): """Return a DecomposedTransform() equivalent of this transformation. The returned solution always has skewY = 0, and angle in the (-180, 180]. :Example: >>> DecomposedTransform.fromTransform(Transform(3, 0, 0, 2, 0, 0)) Decompo...
Return a DecomposedTransform() equivalent of this transformation. The returned solution always has skewY = 0, and angle in the (-180, 180]. :Example: >>> DecomposedTransform.fromTransform(Transform(3, 0, 0, 2, 0, 0)) DecomposedTransform(translateX=0, translateY=0, rotati...
fromTransform
python
fonttools/fonttools
Lib/fontTools/misc/transform.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/transform.py
MIT
def toTransform(self) -> Transform: """Return the Transform() equivalent of this transformation. :Example: >>> DecomposedTransform(scaleX=2, scaleY=2).toTransform() <Transform [2 0 0 2 0 0]> >>> """ t = Transform() t = t.translate(...
Return the Transform() equivalent of this transformation. :Example: >>> DecomposedTransform(scaleX=2, scaleY=2).toTransform() <Transform [2 0 0 2 0 0]> >>>
toTransform
python
fonttools/fonttools
Lib/fontTools/misc/transform.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/transform.py
MIT
def build_n_ary_tree(leaves, n): """Build N-ary tree from sequence of leaf nodes. Return a list of lists where each non-leaf node is a list containing max n nodes. """ if not leaves: return [] assert n > 1 depth = ceil(log(len(leaves), n)) if depth <= 1: return list(l...
Build N-ary tree from sequence of leaf nodes. Return a list of lists where each non-leaf node is a list containing max n nodes.
build_n_ary_tree
python
fonttools/fonttools
Lib/fontTools/misc/treeTools.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/treeTools.py
MIT
def dot(self, other): """Performs vector dot product, returning the sum of ``a[0] * b[0], a[1] * b[1], ...``""" assert len(self) == len(other) return sum(a * b for a, b in zip(self, other))
Performs vector dot product, returning the sum of ``a[0] * b[0], a[1] * b[1], ...``
dot
python
fonttools/fonttools
Lib/fontTools/misc/vector.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/vector.py
MIT
def isclose(self, other: "Vector", **kwargs) -> bool: """Return True if the vector is close to another Vector.""" assert len(self) == len(other) return all(math.isclose(a, b, **kwargs) for a, b in zip(self, other))
Return True if the vector is close to another Vector.
isclose
python
fonttools/fonttools
Lib/fontTools/misc/vector.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/vector.py
MIT
def visitObject(self, obj, *args, **kwargs): """Called to visit an object. This function loops over all non-private attributes of the objects and calls any user-registered (via @register_attr() or @register_attrs()) visit() functions. If there is no user-registered visit function, of if...
Called to visit an object. This function loops over all non-private attributes of the objects and calls any user-registered (via @register_attr() or @register_attrs()) visit() functions. If there is no user-registered visit function, of if there is and it returns True, or it returns Non...
visitObject
python
fonttools/fonttools
Lib/fontTools/misc/visitor.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/visitor.py
MIT
def visitList(self, obj, *args, **kwargs): """Called to visit any value that is a list.""" for value in obj: self.visit(value, *args, **kwargs)
Called to visit any value that is a list.
visitList
python
fonttools/fonttools
Lib/fontTools/misc/visitor.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/visitor.py
MIT
def visitDict(self, obj, *args, **kwargs): """Called to visit any value that is a dictionary.""" for value in obj.values(): self.visit(value, *args, **kwargs)
Called to visit any value that is a dictionary.
visitDict
python
fonttools/fonttools
Lib/fontTools/misc/visitor.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/visitor.py
MIT
def visit(self, obj, *args, **kwargs): """This is the main entry to the visitor. The visitor will visit object obj. The visitor will first determine if there is a registered (via @register()) visit function for the type of object. If there is, it will be called, and (visitor, ob...
This is the main entry to the visitor. The visitor will visit object obj. The visitor will first determine if there is a registered (via @register()) visit function for the type of object. If there is, it will be called, and (visitor, obj, *args, **kwargs) will be passed to the ...
visit
python
fonttools/fonttools
Lib/fontTools/misc/visitor.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/visitor.py
MIT
def totree( value: PlistEncodable, sort_keys: bool = True, skipkeys: bool = False, use_builtin_types: Optional[bool] = None, pretty_print: bool = True, indent_level: int = 1, ) -> etree.Element: """Convert a value derived from a plist into an XML tree. Args: value: Any kind of v...
Convert a value derived from a plist into an XML tree. Args: value: Any kind of value to be serialized to XML. sort_keys: Whether keys of dictionaries should be sorted. skipkeys (bool): Whether to silently skip non-string dictionary keys. use_builtin_types (bool): If tru...
totree
python
fonttools/fonttools
Lib/fontTools/misc/plistlib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/plistlib/__init__.py
MIT
def fromtree( tree: etree.Element, use_builtin_types: Optional[bool] = None, dict_type: Type[MutableMapping[str, Any]] = dict, ) -> Any: """Convert an XML tree to a plist structure. Args: tree: An ``etree`` ``Element``. use_builtin_types: If True, binary data is deserialized to ...
Convert an XML tree to a plist structure. Args: tree: An ``etree`` ``Element``. use_builtin_types: If True, binary data is deserialized to bytes strings. If False, it is wrapped in :py:class:`Data` objects. Defaults to True if not provided. Deprecated. dict_type: Wha...
fromtree
python
fonttools/fonttools
Lib/fontTools/misc/plistlib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/plistlib/__init__.py
MIT
def load( fp: IO[bytes], use_builtin_types: Optional[bool] = None, dict_type: Type[MutableMapping[str, Any]] = dict, ) -> Any: """Load a plist file into an object. Args: fp: An opened file. use_builtin_types: If True, binary data is deserialized to bytes strings. If Fals...
Load a plist file into an object. Args: fp: An opened file. use_builtin_types: If True, binary data is deserialized to bytes strings. If False, it is wrapped in :py:class:`Data` objects. Defaults to True if not provided. Deprecated. dict_type: What type to use for di...
load
python
fonttools/fonttools
Lib/fontTools/misc/plistlib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/plistlib/__init__.py
MIT
def loads( value: bytes, use_builtin_types: Optional[bool] = None, dict_type: Type[MutableMapping[str, Any]] = dict, ) -> Any: """Load a plist file from a string into an object. Args: value: A bytes string containing a plist. use_builtin_types: If True, binary data is deserialized t...
Load a plist file from a string into an object. Args: value: A bytes string containing a plist. use_builtin_types: If True, binary data is deserialized to bytes strings. If False, it is wrapped in :py:class:`Data` objects. Defaults to True if not provided. Deprecated. ...
loads
python
fonttools/fonttools
Lib/fontTools/misc/plistlib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/plistlib/__init__.py
MIT
def dump( value: PlistEncodable, fp: IO[bytes], sort_keys: bool = True, skipkeys: bool = False, use_builtin_types: Optional[bool] = None, pretty_print: bool = True, ) -> None: """Write a Python object to a plist file. Args: value: An object to write. fp: A file opened fo...
Write a Python object to a plist file. Args: value: An object to write. fp: A file opened for writing. sort_keys (bool): Whether keys of dictionaries should be sorted. skipkeys (bool): Whether to silently skip non-string dictionary keys. use_builtin_types (bool):...
dump
python
fonttools/fonttools
Lib/fontTools/misc/plistlib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/plistlib/__init__.py
MIT
def dumps( value: PlistEncodable, sort_keys: bool = True, skipkeys: bool = False, use_builtin_types: Optional[bool] = None, pretty_print: bool = True, ) -> bytes: """Write a Python object to a string in plist format. Args: value: An object to write. sort_keys (bool): Whether...
Write a Python object to a string in plist format. Args: value: An object to write. sort_keys (bool): Whether keys of dictionaries should be sorted. skipkeys (bool): Whether to silently skip non-string dictionary keys. use_builtin_types (bool): If true, byte strings will...
dumps
python
fonttools/fonttools
Lib/fontTools/misc/plistlib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/plistlib/__init__.py
MIT
def build(f, font, tableTag=None): """Convert a Monotype font layout file to an OpenType layout object A font object must be passed, but this may be a "dummy" font; it is only used for sorting glyph sets when making coverage tables and to hold the OpenType layout table while it is being built. Arg...
Convert a Monotype font layout file to an OpenType layout object A font object must be passed, but this may be a "dummy" font; it is only used for sorting glyph sets when making coverage tables and to hold the OpenType layout table while it is being built. Args: f: A file object. ...
build
python
fonttools/fonttools
Lib/fontTools/mtiLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/mtiLib/__init__.py
MIT
def main(args=None, font=None): """Convert a FontDame OTL file to TTX XML Writes XML output to stdout. Args: args: Command line arguments (``--font``, ``--table``, input files). """ import sys from fontTools import configLogger from fontTools.misc.testTools import MockFont ...
Convert a FontDame OTL file to TTX XML Writes XML output to stdout. Args: args: Command line arguments (``--font``, ``--table``, input files).
main
python
fonttools/fonttools
Lib/fontTools/mtiLib/__init__.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/mtiLib/__init__.py
MIT
def buildCoverage(glyphs, glyphMap): """Builds a coverage table. Coverage tables (as defined in the `OpenType spec <https://docs.microsoft.com/en-gb/typography/opentype/spec/chapter2#coverage-table>`__) are used in all OpenType Layout lookups apart from the Extension type, and define the glyphs involve...
Builds a coverage table. Coverage tables (as defined in the `OpenType spec <https://docs.microsoft.com/en-gb/typography/opentype/spec/chapter2#coverage-table>`__) are used in all OpenType Layout lookups apart from the Extension type, and define the glyphs involved in a layout subtable. This allows shaping ...
buildCoverage
python
fonttools/fonttools
Lib/fontTools/otlLib/builder.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py
MIT
def buildLookup(subtables, flags=0, markFilterSet=None, table=None, extension=False): """Turns a collection of rules into a lookup. A Lookup (as defined in the `OpenType Spec <https://docs.microsoft.com/en-gb/typography/opentype/spec/chapter2#lookupTbl>`__) wraps the individual rules in a layout operation ...
Turns a collection of rules into a lookup. A Lookup (as defined in the `OpenType Spec <https://docs.microsoft.com/en-gb/typography/opentype/spec/chapter2#lookupTbl>`__) wraps the individual rules in a layout operation (substitution or positioning) in a data structure expressing their overall lookup type - ...
buildLookup
python
fonttools/fonttools
Lib/fontTools/otlLib/builder.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py
MIT
def buildMarkClasses_(self, marks): """{"cedilla": ("BOTTOM", ast.Anchor), ...} --> {"BOTTOM":0, "TOP":1} Helper for MarkBasePostBuilder, MarkLigPosBuilder, and MarkMarkPosBuilder. Seems to return the same numeric IDs for mark classes as the AFDKO makeotf tool. """ ids =...
{"cedilla": ("BOTTOM", ast.Anchor), ...} --> {"BOTTOM":0, "TOP":1} Helper for MarkBasePostBuilder, MarkLigPosBuilder, and MarkMarkPosBuilder. Seems to return the same numeric IDs for mark classes as the AFDKO makeotf tool.
buildMarkClasses_
python
fonttools/fonttools
Lib/fontTools/otlLib/builder.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py
MIT
def add_subtable_break(self, location): """Add an explicit subtable break. Args: location: A string or tuple representing the location in the original source which produced this break, or ``None`` if no location is provided. """ log.warning( ...
Add an explicit subtable break. Args: location: A string or tuple representing the location in the original source which produced this break, or ``None`` if no location is provided.
add_subtable_break
python
fonttools/fonttools
Lib/fontTools/otlLib/builder.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py
MIT
def build(self): """Build the lookup. Returns: An ``otTables.Lookup`` object representing the alternate substitution lookup. """ subtables = self.build_subst_subtables( self.alternates, buildAlternateSubstSubtable ) return self.buildLo...
Build the lookup. Returns: An ``otTables.Lookup`` object representing the alternate substitution lookup.
build
python
fonttools/fonttools
Lib/fontTools/otlLib/builder.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py
MIT
def build(self): """Build the lookup. Returns: An ``otTables.Lookup`` object representing the chained contextual positioning lookup. """ subtables = [] rulesets = self.rulesets() chaining = any(ruleset.hasPrefixOrSuffix for ruleset in rulesets) ...
Build the lookup. Returns: An ``otTables.Lookup`` object representing the chained contextual positioning lookup.
build
python
fonttools/fonttools
Lib/fontTools/otlLib/builder.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py
MIT
def build(self): """Build the lookup. Returns: An ``otTables.Lookup`` object representing the ligature substitution lookup. """ subtables = self.build_subst_subtables( self.ligatures, buildLigatureSubstSubtable ) return self.buildLooku...
Build the lookup. Returns: An ``otTables.Lookup`` object representing the ligature substitution lookup.
build
python
fonttools/fonttools
Lib/fontTools/otlLib/builder.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py
MIT
def add_attachment(self, location, glyphs, entryAnchor, exitAnchor): """Adds attachment information to the cursive positioning lookup. Args: location: A string or tuple representing the location in the original source which produced this lookup. (Unused.) glyphs:...
Adds attachment information to the cursive positioning lookup. Args: location: A string or tuple representing the location in the original source which produced this lookup. (Unused.) glyphs: A list of glyph names sharing these entry and exit anchor locat...
add_attachment
python
fonttools/fonttools
Lib/fontTools/otlLib/builder.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py
MIT
def build(self): """Build the lookup. Returns: An ``otTables.Lookup`` object representing the cursive positioning lookup. """ attachments = [{}] for key in self.attachments: if key[0] == self.SUBTABLE_BREAK_: attachments.append...
Build the lookup. Returns: An ``otTables.Lookup`` object representing the cursive positioning lookup.
build
python
fonttools/fonttools
Lib/fontTools/otlLib/builder.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py
MIT
def build(self): """Build the lookup. Returns: An ``otTables.Lookup`` object representing the mark-to-base positioning lookup. """ subtables = [] for subtable in self.get_subtables_(): markClasses = self.buildMarkClasses_(subtable[0]) ...
Build the lookup. Returns: An ``otTables.Lookup`` object representing the mark-to-base positioning lookup.
build
python
fonttools/fonttools
Lib/fontTools/otlLib/builder.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py
MIT
def build(self): """Build the lookup. Returns: An ``otTables.Lookup`` object representing the mark-to-ligature positioning lookup. """ subtables = [] for subtable in self.get_subtables_(): markClasses = self.buildMarkClasses_(subtable[0]) ...
Build the lookup. Returns: An ``otTables.Lookup`` object representing the mark-to-ligature positioning lookup.
build
python
fonttools/fonttools
Lib/fontTools/otlLib/builder.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py
MIT
def build(self): """Build the lookup. Returns: An ``otTables.Lookup`` object representing the mark-to-mark positioning lookup. """ subtables = [] for subtable in self.get_subtables_(): markClasses = self.buildMarkClasses_(subtable[0]) ...
Build the lookup. Returns: An ``otTables.Lookup`` object representing the mark-to-mark positioning lookup.
build
python
fonttools/fonttools
Lib/fontTools/otlLib/builder.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py
MIT
def build(self): """Build the lookup. Returns: An ``otTables.Lookup`` object representing the chained contextual substitution lookup. """ subtables = [] for prefix, suffix, mapping in self.rules: st = ot.ReverseChainSingleSubst() s...
Build the lookup. Returns: An ``otTables.Lookup`` object representing the chained contextual substitution lookup.
build
python
fonttools/fonttools
Lib/fontTools/otlLib/builder.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py
MIT
def addPair(self, gc1, value1, gc2, value2): """Add a pair positioning rule. Args: gc1: A set of glyph names for the "left" glyph value1: An ``otTables.ValueRecord`` object for the left glyph's positioning. gc2: A set of glyph names for the "right" gl...
Add a pair positioning rule. Args: gc1: A set of glyph names for the "left" glyph value1: An ``otTables.ValueRecord`` object for the left glyph's positioning. gc2: A set of glyph names for the "right" glyph value2: An ``otTables.ValueRecord`` obje...
addPair
python
fonttools/fonttools
Lib/fontTools/otlLib/builder.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py
MIT
def addGlyphPair(self, location, glyph1, value1, glyph2, value2): """Add a glyph pair positioning rule to the current lookup. Args: location: A string or tuple representing the location in the original source which produced this rule. glyph1: A glyph name for the...
Add a glyph pair positioning rule to the current lookup. Args: location: A string or tuple representing the location in the original source which produced this rule. glyph1: A glyph name for the "left" glyph in the pair. value1: A ``otTables.ValueRecord`` for...
addGlyphPair
python
fonttools/fonttools
Lib/fontTools/otlLib/builder.py
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/otlLib/builder.py
MIT