Automattic / Automattic/node-canvas

Support for color (OpenType SVG) fonts

Open
#1,449 0 comments 3 reactions 0 assignees View on GitHub
Text & Fonts
Dominant language
JavaScript
Stars
10.7k
Forks
1.2k
Avg merge
4d 8h
Merged PRs (30d)
1

Description

## Issue or Feature

It would be great to support colored fonts like these: https://www.colorfonts.wtf/. If these are used now, they just take on the fill color.

```
const fs = require('fs')
const { createCanvas, registerFont } = require('canvas')
const { buildResponse, handleError } = require('./utils')
registerFont('./fonts/gilbert-color.otf', { family: 'Gilbert Color' })

module.exports.canvasTest = async (event) => {
const canvas = createCanvas(200, 200)
const ctx = canvas.getContext('2d')
ctx.font = '12px "Gilbert Color"'
ctx.fillText('Awesome!', 50, 100)

const buf = canvas.toBuffer();
fs.writeFileSync("test.png", buf);
// return buildResponse('test.png')
}
```

Results in

![image](https://user-images.githubusercontent.com/4934366/60349564-df76f900-998f-11e9-807c-023116ae07ae.png)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.