コード例 #1
0
ファイル: __init__.py プロジェクト: StGlolry/fonttools
def reorderFontTables(inFile, outFile, tableOrder=None, checkChecksums=False):
	"""Rewrite a font file, ordering the tables as recommended by the
	OpenType specification 1.4.
	"""
	from fontTools.ttLib.sfnt import SFNTReader, SFNTWriter
	reader = SFNTReader(inFile, checkChecksums=checkChecksums)
	writer = SFNTWriter(outFile, len(reader.tables), reader.sfntVersion, reader.flavor, reader.flavorData)
	tables = list(reader.keys())
	for tag in sortedTagList(tables, tableOrder):
		writer[tag] = reader[tag]
	writer.close()
コード例 #2
0
ファイル: __init__.py プロジェクト: medicalwei/fonttools
def reorderFontTables(inFile, outFile, tableOrder=None, checkChecksums=False):
	"""Rewrite a font file, ordering the tables as recommended by the
	OpenType specification 1.4.
	"""
	from fontTools.ttLib.sfnt import SFNTReader, SFNTWriter
	reader = SFNTReader(inFile, checkChecksums=checkChecksums)
	writer = SFNTWriter(outFile, len(reader.tables), reader.sfntVersion, reader.flavor, reader.flavorData)
	tables = list(reader.keys())
	for tag in sortedTagList(tables, tableOrder):
		writer[tag] = reader[tag]
	writer.close()
コード例 #3
0
ファイル: ttFont.py プロジェクト: MrBrezina/fonttools
	def _save(self, file, tableCache=None):
		"""Internal function, to be shared by save() and TTCollection.save()"""

		if self.recalcTimestamp and 'head' in self:
			self['head']  # make sure 'head' is loaded so the recalculation is actually done

		tags = list(self.keys())
		if "GlyphOrder" in tags:
			tags.remove("GlyphOrder")
		numTables = len(tags)
		# write to a temporary stream to allow saving to unseekable streams
		writer = SFNTWriter(file, numTables, self.sfntVersion, self.flavor, self.flavorData)

		done = []
		for tag in tags:
			self._writeTable(tag, writer, done, tableCache)

		writer.close()

		return writer.reordersTables()
コード例 #4
0
ファイル: ttFont.py プロジェクト: dafneM2/calmadita_typeface
	def _save(self, file, tableCache=None):
		"""Internal function, to be shared by save() and TTCollection.save()"""

		if self.recalcTimestamp and 'head' in self:
			self['head']  # make sure 'head' is loaded so the recalculation is actually done

		tags = list(self.keys())
		if "GlyphOrder" in tags:
			tags.remove("GlyphOrder")
		numTables = len(tags)
		# write to a temporary stream to allow saving to unseekable streams
		writer = SFNTWriter(file, numTables, self.sfntVersion, self.flavor, self.flavorData)

		done = []
		for tag in tags:
			self._writeTable(tag, writer, done, tableCache)

		writer.close()

		return writer.reordersTables()