id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
175,462 | from fontTools.config import Config
from fontTools.misc import xmlWriter
from fontTools.misc.configTools import AbstractConfig
from fontTools.misc.textTools import Tag, byteord, tostr
from fontTools.misc.loggingTools import deprecateArgument
from fontTools.ttLib import TTLibError
from fontTools.ttLib.ttGlyphSet import ... | Register a custom packer/unpacker class for a table. The 'moduleName' must be an importable module. If no 'className' is given, it is derived from the tag, for example it will be ``table_C_U_S_T_`` for a 'CUST' tag. The registered table class should be a subclass of :py:class:`fontTools.ttLib.tables.DefaultTable.Defaul... |
175,463 | from fontTools.config import Config
from fontTools.misc import xmlWriter
from fontTools.misc.configTools import AbstractConfig
from fontTools.misc.textTools import Tag, byteord, tostr
from fontTools.misc.loggingTools import deprecateArgument
from fontTools.ttLib import TTLibError
from fontTools.ttLib.ttGlyphSet import ... | Unregister the custom packer/unpacker class for a table. |
175,464 | from fontTools.config import Config
from fontTools.misc import xmlWriter
from fontTools.misc.configTools import AbstractConfig
from fontTools.misc.textTools import Tag, byteord, tostr
from fontTools.misc.loggingTools import deprecateArgument
from fontTools.ttLib import TTLibError
from fontTools.ttLib.ttGlyphSet import ... | Fetch the table tag for a class object. |
175,465 | from fontTools.config import Config
from fontTools.misc import xmlWriter
from fontTools.misc.configTools import AbstractConfig
from fontTools.misc.textTools import Tag, byteord, tostr
from fontTools.misc.loggingTools import deprecateArgument
from fontTools.ttLib import TTLibError
from fontTools.ttLib.ttGlyphSet import ... | Return a new instance of a table. |
175,466 | from fontTools.config import Config
from fontTools.misc import xmlWriter
from fontTools.misc.configTools import AbstractConfig
from fontTools.misc.textTools import Tag, byteord, tostr
from fontTools.misc.loggingTools import deprecateArgument
from fontTools.ttLib import TTLibError
from fontTools.ttLib.ttGlyphSet import ... | Similarly to tagToIdentifier(), this converts a TT tag to a valid XML element name. Since XML element names are case sensitive, this is a fairly simple/readable translation. |
175,467 | from fontTools.config import Config
from fontTools.misc import xmlWriter
from fontTools.misc.configTools import AbstractConfig
from fontTools.misc.textTools import Tag, byteord, tostr
from fontTools.misc.loggingTools import deprecateArgument
from fontTools.ttLib import TTLibError
from fontTools.ttLib.ttGlyphSet import ... | The opposite of tagToXML() |
175,468 | from fontTools.config import Config
from fontTools.misc import xmlWriter
from fontTools.misc.configTools import AbstractConfig
from fontTools.misc.textTools import Tag, byteord, tostr
from fontTools.misc.loggingTools import deprecateArgument
from fontTools.ttLib import TTLibError
from fontTools.ttLib.ttGlyphSet import ... | Rewrite a font file, ordering the tables as recommended by the OpenType specification 1.4. |
175,469 | from fontTools.config import Config
from fontTools.misc import xmlWriter
from fontTools.misc.configTools import AbstractConfig
from fontTools.misc.textTools import Tag, byteord, tostr
from fontTools.misc.loggingTools import deprecateArgument
from fontTools.ttLib import TTLibError
from fontTools.ttLib.ttGlyphSet import ... | Calculate searchRange, entrySelector, rangeShift. |
175,470 | from io import BytesIO
from fontTools.misc.macRes import ResourceReader, ResourceError
def getSFNTResIndices(path):
"""Determine whether a file has a 'sfnt' resource fork or not."""
try:
reader = ResourceReader(path)
indices = reader.getIndices("sfnt")
reader.close()
return indic... | Given a pathname, return a list of TTFont objects. In the case of a flat TTF/OTF file, the list will contain just one font object; but in the case of a Mac font suitcase it will contain as many font objects as there are sfnt resources in the file. |
175,471 | _accessstrings = {0: "", 1: "readonly", 2: "executeonly", 3: "noaccess"}
def _type1_Encoding_repr(encoding, access):
def _type1_CharString_repr(charstrings):
from fontTools.encodings.StandardEncoding import StandardEncoding
def _type1_item_repr(key, value):
psstring = ""
access = _accessstrings[value.access]
... | null |
175,472 | from .roundTools import otRound, nearestMultipleShortestRepr
import logging
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
... | 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``:: >>> fixedToStr(-10139, precisionBits=14) ... |
175,473 | from .roundTools import otRound, nearestMultipleShortestRepr
import logging
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/otvaroverv... | 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:: >>> ## to convert a float string to a 2.14 fixed-point number: >... |
175,474 | from .roundTools import otRound, nearestMultipleShortestRepr
import logging
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/otvaroverv... | 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: string (str): A string rep... |
175,475 | from .roundTools import otRound, nearestMultipleShortestRepr
import logging
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
... | 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(-... |
175,476 | from .roundTools import otRound, nearestMultipleShortestRepr
import logging
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... | 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. |
175,477 |
The provided code snippet includes necessary dependencies for implementing the `bit_indices` function. Write a Python function `def bit_indices(v)` to solve the following problem:
Return list of indices where bits are set, 0 being the index of the least significant bit. >>> bit_indices(0b101) [0, 2]
Here is the func... | Return list of indices where bits are set, 0 being the index of the least significant bit. >>> bit_indices(0b101) [0, 2] |
175,478 | from fontTools.misc.textTools import bytechr, bytesjoin, byteord
def _decryptChar(cipher, R):
cipher = byteord(cipher)
plain = ((cipher ^ (R >> 8))) & 0xFF
R = ((cipher + R) * 52845 + 22719) & 0xFFFF
return bytechr(plain), R
def bytesjoin(iterable, joiner=b""):
return tobytes(joiner).join(tobytes(i... | 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:: >>> testStr = b"\0\0asdadads asds\265" >>> decryptedStr, R = decrypt(testStr, 12321) >>> decryptedStr == b... |
175,479 | from fontTools.misc.textTools import bytechr, bytesjoin, byteord
def _encryptChar(plain, R):
plain = byteord(plain)
cipher = ((plain ^ (R >> 8))) & 0xFF
R = ((cipher + R) * 52845 + 22719) & 0xFFFF
return bytechr(cipher), R
def bytesjoin(iterable, joiner=b""):
return tobytes(joiner).join(tobytes(ite... | 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 *not* add the random prefix to its input. Args: pl... |
175,480 | from fontTools.misc.textTools import bytechr, bytesjoin, byteord
def hexString(s):
import binascii
return binascii.hexlify(s) | null |
175,481 | from fontTools.misc.textTools import bytechr, bytesjoin, byteord
def bytesjoin(iterable, joiner=b""):
return tobytes(joiner).join(tobytes(item) for item in iterable)
def deHexString(h):
import binascii
h = bytesjoin(h.split())
return binascii.unhexlify(h) | null |
175,482 | from fontTools.misc.fixedTools import (
fixedToFloat,
floatToFixed,
floatToFixedToStr,
strToFixedToFloat,
)
from fontTools.misc.textTools import bytechr, byteord, bytesjoin, strjoin
from fontTools.pens.boundsPen import BoundsPen
import struct
import logging
def byteord(c):
return c if isinstance(c,... | null |
175,483 | from fontTools.misc.fixedTools import (
fixedToFloat,
floatToFixed,
floatToFixedToStr,
strToFixedToFloat,
)
from fontTools.misc.textTools import bytechr, byteord, bytesjoin, strjoin
from fontTools.pens.boundsPen import BoundsPen
import struct
import logging
def read_byte(self, b0, data, index):
ret... | null |
175,484 | from fontTools.misc.fixedTools import (
fixedToFloat,
floatToFixed,
floatToFixedToStr,
strToFixedToFloat,
)
from fontTools.misc.textTools import bytechr, byteord, bytesjoin, strjoin
from fontTools.pens.boundsPen import BoundsPen
import struct
import logging
def byteord(c):
return c if isinstance(c,... | null |
175,485 | from fontTools.misc.fixedTools import (
fixedToFloat,
floatToFixed,
floatToFixedToStr,
strToFixedToFloat,
)
from fontTools.misc.textTools import bytechr, byteord, bytesjoin, strjoin
from fontTools.pens.boundsPen import BoundsPen
import struct
import logging
def byteord(c):
return c if isinstance(c,... | null |
175,486 | from fontTools.misc.fixedTools import (
fixedToFloat,
floatToFixed,
floatToFixedToStr,
strToFixedToFloat,
)
from fontTools.misc.textTools import bytechr, byteord, bytesjoin, strjoin
from fontTools.pens.boundsPen import BoundsPen
import struct
import logging
def read_shortInt(self, b0, data, index):
... | null |
175,487 | from fontTools.misc.fixedTools import (
fixedToFloat,
floatToFixed,
floatToFixedToStr,
strToFixedToFloat,
)
from fontTools.misc.textTools import bytechr, byteord, bytesjoin, strjoin
from fontTools.pens.boundsPen import BoundsPen
import struct
import logging
def read_longInt(self, b0, data, index):
... | null |
175,488 | from fontTools.misc.fixedTools import (
fixedToFloat,
floatToFixed,
floatToFixedToStr,
strToFixedToFloat,
)
from fontTools.misc.textTools import bytechr, byteord, bytesjoin, strjoin
from fontTools.pens.boundsPen import BoundsPen
import struct
import logging
def fixedToFloat(value, precisionBits):
"... | null |
175,489 | from fontTools.misc.fixedTools import (
fixedToFloat,
floatToFixed,
floatToFixedToStr,
strToFixedToFloat,
)
from fontTools.misc.textTools import bytechr, byteord, bytesjoin, strjoin
from fontTools.pens.boundsPen import BoundsPen
import struct
import logging
def read_reserved(self, b0, data, index):
... | null |
175,490 | from fontTools.misc.fixedTools import (
fixedToFloat,
floatToFixed,
floatToFixedToStr,
strToFixedToFloat,
)
from fontTools.misc.textTools import bytechr, byteord, bytesjoin, strjoin
from fontTools.pens.boundsPen import BoundsPen
import struct
import logging
realNibbles = [
"0",
"1",
"2",
... | null |
175,491 | from fontTools.misc.fixedTools import (
fixedToFloat,
floatToFixed,
floatToFixedToStr,
strToFixedToFloat,
)
from fontTools.misc.textTools import bytechr, byteord, bytesjoin, strjoin
from fontTools.pens.boundsPen import BoundsPen
import struct
import logging
assert len(t1OperandEncoding) == 256
def buil... | null |
175,492 | from fontTools.misc.fixedTools import (
fixedToFloat,
floatToFixed,
floatToFixedToStr,
strToFixedToFloat,
)
from fontTools.misc.textTools import bytechr, byteord, bytesjoin, strjoin
from fontTools.pens.boundsPen import BoundsPen
import struct
import logging
log = logging.getLogger(__name__)
def bytechr... | null |
175,493 | from fontTools.misc.fixedTools import (
fixedToFloat,
floatToFixed,
floatToFixedToStr,
strToFixedToFloat,
)
from fontTools.misc.textTools import bytechr, byteord, bytesjoin, strjoin
from fontTools.pens.boundsPen import BoundsPen
import struct
import logging
encodeIntT2 = getIntEncoder("t2")
def floatTo... | For T2 only |
175,494 | from fontTools.misc.fixedTools import (
fixedToFloat,
floatToFixed,
floatToFixedToStr,
strToFixedToFloat,
)
from fontTools.misc.textTools import bytechr, byteord, bytesjoin, strjoin
from fontTools.pens.boundsPen import BoundsPen
import struct
import logging
assert len(t1OperandEncoding) == 256
realNibbl... | null |
175,495 | from fontTools.misc.textTools import byteord, strjoin, tobytes, tostr
import sys
import os
import string
def escape(data):
data = tostr(data, "utf_8")
data = data.replace("&", "&")
data = data.replace("<", "<")
data = data.replace(">", ">")
data = data.replace("\r", " ")
return dat... | null |
175,496 | from fontTools.misc.textTools import byteord, strjoin, tobytes, tostr
import sys
import os
import string
def strjoin(iterable, joiner=""):
return tostr(joiner).join(iterable)
The provided code snippet includes necessary dependencies for implementing the `escape8bit` function. Write a Python function `def escape8b... | Input is Unicode string. |
175,497 | from fontTools.misc.textTools import byteord, strjoin, tobytes, tostr
import sys
import os
import string
def byteord(c):
return c if isinstance(c, int) else ord(c)
def hexStr(s):
h = string.hexdigits
r = ""
for c in s:
i = byteord(c)
r = r + h[(i >> 4) & 0xF] + h[i & 0xF]
return r | null |
175,498 | from fontTools.misc.textTools import Tag, bytesjoin, strjoin
def strjoin(iterable, joiner=""):
def _reverseString(s):
s = list(s)
s.reverse()
return strjoin(s) | null |
175,499 | from fontTools.misc.textTools import Tag, bytesjoin, strjoin
try:
import xattr
except ImportError:
xattr = None
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(p... | 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. |
175,500 | from fontTools.misc.roundTools import otRound
from fontTools.misc.vector import Vector as _Vector
import math
import warnings
def calcBounds(array):
"""Calculate the bounding rectangle of a 2D points array.
Args:
array: A sequence of 2D tuples.
Returns:
A four-item tuple representing the bou... | Calculate the integer bounding rectangle of a 2D points array. Values are rounded to closest integer towards ``+Infinity`` using the :func:`fontTools.misc.fixedTools.otRound` function by default, unless an optional ``round`` function is passed. Args: array: A sequence of 2D tuples. round: A rounding function of type ``... |
175,501 | from fontTools.misc.roundTools import otRound
from fontTools.misc.vector import Vector as _Vector
import math
import warnings
The provided code snippet includes necessary dependencies for implementing the `updateBounds` function. Write a Python function `def updateBounds(bounds, p, min=min, max=max)` to solve the foll... | Add a point to a bounding rectangle. Args: bounds: A bounding rectangle expressed as a tuple ``(xMin, yMin, xMax, yMax)``. p: A 2D tuple representing a point. min,max: functions to compute the minimum and maximum. Returns: The updated bounding rectangle ``(xMin, yMin, xMax, yMax)``. |
175,502 | from fontTools.misc.roundTools import otRound
from fontTools.misc.vector import Vector as _Vector
import math
import warnings
The provided code snippet includes necessary dependencies for implementing the `pointInRect` function. Write a Python function `def pointInRect(p, rect)` to solve the following problem:
Test if... | Test if a point is inside a bounding rectangle. Args: p: A 2D tuple representing a point. rect: A bounding rectangle expressed as a tuple ``(xMin, yMin, xMax, yMax)``. Returns: ``True`` if the point is inside the rectangle, ``False`` otherwise. |
175,503 | from fontTools.misc.roundTools import otRound
from fontTools.misc.vector import Vector as _Vector
import math
import warnings
The provided code snippet includes necessary dependencies for implementing the `pointsInRect` function. Write a Python function `def pointsInRect(array, rect)` to solve the following problem:
D... | Determine which points are inside a bounding rectangle. Args: array: A sequence of 2D tuples. rect: A bounding rectangle expressed as a tuple ``(xMin, yMin, xMax, yMax)``. Returns: A list containing the points inside the rectangle. |
175,504 | from fontTools.misc.roundTools import otRound
from fontTools.misc.vector import Vector as _Vector
import math
import warnings
The provided code snippet includes necessary dependencies for implementing the `vectorLength` function. Write a Python function `def vectorLength(vector)` to solve the following problem:
Calcul... | Calculate the length of the given vector. Args: vector: A 2D tuple. Returns: The Euclidean length of the vector. |
175,505 | from fontTools.misc.roundTools import otRound
from fontTools.misc.vector import Vector as _Vector
import math
import warnings
The provided code snippet includes necessary dependencies for implementing the `asInt16` function. Write a Python function `def asInt16(array)` to solve the following problem:
Round a list of f... | Round a list of floats to 16-bit signed integers. Args: array: List of float values. Returns: A list of rounded integers. |
175,506 | from fontTools.misc.roundTools import otRound
from fontTools.misc.vector import Vector as _Vector
import math
import warnings
The provided code snippet includes necessary dependencies for implementing the `scaleRect` function. Write a Python function `def scaleRect(rect, x, y)` to solve the following problem:
Scale a ... | Scale a bounding box rectangle. Args: rect: A bounding rectangle expressed as a tuple ``(xMin, yMin, xMax, yMax)``. x: Factor to scale the rectangle along the X axis. Y: Factor to scale the rectangle along the Y axis. Returns: A scaled bounding rectangle. |
175,507 | from fontTools.misc.roundTools import otRound
from fontTools.misc.vector import Vector as _Vector
import math
import warnings
The provided code snippet includes necessary dependencies for implementing the `offsetRect` function. Write a Python function `def offsetRect(rect, dx, dy)` to solve the following problem:
Offs... | Offset a bounding box rectangle. Args: rect: A bounding rectangle expressed as a tuple ``(xMin, yMin, xMax, yMax)``. dx: Amount to offset the rectangle along the X axis. dY: Amount to offset the rectangle along the Y axis. Returns: An offset bounding rectangle. |
175,508 | from fontTools.misc.roundTools import otRound
from fontTools.misc.vector import Vector as _Vector
import math
import warnings
The provided code snippet includes necessary dependencies for implementing the `insetRect` function. Write a Python function `def insetRect(rect, dx, dy)` to solve the following problem:
Inset ... | Inset a bounding box rectangle on all sides. Args: rect: A bounding rectangle expressed as a tuple ``(xMin, yMin, xMax, yMax)``. dx: Amount to inset the rectangle along the X axis. dY: Amount to inset the rectangle along the Y axis. Returns: An inset bounding rectangle. |
175,509 | from fontTools.misc.roundTools import otRound
from fontTools.misc.vector import Vector as _Vector
import math
import warnings
The provided code snippet includes necessary dependencies for implementing the `unionRect` function. Write a Python function `def unionRect(rect1, rect2)` to solve the following problem:
Determ... | Determine union of bounding rectangles. Args: rect1: First bounding rectangle, expressed as tuples ``(xMin, yMin, xMax, yMax)``. rect2: Second bounding rectangle. Returns: The smallest rectangle in which both input rectangles are fully enclosed. |
175,510 | from fontTools.misc.roundTools import otRound
from fontTools.misc.vector import Vector as _Vector
import math
import warnings
The provided code snippet includes necessary dependencies for implementing the `rectCenter` function. Write a Python function `def rectCenter(rect)` to solve the following problem:
Determine re... | Determine rectangle center. Args: rect: Bounding rectangle, expressed as tuples ``(xMin, yMin, xMax, yMax)``. Returns: A 2D tuple representing the point at the center of the rectangle. |
175,511 | from fontTools.misc.roundTools import otRound
from fontTools.misc.vector import Vector as _Vector
import math
import warnings
def normRect(rect):
"""Normalize a bounding box rectangle.
This function "turns the rectangle the right way up", so that the following
holds::
xMin <= xMax and yMin <= yMax
... | >>> bounds = (72.3, -218.4, 1201.3, 919.1) >>> quantizeRect(bounds) (72, -219, 1202, 920) >>> quantizeRect(bounds, factor=10) (70, -220, 1210, 920) >>> quantizeRect(bounds, factor=100) (0, -300, 1300, 1000) |
175,512 | from fontTools.misc.roundTools import otRound
from fontTools.misc.vector import Vector as _Vector
import math
import warnings
The provided code snippet includes necessary dependencies for implementing the `_test` function. Write a Python function `def _test()` to solve the following problem:
>>> import math >>> calcBo... | >>> import math >>> calcBounds([]) (0, 0, 0, 0) >>> calcBounds([(0, 40), (0, 100), (50, 50), (80, 10)]) (0, 10, 80, 100) >>> updateBounds((0, 0, 0, 0), (100, 100)) (0, 0, 100, 100) >>> pointInRect((50, 50), (0, 0, 100, 100)) True >>> pointInRect((0, 0), (0, 0, 100, 100)) True >>> pointInRect((100, 100), (0, 0, 100, 100... |
175,513 | from fontTools.pens.basePen import BasePen
from functools import partial
from itertools import count
import sympy as sp
import sys
n = 3
X = tuple(sp.symbols("x:%d" % (n + 1), real=True))
Y = tuple(sp.symbols("y:%d" % (n + 1), real=True))
P = tuple(zip(*(sp.symbols("p:%d[%s]" % (n + 1, w), real=True) for w in "01")))
... | null |
175,514 | from numbers import Number
import math
import operator
import warnings
def _operator_rsub(a, b):
return operator.sub(b, a) | null |
175,515 | from numbers import Number
import math
import operator
import warnings
def _operator_rtruediv(a, b):
return operator.truediv(b, a) | null |
175,516 | from fontTools.misc.fixedTools import fixedToFloat as fi2fl, floatToFixed as fl2fi
from fontTools.misc.textTools import tobytes, tostr
import struct
import re
def unpack(fmt, data, obj=None):
if obj is None:
obj = {}
data = tobytes(data)
formatstring, names, fixes = getformat(fmt)
if isinstance(... | null |
175,517 | from fontTools.misc.fixedTools import fixedToFloat as fi2fl, floatToFixed as fl2fi
from fontTools.misc.textTools import tobytes, tostr
import struct
import re
def pack(fmt, obj):
formatstring, names, fixes = getformat(fmt, keep_pad_byte=True)
elements = []
if not isinstance(obj, dict):
obj = obj.__d... | null |
175,518 | from fontTools.misc.arrayTools import calcBounds, sectRect, rectArea
from fontTools.misc.transform import Identity
import math
from collections import namedtuple
def calcCubicArcLengthC(pt1, pt2, pt3, pt4, tolerance=0.005):
"""Calculates the arc length for a cubic Bezier segment.
Args:
pt1,pt2,pt3,pt4: ... | Calculates the arc length for a cubic Bezier segment. Whereas :func:`approximateCubicArcLength` approximates the length, this function calculates it by "measuring", recursively dividing the curve until the divided segments are shorter than ``tolerance``. Args: pt1,pt2,pt3,pt4: Control points of the Bezier as 2D tuples.... |
175,519 | from fontTools.misc.arrayTools import calcBounds, sectRect, rectArea
from fontTools.misc.transform import Identity
import math
from collections import namedtuple
def calcQuadraticArcLengthC(pt1, pt2, pt3):
"""Calculates the arc length for a quadratic Bezier segment.
Args:
pt1: Start point of the Bezier ... | Calculates the arc length for a quadratic Bezier segment. Args: pt1: Start point of the Bezier as 2D tuple. pt2: Handle point of the Bezier as 2D tuple. pt3: End point of the Bezier as 2D tuple. Returns: Arc length value. Example:: >>> calcQuadraticArcLength((0, 0), (0, 0), (0, 0)) # empty segment 0.0 >>> calcQuadratic... |
175,520 | from fontTools.misc.arrayTools import calcBounds, sectRect, rectArea
from fontTools.misc.transform import Identity
import math
from collections import namedtuple
def approximateQuadraticArcLengthC(pt1, pt2, pt3):
"""Calculates the arc length for a quadratic Bezier segment.
Uses Gauss-Legendre quadrature for a b... | Calculates the arc length for a quadratic Bezier segment. Uses Gauss-Legendre quadrature for a branch-free approximation. See :func:`calcQuadraticArcLength` for a slower but more accurate result. Args: pt1: Start point of the Bezier as 2D tuple. pt2: Handle point of the Bezier as 2D tuple. pt3: End point of the Bezier ... |
175,521 | from fontTools.misc.arrayTools import calcBounds, sectRect, rectArea
from fontTools.misc.transform import Identity
import math
from collections import namedtuple
def approximateCubicArcLengthC(pt1, pt2, pt3, pt4):
"""Approximates the arc length for a cubic Bezier segment.
Args:
pt1,pt2,pt3,pt4: Control ... | Approximates the arc length for a cubic Bezier segment. Uses Gauss-Lobatto quadrature with n=5 points to approximate arc length. See :func:`calcCubicArcLength` for a slower but more accurate result. Args: pt1,pt2,pt3,pt4: Control points of the Bezier as 2D tuples. Returns: Arc length value. Example:: >>> approximateCub... |
175,522 | from fontTools.misc.arrayTools import calcBounds, sectRect, rectArea
from fontTools.misc.transform import Identity
import math
from collections import namedtuple
a=cython.double,
from math import sqrt, acos, cos, pi
The provided code snippet includes necessary dependencies for implementing the `splitLine` function... | Split a line at a given coordinate. Args: pt1: Start point of line as 2D tuple. pt2: End point of line as 2D tuple. where: Position at which to split the line. isHorizontal: Direction of the ray splitting the line. If true, ``where`` is interpreted as a Y coordinate; if false, then ``where`` is interpreted as an X coor... |
175,523 | from fontTools.misc.arrayTools import calcBounds, sectRect, rectArea
from fontTools.misc.transform import Identity
import math
from collections import namedtuple
a=cython.double,
b=cython.double,
def _splitQuadraticAtT(a, b, c, *ts):
ts = list(ts)
segments = []
ts.insert(0, 0.0)
ts.append(1.0)
... | Split a quadratic Bezier curve at a given coordinate. Args: pt1,pt2,pt3: Control points of the Bezier as 2D tuples. where: Position at which to split the curve. isHorizontal: Direction of the ray splitting the curve. If true, ``where`` is interpreted as a Y coordinate; if false, then ``where`` is interpreted as an X co... |
175,524 | from fontTools.misc.arrayTools import calcBounds, sectRect, rectArea
from fontTools.misc.transform import Identity
import math
from collections import namedtuple
a=cython.double,
b=cython.double,
def _splitCubicAtT(a, b, c, d, *ts):
ts = list(ts)
ts.insert(0, 0.0)
ts.append(1.0)
segments = []
... | Split a cubic Bezier curve at a given coordinate. Args: pt1,pt2,pt3,pt4: Control points of the Bezier as 2D tuples. where: Position at which to split the curve. isHorizontal: Direction of the ray splitting the curve. If true, ``where`` is interpreted as a Y coordinate; if false, then ``where`` is interpreted as an X co... |
175,525 | from fontTools.misc.arrayTools import calcBounds, sectRect, rectArea
from fontTools.misc.transform import Identity
import math
from collections import namedtuple
t2=cython.double, _1_t=cython.double, _1_t_2=cython.double, _2_t_1_t=cython.doubl
from math import sqrt, acos, cos, pi
The provided code snippet includes... | Split a cubic Bezier curve at t. Args: pt1,pt2,pt3,pt4: Control points of the Bezier as complex numbers. t: Position at which to split the curve. Returns: A tuple of two curve segments (each curve segment being four complex numbers). |
175,526 | from fontTools.misc.arrayTools import calcBounds, sectRect, rectArea
from fontTools.misc.transform import Identity
import math
from collections import namedtuple
t2=cython.double, _1_t=cython.double, _1_t_2=cython.double, _2_t_1_t=cython.doubl
from math import sqrt, acos, cos, pi
The provided code snippet includes... | Finds the point at time `t` on a cubic curve. Args: pt1, pt2, pt3, pt4: Coordinates of the curve as complex numbers. t: The time along the curve. Returns: A complex number with the coordinates of the point. |
175,527 | from fontTools.misc.arrayTools import calcBounds, sectRect, rectArea
from fontTools.misc.transform import Identity
import math
from collections import namedtuple
Intersection = namedtuple("Intersection", ["pt", "t1", "t2"])
t2=cython.double, _1_t=cython.double, _1_t_2=cython.double, _2_t_1_t=cython.doubl
from math ... | 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 containing the intersection point, time on first... |
175,528 | from fontTools.misc.arrayTools import calcBounds, sectRect, rectArea
from fontTools.misc.transform import Identity
import math
from collections import namedtuple
from math import sqrt, acos, cos, pi
def _segmentrepr(obj):
"""
>>> _segmentrepr([1, [2, 3], [], [[2, [3, 4], [0.1, 2.2]]]])
'(1, (2, 3), (), ((2,... | Helper for the doctests, displaying each segment in a list of segments on a single line as a tuple. |
175,529 | import os
import time
from datetime import datetime, timezone
import calendar
epoch_diff = calendar.timegm((1904, 1, 1, 0, 0, 0, 0, 0, 0))
def asctime(t=None):
def timestampToString(value):
return asctime(time.gmtime(max(0, value + epoch_diff))) | null |
175,530 | import os
import time
from datetime import datetime, timezone
import calendar
epoch_diff = calendar.timegm((1904, 1, 1, 0, 0, 0, 0, 0, 0))
DAYNAMES = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
MONTHNAMES = [
None,
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Se... | null |
175,531 | import sys
import logging
import timeit
from functools import wraps
from collections.abc import Mapping, Callable
import warnings
from logging import PercentStyle
class LevelFormatter(logging.Formatter):
"""Log formatter with level-specific formatting.
Formatter class which optionally takes a dict of logging le... | 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, and add the hand... |
175,532 | import sys
import logging
import timeit
from functools import wraps
from collections.abc import Mapping, Callable
import warnings
from logging import PercentStyle
The provided code snippet includes necessary dependencies for implementing the `deprecateArgument` function. Write a Python function `def deprecateArgument(... | Raise a warning about deprecated function argument 'name'. |
175,533 | import sys
import logging
import timeit
from functools import wraps
from collections.abc import Mapping, Callable
import warnings
from logging import PercentStyle
def wraps(wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequence[str] = ...) -> Callable[[_T], _T]: ...
The provided code snippet includes... | Decorator to raise a warning when a deprecated function is called. |
175,534 | from fontTools.misc.textTools import bytechr, byteord, bytesjoin, tobytes, tostr
from fontTools.misc import eexec
from .psOperators import (
PSOperators,
ps_StandardEncoding,
ps_array,
ps_boolean,
ps_dict,
ps_integer,
ps_literal,
ps_mark,
ps_name,
ps_operator,
ps_procedure,
... | null |
175,535 | import math
import functools
import logging
def noRound(value):
return value
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/otvarov... | null |
175,536 | from fontTools.misc.textTools import tostr
try:
from lxml.etree import *
_have_lxml = True
except ImportError:
try:
from xml.etree.cElementTree import *
# the cElementTree version of XML function doesn't support
# the optional 'parser' keyword argument
from xml.etree.ElementT... | 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. |
175,537 | from fontTools.misc.textTools import tostr
def _get_writer(file_or_filename, encoding):
# returns text write method and release all resources after using
try:
write = file_or_filename.write
except AttributeError:
# file_or_filename is a file name
f = open(
... | null |
175,538 | from fontTools.misc.textTools import tostr
try:
from lxml.etree import *
_have_lxml = True
except ImportError:
try:
from xml.etree.cElementTree import *
# the cElementTree version of XML function doesn't support
# the optional 'parser' keyword argument
from xml.etree.ElementT... | null |
175,539 | from fontTools.misc.textTools import tostr
try:
from lxml.etree import *
_have_lxml = True
except ImportError:
try:
from xml.etree.cElementTree import *
# the cElementTree version of XML function doesn't support
# the optional 'parser' keyword argument
from xml.etree.ElementT... | null |
175,540 | from fontTools.misc.textTools import tostr
def _indent(elem, level=0):
# From http://effbot.org/zone/element-lib.htm#prettyprint
i = "\n" + level * " "
if len(elem):
if not elem.text or not elem.text.strip():
elem.text = i + " "
if not elem.tail or not ... | null |
175,541 | import math
from typing import NamedTuple
from dataclasses import dataclass
_EPSILON = 1e-15
_ONE_EPSILON = 1 - _EPSILON
_MINUS_ONE_EPSILON = -1 + _EPSILON
def _normSinCos(v):
if abs(v) < _EPSILON:
v = 0
elif v > _ONE_EPSILON:
v = 1
elif v < _MINUS_ONE_EPSILON:
v = -1
return v | null |
175,542 | import math
from typing import NamedTuple
from dataclasses import dataclass
class Transform(NamedTuple):
"""2x2 transformation matrix plus offset, a.k.a. Affine transform.
Transform instances are immutable: all transforming methods, eg.
rotate(), return a new Transform instance.
:Example:
>>... | Return the identity transformation offset by x, y. :Example: >>> Offset(2, 3) <Transform [1 0 0 1 2 3]> >>> |
175,543 | import ast
import string
def num2binary(l, bits=32):
items = []
binary = ""
for i in range(bits):
if l & 0x1:
binary = "1" + binary
else:
binary = "0" + binary
l = l >> 1
if not ((i + 1) % 8):
items.append(binary)
binary = ""
... | null |
175,544 | import ast
import string
def strjoin(iterable, joiner=""):
def binary2num(bin):
bin = strjoin(bin.split())
l = 0
for digit in bin:
l = l << 1
if digit != "0":
l = l | 0x1
return l | null |
175,545 | import ast
import string
The provided code snippet includes necessary dependencies for implementing the `caselessSort` function. Write a Python function `def caselessSort(alist)` to solve the following problem:
Return a sorted copy of a list. If there are only strings in the list, it will not consider case.
Here is t... | Return a sorted copy of a list. If there are only strings in the list, it will not consider case. |
175,546 | from types import SimpleNamespace
def _empty_decorator(x):
return x | null |
175,547 | class Classifier(object):
"""
Main Classifier object, used to classify things into similar sets.
"""
def __init__(self, sort=True):
self._things = set() # set of all things known so far
self._sets = [] # list of class sets produced so far
self._mapping = {} # map from things t... | 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 sets, into similar classes, b... |
175,548 | illegalCharacters = r"\" * + / : < > ? [ \ ] | \0".split(" ")
illegalCharacters += [chr(i) for i in range(1, 32)]
illegalCharacters += [chr(0x7F)]
reservedFileNames = "CON PRN AUX CLOCK$ NUL A:-Z: COM1".lower().split(" ")
reservedFileNames += "LPT1 LPT2 LPT3 COM2 COM3 COM4".lower().split(" ")
maxFileNameLength = 255
de... | 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 file names. prefix: Prefix to be prepen... |
175,549 | import decimal as _decimal
import math as _math
import warnings
from contextlib import redirect_stderr, redirect_stdout
from io import BytesIO
from io import StringIO as UnicodeIO
from types import SimpleNamespace
from .textTools import Tag, bytechr, byteord, bytesjoin, strjoin, tobytes, tostr
class Py23Error(NotImplem... | null |
175,550 | import decimal as _decimal
import math as _math
import warnings
from contextlib import redirect_stderr, redirect_stdout
from io import BytesIO
from io import StringIO as UnicodeIO
from types import SimpleNamespace
from .textTools import Tag, bytechr, byteord, bytesjoin, strjoin, tobytes, tostr
The provided code snippe... | 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 away from 0. ndigits m... |
175,551 |
def _makeunicodes(f):
lines = iter(f.readlines())
unicodes = {}
for line in lines:
if not line:
continue
num, name = line.split(";")[:2]
if name[0] == "<":
continue # "<control>", etc.
num = int(num, 16)
unicodes[num] = name
return unico... | null |
175,552 | from .arc import EllipticalArc
import re
COMMANDS = set("MmZzLlHhVvCcSsQqTtAa")
UPPERCASE = set("MZLHVCSQTA")
def _tokenize_path(pathdef):
arc_cmd = None
for x in COMMAND_RE.split(pathdef):
if x in COMMANDS:
arc_cmd = x if x in ARC_COMMANDS else None
yield x
continue
... | Parse SVG path definition (i.e. "d" attribute of <path> elements) and call a 'pen' object's moveTo, lineTo, curveTo, qCurveTo and closePath methods. If 'current_pos' (2-float tuple) is provided, the initial moveTo will be relative to that instead being absolute. If the pen has an "arcTo" method, it is called with the o... |
175,553 | from fontTools.misc.transform import Identity, Scale
from math import atan2, ceil, cos, fabs, isfinite, pi, radians, sin, sqrt, tan
def _map_point(matrix, pt):
# apply Transform matrix to a point represented as a complex number
r = matrix.transformPoint((pt.real, pt.imag))
return r[0] + r[1] * 1j | null |
175,554 | import re
def _prefer_non_zero(*args):
for arg in args:
if arg != 0:
return arg
return 0.0 | null |
175,555 | import re
def _ntos(n):
# %f likes to add unnecessary 0's, %g isn't consistent about # decimals
return ("%.3f" % n).rstrip("0").rstrip(".") | null |
175,556 | import re
def _strip_xml_ns(tag):
# ElementTree API doesn't provide a way to ignore XML namespaces in tags
# so we here strip them ourselves: cf. https://bugs.python.org/issue18304
return tag.split("}", 1)[1] if "}" in tag else tag | null |
175,557 | import re
def _transform(raw_value):
# TODO assumes a 'matrix' transform.
# No other transform functions are supported at the moment.
# https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform
# start simple: if you aren't exactly matrix(...) then no love
match = re.match(r"matrix\((.*)... | null |
175,558 | from __future__ import absolute_import
import logging
import os
from email.parser import FeedParser
from pip._vendor import pkg_resources
from pip._vendor.packaging.utils import canonicalize_name
from pip._internal.cli.base_command import Command
from pip._internal.cli.status_codes import ERROR, SUCCESS
from pip._inter... | Gather details from installed distributions. Print distribution name, version, location, and installed files. Installed files requires a pip generated 'installed-files.txt' in the distributions '.egg-info' directory. |
175,559 | from __future__ import absolute_import
import logging
import os
from email.parser import FeedParser
from pip._vendor import pkg_resources
from pip._vendor.packaging.utils import canonicalize_name
from pip._internal.cli.base_command import Command
from pip._internal.cli.status_codes import ERROR, SUCCESS
from pip._inter... | Print the information from installed distributions found. |
175,560 | from __future__ import absolute_import
import hashlib
import logging
import sys
from pip._internal.cli.base_command import Command
from pip._internal.cli.status_codes import ERROR, SUCCESS
from pip._internal.utils.hashes import FAVORITE_HASH, STRONG_HASHES
from pip._internal.utils.misc import read_chunks, write_output
... | Return the hash digest of a file. |
175,561 | from __future__ import absolute_import
import errno
import logging
import operator
import os
import shutil
import site
from optparse import SUPPRESS_HELP
from pip._vendor import pkg_resources
from pip._vendor.packaging.utils import canonicalize_name
from pip._internal.cache import WheelCache
from pip._internal.cli impo... | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.