本文整理汇总了Python中bakery_cli.ttfont.Font.save方法的典型用法代码示例。如果您正苦于以下问题:Python Font.save方法的具体用法?Python Font.save怎么用?Python Font.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bakery_cli.ttfont.Font
的用法示例。
在下文中一共展示了Font.save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fix_style_names
# 需要导入模块: from bakery_cli.ttfont import Font [as 别名]
# 或者: from bakery_cli.ttfont.Font import save [as 别名]
def fix_style_names(fontpath):
from bakery_cli.ttfont import Font
try:
font = Font(fontpath)
except TTLibError as ex:
print("ERROR: %s" % ex)
return
# font['name'].fsType = 0
font.save(fontpath + '.fix')
示例2: reset_fstype
# 需要导入模块: from bakery_cli.ttfont import Font [as 别名]
# 或者: from bakery_cli.ttfont.Font import save [as 别名]
def reset_fstype(fontpath):
from bakery_cli.ttfont import Font
try:
font = Font(fontpath)
except TTLibError as ex:
print("ERROR: %s" % ex, file=sys.stderr)
return
font['OS/2'].fsType = 0
font.save(fontpath + '.fix')
示例3: metricfix
# 需要导入模块: from bakery_cli.ttfont import Font [as 别名]
# 或者: from bakery_cli.ttfont.Font import save [as 别名]
def metricfix(fonts):
from bakery_cli.ttfont import Font
ymin = 0
ymax = 0
for f in fonts:
metrics = Font(f)
font_ymin, font_ymax = metrics.get_bounding()
ymin = min(font_ymin, ymin)
ymax = max(font_ymax, ymax)
for f in fonts:
metrics = Font(f)
metrics.ascents.set(ymax)
metrics.descents.set(ymin)
metrics.linegaps.set(0)
metrics.save(f + '.fix')
示例4: fix_name_table
# 需要导入模块: from bakery_cli.ttfont import Font [as 别名]
# 或者: from bakery_cli.ttfont.Font import save [as 别名]
def fix_name_table(fontfile):
try:
font = Font(fontfile)
except TTLibError:
print("Unable to open {}".format(os.path.basename(fontfile)),
file=sys.stderr)
return
for name in font['name'].names:
title = Font.bin2unistring(name)
title = normalizestr(title)
if name.platformID == 3:
name.string = title.encode('utf-16-be')
else:
name.string = title
font.save(fontfile + '.fix')
示例5: Font
# 需要导入模块: from bakery_cli.ttfont import Font [as 别名]
# 或者: from bakery_cli.ttfont.Font import save [as 别名]
for f in fonts:
try:
metrics = Font(f)
except TTLibError, ex:
print('Error: %s' % ex)
continue
# set ascents, descents and linegaps. FontVerticalMetrics will
# not set those values if None, and overwrite them if concrete
# argument has been passed
metrics.ascents.set(options.ascents)
metrics.descents.set(options.descents)
metrics.linegaps.set(options.linegaps)
metrics.ascents.hhea = options.ascents_hhea
metrics.ascents.os2typo = options.ascents_typo
metrics.ascents.os2win = options.ascents_win
metrics.descents.hhea = options.descents_hhea
metrics.descents.os2typo = options.descents_typo
metrics.descents.os2win = options.descents_win
metrics.linegaps.hhea = options.linegaps_hhea
metrics.linegaps.os2typo = options.linegaps_typo
metrics.save(f + '.fix')
elif options.autofix:
vmet.metricfix(fonts)
else:
print(vmet.metricview(fonts))