@@ -38,6 +38,10 @@ export interface Font {
3838 "OS/2" : Os2Table ;
3939 /** the font's horizontal header table consisting of information needed to layout fonts with horizontal characters */
4040 hhea : HHEA ;
41+ /** the color table containing layer records for color glyphs (optional, present in fonts with color glyphs) */
42+ COLR ?: COLRTable ;
43+ /** the color palette table containing color definitions (optional, present in fonts with color glyphs) */
44+ CPAL ?: CPALTable ;
4145
4246 /** the number of glyphs in the font */
4347 numGlyphs : number ;
@@ -243,6 +247,12 @@ export interface Glyph {
243247
244248 /** The glyph's name. Commonly the character, or 'space' or UTF**** */
245249 name : string ;
250+
251+ /**
252+ * For COLR glyphs, an array of objects containing the glyph and color for each layer.
253+ * Each layer has a `glyph` property with the glyph object and a `color` property with RGBA values.
254+ */
255+ layers ?: Array < { glyph : Glyph ; color : { red : number ; green : number ; blue : number ; alpha : number } } > ;
246256}
247257
248258/**
@@ -373,6 +383,35 @@ export interface HHEA {
373383 numberOfMetrics : number ;
374384}
375385
386+ export interface COLRTable {
387+ version : number ;
388+ numBaseGlyphRecords : number ;
389+ baseGlyphRecord : Array < {
390+ gid : number ;
391+ firstLayerIndex : number ;
392+ numLayers : number ;
393+ } > ;
394+ layerRecords : Array < {
395+ gid : number ;
396+ paletteIndex : number ;
397+ } > ;
398+ numLayerRecords : number ;
399+ }
400+
401+ export interface CPALTable {
402+ version : number ;
403+ numPaletteEntries : number ;
404+ numPalettes : number ;
405+ numColorRecords : number ;
406+ colorRecords : Array < {
407+ red : number ;
408+ green : number ;
409+ blue : number ;
410+ alpha : number ;
411+ } > ;
412+ colorRecordIndices : number [ ] ;
413+ }
414+
376415export interface FontCollection {
377416 type : "TTC" | "DFont" ;
378417 getFont ( name : string ) : Font | null ;
0 commit comments