ChromaCheck is a feature test to check if browsers support one of the five color font formats (see list below) when loaded as webfonts through @font-face
. See it in action here!
Also, check out this this older article on color font formats, written before COLRv1 existed.
Please note that ChromaCheck currently doesn't work for Edge 18+ :-(
We test for color font support by rendering color glyphs to canvas, and then reading out the pixels to see if we have any color.
Older versions of Firefox, the first browser to support color fonts, had some bugs that needed to be circumvented. This was done by sticking the font in an SVG image, and then drawing that image on canvas. This is how ChromaCheck still works today.
Include chromacheck-min.js
in your page and it'll add classes to the html
element for each supported color format:
chromacheck-svg
if there's support for OpenType-SVG.chromacheck-colr
if there's support for COLRv0.chromacheck-colrv1
if there's support for COLRv1.chromacheck-sbix
if there's support for SBIX.chromacheck-cbdt
if there's support for CBDT/CBLC.
Take note that this test is async, so it can take a split millisecond before the classes are added.
- IE11 on Windows 8 will report false negatives because of a bug in drawing SVG to canvas in IE11.
- IE10 in Windows 8 will report false negatives because of a very strict security measure when drawing SVG to canvas.
- CBDT/CBLC might be reported as not being supported, because ChromaCheck checks for the implementation as described by the spec. A few implementations in the wild, specifically Chrome on Android, do support CBDT/CBLC, but only when implemented with the specs during the proposal phase instead of the final specs. More info.
The SVG-on-canvas method might be replaced or extended with a non-SVG method to address the SVG related issues. Likewise it'd be possible to include two CBDT/CBLC fonts to test with: one on the old specs, one one the new. If you have a need for that right now, check out the feature/regular-test-page
branch.
ChromaCheck is released under the MIT license.