diff --git a/Lib/fontTools/colorLib/builder.py b/Lib/fontTools/colorLib/builder.py index dae00b918..377368f69 100644 --- a/Lib/fontTools/colorLib/builder.py +++ b/Lib/fontTools/colorLib/builder.py @@ -132,7 +132,7 @@ def buildCOLR( colr.BaseGlyphRecordArray = colr.LayerRecordArray = None if colorGlyphsV1: - colr.BaseGlyphV1Array = buildBaseGlyphV1Array(colorGlyphsV1, glyphMap) + colr.BaseGlyphV1List = buildBaseGlyphV1List(colorGlyphsV1, glyphMap) if version is None: version = 1 if (varStore or colorGlyphsV1) else 0 @@ -495,7 +495,7 @@ def buildLayerV1Array( def buildBaseGlyphV1Record( baseGlyph: str, layers: Union[_LayersList, ot.LayerV1Array] -) -> ot.BaseGlyphV1Array: +) -> ot.BaseGlyphV1List: self = ot.BaseGlyphV1Record() self.BaseGlyph = baseGlyph if not isinstance(layers, ot.LayerV1Array): @@ -504,10 +504,10 @@ def buildBaseGlyphV1Record( return self -def buildBaseGlyphV1Array( +def buildBaseGlyphV1List( colorGlyphs: Union[_ColorGlyphsDict, Dict[str, ot.LayerV1Array]], glyphMap: Optional[Mapping[str, int]] = None, -) -> ot.BaseGlyphV1Array: +) -> ot.BaseGlyphV1List: if glyphMap is not None: colorGlyphItems = sorted( colorGlyphs.items(), key=lambda item: glyphMap[item[0]] @@ -518,7 +518,7 @@ def buildBaseGlyphV1Array( buildBaseGlyphV1Record(baseGlyph, layers) for baseGlyph, layers in colorGlyphItems ] - self = ot.BaseGlyphV1Array() + self = ot.BaseGlyphV1List() self.BaseGlyphCount = len(records) self.BaseGlyphV1Record = records return self diff --git a/Lib/fontTools/ttLib/tables/otData.py b/Lib/fontTools/ttLib/tables/otData.py index b893a7b48..76d4d678e 100755 --- a/Lib/fontTools/ttLib/tables/otData.py +++ b/Lib/fontTools/ttLib/tables/otData.py @@ -1549,7 +1549,7 @@ otData = [ ('LOffset', 'BaseGlyphRecordArray', None, None, 'Offset (from beginning of COLR table) to Base Glyph records.'), ('LOffset', 'LayerRecordArray', None, None, 'Offset (from beginning of COLR table) to Layer Records.'), ('uint16', 'LayerRecordCount', None, None, 'Number of Layer Records.'), - ('LOffset', 'BaseGlyphV1Array', None, 'Version >= 1', 'Offset (from beginning of COLR table) to array of Version-1 Base Glyph records.'), + ('LOffset', 'BaseGlyphV1List', None, 'Version >= 1', 'Offset (from beginning of COLR table) to array of Version-1 Base Glyph records.'), ('LOffset', 'VarStore', None, 'Version >= 1', 'Offset to variation store (may be NULL)'), ]), @@ -1572,14 +1572,14 @@ otData = [ ('uint16', 'PaletteIndex', None, None, 'Index value to use with a selected color palette.'), ]), - ('BaseGlyphV1Array', [ + ('BaseGlyphV1List', [ ('uint32', 'BaseGlyphCount', None, None, 'Number of Version-1 Base Glyph records'), ('struct', 'BaseGlyphV1Record', 'BaseGlyphCount', 0, 'Array of Version-1 Base Glyph records'), ]), ('BaseGlyphV1Record', [ ('GlyphID', 'BaseGlyph', None, None, 'Glyph ID of reference glyph.'), - ('LOffset', 'LayerV1Array', None, None, 'Offset (from beginning of BaseGlyphV1Array) to LayerV1Array.'), + ('LOffset', 'LayerV1Array', None, None, 'Offset (from beginning of BaseGlyphV1List) to LayerV1Array.'), ]), ('LayerV1Array', [ diff --git a/Lib/fontTools/ttLib/tables/otTables.py b/Lib/fontTools/ttLib/tables/otTables.py index fa8638a4e..b821fa36c 100644 --- a/Lib/fontTools/ttLib/tables/otTables.py +++ b/Lib/fontTools/ttLib/tables/otTables.py @@ -1197,7 +1197,7 @@ class BaseGlyphRecordArray(BaseTable): return self.__dict__.copy() -class BaseGlyphV1Array(BaseTable): +class BaseGlyphV1List(BaseTable): def preWrite(self, font): self.BaseGlyphV1Record = sorted( diff --git a/Tests/colorLib/builder_test.py b/Tests/colorLib/builder_test.py index 24cac8bec..b52e62bbf 100644 --- a/Tests/colorLib/builder_test.py +++ b/Tests/colorLib/builder_test.py @@ -521,7 +521,7 @@ def test_buildBaseGlyphV1Record(): assert baseGlyphRec.LayerV1Array == layerArray -def test_buildBaseGlyphV1Array(): +def test_buildBaseGlyphV1List(): colorGlyphs = { "a": [("b", 0), ("c", 1)], "d": [ @@ -552,13 +552,13 @@ def test_buildBaseGlyphV1Array(): "h": 8, } - baseGlyphArray = builder.buildBaseGlyphV1Array(colorGlyphs, glyphMap) + baseGlyphArray = builder.buildBaseGlyphV1List(colorGlyphs, glyphMap) assert baseGlyphArray.BaseGlyphCount == len(colorGlyphs) assert baseGlyphArray.BaseGlyphV1Record[0].BaseGlyph == "d" assert baseGlyphArray.BaseGlyphV1Record[1].BaseGlyph == "a" assert baseGlyphArray.BaseGlyphV1Record[2].BaseGlyph == "g" - baseGlyphArray = builder.buildBaseGlyphV1Array(colorGlyphs) + baseGlyphArray = builder.buildBaseGlyphV1List(colorGlyphs) assert baseGlyphArray.BaseGlyphCount == len(colorGlyphs) assert baseGlyphArray.BaseGlyphV1Record[0].BaseGlyph == "a" assert baseGlyphArray.BaseGlyphV1Record[1].BaseGlyph == "d" @@ -706,18 +706,18 @@ class BuildCOLRTest(object): assert colr.table.LayerRecordCount == 2 assert isinstance(colr.table.LayerRecordArray, ot.LayerRecordArray) - assert isinstance(colr.table.BaseGlyphV1Array, ot.BaseGlyphV1Array) - assert colr.table.BaseGlyphV1Array.BaseGlyphCount == 1 + assert isinstance(colr.table.BaseGlyphV1List, ot.BaseGlyphV1List) + assert colr.table.BaseGlyphV1List.BaseGlyphCount == 1 assert isinstance( - colr.table.BaseGlyphV1Array.BaseGlyphV1Record[0], ot.BaseGlyphV1Record + colr.table.BaseGlyphV1List.BaseGlyphV1Record[0], ot.BaseGlyphV1Record ) - assert colr.table.BaseGlyphV1Array.BaseGlyphV1Record[0].BaseGlyph == "d" + assert colr.table.BaseGlyphV1List.BaseGlyphV1Record[0].BaseGlyph == "d" assert isinstance( - colr.table.BaseGlyphV1Array.BaseGlyphV1Record[0].LayerV1Array, + colr.table.BaseGlyphV1List.BaseGlyphV1Record[0].LayerV1Array, ot.LayerV1Array, ) assert ( - colr.table.BaseGlyphV1Array.BaseGlyphV1Record[0] + colr.table.BaseGlyphV1List.BaseGlyphV1Record[0] .LayerV1Array.LayerV1Record[0] .LayerGlyph == "e" diff --git a/Tests/ttLib/tables/C_O_L_R_test.py b/Tests/ttLib/tables/C_O_L_R_test.py index cdd94afa7..991b88ca0 100644 --- a/Tests/ttLib/tables/C_O_L_R_test.py +++ b/Tests/ttLib/tables/C_O_L_R_test.py @@ -71,7 +71,7 @@ COLR_V1_DATA = ( b"\x00\x00\x00\x16" # Offset to BaseGlyphRecordArray from beginning of table (22) b"\x00\x00\x00\x1c" # Offset to LayerRecordArray from beginning of table (28) b"\x00\x03" # LayerRecordCount (3) - b"\x00\x00\x00(" # Offset to BaseGlyphV1Array from beginning of table (40) + b"\x00\x00\x00(" # Offset to BaseGlyphV1List from beginning of table (40) b"\x00\x00\x00\x00" # Offset to VarStore (NULL) b"\x00\x06" # BaseGlyphRecord[0].BaseGlyph (6) b"\x00\x00" # BaseGlyphRecord[0].FirstLayerIndex (0) @@ -82,9 +82,9 @@ COLR_V1_DATA = ( b"\x00\x01" # LayerRecord[1].PaletteIndex (1) b"\x00\t" # LayerRecord[2].LayerGlyph (9) b"\x00\x02" # LayerRecord[2].PaletteIndex (2) - b"\x00\x00\x00\x01" # BaseGlyphV1Array.BaseGlyphCount (1) - b"\x00\n" # BaseGlyphV1Array.BaseGlyphV1Record[0].BaseGlyph (10) - b"\x00\x00\x00\n" # Offset to LayerV1Array from beginning of BaseGlyphV1Array (10) + b"\x00\x00\x00\x01" # BaseGlyphV1List.BaseGlyphCount (1) + b"\x00\n" # BaseGlyphV1List.BaseGlyphV1Record[0].BaseGlyph (10) + b"\x00\x00\x00\n" # Offset to LayerV1Array from beginning of BaseGlyphV1List (10) b"\x00\x00\x00\x03" # LayerV1Array.LayerCount (3) b"\x00\x0b" # LayerV1Array.LayerV1Record[0].LayerGlyph (11) b"\x00\x00\x00\x16" # Offset to Paint from beginning of LayerV1Array (22) @@ -190,7 +190,7 @@ COLR_V1_XML = [ " ", "", "", - "", + "", " ", ' ', ' ', @@ -288,7 +288,7 @@ COLR_V1_XML = [ " ", " ", " ", - "", + "", ]