Brooooooklyn / canvas

High performance skia binding to Node.js. Zero system dependencies and pure npm packages without any postinstall scripts nor node-gyp.
https://vercel.skia.rs
MIT License
1.78k stars 76 forks source link

context.fillText is missing letters (depending on font family, when using SvgExportFlag NoPrettyXML or RelativePathEncoding) #901

Open dimitriiBirsan opened 2 months ago

dimitriiBirsan commented 2 months ago

Version : 0.1.56 Example:

const { writeFileSync } = require('fs')
const { join } = require('path')

const { createCanvas, GlobalFonts, SvgExportFlag } = require('@napi-rs/canvas')

const canvas = createCanvas(1024, 2768, SvgExportFlag.NoPrettyXML )
const ctx = canvas.getContext('2d')
let y = 20
let alphabet = ""
for (i = 97; i <= 122; i++) {
    alphabet += (String.fromCharCode(i))
    alphabet += (String.fromCharCode(i))
}
GlobalFonts.families.forEach(element => {
    ctx.font = '20px ' + element.family
    ctx.fillText(alphabet + " " + element.family, 50, y)
    y+=20

});

const b = canvas.getContent()

writeFileSync(join(__dirname, 'export-text.svg'), b)