rename Paint{ColorGlyph,ColrSlice}

This commit is contained in:
Cosimo Lupo 2020-10-27 19:15:50 +00:00
parent d5e645a3c9
commit 6c752f677f
No known key found for this signature in database
GPG Key ID: 179A8F0895A02F4F
4 changed files with 13 additions and 13 deletions

View File

@ -493,11 +493,11 @@ def buildPaintGlyph(glyph: str, paint: _PaintInput) -> ot.Paint:
return self
def buildPaintColorGlyph(
def buildPaintColrSlice(
glyph: str, firstLayerIndex: int = 0, lastLayerIndex: int = 255
) -> ot.Paint:
self = ot.Paint()
self.Format = int(ot.Paint.Format.PaintColorGlyph)
self.Format = int(ot.Paint.Format.PaintColrSlice)
self.Glyph = glyph
if firstLayerIndex > lastLayerIndex:
raise ValueError(
@ -539,7 +539,7 @@ _PAINT_BUILDERS = {
2: buildPaintLinearGradient,
3: buildPaintRadialGradient,
4: buildPaintGlyph,
5: buildPaintColorGlyph,
5: buildPaintColrSlice,
6: buildPaintTransform,
7: buildPaintComposite,
}

View File

@ -1331,7 +1331,7 @@ class Paint(getFormatSwitchingBaseTableClass("uint8")):
PaintLinearGradient = 2
PaintRadialGradient = 3
PaintGlyph = 4
PaintColorGlyph = 5
PaintColrSlice = 5
PaintTransform = 6
PaintComposite = 7

View File

@ -437,23 +437,23 @@ def test_buildPaintGlyph_from_dict():
assert layer.Paint.r0.value == 4
def test_buildPaintColorGlyph():
paint = builder.buildPaintColorGlyph("a")
assert paint.Format == ot.Paint.Format.PaintColorGlyph
def test_buildPaintColrSlice():
paint = builder.buildPaintColrSlice("a")
assert paint.Format == ot.Paint.Format.PaintColrSlice
assert paint.Glyph == "a"
assert paint.FirstLayerIndex == 0
assert paint.LastLayerIndex == 255
paint = builder.buildPaintColorGlyph("a", firstLayerIndex=1, lastLayerIndex=254)
paint = builder.buildPaintColrSlice("a", firstLayerIndex=1, lastLayerIndex=254)
assert paint.FirstLayerIndex == 1
assert paint.LastLayerIndex == 254
with pytest.raises(ValueError, match="Expected first <= last index"):
builder.buildPaintColorGlyph("a", 255, 0)
builder.buildPaintColrSlice("a", 255, 0)
with pytest.raises(OverflowError, match="firstLayerIndex .* out of range"):
builder.buildPaintColorGlyph("a", -1, 255)
builder.buildPaintColrSlice("a", -1, 255)
with pytest.raises(OverflowError, match="lastLayerIndex .* out of range"):
builder.buildPaintColorGlyph("a", 0, 256)
builder.buildPaintColrSlice("a", 0, 256)
def test_buildPaintTransform():

View File

@ -324,14 +324,14 @@ COLR_V1_XML = [
" <LayerV1List>",
" <!-- LayerCount=1 -->",
' <Paint index="0" Format="7"><!-- PaintComposite -->',
' <SourcePaint Format="5"><!-- PaintColorGlyph -->',
' <SourcePaint Format="5"><!-- PaintColrSlice -->',
' <Glyph value="glyph00010"/>',
' <FirstLayerIndex value="0"/>',
' <LastLayerIndex value="255"/>',
" </SourcePaint>",
' <CompositeMode value="src_over"/>',
' <BackdropPaint Format="6"><!-- PaintTransform -->',
' <Paint Format="5"><!-- PaintColorGlyph -->',
' <Paint Format="5"><!-- PaintColrSlice -->',
' <Glyph value="glyph00010"/>',
' <FirstLayerIndex value="0"/>',
' <LastLayerIndex value="255"/>',