Automattic / Automattic/node-canvas

lineWidth not working for strokeText on glyph mode

Open
#2,460 0 comments 1 reaction 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

The lineWidth not working for strokeText on glyph mode.

Look at this code:

```js
const { createCanvas } = require('canvas')
const fs = require('fs')
const canvas = createCanvas(200, 400, 'pdf')
const ctx = canvas.getContext('2d')
ctx.textDrawingMode = 'glyph';

ctx.font = '30pt Helvetica'
ctx.fillText('A', 50, 50)

ctx.lineWidth = 20
ctx.strokeStyle = 'red';
ctx.strokeText('A', 50, 100)

const PDFStream = canvas.createPDFStream()

const outputFile = fs.createWriteStream('./output.pdf')

PDFStream.pipe(outputFile);

PDFStream.on('finish', () => {
console.log('PDF file generated successfully!');
});

PDFStream.on('error', (err) => {
console.error('Error generating PDF:', err);
});

```

Output:

![Image](https://github.com/user-attachments/assets/1b7034fb-e2e3-4b8a-b156-b45436e5a3d3)

But path mode is work:
```diff
- ctx.textDrawingMode = 'glyph';
```

![Image](https://github.com/user-attachments/assets/4845f58e-539b-42ac-9671-cafedd4968d7)

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.