OPF
DocsReferenceView source

Inherited table text colors

The published core 0.11.0 and later, renderer 0.9.0 and later, and PPTX 0.9.1 and later (current core 0.14.0, renderer 0.14.0, PPTX 0.14.0) use one core rule for inherited table text colors in SVG and editable PowerPoint cells. After resolving the cell fill, keep the inherited text color when its unrounded contrast is at least 4.5:1. Otherwise choose the higher-contrast black or white. This covers pale headers and dark body-cell fills without changing the source document.

An explicit cell style.color or rich-text run color remains authoritative, including a deliberately low-contrast color. Translucent fills and unresolved colors keep the inherited preference: their actual backdrop must be known before assessing contrast. This rule does not alter fills, borders, fonts, layout or metadata.

Core exports colorContrast(foreground, background) and textColorForFill(fill, preferred) from its /composition entrypoint. They accept opaque hexadecimal #RGB, #RRGGBB and #RRGGBBFF colors. colorContrast returns undefined for unsupported or translucent colors. Callers must apply explicit text-color overrides before invoking the fallback.

The ratio uses W3C's sRGB relative luminance definition. Passing this narrow color check is not a WCAG certification, a readability guarantee, a browser/native raster equivalence result or an arbitrary PowerPoint round-trip claim. Source tests check actual SVG attributes and native OOXML text colors, including inherited and explicit rich-text colors. A recorded six-slide real PowerPoint test passed on Node 20.20.2 and 24.20.0 at its source checkpoint: all 48 original/reopened cell observations and 624 character-color observations match per runtime. Those historical native rasters remain distinct from current-package and browser acceptance.