Automattic / Automattic/node-canvas

Support context.letterSpacing

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

Description

## Issue or Feature
I would like to be able to adjust the kerning/letter-spacing of fonts when drawing text on node-canvas. In a browser this is possible by setting canvas.style.letterSpacing to something like "-3px". But canvas.style I believe does not exist on node-canvas.

(BTW we love node-canvas, it is an amazing piece of software.)

## Steps to Reproduce

Interactive example of it working with browser-based Canvas:

https://jsfiddle.net/hg4pbsne/1/

Example code:
```
canvas.style.letterSpacing = '-5px';
ctx = canvas.getContext('2d');
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.font = '4em sans-serif';
ctx.fillText('World', can.width/2, can.height*3/4);
```

This is not possible to reproduce with node-canvas as there is no canvas.style property exposed.

## Your Environment

All versions of node-canvas.

## My Suggestion

We add a non-standard ctx._letterSpacing parameter to node-canvas that exposes this functionality?

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue names no source file, test, or entry point. Start by comparing the linked browser example with node-canvas text drawing, then clarify the API and rendering semantics for letter spacing; done means the requested spacing works when drawing text.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.