當前位置: 首頁>>代碼示例>>Python>>正文


Python Axis.flags方法代碼示例

本文整理匯總了Python中fontTools.ttLib.tables._f_v_a_r.Axis.flags方法的典型用法代碼示例。如果您正苦於以下問題:Python Axis.flags方法的具體用法?Python Axis.flags怎麽用?Python Axis.flags使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在fontTools.ttLib.tables._f_v_a_r.Axis的用法示例。


在下文中一共展示了Axis.flags方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _add_fvar

# 需要導入模塊: from fontTools.ttLib.tables._f_v_a_r import Axis [as 別名]
# 或者: from fontTools.ttLib.tables._f_v_a_r.Axis import flags [as 別名]
def _add_fvar(font, axes, instances):
	"""
	Add 'fvar' table to font.

	axes is an ordered dictionary of DesignspaceAxis objects.

	instances is list of dictionary objects with 'location', 'stylename',
	and possibly 'postscriptfontname' entries.
	"""

	assert axes
	assert isinstance(axes, OrderedDict)

	log.info("Generating fvar")

	fvar = newTable('fvar')
	nameTable = font['name']

	for a in axes.values():
		axis = Axis()
		axis.axisTag = Tag(a.tag)
		# TODO Skip axes that have no variation.
		axis.minValue, axis.defaultValue, axis.maxValue = a.minimum, a.default, a.maximum
		axis.axisNameID = nameTable.addMultilingualName(a.labelNames, font)
		axis.flags = int(a.hidden)
		fvar.axes.append(axis)

	for instance in instances:
		coordinates = instance.location

		if "en" not in instance.localisedStyleName:
			assert instance.styleName
			localisedStyleName = dict(instance.localisedStyleName)
			localisedStyleName["en"] = tounicode(instance.styleName)
		else:
			localisedStyleName = instance.localisedStyleName

		psname = instance.postScriptFontName

		inst = NamedInstance()
		inst.subfamilyNameID = nameTable.addMultilingualName(localisedStyleName)
		if psname is not None:
			psname = tounicode(psname)
			inst.postscriptNameID = nameTable.addName(psname)
		inst.coordinates = {axes[k].tag:axes[k].map_backward(v) for k,v in coordinates.items()}
		#inst.coordinates = {axes[k].tag:v for k,v in coordinates.items()}
		fvar.instances.append(inst)

	assert "fvar" not in font
	font['fvar'] = fvar

	return fvar
開發者ID:khaledhosny,項目名稱:fonttools,代碼行數:54,代碼來源:__init__.py

示例2: test_toXML

# 需要導入模塊: from fontTools.ttLib.tables._f_v_a_r import Axis [as 別名]
# 或者: from fontTools.ttLib.tables._f_v_a_r.Axis import flags [as 別名]
 def test_toXML(self):
     font = MakeFont()
     axis = Axis()
     axis.decompile(FVAR_AXIS_DATA)
     AddName(font, "Optical Size").nameID = 256
     axis.axisNameID = 256
     axis.flags = 0xABC
     writer = XMLWriter(BytesIO())
     axis.toXML(writer, font)
     self.assertEqual([
         '',
         '<!-- Optical Size -->',
         '<Axis>',
             '<AxisTag>opsz</AxisTag>',
             '<Flags>0xABC</Flags>',
             '<MinValue>-0.5</MinValue>',
             '<DefaultValue>1.3</DefaultValue>',
             '<MaxValue>1.5</MaxValue>',
             '<AxisNameID>256</AxisNameID>',
         '</Axis>'
     ], xml_lines(writer))
開發者ID:MrBrezina,項目名稱:fonttools,代碼行數:23,代碼來源:_f_v_a_r_test.py


注:本文中的fontTools.ttLib.tables._f_v_a_r.Axis.flags方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。