Adding more unittests, based on feedback.
This commit is contained in:
parent
6bf842a30e
commit
51eda21b0a
@ -1448,8 +1448,33 @@ def test_buildStatTable_name_duplicates():
|
|||||||
builder.buildStatTable(font_obj, AXES, windowsNames=True, macNames=False)
|
builder.buildStatTable(font_obj, AXES, windowsNames=True, macNames=False)
|
||||||
actual_names = [x.string for x in font_obj["name"].names]
|
actual_names = [x.string for x in font_obj["name"].names]
|
||||||
|
|
||||||
|
# no new name records were added by buildStatTable
|
||||||
|
# because windows-only names with the same strings were already present
|
||||||
assert expected_names == actual_names
|
assert expected_names == actual_names
|
||||||
|
|
||||||
|
font_obj["name"].removeNames(nameID=270)
|
||||||
|
expected_names = [x.string for x in font_obj["name"].names] + ['Weight']
|
||||||
|
|
||||||
|
builder.buildStatTable(font_obj, AXES, windowsNames=True, macNames=False)
|
||||||
|
actual_names = [x.string for x in font_obj["name"].names]
|
||||||
|
# One new name records 'Weight' were added by buildStatTable
|
||||||
|
assert expected_names == actual_names
|
||||||
|
|
||||||
|
builder.buildStatTable(font_obj, AXES, windowsNames=True, macNames=True)
|
||||||
|
actual_names = [x.string for x in font_obj["name"].names]
|
||||||
|
expected_names = ['Weight', 'Weight',
|
||||||
|
'ExtraLight', 'ExtraLight',
|
||||||
|
'Light', 'Light',
|
||||||
|
'Regular', 'Regular',
|
||||||
|
'Medium', 'Medium',
|
||||||
|
'Bold', 'Bold',
|
||||||
|
'ExtraBold', 'ExtraBold',
|
||||||
|
'Black', 'Black']
|
||||||
|
# Multiple name records were added by buildStatTable
|
||||||
|
assert expected_names == actual_names
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_stat_infinities():
|
def test_stat_infinities():
|
||||||
negInf = floatToFixed(builder.AXIS_VALUE_NEGATIVE_INFINITY, 16)
|
negInf = floatToFixed(builder.AXIS_VALUE_NEGATIVE_INFINITY, 16)
|
||||||
|
@ -6,6 +6,7 @@ from fontTools.misc.xmlWriter import XMLWriter
|
|||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
import struct
|
import struct
|
||||||
import unittest
|
import unittest
|
||||||
|
from fontTools import ttLib
|
||||||
from fontTools.ttLib import newTable
|
from fontTools.ttLib import newTable
|
||||||
from fontTools.ttLib.tables._n_a_m_e import (
|
from fontTools.ttLib.tables._n_a_m_e import (
|
||||||
table__n_a_m_e, NameRecord, nameRecordFormat, nameRecordSize, makeName, log)
|
table__n_a_m_e, NameRecord, nameRecordFormat, nameRecordSize, makeName, log)
|
||||||
@ -305,6 +306,23 @@ class NameTableTest(unittest.TestCase):
|
|||||||
self.assertGreaterEqual(nameID, 256)
|
self.assertGreaterEqual(nameID, 256)
|
||||||
self.assertEqual(nameID, table.findMultilingualName(names, minNameID=256))
|
self.assertEqual(nameID, table.findMultilingualName(names, minNameID=256))
|
||||||
|
|
||||||
|
def test_addMultilingualName_no_mac_but_win(self):
|
||||||
|
'''
|
||||||
|
Test if addMultilingualName adds
|
||||||
|
a Mac name table entry equal to Windows entry.
|
||||||
|
'''
|
||||||
|
|
||||||
|
font_obj = ttLib.TTFont()
|
||||||
|
font_obj["name"] = ttLib.newTable("name")
|
||||||
|
font_obj["name"].names = []
|
||||||
|
|
||||||
|
font_obj["name"].setName('Weight', 270, 3, 1, 0x409)
|
||||||
|
names = {'en': 'Weight', }
|
||||||
|
nameID = font_obj["name"].addMultilingualName(names, minNameID=256)
|
||||||
|
|
||||||
|
self.assertEqual(270, nameID)
|
||||||
|
|
||||||
|
|
||||||
def test_decompile_badOffset(self):
|
def test_decompile_badOffset(self):
|
||||||
# https://github.com/fonttools/fonttools/issues/525
|
# https://github.com/fonttools/fonttools/issues/525
|
||||||
table = table__n_a_m_e()
|
table = table__n_a_m_e()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user