parent
800bf85b2f
commit
58ac5a9fd8
@ -252,7 +252,7 @@ def buildCOLR(
|
|||||||
|
|
||||||
def buildClipList(clipBoxes: Dict[str, _ClipBoxInput]) -> ot.ClipList:
|
def buildClipList(clipBoxes: Dict[str, _ClipBoxInput]) -> ot.ClipList:
|
||||||
clipList = ot.ClipList()
|
clipList = ot.ClipList()
|
||||||
clipList.Format = 0
|
clipList.Format = 1
|
||||||
clipList.clips = {name: buildClipBox(box) for name, box in clipBoxes.items()}
|
clipList.clips = {name: buildClipBox(box) for name, box in clipBoxes.items()}
|
||||||
return clipList
|
return clipList
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ def buildClipBox(clipBox: _ClipBoxInput) -> ot.ClipBox:
|
|||||||
if n not in (4, 5):
|
if n not in (4, 5):
|
||||||
raise ValueError(f"Invalid ClipBox: expected 4 or 5 values, found {n}")
|
raise ValueError(f"Invalid ClipBox: expected 4 or 5 values, found {n}")
|
||||||
clip.xMin, clip.yMin, clip.xMax, clip.yMax = intRect(clipBox[:4])
|
clip.xMin, clip.yMin, clip.xMax, clip.yMax = intRect(clipBox[:4])
|
||||||
clip.Format = int(n == 5)
|
clip.Format = int(n == 5) + 1
|
||||||
if n == 5:
|
if n == 5:
|
||||||
clip.VarIndexBase = int(clipBox[4])
|
clip.VarIndexBase = int(clipBox[4])
|
||||||
return clip
|
return clip
|
||||||
|
@ -1601,8 +1601,8 @@ otData = [
|
|||||||
('LOffset', 'Paint', 'LayerCount', 0, 'Array of offsets to Paint tables, from the start of the LayerList table.'),
|
('LOffset', 'Paint', 'LayerCount', 0, 'Array of offsets to Paint tables, from the start of the LayerList table.'),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
('ClipListFormat0', [
|
('ClipListFormat1', [
|
||||||
('uint8', 'Format', None, None, 'Format for ClipList with 16bit glyph IDs: 0'),
|
('uint8', 'Format', None, None, 'Format for ClipList with 16bit glyph IDs: 1'),
|
||||||
('uint32', 'ClipCount', None, None, 'Number of Clip records.'),
|
('uint32', 'ClipCount', None, None, 'Number of Clip records.'),
|
||||||
('struct', 'ClipRecord', 'ClipCount', 0, 'Array of Clip records sorted by glyph ID.'),
|
('struct', 'ClipRecord', 'ClipCount', 0, 'Array of Clip records sorted by glyph ID.'),
|
||||||
]),
|
]),
|
||||||
@ -1613,16 +1613,16 @@ otData = [
|
|||||||
('Offset24', 'ClipBox', None, None, 'Offset to a ClipBox table.'),
|
('Offset24', 'ClipBox', None, None, 'Offset to a ClipBox table.'),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
('ClipBoxFormat0', [
|
('ClipBoxFormat1', [
|
||||||
('uint8', 'Format', None, None, 'Format for ClipBox without variation: set to 0.'),
|
('uint8', 'Format', None, None, 'Format for ClipBox without variation: set to 1.'),
|
||||||
('int16', 'xMin', None, None, 'Minimum x of clip box.'),
|
('int16', 'xMin', None, None, 'Minimum x of clip box.'),
|
||||||
('int16', 'yMin', None, None, 'Minimum y of clip box.'),
|
('int16', 'yMin', None, None, 'Minimum y of clip box.'),
|
||||||
('int16', 'xMax', None, None, 'Maximum x of clip box.'),
|
('int16', 'xMax', None, None, 'Maximum x of clip box.'),
|
||||||
('int16', 'yMax', None, None, 'Maximum y of clip box.'),
|
('int16', 'yMax', None, None, 'Maximum y of clip box.'),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
('ClipBoxFormat1', [
|
('ClipBoxFormat2', [
|
||||||
('uint8', 'Format', None, None, 'Format for variable ClipBox: set to 1.'),
|
('uint8', 'Format', None, None, 'Format for variable ClipBox: set to 2.'),
|
||||||
('int16', 'xMin', None, None, 'Minimum x of clip box.'),
|
('int16', 'xMin', None, None, 'Minimum x of clip box.'),
|
||||||
('int16', 'yMin', None, None, 'Minimum y of clip box.'),
|
('int16', 'yMin', None, None, 'Minimum y of clip box.'),
|
||||||
('int16', 'xMax', None, None, 'Maximum x of clip box.'),
|
('int16', 'xMax', None, None, 'Maximum x of clip box.'),
|
||||||
|
@ -1681,7 +1681,7 @@ class BuildCOLRTest(object):
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert colr.table.ClipList.Format == 0
|
assert colr.table.ClipList.Format == 1
|
||||||
clipBoxes = colr.table.ClipList.clips
|
clipBoxes = colr.table.ClipList.clips
|
||||||
assert [
|
assert [
|
||||||
(baseGlyph, clipBox.as_tuple()) for baseGlyph, clipBox in clipBoxes.items()
|
(baseGlyph, clipBox.as_tuple()) for baseGlyph, clipBox in clipBoxes.items()
|
||||||
@ -1689,8 +1689,8 @@ class BuildCOLRTest(object):
|
|||||||
("a", (0, 0, 1000, 1000, 0)),
|
("a", (0, 0, 1000, 1000, 0)),
|
||||||
("c", (-101, -201, 1101, 1201)),
|
("c", (-101, -201, 1101, 1201)),
|
||||||
]
|
]
|
||||||
assert clipBoxes["a"].Format == 1
|
assert clipBoxes["a"].Format == 2
|
||||||
assert clipBoxes["c"].Format == 0
|
assert clipBoxes["c"].Format == 1
|
||||||
|
|
||||||
|
|
||||||
class TrickyRadialGradientTest:
|
class TrickyRadialGradientTest:
|
||||||
|
@ -298,7 +298,7 @@ COLR_V1_SAMPLE = (
|
|||||||
(b" \x00", "Paint.Alpha (0.5)"),
|
(b" \x00", "Paint.Alpha (0.5)"),
|
||||||
|
|
||||||
# ClipList
|
# ClipList
|
||||||
(b'\x00', "ClipList.Format (0)"),
|
(b'\x01', "ClipList.Format (1)"),
|
||||||
(b'\x00\x00\x00\x02', "ClipList.ClipCount (2)"),
|
(b'\x00\x00\x00\x02', "ClipList.ClipCount (2)"),
|
||||||
(b'\x00\x0a', "ClipRecord[0].StartGlyphID (10)"),
|
(b'\x00\x0a', "ClipRecord[0].StartGlyphID (10)"),
|
||||||
(b'\x00\x0a', "ClipRecord[0].EndGlyphID (10)"),
|
(b'\x00\x0a', "ClipRecord[0].EndGlyphID (10)"),
|
||||||
@ -307,14 +307,14 @@ COLR_V1_SAMPLE = (
|
|||||||
(b'\x00\x0f', "ClipRecord[1].EndGlyphID (15)"),
|
(b'\x00\x0f', "ClipRecord[1].EndGlyphID (15)"),
|
||||||
(b'\x00\x00\x20', "Offset to ClipBox subtable from beginning of ClipList (32)"),
|
(b'\x00\x00\x20', "Offset to ClipBox subtable from beginning of ClipList (32)"),
|
||||||
|
|
||||||
(b'\x01', "ClipBox.Format (1)"),
|
(b'\x02', "ClipBox.Format (2)"),
|
||||||
(b'\x00\x00', "ClipBox.xMin (0)"),
|
(b'\x00\x00', "ClipBox.xMin (0)"),
|
||||||
(b'\x00\x00', "ClipBox.yMin (0)"),
|
(b'\x00\x00', "ClipBox.yMin (0)"),
|
||||||
(b'\x01\xf4', "ClipBox.xMax (500)"),
|
(b'\x01\xf4', "ClipBox.xMax (500)"),
|
||||||
(b'\x01\xf4', "ClipBox.yMax (500)"),
|
(b'\x01\xf4', "ClipBox.yMax (500)"),
|
||||||
(b'\x00\x00\x00\t', "ClipBox.VarIndexBase (9)"),
|
(b'\x00\x00\x00\t', "ClipBox.VarIndexBase (9)"),
|
||||||
|
|
||||||
(b'\x00', "ClipBox.Format (0)"),
|
(b'\x01', "ClipBox.Format (1)"),
|
||||||
(b'\x00\x00', "ClipBox.xMin (0)"),
|
(b'\x00\x00', "ClipBox.xMin (0)"),
|
||||||
(b'\x00\x00', "ClipBox.yMin (0)"),
|
(b'\x00\x00', "ClipBox.yMin (0)"),
|
||||||
(b'\x03\xe8', "ClipBox.xMax (1000)"),
|
(b'\x03\xe8', "ClipBox.xMax (1000)"),
|
||||||
@ -506,10 +506,10 @@ COLR_V1_XML = [
|
|||||||
' <dy value="258"/>',
|
' <dy value="258"/>',
|
||||||
" </Paint>",
|
" </Paint>",
|
||||||
"</LayerList>",
|
"</LayerList>",
|
||||||
'<ClipList Format="0">',
|
'<ClipList Format="1">',
|
||||||
" <Clip>",
|
" <Clip>",
|
||||||
' <Glyph value="glyph00010"/>',
|
' <Glyph value="glyph00010"/>',
|
||||||
' <ClipBox Format="1">',
|
' <ClipBox Format="2">',
|
||||||
' <xMin value="0"/>',
|
' <xMin value="0"/>',
|
||||||
' <yMin value="0"/>',
|
' <yMin value="0"/>',
|
||||||
' <xMax value="500"/>',
|
' <xMax value="500"/>',
|
||||||
@ -520,7 +520,7 @@ COLR_V1_XML = [
|
|||||||
" <Clip>",
|
" <Clip>",
|
||||||
' <Glyph value="glyph00014"/>',
|
' <Glyph value="glyph00014"/>',
|
||||||
' <Glyph value="glyph00015"/>',
|
' <Glyph value="glyph00015"/>',
|
||||||
' <ClipBox Format="0">',
|
' <ClipBox Format="1">',
|
||||||
' <xMin value="0"/>',
|
' <xMin value="0"/>',
|
||||||
' <yMin value="0"/>',
|
' <yMin value="0"/>',
|
||||||
' <xMax value="1000"/>',
|
' <xMax value="1000"/>',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user