当前位置: 首页>>代码示例>>Python>>正文


Python DefaultTable.DefaultTable类代码示例

本文整理汇总了Python中fontTools.ttLib.tables.DefaultTable.DefaultTable的典型用法代码示例。如果您正苦于以下问题:Python DefaultTable类的具体用法?Python DefaultTable怎么用?Python DefaultTable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DefaultTable类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: doit

def doit(args) :
    infont = args.ifont
    for tag, version in (('Silf', 5), ('Glat', 3)) :
        dat = infont.getTableData(tag)
        newdat = compressGr(dat, version)
        table = DefaultTable(tag)
        table.decompile(newdat, infont)
        infont[tag] = table
    return infont
开发者ID:moyogo,项目名称:pysilfont,代码行数:9,代码来源:psfcompressgr.py

示例2: merge

def merge(self, m, tables):

	assert len(tables) == len(m.duplicateGlyphsPerFont)
	for i,(table,dups) in enumerate(zip(tables, m.duplicateGlyphsPerFont)):
		if not dups: continue
		assert (table is not None and table is not NotImplemented), "Have duplicates to resolve for font %d but no GSUB: %s" % (i + 1, dups)
		synthFeature = None
		synthLookup = None
		for script in table.table.ScriptList.ScriptRecord:
			if script.ScriptTag == 'DFLT': continue # XXX
			for langsys in [script.Script.DefaultLangSys] + [l.LangSys for l in script.Script.LangSysRecord]:
				if langsys is None: continue # XXX Create!
				feature = [v for v in langsys.FeatureIndex if v.FeatureTag == 'locl']
				assert len(feature) <= 1
				if feature:
					feature = feature[0]
				else:
					if not synthFeature:
						synthFeature = otTables.FeatureRecord()
						synthFeature.FeatureTag = 'locl'
						f = synthFeature.Feature = otTables.Feature()
						f.FeatureParams = None
						f.LookupCount = 0
						f.LookupListIndex = []
						langsys.FeatureIndex.append(synthFeature)
						langsys.FeatureIndex.sort(key=lambda v: v.FeatureTag)
						table.table.FeatureList.FeatureRecord.append(synthFeature)
						table.table.FeatureList.FeatureCount += 1
					feature = synthFeature

				if not synthLookup:
					subtable = otTables.SingleSubst()
					subtable.mapping = dups
					synthLookup = otTables.Lookup()
					synthLookup.LookupFlag = 0
					synthLookup.LookupType = 1
					synthLookup.SubTableCount = 1
					synthLookup.SubTable = [subtable]
					if table.table.LookupList is None:
						# mtiLib uses None as default value for LookupList,
						# while feaLib points to an empty array with count 0
						# TODO: make them do the same
						table.table.LookupList = otTables.LookupList()
						table.table.LookupList.Lookup = []
						table.table.LookupList.LookupCount = 0
					table.table.LookupList.Lookup.append(synthLookup)
					table.table.LookupList.LookupCount += 1

				feature.Feature.LookupListIndex[:0] = [synthLookup]
				feature.Feature.LookupCount += 1

	DefaultTable.merge(self, m, tables)
	return self
开发者ID:MrBrezina,项目名称:fonttools,代码行数:53,代码来源:merge.py

示例3: TTFont

from fontTools.ttLib.tables.DefaultTable import DefaultTable

font_path = "myfont.ttf"
output_path = "myfont_patched.ttf"

table_tag = "DSIG"


# Get raw table data from the source font

font = TTFont(font_path)
raw_data = font.getTableData(table_tag)


# Do something with the raw table data
# This example just sets an empty DSIG table.

raw_data = b"\0\0\0\1\0\0\0\0"


# Write the data back to the font

# We could re-use the existing table when the source and target font are
# identical, but let's make a new empty table to be more universal.
table = DefaultTable(table_tag)
table.data = raw_data

# Add the new table back into the source font and save under a new name.
font[table_tag] = table
font.save(output_path)
开发者ID:MrBrezina,项目名称:fonttools,代码行数:30,代码来源:edit_raw_table_data.py


注:本文中的fontTools.ttLib.tables.DefaultTable.DefaultTable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。