How to use the build.prod.python.fontTools.ttLib.tables.DefaultTable.DefaultTable function in build

To help you get started, we’ve selected a few build examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MitchTalmadge / Emoji-Tools-Rewritten / build / prod / python / fontTools / ttLib / tables / _g_l_y_f.py View on Github external
log = logging.getLogger(__name__)

#
# The Apple and MS rasterizers behave differently for
# scaled composite components: one does scale first and then translate
# and the other does it vice versa. MS defined some flags to indicate
# the difference, but it seems nobody actually _sets_ those flags.
#
# Funny thing: Apple seems to _only_ do their thing in the
# WE_HAVE_A_SCALE (eg. Chicago) case, and not when it's WE_HAVE_AN_X_AND_Y_SCALE
# (eg. Charcoal)...
#
SCALE_COMPONENT_OFFSET_DEFAULT = 0   # 0 == MS, 1 == Apple


class table__g_l_y_f(DefaultTable.DefaultTable):

	# this attribute controls the amount of padding applied to glyph data upon compile.
	# Glyph lenghts are aligned to multiples of the specified value. 
	# Allowed values are (0, 1, 2, 4). '0' means no padding; '1' (default) also means
	# no padding, except for when padding would allow to use short loca offsets.
	padding = 1

	def decompile(self, data, ttFont):
		loca = ttFont['loca']
		last = int(loca[0])
		noname = 0
		self.glyphs = {}
		self.glyphOrder = glyphOrder = ttFont.getGlyphOrder()
		for i in range(0, len(loca)-1):
			try:
				glyphName = glyphOrder[i]
github MitchTalmadge / Emoji-Tools-Rewritten / build / prod / python / fontTools / ttLib / tables / _f_p_g_m.py View on Github external
from __future__ import print_function, division, absolute_import
from fontTools.misc.py23 import *
from . import DefaultTable
from . import ttProgram

class table__f_p_g_m(DefaultTable.DefaultTable):

	def decompile(self, data, ttFont):
		program = ttProgram.Program()
		program.fromBytecode(data)
		self.program = program

	def compile(self, ttFont):
		return self.program.getBytecode()

	def toXML(self, writer, ttFont):
		self.program.toXML(writer, ttFont)

	def fromXML(self, name, attrs, content, ttFont):
		program = ttProgram.Program()
		program.fromXML(name, attrs, content, ttFont)
		self.program = program
github MitchTalmadge / Emoji-Tools-Rewritten / build / prod / python / fontTools / ttLib / tables / S_V_G_.py View on Github external
def __init__(self, tag=None):
		DefaultTable.DefaultTable.__init__(self, tag)
		self.colorPalettes = None
github MitchTalmadge / Emoji-Tools-Rewritten / build / prod / python / fontTools / ttLib / tables / _s_b_i_x.py View on Github external
#     1: Draw both 'sbix' bitmaps and outlines, in that
						#        order
	numStrikes:    L	# Number of bitmap strikes to follow
"""
sbixHeaderFormatSize = sstruct.calcsize(sbixHeaderFormat)


sbixStrikeOffsetFormat = """
	>
	strikeOffset:  L	# Offset from begining of table to data for the
						# individual strike
"""
sbixStrikeOffsetFormatSize = sstruct.calcsize(sbixStrikeOffsetFormat)


class table__s_b_i_x(DefaultTable.DefaultTable):

	def __init__(self, tag=None):
		DefaultTable.DefaultTable.__init__(self, tag)
		self.version = 1
		self.flags = 1
		self.numStrikes = 0
		self.strikes = {}
		self.strikeOffsets = []

	def decompile(self, data, ttFont):
		# read table header
		sstruct.unpack(sbixHeaderFormat, data[ : sbixHeaderFormatSize], self)
		# collect offsets to individual strikes in self.strikeOffsets
		for i in range(self.numStrikes):
			current_offset = sbixHeaderFormatSize + i * sbixStrikeOffsetFormatSize
			offset_entry = sbixStrikeOffset()
github MitchTalmadge / Emoji-Tools-Rewritten / build / prod / python / fontTools / ttLib / tables / V_D_M_X_.py View on Github external
VDMX_GroupFmt = """
	>                 # big endian
	recs:        H    # Number of height records in this group
	startsz:     B    # Starting yPelHeight
	endsz:       B    # Ending yPelHeight
"""
# followed by an array of vTable[recs] records.
VDMX_vTableFmt = """
	>                 # big endian
	yPelHeight:  H    # yPelHeight to which values apply
	yMax:        h    # Maximum value (in pels) for this yPelHeight
	yMin:        h    # Minimum value (in pels) for this yPelHeight
"""


class table_V_D_M_X_(DefaultTable.DefaultTable):

	def decompile(self, data, ttFont):
		pos = 0  # track current position from to start of VDMX table
		dummy, data = sstruct.unpack2(VDMX_HeaderFmt, data, self)
		pos += sstruct.calcsize(VDMX_HeaderFmt)
		self.ratRanges = []
		for i in range(self.numRatios):
			ratio, data = sstruct.unpack2(VDMX_RatRangeFmt, data)
			pos += sstruct.calcsize(VDMX_RatRangeFmt)
			# the mapping between a ratio and a group is defined further below
			ratio['groupIndex'] = None
			self.ratRanges.append(ratio)
		lenOffset = struct.calcsize('>H')
		_offsets = []  # temporarily store offsets to groups
		for i in range(self.numRatios):
			offset = struct.unpack('>H', data[0:lenOffset])[0]
github MitchTalmadge / Emoji-Tools-Rewritten / build / prod / python / fontTools / ttLib / tables / T_S_I__1.py View on Github external
""" TSI{0,1,2,3,5} are private tables used by Microsoft Visual TrueType (VTT)
tool to store its hinting source data.

TSI1 contains the text of the glyph programs in the form of low-level assembly
code, as well as the 'extra' programs 'fpgm', 'ppgm' (i.e. 'prep'), and 'cvt'.
"""
from __future__ import print_function, division, absolute_import
from fontTools.misc.py23 import *
from . import DefaultTable
from fontTools.misc.loggingTools import LogMixin


class table_T_S_I__1(LogMixin, DefaultTable.DefaultTable):

	extras = {0xfffa: "ppgm", 0xfffb: "cvt", 0xfffc: "reserved", 0xfffd: "fpgm"}

	indextable = "TSI0"

	def decompile(self, data, ttFont):
		totalLength = len(data)
		indextable = ttFont[self.indextable]
		for indices, isExtra in zip(
				(indextable.indices, indextable.extra_indices), (False, True)):
			programs = {}
			for i, (glyphID, textLength, textOffset) in enumerate(indices):
				if isExtra:
					name = self.extras[glyphID]
				else:
					name = ttFont.getGlyphName(glyphID)
github MitchTalmadge / Emoji-Tools-Rewritten / build / prod / python / fontTools / ttLib / tables / C_F_F__2.py View on Github external
from __future__ import print_function, division, absolute_import
from fontTools.misc.py23 import *
from fontTools import cffLib
from . import DefaultTable


class table_C_F_F__2(DefaultTable.DefaultTable):

	def __init__(self, tag=None):
		DefaultTable.DefaultTable.__init__(self, tag)
		self.cff = cffLib.CFFFontSet()
		self._gaveGlyphOrder = False

	def decompile(self, data, otFont):
		self.cff.decompile(BytesIO(data), otFont)
		assert len(self.cff) < 2, "can't deal with multi-font CFF tables."

	def compile(self, otFont):
		f = BytesIO()
		self.cff.compile(f, otFont)
		return f.getvalue()

	def haveGlyphNames(self):
github MitchTalmadge / Emoji-Tools-Rewritten / build / prod / python / fontTools / ttLib / tables / _a_v_a_r.py View on Github external
def __init__(self, tag=None):
        DefaultTable.DefaultTable.__init__(self, tag)
        self.segments = {}
github MitchTalmadge / Emoji-Tools-Rewritten / build / prod / python / fontTools / ttLib / __init__.py View on Github external
def getTableClass(tag):
	"""Fetch the packer/unpacker class for a table.
	Return None when no class is found.
	"""
	module = getTableModule(tag)
	if module is None:
		from .tables.DefaultTable import DefaultTable
		return DefaultTable
	pyTag = tagToIdentifier(tag)
	tableClass = getattr(module, "table_" + pyTag)
	return tableClass
github MitchTalmadge / Emoji-Tools-Rewritten / build / prod / python / fontTools / ttLib / tables / _v_h_e_a.py View on Github external
advanceHeightMax:	H
		minTopSideBearing:	h
		minBottomSideBearing:	h
		yMaxExtent:		h
		caretSlopeRise:		h
		caretSlopeRun:		h
		caretOffset:		h
		reserved1:		h
		reserved2:		h
		reserved3:		h
		reserved4:		h
		metricDataFormat:	h
		numberOfVMetrics:	H
"""

class table__v_h_e_a(DefaultTable.DefaultTable):

	# Note: Keep in sync with table__h_h_e_a

	dependencies = ['vmtx', 'glyf']

	def decompile(self, data, ttFont):
		sstruct.unpack(vheaFormat, data, self)

	def compile(self, ttFont):
		if ttFont.isLoaded('glyf') and ttFont.recalcBBoxes:
			self.recalc(ttFont)
		self.tableVersion = fi2ve(self.tableVersion)
		return sstruct.pack(vheaFormat, self)

	def recalc(self, ttFont):
		vtmxTable = ttFont['vmtx']