@@ -10,44 +10,67 @@ func TestCOLR(t *testing.T) {
1010 ft := readFontFile (t , "color/NotoColorEmoji-Regular.ttf" )
1111 colr , err := ParseCOLR (readTable (t , ft , "COLR" ))
1212 tu .AssertNoErr (t , err )
13- tu .Assert (t , len (colr .BaseGlyphRecords ) == 0 )
14- tu .Assert (t , len (colr .LayerRecords ) == 0 )
15- tu .Assert (t , len (colr .BaseGlyphList . PaintRecords ) == 3845 )
16- tu .Assert (t , colr .BaseGlyphList . PaintRecords [0 ].Paint == PaintColrLayers {1 , 3 , 47625 })
17- tu .Assert (t , colr .ClipList .Clips [0 ].ClipBox == ClipBoxFormat1 {1 , 480 , 192 , 800 , 512 })
13+ tu .Assert (t , len (colr .baseGlyphRecords ) == 0 )
14+ tu .Assert (t , len (colr .layerRecords ) == 0 )
15+ tu .Assert (t , len (colr .baseGlyphList . paintRecords ) == 3845 )
16+ tu .Assert (t , colr .baseGlyphList . paintRecords [0 ].Paint == PaintColrLayers {1 , 3 , 47625 })
17+ tu .Assert (t , colr .ClipList .clips [0 ].ClipBox == ClipBoxFormat1 {1 , 480 , 192 , 800 , 512 })
1818 tu .Assert (t , colr .VarIndexMap == nil && colr .ItemVariationStore == nil )
19- tu .Assert (t , len (colr .LayerList .PaintTables ) == 69264 )
19+ tu .Assert (t , len (colr .LayerList .paintTables ) == 69264 )
20+
21+ clipBox , ok := colr .ClipList .Search (87 )
22+ tu .Assert (t , ok && clipBox == ClipBoxFormat1 {1 , 64 , - 224 , 1216 , 928 })
2023
2124 // reference from fonttools
22- paint := colr .LayerList .PaintTables [6 ]
25+ paint := colr .LayerList .paintTables [6 ]
2326 transform , ok := paint .(PaintTransform )
2427 tu .Assert (t , ok )
2528 _ , innerOK := transform .Paint .(PaintGlyph )
2629 tu .Assert (t , transform .Transform == Affine2x3 {1 , 0 , 0 , 1 , 4.3119965 , 0.375 })
2730 tu .Assert (t , innerOK )
2831
32+ pt , ok := colr .Search (12 )
33+ asColrLayers , ok2 := pt .(PaintColrLayers )
34+ tu .Assert (t , ok && ok2 )
35+ tu .Assert (t , asColrLayers == PaintColrLayers {1 , 9 , 2427 })
36+
37+ for _ , paint := range colr .baseGlyphList .paintRecords {
38+ if layers , ok := paint .Paint .(PaintColrLayers ); ok {
39+ l , err := colr .LayerList .Resolve (layers )
40+ tu .AssertNoErr (t , err )
41+ tu .Assert (t , len (l ) == int (layers .NumLayers ))
42+ }
43+ }
44+
2945 ft = readFontFile (t , "color/CoralPixels-Regular.ttf" )
3046 colr , err = ParseCOLR (readTable (t , ft , "COLR" ))
3147 tu .AssertNoErr (t , err )
32- tu .Assert (t , len (colr .BaseGlyphRecords ) == 335 )
33- tu .Assert (t , len (colr .LayerRecords ) == 5603 )
34- g1 , g2 := colr .BaseGlyphRecords [0 ], colr .BaseGlyphRecords [1 ]
35- tu .Assert (t , g1 == BaseGlyph {0 , 0 , 11 } && g2 == BaseGlyph {2 , 11 , 18 })
36- tu .Assert (t , colr .LayerRecords [0 ].PaletteIndex == 4 )
48+ tu .Assert (t , len (colr .baseGlyphRecords ) == 335 )
49+ tu .Assert (t , len (colr .layerRecords ) == 5603 )
50+ g1 , g2 := colr .baseGlyphRecords [0 ], colr .baseGlyphRecords [1 ]
51+ tu .Assert (t , g1 == baseGlyph {0 , 0 , 11 } && g2 == baseGlyph {2 , 11 , 18 })
52+ tu .Assert (t , colr .layerRecords [0 ].PaletteIndex == 4 )
53+
54+ pt , ok = colr .Search (0 )
55+ asLayers , ok2 := pt .(PaintColrLayersResolved )
56+ tu .Assert (t , ok && ok2 )
57+ tu .Assert (t , len (asLayers ) == 11 )
58+ tu .Assert (t , asLayers [0 ].PaletteIndex == 4 )
59+ tu .Assert (t , asLayers [10 ].PaletteIndex == 11 )
3760}
3861
3962func TestCPAL (t * testing.T ) {
4063 ft := readFontFile (t , "color/NotoColorEmoji-Regular.ttf" )
4164 cpal , _ , err := ParseCPAL (readTable (t , ft , "CPAL" ))
4265 tu .AssertNoErr (t , err )
4366 tu .Assert (t , cpal .Version == 0 )
44- tu .Assert (t , cpal .numPaletteEntries == 5921 )
67+ tu .Assert (t , cpal .NumPaletteEntries == 5921 )
4568 tu .Assert (t , cpal .numPalettes == 1 && len (cpal .ColorRecordIndices ) == 1 )
4669
4770 ft = readFontFile (t , "color/CoralPixels-Regular.ttf" )
4871 cpal , _ , err = ParseCPAL (readTable (t , ft , "CPAL" ))
4972 tu .AssertNoErr (t , err )
5073 tu .Assert (t , cpal .Version == 0 )
51- tu .Assert (t , cpal .numPaletteEntries == 32 )
74+ tu .Assert (t , cpal .NumPaletteEntries == 32 )
5275 tu .Assert (t , cpal .numPalettes == 2 && len (cpal .ColorRecordIndices ) == 2 )
5376}
0 commit comments