[otTables] Default varIdx should be 0xFFFFFFFF (#2298)

* default value for varIdx should be 0xFFFFFFFF to indicate 'no variations'

* use lc hex notation as per feedback
This commit is contained in:
Just van Rossum 2021-05-07 22:26:48 +02:00 committed by GitHub
parent 9c18e2a07d
commit d601951eab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 19 deletions

View File

@ -1261,7 +1261,7 @@ class VariableValue(namedtuple("VariableValue", ["value", "varIdx"])):
_value_mapper = None _value_mapper = None
def __new__(cls, value, varIdx=0): def __new__(cls, value, varIdx=0xFFFFFFFF):
return super().__new__( return super().__new__(
cls, cls,
cls._value_mapper(value) if cls._value_mapper else value, cls._value_mapper(value) if cls._value_mapper else value,

View File

@ -241,7 +241,7 @@ def test_buildVarColorIndex_Minimal():
c = _build(ot.VarColorIndex, 1) c = _build(ot.VarColorIndex, 1)
assert c.PaletteIndex == 1 assert c.PaletteIndex == 1
assert c.Alpha.value == 1.0 assert c.Alpha.value == 1.0
assert c.Alpha.varIdx == 0 assert c.Alpha.varIdx == 0xFFFFFFFF
def test_buildColorIndex(): def test_buildColorIndex():

View File

@ -147,12 +147,12 @@ COLR_V1_SAMPLE = (
(b"\x00\x00\x08", "Offset to BackdropPaint from beginning of PaintComposite (8)"), (b"\x00\x00\x08", "Offset to BackdropPaint from beginning of PaintComposite (8)"),
(b"\x0d", "BaseGlyphV1Record[1].Paint.BackdropPaint.Format (13)"), (b"\x0d", "BaseGlyphV1Record[1].Paint.BackdropPaint.Format (13)"),
(b"\x00\x00\x34", "Offset to Paint from beginning of PaintVarTransform (52)"), (b"\x00\x00\x34", "Offset to Paint from beginning of PaintVarTransform (52)"),
(b"\x00\x01\x00\x00\x00\x00\x00\x00", "Affine2x3.xx.value (1.0)"), (b"\x00\x01\x00\x00\xff\xff\xff\xff", "Affine2x3.xx.value (1.0)"),
(b"\x00\x00\x00\x00\x00\x00\x00\x00", "Affine2x3.xy.value (0.0)"), (b"\x00\x00\x00\x00\xff\xff\xff\xff", "Affine2x3.xy.value (0.0)"),
(b"\x00\x00\x00\x00\x00\x00\x00\x00", "Affine2x3.yx.value (0.0)"), (b"\x00\x00\x00\x00\xff\xff\xff\xff", "Affine2x3.yx.value (0.0)"),
(b"\x00\x01\x00\x00\x00\x00\x00\x00", "Affine2x3.yy.value (1.0)"), (b"\x00\x01\x00\x00\xff\xff\xff\xff", "Affine2x3.yy.value (1.0)"),
(b"\x01\x2c\x00\x00\x00\x00\x00\x00", "Affine2x3.dx.value (300.0)"), (b"\x01\x2c\x00\x00\xff\xff\xff\xff", "Affine2x3.dx.value (300.0)"),
(b"\x00\x00\x00\x00\x00\x00\x00\x00", "Affine2x3.dy.value (0.0)"), (b"\x00\x00\x00\x00\xff\xff\xff\xff", "Affine2x3.dy.value (0.0)"),
(b"\x0b", "BaseGlyphV1Record[1].Paint.SourcePaint.Format (11)"), (b"\x0b", "BaseGlyphV1Record[1].Paint.SourcePaint.Format (11)"),
(b"\x00\n", "BaseGlyphV1Record[1].Paint.SourcePaint.Glyph (10)"), (b"\x00\n", "BaseGlyphV1Record[1].Paint.SourcePaint.Glyph (10)"),
# BaseGlyphV1Record[2] # BaseGlyphV1Record[2]
@ -199,7 +199,7 @@ COLR_V1_SAMPLE = (
(b"\x03", "LayerV1List.Paint[0].Paint.Format (3)"), (b"\x03", "LayerV1List.Paint[0].Paint.Format (3)"),
(b"\x00\x02", "Paint.Color.PaletteIndex (2)"), (b"\x00\x02", "Paint.Color.PaletteIndex (2)"),
(b" \x00", "Paint.Color.Alpha.value (0.5)"), (b" \x00", "Paint.Color.Alpha.value (0.5)"),
(b"\x00\x00\x00\x00", "Paint.Color.Alpha.varIdx (0)"), (b"\xff\xff\xff\xff", "Paint.Color.Alpha.varIdx (0xFFFFFFFF)"),
# PaintGlyph glyph00012 # PaintGlyph glyph00012
(b"\x0a", "LayerV1List.Paint[1].Format (10)"), (b"\x0a", "LayerV1List.Paint[1].Format (10)"),
(b"\x00\x00\x06", "Offset to Paint subtable from beginning of PaintGlyph (6)"), (b"\x00\x00\x06", "Offset to Paint subtable from beginning of PaintGlyph (6)"),
@ -237,20 +237,20 @@ COLR_V1_SAMPLE = (
(b"\x00\x13\x00\x00", "Affine2x3.yy (19)"), (b"\x00\x13\x00\x00", "Affine2x3.yy (19)"),
(b"\x07", "LayerV1List.Paint[2].Paint.Paint.Format (7)"), (b"\x07", "LayerV1List.Paint[2].Paint.Paint.Format (7)"),
(b"\x00\x00(", "Offset to ColorLine from beginning of PaintVarRadialGradient (40)"), (b"\x00\x00(", "Offset to ColorLine from beginning of PaintVarRadialGradient (40)"),
(b"\x00\x07\x00\x00\x00\x00", "Paint.x0.value (7)"), (b"\x00\x07\xff\xff\xff\xff", "Paint.x0.value (7)"),
(b"\x00\x08\x00\x00\x00\x00", "Paint.y0.value (8)"), (b"\x00\x08\xff\xff\xff\xff", "Paint.y0.value (8)"),
(b"\x00\t\x00\x00\x00\x00", "Paint.r0.value (9)"), (b"\x00\t\xff\xff\xff\xff", "Paint.r0.value (9)"),
(b"\x00\n\x00\x00\x00\x00", "Paint.x1.value (10)"), (b"\x00\n\xff\xff\xff\xff", "Paint.x1.value (10)"),
(b"\x00\x0b\x00\x00\x00\x00", "Paint.y1.value (11)"), (b"\x00\x0b\xff\xff\xff\xff", "Paint.y1.value (11)"),
(b"\x00\x0c\x00\x00\x00\x00", "Paint.r1.value (12)"), (b"\x00\x0c\xff\xff\xff\xff", "Paint.r1.value (12)"),
(b"\x00", "ColorLine.Extend (0; pad)"), (b"\x00", "ColorLine.Extend (0; pad)"),
(b"\x00\x02", "ColorLine.StopCount (2)"), (b"\x00\x02", "ColorLine.StopCount (2)"),
(b"\x00\x00\x00\x00\x00\x00", "ColorLine.ColorStop[0].StopOffset.value (0.0)"), (b"\x00\x00\xff\xff\xff\xff", "ColorLine.ColorStop[0].StopOffset.value (0.0)"),
(b"\x00\x06", "ColorLine.ColorStop[0].Color.PaletteIndex (6)"), (b"\x00\x06", "ColorLine.ColorStop[0].Color.PaletteIndex (6)"),
(b"@\x00\x00\x00\x00\x00", "ColorLine.ColorStop[0].Color.Alpha.value (1.0)"), (b"@\x00\xff\xff\xff\xff", "ColorLine.ColorStop[0].Color.Alpha.value (1.0)"),
(b"@\x00\x00\x00\x00\x00", "ColorLine.ColorStop[1].StopOffset.value (1.0)"), (b"@\x00\xff\xff\xff\xff", "ColorLine.ColorStop[1].StopOffset.value (1.0)"),
(b"\x00\x07", "ColorLine.ColorStop[1].Color.PaletteIndex (7)"), (b"\x00\x07", "ColorLine.ColorStop[1].Color.PaletteIndex (7)"),
(b"\x19\x9a\x00\x00\x00\x00", "ColorLine.ColorStop[1].Color.Alpha.value (0.4)"), (b"\x19\x9a\xff\xff\xff\xff", "ColorLine.ColorStop[1].Color.Alpha.value (0.4)"),
# PaintTranslate # PaintTranslate
(b"\x0e", "LayerV1List.Paint[3].Format (14)"), (b"\x0e", "LayerV1List.Paint[3].Format (14)"),
(b"\x00\x00\x0c", "Offset to Paint subtable from beginning of PaintTranslate (12)"), (b"\x00\x00\x0c", "Offset to Paint subtable from beginning of PaintTranslate (12)"),