py23 Use new-style classes
Such that we get the same semantics in both Python 2 and 3.
This commit is contained in:
parent
b475c03b4d
commit
e388db566b
@ -83,7 +83,7 @@ preferredAttributeOrder = [
|
|||||||
class error(Exception): pass
|
class error(Exception): pass
|
||||||
|
|
||||||
|
|
||||||
class AFM:
|
class AFM(object):
|
||||||
|
|
||||||
_attrs = None
|
_attrs = None
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ cffHeaderFormat = """
|
|||||||
offSize: B
|
offSize: B
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class CFFFontSet:
|
class CFFFontSet(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
@ -126,7 +126,7 @@ class CFFFontSet:
|
|||||||
self.GlobalSubrs.append(subr)
|
self.GlobalSubrs.append(subr)
|
||||||
|
|
||||||
|
|
||||||
class CFFWriter:
|
class CFFWriter(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.data = []
|
self.data = []
|
||||||
@ -180,7 +180,7 @@ def calcOffSize(largestOffset):
|
|||||||
return offSize
|
return offSize
|
||||||
|
|
||||||
|
|
||||||
class IndexCompiler:
|
class IndexCompiler(object):
|
||||||
|
|
||||||
def __init__(self, items, strings, parent):
|
def __init__(self, items, strings, parent):
|
||||||
self.items = self.getItems(items, strings)
|
self.items = self.getItems(items, strings)
|
||||||
@ -303,7 +303,7 @@ class CharStringsCompiler(GlobalSubrsCompiler):
|
|||||||
self.parent.rawDict["CharStrings"] = pos
|
self.parent.rawDict["CharStrings"] = pos
|
||||||
|
|
||||||
|
|
||||||
class Index:
|
class Index(object):
|
||||||
|
|
||||||
"""This class represents what the CFF spec calls an INDEX."""
|
"""This class represents what the CFF spec calls an INDEX."""
|
||||||
|
|
||||||
@ -500,7 +500,7 @@ class FDSelect:
|
|||||||
self.gidArray.append(fdSelectValue)
|
self.gidArray.append(fdSelectValue)
|
||||||
|
|
||||||
|
|
||||||
class CharStrings:
|
class CharStrings(object):
|
||||||
|
|
||||||
def __init__(self, file, charset, globalSubrs, private, fdSelect, fdArray):
|
def __init__(self, file, charset, globalSubrs, private, fdSelect, fdArray):
|
||||||
if file is not None:
|
if file is not None:
|
||||||
@ -662,7 +662,7 @@ def buildConverters(table):
|
|||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
||||||
class SimpleConverter:
|
class SimpleConverter(object):
|
||||||
def read(self, parent, value):
|
def read(self, parent, value):
|
||||||
return value
|
return value
|
||||||
def write(self, parent, value):
|
def write(self, parent, value):
|
||||||
@ -783,7 +783,7 @@ class CharStringsConverter(TableConverter):
|
|||||||
charStrings.fromXML(name, attrs, content)
|
charStrings.fromXML(name, attrs, content)
|
||||||
return charStrings
|
return charStrings
|
||||||
|
|
||||||
class CharsetConverter:
|
class CharsetConverter(object):
|
||||||
def read(self, parent, value):
|
def read(self, parent, value):
|
||||||
isCID = hasattr(parent, "ROS")
|
isCID = hasattr(parent, "ROS")
|
||||||
if value > 2:
|
if value > 2:
|
||||||
@ -827,7 +827,7 @@ class CharsetConverter:
|
|||||||
return safeEval(attrs["value"])
|
return safeEval(attrs["value"])
|
||||||
|
|
||||||
|
|
||||||
class CharsetCompiler:
|
class CharsetCompiler(object):
|
||||||
|
|
||||||
def __init__(self, strings, charset, parent):
|
def __init__(self, strings, charset, parent):
|
||||||
assert charset[0] == '.notdef'
|
assert charset[0] == '.notdef'
|
||||||
@ -936,7 +936,7 @@ def parseCharset(numGlyphs, file, strings, isCID, format):
|
|||||||
return charset
|
return charset
|
||||||
|
|
||||||
|
|
||||||
class EncodingCompiler:
|
class EncodingCompiler(object):
|
||||||
|
|
||||||
def __init__(self, strings, encoding, parent):
|
def __init__(self, strings, encoding, parent):
|
||||||
assert not isinstance(encoding, basestring)
|
assert not isinstance(encoding, basestring)
|
||||||
@ -1121,7 +1121,7 @@ class FDArrayConverter(TableConverter):
|
|||||||
return fdArray
|
return fdArray
|
||||||
|
|
||||||
|
|
||||||
class FDSelectConverter:
|
class FDSelectConverter(object):
|
||||||
|
|
||||||
def read(self, parent, value):
|
def read(self, parent, value):
|
||||||
file = parent.file
|
file = parent.file
|
||||||
@ -1177,7 +1177,7 @@ def packFDSelect3(fdSelectArray):
|
|||||||
return bytesjoin(data)
|
return bytesjoin(data)
|
||||||
|
|
||||||
|
|
||||||
class FDSelectCompiler:
|
class FDSelectCompiler(object):
|
||||||
|
|
||||||
def __init__(self, fdSelect, parent):
|
def __init__(self, fdSelect, parent):
|
||||||
format = fdSelect.format
|
format = fdSelect.format
|
||||||
@ -1315,7 +1315,7 @@ class PrivateDictDecompiler(psCharStrings.DictDecompiler):
|
|||||||
operators = buildOperatorDict(privateDictOperators)
|
operators = buildOperatorDict(privateDictOperators)
|
||||||
|
|
||||||
|
|
||||||
class DictCompiler:
|
class DictCompiler(object):
|
||||||
|
|
||||||
def __init__(self, dictObj, strings, parent):
|
def __init__(self, dictObj, strings, parent):
|
||||||
assert isinstance(strings, IndexedStrings)
|
assert isinstance(strings, IndexedStrings)
|
||||||
@ -1471,7 +1471,7 @@ class PrivateDictCompiler(DictCompiler):
|
|||||||
return children
|
return children
|
||||||
|
|
||||||
|
|
||||||
class BaseDict:
|
class BaseDict(object):
|
||||||
|
|
||||||
def __init__(self, strings=None, file=None, offset=None):
|
def __init__(self, strings=None, file=None, offset=None):
|
||||||
self.rawDict = {}
|
self.rawDict = {}
|
||||||
@ -1603,7 +1603,7 @@ class PrivateDict(BaseDict):
|
|||||||
compilerClass = PrivateDictCompiler
|
compilerClass = PrivateDictCompiler
|
||||||
|
|
||||||
|
|
||||||
class IndexedStrings:
|
class IndexedStrings(object):
|
||||||
|
|
||||||
"""SID -> string mapping."""
|
"""SID -> string mapping."""
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ headerformat = """
|
|||||||
|
|
||||||
FONDheadersize = 52
|
FONDheadersize = 52
|
||||||
|
|
||||||
class FontFamily:
|
class FontFamily(object):
|
||||||
|
|
||||||
def __init__(self, theRes, mode = 'r'):
|
def __init__(self, theRes, mode = 'r'):
|
||||||
self.ID, type, self.name = theRes.GetResInfo()
|
self.ID, type, self.name = theRes.GetResInfo()
|
||||||
@ -464,7 +464,7 @@ def makeLWFNfilename(name):
|
|||||||
lwfnname = lwfnname + part[:3]
|
lwfnname = lwfnname + part[:3]
|
||||||
return lwfnname
|
return lwfnname
|
||||||
|
|
||||||
class BitmapFontFile:
|
class BitmapFontFile(object):
|
||||||
|
|
||||||
def __init__(self, path, mode='r'):
|
def __init__(self, path, mode='r'):
|
||||||
if mode == 'r':
|
if mode == 'r':
|
||||||
@ -507,7 +507,7 @@ class BitmapFontFile:
|
|||||||
self.resref = None
|
self.resref = None
|
||||||
|
|
||||||
|
|
||||||
class FondSelector:
|
class FondSelector(object):
|
||||||
|
|
||||||
def __init__(self, fondlist):
|
def __init__(self, fondlist):
|
||||||
import W
|
import W
|
||||||
|
@ -51,7 +51,7 @@ _FCBPBFormat = """
|
|||||||
ioFCBParID: l
|
ioFCBParID: l
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class ParamBlock:
|
class ParamBlock(object):
|
||||||
|
|
||||||
"""Wrapper for the very low level FCBPB record."""
|
"""Wrapper for the very low level FCBPB record."""
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ for _i in range(len(realNibbles)):
|
|||||||
realNibblesDict[realNibbles[_i]] = _i
|
realNibblesDict[realNibbles[_i]] = _i
|
||||||
|
|
||||||
|
|
||||||
class ByteCodeBase:
|
class ByteCodeBase(object):
|
||||||
|
|
||||||
def read_byte(self, b0, data, index):
|
def read_byte(self, b0, data, index):
|
||||||
return b0 - 139, index
|
return b0 - 139, index
|
||||||
@ -482,7 +482,7 @@ class T1CharString(T2CharString):
|
|||||||
self.width = extractor.width
|
self.width = extractor.width
|
||||||
|
|
||||||
|
|
||||||
class SimpleT2Decompiler:
|
class SimpleT2Decompiler(object):
|
||||||
|
|
||||||
def __init__(self, localSubrs, globalSubrs):
|
def __init__(self, localSubrs, globalSubrs):
|
||||||
self.localSubrs = localSubrs
|
self.localSubrs = localSubrs
|
||||||
|
@ -185,7 +185,7 @@ def _test():
|
|||||||
|
|
||||||
print('size:', calcsize(format))
|
print('size:', calcsize(format))
|
||||||
|
|
||||||
class foo:
|
class foo(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
i = foo()
|
i = foo()
|
||||||
|
@ -66,7 +66,7 @@ def _normSinCos(v):
|
|||||||
return v
|
return v
|
||||||
|
|
||||||
|
|
||||||
class Transform:
|
class Transform(object):
|
||||||
|
|
||||||
"""2x2 transformation matrix plus offset, a.k.a. Affine transform.
|
"""2x2 transformation matrix plus offset, a.k.a. Affine transform.
|
||||||
Transform instances are immutable: all transforming methods, eg.
|
Transform instances are immutable: all transforming methods, eg.
|
||||||
|
@ -11,7 +11,7 @@ class TTXParseError(Exception): pass
|
|||||||
BUFSIZE = 0x4000
|
BUFSIZE = 0x4000
|
||||||
|
|
||||||
|
|
||||||
class XMLReader:
|
class XMLReader(object):
|
||||||
|
|
||||||
def __init__(self, fileName, ttFont, progress=None, quiet=False):
|
def __init__(self, fileName, ttFont, progress=None, quiet=False):
|
||||||
self.ttFont = ttFont
|
self.ttFont = ttFont
|
||||||
@ -116,7 +116,7 @@ class XMLReader:
|
|||||||
self.root = None
|
self.root = None
|
||||||
|
|
||||||
|
|
||||||
class ProgressPrinter:
|
class ProgressPrinter(object):
|
||||||
|
|
||||||
def __init__(self, title, maxval=100):
|
def __init__(self, title, maxval=100):
|
||||||
print(title)
|
print(title)
|
||||||
|
@ -9,7 +9,7 @@ import struct
|
|||||||
INDENT = " "
|
INDENT = " "
|
||||||
|
|
||||||
|
|
||||||
class XMLWriter:
|
class XMLWriter(object):
|
||||||
|
|
||||||
def __init__(self, fileOrPath, indentwhite=INDENT, idlefunc=None):
|
def __init__(self, fileOrPath, indentwhite=INDENT, idlefunc=None):
|
||||||
if not hasattr(fileOrPath, "write"):
|
if not hasattr(fileOrPath, "write"):
|
||||||
|
@ -25,7 +25,7 @@ headerSize = sstruct.calcsize(nfntHeaderFormat)
|
|||||||
assert headerSize == 26
|
assert headerSize == 26
|
||||||
|
|
||||||
|
|
||||||
class NFNT:
|
class NFNT(object):
|
||||||
|
|
||||||
def __init__(self, data=None):
|
def __init__(self, data=None):
|
||||||
if data is not None:
|
if data is not None:
|
||||||
@ -259,7 +259,7 @@ class NFNT:
|
|||||||
return width, srcbounds, destbounds
|
return width, srcbounds, destbounds
|
||||||
|
|
||||||
|
|
||||||
class Glyph:
|
class Glyph(object):
|
||||||
|
|
||||||
def __init__(self, width, offset, pixels=None, pixelDepth=1):
|
def __init__(self, width, offset, pixels=None, pixelDepth=1):
|
||||||
self.width = width
|
self.width = width
|
||||||
|
@ -43,7 +43,7 @@ else:
|
|||||||
class T1Error(Exception): pass
|
class T1Error(Exception): pass
|
||||||
|
|
||||||
|
|
||||||
class T1Font:
|
class T1Font(object):
|
||||||
|
|
||||||
"""Type 1 font class.
|
"""Type 1 font class.
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ elif sys.platform == "darwin" and sys.version_info[:3] != (2, 2, 0):
|
|||||||
class TTLibError(Exception): pass
|
class TTLibError(Exception): pass
|
||||||
|
|
||||||
|
|
||||||
class TTFont:
|
class TTFont(object):
|
||||||
|
|
||||||
"""The main font object. It manages file input and output, and offers
|
"""The main font object. It manages file input and output, and offers
|
||||||
a convenient way of accessing tables.
|
a convenient way of accessing tables.
|
||||||
@ -650,7 +650,7 @@ class TTFont:
|
|||||||
raise TTLibError("Font contains no outlines")
|
raise TTLibError("Font contains no outlines")
|
||||||
|
|
||||||
|
|
||||||
class _TTGlyphSet:
|
class _TTGlyphSet(object):
|
||||||
|
|
||||||
"""Generic dict-like GlyphSet class, meant as a TrueType counterpart
|
"""Generic dict-like GlyphSet class, meant as a TrueType counterpart
|
||||||
to CFF's CharString dict. See TTFont.getGlyphSet().
|
to CFF's CharString dict. See TTFont.getGlyphSet().
|
||||||
@ -681,7 +681,7 @@ class _TTGlyphSet:
|
|||||||
return default
|
return default
|
||||||
|
|
||||||
|
|
||||||
class _TTGlyph:
|
class _TTGlyph(object):
|
||||||
|
|
||||||
"""Wrapper for a TrueType glyph that supports the Pen protocol, meaning
|
"""Wrapper for a TrueType glyph that supports the Pen protocol, meaning
|
||||||
that it has a .draw() method that takes a pen object as its only
|
that it has a .draw() method that takes a pen object as its only
|
||||||
@ -742,7 +742,7 @@ class _TTGlyph:
|
|||||||
pen.closePath()
|
pen.closePath()
|
||||||
|
|
||||||
|
|
||||||
class GlyphOrder:
|
class GlyphOrder(object):
|
||||||
|
|
||||||
"""A pseudo table. The glyph order isn't in the font as a separate
|
"""A pseudo table. The glyph order isn't in the font as a separate
|
||||||
table, but it's nice to present it as such in the TTX format.
|
table, but it's nice to present it as such in the TTX format.
|
||||||
|
@ -54,7 +54,7 @@ def openTTFonts(path):
|
|||||||
return fonts
|
return fonts
|
||||||
|
|
||||||
|
|
||||||
class SFNTResourceReader:
|
class SFNTResourceReader(object):
|
||||||
|
|
||||||
"""Simple (Mac-only) read-only file wrapper for 'sfnt' resources."""
|
"""Simple (Mac-only) read-only file wrapper for 'sfnt' resources."""
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ class SFNTResourceReader:
|
|||||||
return getattr(self.file, attr)
|
return getattr(self.file, attr)
|
||||||
|
|
||||||
|
|
||||||
class SFNTResourceWriter:
|
class SFNTResourceWriter(object):
|
||||||
|
|
||||||
"""Simple (Mac-only) file wrapper for 'sfnt' resources."""
|
"""Simple (Mac-only) file wrapper for 'sfnt' resources."""
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ from fontTools.misc import sstruct
|
|||||||
import struct
|
import struct
|
||||||
|
|
||||||
|
|
||||||
class SFNTReader:
|
class SFNTReader(object):
|
||||||
|
|
||||||
def __init__(self, file, checkChecksums=1, fontNumber=-1):
|
def __init__(self, file, checkChecksums=1, fontNumber=-1):
|
||||||
self.file = file
|
self.file = file
|
||||||
@ -101,7 +101,7 @@ class SFNTReader:
|
|||||||
self.file.close()
|
self.file.close()
|
||||||
|
|
||||||
|
|
||||||
class SFNTWriter:
|
class SFNTWriter(object):
|
||||||
|
|
||||||
def __init__(self, file, numTables, sfntVersion="\000\001\000\000",
|
def __init__(self, file, numTables, sfntVersion="\000\001\000\000",
|
||||||
flavor=None, flavorData=None):
|
flavor=None, flavorData=None):
|
||||||
@ -340,7 +340,7 @@ woffDirectoryEntryFormat = """
|
|||||||
woffDirectoryEntrySize = sstruct.calcsize(woffDirectoryEntryFormat)
|
woffDirectoryEntrySize = sstruct.calcsize(woffDirectoryEntryFormat)
|
||||||
|
|
||||||
|
|
||||||
class DirectoryEntry:
|
class DirectoryEntry(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.uncompressed = False # if True, always embed entry raw
|
self.uncompressed = False # if True, always embed entry raw
|
||||||
|
@ -27,7 +27,7 @@ smallGlyphMetricsFormat = """
|
|||||||
Advance: B
|
Advance: B
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class BitmapGlyphMetrics:
|
class BitmapGlyphMetrics(object):
|
||||||
|
|
||||||
def toXML(self, writer, ttFont):
|
def toXML(self, writer, ttFont):
|
||||||
writer.begintag(self.__class__.__name__)
|
writer.begintag(self.__class__.__name__)
|
||||||
|
@ -138,7 +138,7 @@ class table_C_O_L_R_(DefaultTable.DefaultTable):
|
|||||||
elif glyphSelector in self.ColorLayers:
|
elif glyphSelector in self.ColorLayers:
|
||||||
del self.ColorLayers[glyphSelector]
|
del self.ColorLayers[glyphSelector]
|
||||||
|
|
||||||
class LayerRecord:
|
class LayerRecord(object):
|
||||||
|
|
||||||
def __init__(self, name = None, colorID = None):
|
def __init__(self, name = None, colorID = None):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
@ -72,7 +72,7 @@ class table_C_P_A_L_(DefaultTable.DefaultTable):
|
|||||||
value = safeEval(attrs["value"])
|
value = safeEval(attrs["value"])
|
||||||
setattr(self, name, value)
|
setattr(self, name, value)
|
||||||
|
|
||||||
class Color:
|
class Color(object):
|
||||||
|
|
||||||
def __init__(self, blue=None, green=None, red=None, alpha=None):
|
def __init__(self, blue=None, green=None, red=None, alpha=None):
|
||||||
self.blue = blue
|
self.blue = blue
|
||||||
|
@ -112,7 +112,7 @@ def b64encode(b):
|
|||||||
s = s[76:]
|
s = s[76:]
|
||||||
return strjoin(items)
|
return strjoin(items)
|
||||||
|
|
||||||
class SignatureRecord:
|
class SignatureRecord(object):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<%s: %s>" % (self.__class__.__name__, self.__dict__)
|
return "<%s: %s>" % (self.__class__.__name__, self.__dict__)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from __future__ import print_function, division
|
from __future__ import print_function, division
|
||||||
from fontTools.misc.py23 import *
|
from fontTools.misc.py23 import *
|
||||||
|
|
||||||
class DefaultTable:
|
class DefaultTable(object):
|
||||||
|
|
||||||
dependencies = []
|
dependencies = []
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ class table_E_B_D_T_(DefaultTable.DefaultTable):
|
|||||||
assert self.strikeData[strikeIndex] == None, "Duplicate strike EBDT indices."
|
assert self.strikeData[strikeIndex] == None, "Duplicate strike EBDT indices."
|
||||||
self.strikeData[strikeIndex] = bitmapGlyphDict
|
self.strikeData[strikeIndex] = bitmapGlyphDict
|
||||||
|
|
||||||
class EbdtComponent:
|
class EbdtComponent(object):
|
||||||
|
|
||||||
def toXML(self, writer, ttFont):
|
def toXML(self, writer, ttFont):
|
||||||
writer.begintag('ebdtComponent', [('name', self.name)])
|
writer.begintag('ebdtComponent', [('name', self.name)])
|
||||||
@ -364,7 +364,7 @@ def _readExtFileImageData(bitmapObject, name, attrs, content, ttFont):
|
|||||||
# in XML.
|
# in XML.
|
||||||
_bitmapGlyphSubclassPrefix = 'ebdt_bitmap_format_'
|
_bitmapGlyphSubclassPrefix = 'ebdt_bitmap_format_'
|
||||||
|
|
||||||
class BitmapGlyph:
|
class BitmapGlyph(object):
|
||||||
|
|
||||||
# For the external file format. This can be changed in subclasses. This way
|
# For the external file format. This can be changed in subclasses. This way
|
||||||
# when the extfile option is turned on files have the form: glyphName.ext
|
# when the extfile option is turned on files have the form: glyphName.ext
|
||||||
@ -459,7 +459,7 @@ def _createBitmapPlusMetricsMixin(metricsClass):
|
|||||||
metricsId = metricStrings.index(curMetricsName)
|
metricsId = metricStrings.index(curMetricsName)
|
||||||
oppositeMetricsName = metricStrings[1-metricsId]
|
oppositeMetricsName = metricStrings[1-metricsId]
|
||||||
|
|
||||||
class BitmapPlusMetricsMixin:
|
class BitmapPlusMetricsMixin(object):
|
||||||
|
|
||||||
def writeMetrics(self, writer, ttFont):
|
def writeMetrics(self, writer, ttFont):
|
||||||
self.metrics.toXML(writer, ttFont)
|
self.metrics.toXML(writer, ttFont)
|
||||||
@ -484,7 +484,7 @@ BitmapPlusSmallMetricsMixin = _createBitmapPlusMetricsMixin(SmallGlyphMetrics)
|
|||||||
# Data that is bit aligned can be tricky to deal with. These classes implement
|
# Data that is bit aligned can be tricky to deal with. These classes implement
|
||||||
# helper functionality for dealing with the data and getting a particular row
|
# helper functionality for dealing with the data and getting a particular row
|
||||||
# of bitwise data. Also helps implement fancy data export/import in XML.
|
# of bitwise data. Also helps implement fancy data export/import in XML.
|
||||||
class BitAlignedBitmapMixin:
|
class BitAlignedBitmapMixin(object):
|
||||||
|
|
||||||
def _getBitRange(self, row, bitDepth, metrics):
|
def _getBitRange(self, row, bitDepth, metrics):
|
||||||
rowBits = (bitDepth * metrics.width)
|
rowBits = (bitDepth * metrics.width)
|
||||||
@ -572,7 +572,7 @@ class BitAlignedBitmapMixin:
|
|||||||
# Save the image data with the bits going the correct way.
|
# Save the image data with the bits going the correct way.
|
||||||
self.imageData = _reverseBytes(bytesjoin(map(bytechr, ordDataList)))
|
self.imageData = _reverseBytes(bytesjoin(map(bytechr, ordDataList)))
|
||||||
|
|
||||||
class ByteAlignedBitmapMixin:
|
class ByteAlignedBitmapMixin(object):
|
||||||
|
|
||||||
def _getByteRange(self, row, bitDepth, metrics):
|
def _getByteRange(self, row, bitDepth, metrics):
|
||||||
rowBytes = (bitDepth * metrics.width + 7) // 8
|
rowBytes = (bitDepth * metrics.width + 7) // 8
|
||||||
|
@ -222,7 +222,7 @@ class table_E_B_L_C_(DefaultTable.DefaultTable):
|
|||||||
assert self.strikes[strikeIndex] == None, "Duplicate strike EBLC indices."
|
assert self.strikes[strikeIndex] == None, "Duplicate strike EBLC indices."
|
||||||
self.strikes[strikeIndex] = curStrike
|
self.strikes[strikeIndex] = curStrike
|
||||||
|
|
||||||
class Strike:
|
class Strike(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.bitmapSizeTable = BitmapSizeTable()
|
self.bitmapSizeTable = BitmapSizeTable()
|
||||||
@ -255,7 +255,7 @@ class Strike:
|
|||||||
self.indexSubTables.append(indexSubTable)
|
self.indexSubTables.append(indexSubTable)
|
||||||
|
|
||||||
|
|
||||||
class BitmapSizeTable:
|
class BitmapSizeTable(object):
|
||||||
|
|
||||||
# Returns all the simple metric names that bitmap size table
|
# Returns all the simple metric names that bitmap size table
|
||||||
# cares about in terms of XML creation.
|
# cares about in terms of XML creation.
|
||||||
@ -296,7 +296,7 @@ class BitmapSizeTable:
|
|||||||
print("Warning: unknown name '%s' being ignored in BitmapSizeTable." % name)
|
print("Warning: unknown name '%s' being ignored in BitmapSizeTable." % name)
|
||||||
|
|
||||||
|
|
||||||
class SbitLineMetrics:
|
class SbitLineMetrics(object):
|
||||||
|
|
||||||
def toXML(self, name, writer, ttFont):
|
def toXML(self, name, writer, ttFont):
|
||||||
writer.begintag('sbitLineMetrics', [('direction', name)])
|
writer.begintag('sbitLineMetrics', [('direction', name)])
|
||||||
@ -319,7 +319,7 @@ class SbitLineMetrics:
|
|||||||
# Important information about the naming scheme. Used for identifying subtables.
|
# Important information about the naming scheme. Used for identifying subtables.
|
||||||
_indexSubTableSubclassPrefix = 'eblc_index_sub_table_'
|
_indexSubTableSubclassPrefix = 'eblc_index_sub_table_'
|
||||||
|
|
||||||
class EblcIndexSubTable:
|
class EblcIndexSubTable(object):
|
||||||
|
|
||||||
def __init__(self, data, ttFont):
|
def __init__(self, data, ttFont):
|
||||||
self.data = data
|
self.data = data
|
||||||
@ -424,7 +424,7 @@ def _createOffsetArrayIndexSubTableMixin(formatStringForDataType):
|
|||||||
dataFormat = '>'+formatStringForDataType
|
dataFormat = '>'+formatStringForDataType
|
||||||
offsetDataSize = struct.calcsize(dataFormat)
|
offsetDataSize = struct.calcsize(dataFormat)
|
||||||
|
|
||||||
class OffsetArrayIndexSubTableMixin:
|
class OffsetArrayIndexSubTableMixin(object):
|
||||||
|
|
||||||
def decompile(self):
|
def decompile(self):
|
||||||
|
|
||||||
@ -485,7 +485,7 @@ def _createOffsetArrayIndexSubTableMixin(formatStringForDataType):
|
|||||||
# A Mixin for functionality shared between the different kinds
|
# A Mixin for functionality shared between the different kinds
|
||||||
# of fixed sized data handling. Both kinds have big metrics so
|
# of fixed sized data handling. Both kinds have big metrics so
|
||||||
# that kind of special processing is also handled in this mixin.
|
# that kind of special processing is also handled in this mixin.
|
||||||
class FixedSizeIndexSubTableMixin:
|
class FixedSizeIndexSubTableMixin(object):
|
||||||
|
|
||||||
def writeMetrics(self, writer, ttFont):
|
def writeMetrics(self, writer, ttFont):
|
||||||
writer.simpletag('imageSize', value=self.imageSize)
|
writer.simpletag('imageSize', value=self.imageSize)
|
||||||
|
@ -27,7 +27,7 @@ GMAPRecordFormat1 = """
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class GMAPRecord:
|
class GMAPRecord(object):
|
||||||
def __init__(self, uv = 0, cid = 0, gid = 0, ggid = 0, name = ""):
|
def __init__(self, uv = 0, cid = 0, gid = 0, ggid = 0, name = ""):
|
||||||
self.UV = uv
|
self.UV = uv
|
||||||
self.cid = cid
|
self.cid = cid
|
||||||
|
@ -184,7 +184,7 @@ class table_M_E_T_A_(DefaultTable.DefaultTable):
|
|||||||
setattr(self, name, safeEval(attrs["value"]))
|
setattr(self, name, safeEval(attrs["value"]))
|
||||||
|
|
||||||
|
|
||||||
class GlyphRecord:
|
class GlyphRecord(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.glyphID = -1
|
self.glyphID = -1
|
||||||
self.nMetaEntry = -1
|
self.nMetaEntry = -1
|
||||||
@ -267,7 +267,7 @@ def mapUTF8toXML(string):
|
|||||||
return string
|
return string
|
||||||
|
|
||||||
|
|
||||||
class StringRecord:
|
class StringRecord(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.labelID = -1
|
self.labelID = -1
|
||||||
self.string = ""
|
self.string = ""
|
||||||
|
@ -21,7 +21,7 @@ panoseFormat = """
|
|||||||
bXHeight: B
|
bXHeight: B
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class Panose:
|
class Panose(object):
|
||||||
|
|
||||||
def toXML(self, writer, ttFont):
|
def toXML(self, writer, ttFont):
|
||||||
formatstring, names, fixes = sstruct.getformat(panoseFormat)
|
formatstring, names, fixes = sstruct.getformat(panoseFormat)
|
||||||
|
@ -307,7 +307,7 @@ class table_S_V_G_(DefaultTable.DefaultTable):
|
|||||||
else:
|
else:
|
||||||
print("Unknown", name, content)
|
print("Unknown", name, content)
|
||||||
|
|
||||||
class DocumentIndexEntry:
|
class DocumentIndexEntry(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.startGlyphID = None # USHORT
|
self.startGlyphID = None # USHORT
|
||||||
self.endGlyphID = None # USHORT
|
self.endGlyphID = None # USHORT
|
||||||
@ -317,7 +317,7 @@ class DocumentIndexEntry:
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "startGlyphID: %s, endGlyphID: %s, svgDocOffset: %s, svgDocLength: %s" % (self.startGlyphID, self.endGlyphID, self.svgDocOffset, self.svgDocLength)
|
return "startGlyphID: %s, endGlyphID: %s, svgDocOffset: %s, svgDocLength: %s" % (self.startGlyphID, self.endGlyphID, self.svgDocOffset, self.svgDocLength)
|
||||||
|
|
||||||
class ColorPalettes:
|
class ColorPalettes(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.numColorParams = None # USHORT
|
self.numColorParams = None # USHORT
|
||||||
self.colorParamUINameIDs = [] # list of name table name ID values that provide UI description of each color palette.
|
self.colorParamUINameIDs = [] # list of name table name ID values that provide UI description of each color palette.
|
||||||
@ -343,7 +343,7 @@ class ColorPalettes:
|
|||||||
if len(colorPalette.paletteColors) != self.numColorParams:
|
if len(colorPalette.paletteColors) != self.numColorParams:
|
||||||
raise ValueError("Number of color records in a colorPalette ('%s') does not match the number of colorParamUINameIDs elements ('%s')." % (len(colorPalette.paletteColors), self.numColorParams))
|
raise ValueError("Number of color records in a colorPalette ('%s') does not match the number of colorParamUINameIDs elements ('%s')." % (len(colorPalette.paletteColors), self.numColorParams))
|
||||||
|
|
||||||
class ColorPalette:
|
class ColorPalette(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.uiNameID = None # USHORT. name table ID that describes user interface strings associated with this color palette.
|
self.uiNameID = None # USHORT. name table ID that describes user interface strings associated with this color palette.
|
||||||
self.paletteColors = [] # list of ColorRecords
|
self.paletteColors = [] # list of ColorRecords
|
||||||
@ -362,7 +362,7 @@ class ColorPalette:
|
|||||||
colorRecord.blue = eval(attrib["blue"])
|
colorRecord.blue = eval(attrib["blue"])
|
||||||
colorRecord.alpha = eval(attrib["alpha"])
|
colorRecord.alpha = eval(attrib["alpha"])
|
||||||
|
|
||||||
class ColorRecord:
|
class ColorRecord(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.red = 255 # all are one byte values.
|
self.red = 255 # all are one byte values.
|
||||||
self.green = 255
|
self.green = 255
|
||||||
|
@ -115,7 +115,7 @@ class table_V_O_R_G_(DefaultTable.DefaultTable):
|
|||||||
elif glyphSelector in self.VOriginRecords:
|
elif glyphSelector in self.VOriginRecords:
|
||||||
del self.VOriginRecords[glyphSelector]
|
del self.VOriginRecords[glyphSelector]
|
||||||
|
|
||||||
class VOriginRecord:
|
class VOriginRecord(object):
|
||||||
|
|
||||||
def __init__(self, name = None, vOrigin = None):
|
def __init__(self, name = None, vOrigin = None):
|
||||||
self.glyphName = name
|
self.glyphName = name
|
||||||
|
@ -97,7 +97,7 @@ class table__c_m_a_p(DefaultTable.DefaultTable):
|
|||||||
self.tables.append(table)
|
self.tables.append(table)
|
||||||
|
|
||||||
|
|
||||||
class CmapSubtable:
|
class CmapSubtable(object):
|
||||||
|
|
||||||
def __init__(self, format):
|
def __init__(self, format):
|
||||||
self.format = format
|
self.format = format
|
||||||
@ -217,7 +217,7 @@ class cmap_format_0(CmapSubtable):
|
|||||||
|
|
||||||
|
|
||||||
subHeaderFormat = ">HHhH"
|
subHeaderFormat = ">HHhH"
|
||||||
class SubHeader:
|
class SubHeader(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.firstCode = None
|
self.firstCode = None
|
||||||
self.entryCount = None
|
self.entryCount = None
|
||||||
|
@ -203,7 +203,7 @@ SCALED_COMPONENT_OFFSET = 0x0800 # composite designed to have the component
|
|||||||
UNSCALED_COMPONENT_OFFSET = 0x1000 # composite designed not to have the component offset scaled (designed for MS)
|
UNSCALED_COMPONENT_OFFSET = 0x1000 # composite designed not to have the component offset scaled (designed for MS)
|
||||||
|
|
||||||
|
|
||||||
class Glyph:
|
class Glyph(object):
|
||||||
|
|
||||||
def __init__(self, data=""):
|
def __init__(self, data=""):
|
||||||
if not data:
|
if not data:
|
||||||
@ -730,7 +730,7 @@ class Glyph:
|
|||||||
return self.__dict__ == other.__dict__
|
return self.__dict__ == other.__dict__
|
||||||
|
|
||||||
|
|
||||||
class GlyphComponent:
|
class GlyphComponent(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
@ -890,7 +890,7 @@ class GlyphComponent:
|
|||||||
raise TypeError("unordered types %s() < %s()", type(self), type(other))
|
raise TypeError("unordered types %s() < %s()", type(self), type(other))
|
||||||
return self.__dict__ == other.__dict__
|
return self.__dict__ == other.__dict__
|
||||||
|
|
||||||
class GlyphCoordinates:
|
class GlyphCoordinates(object):
|
||||||
|
|
||||||
def __init__(self, iterable=[]):
|
def __init__(self, iterable=[]):
|
||||||
self._a = array.array("h")
|
self._a = array.array("h")
|
||||||
|
@ -84,7 +84,7 @@ class table__k_e_r_n(DefaultTable.DefaultTable):
|
|||||||
subtable.fromXML(name, attrs, content, ttFont)
|
subtable.fromXML(name, attrs, content, ttFont)
|
||||||
|
|
||||||
|
|
||||||
class KernTable_format_0:
|
class KernTable_format_0(object):
|
||||||
|
|
||||||
def decompile(self, data, ttFont):
|
def decompile(self, data, ttFont):
|
||||||
version, length, coverage = (0,0,0)
|
version, length, coverage = (0,0,0)
|
||||||
@ -162,7 +162,7 @@ class KernTable_format_0:
|
|||||||
del self.kernTable[pair]
|
del self.kernTable[pair]
|
||||||
|
|
||||||
|
|
||||||
class KernTable_format_2:
|
class KernTable_format_2(object):
|
||||||
|
|
||||||
def decompile(self, data, ttFont):
|
def decompile(self, data, ttFont):
|
||||||
self.data = data
|
self.data = data
|
||||||
@ -181,7 +181,7 @@ class KernTable_format_2:
|
|||||||
self.decompile(readHex(content), ttFont)
|
self.decompile(readHex(content), ttFont)
|
||||||
|
|
||||||
|
|
||||||
class KernTable_format_unkown:
|
class KernTable_format_unkown(object):
|
||||||
|
|
||||||
def __init__(self, format):
|
def __init__(self, format):
|
||||||
self.format = format
|
self.format = format
|
||||||
|
@ -88,7 +88,7 @@ class table__n_a_m_e(DefaultTable.DefaultTable):
|
|||||||
return None # not found
|
return None # not found
|
||||||
|
|
||||||
|
|
||||||
class NameRecord:
|
class NameRecord(object):
|
||||||
|
|
||||||
def toXML(self, writer, ttFont):
|
def toXML(self, writer, ttFont):
|
||||||
writer.begintag("namerecord", [
|
writer.begintag("namerecord", [
|
||||||
|
@ -3,7 +3,7 @@ from fontTools.misc.py23 import *
|
|||||||
from .DefaultTable import DefaultTable
|
from .DefaultTable import DefaultTable
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
class OverflowErrorRecord:
|
class OverflowErrorRecord(object):
|
||||||
def __init__(self, overflowTuple):
|
def __init__(self, overflowTuple):
|
||||||
self.tableType = overflowTuple[0]
|
self.tableType = overflowTuple[0]
|
||||||
self.LookupListIndex = overflowTuple[1]
|
self.LookupListIndex = overflowTuple[1]
|
||||||
@ -32,7 +32,7 @@ class BaseTTXConverter(DefaultTable):
|
|||||||
def decompile(self, data, font):
|
def decompile(self, data, font):
|
||||||
from . import otTables
|
from . import otTables
|
||||||
cachingStats = None if True else {}
|
cachingStats = None if True else {}
|
||||||
class GlobalState:
|
class GlobalState(object):
|
||||||
def __init__(self, tableType, cachingStats):
|
def __init__(self, tableType, cachingStats):
|
||||||
self.tableType = tableType
|
self.tableType = tableType
|
||||||
self.cachingStats = cachingStats
|
self.cachingStats = cachingStats
|
||||||
@ -73,7 +73,7 @@ class BaseTTXConverter(DefaultTable):
|
|||||||
|
|
||||||
If a lookup subtable overflows an offset, we have to start all over.
|
If a lookup subtable overflows an offset, we have to start all over.
|
||||||
"""
|
"""
|
||||||
class GlobalState:
|
class GlobalState(object):
|
||||||
def __init__(self, tableType):
|
def __init__(self, tableType):
|
||||||
self.tableType = tableType
|
self.tableType = tableType
|
||||||
globalState = GlobalState(tableType=self.tableTag)
|
globalState = GlobalState(tableType=self.tableTag)
|
||||||
@ -468,7 +468,7 @@ class OTTableWriter(object):
|
|||||||
return OverflowErrorRecord( (self.globalState.tableType, LookupListIndex, SubTableIndex, itemName, itemIndex) )
|
return OverflowErrorRecord( (self.globalState.tableType, LookupListIndex, SubTableIndex, itemName, itemIndex) )
|
||||||
|
|
||||||
|
|
||||||
class CountReference:
|
class CountReference(object):
|
||||||
"""A reference to a Count value, not a count of references."""
|
"""A reference to a Count value, not a count of references."""
|
||||||
def __init__(self, table, name):
|
def __init__(self, table, name):
|
||||||
self.table = table
|
self.table = table
|
||||||
@ -740,7 +740,7 @@ def _buildDict():
|
|||||||
valueRecordFormatDict = _buildDict()
|
valueRecordFormatDict = _buildDict()
|
||||||
|
|
||||||
|
|
||||||
class ValueRecordFactory:
|
class ValueRecordFactory(object):
|
||||||
|
|
||||||
"""Given a format code, this object convert ValueRecords."""
|
"""Given a format code, this object convert ValueRecords."""
|
||||||
|
|
||||||
@ -788,7 +788,7 @@ class ValueRecordFactory:
|
|||||||
writer.writeUShort(value)
|
writer.writeUShort(value)
|
||||||
|
|
||||||
|
|
||||||
class ValueRecord:
|
class ValueRecord(object):
|
||||||
|
|
||||||
# see ValueRecordFactory
|
# see ValueRecordFactory
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ def _skipWhite(data, pos, _whiteRE=_whiteRE):
|
|||||||
return newPos
|
return newPos
|
||||||
|
|
||||||
|
|
||||||
class Program:
|
class Program(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
@ -100,7 +100,7 @@ def makeOutputFileName(input, outputDir, extension):
|
|||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
class Options:
|
class Options(object):
|
||||||
|
|
||||||
listTables = False
|
listTables = False
|
||||||
outputDir = None
|
outputDir = None
|
||||||
|
@ -24471,7 +24471,7 @@ def _makeunicodes():
|
|||||||
return unicodes
|
return unicodes
|
||||||
|
|
||||||
|
|
||||||
class _Unicode:
|
class _Unicode(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.codes = _makeunicodes()
|
self.codes = _makeunicodes()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user