-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Cannot set property 'font' of null #7
Comments
how to solve? |
Are you using |
@hktalent - as per my comment above, are you using const { createCanvas } = require('canvas')
const vectorizeText = require('vectorize-text')
const width = 200
const height = 200
const canvas = createCanvas(width, height)
const context = canvas.getContext('2d')
vectorizeText('Hello world', {
font: 'Sans-serif',
width,
canvas,
context,
}) |
I adapted the example provided in the read me with the comment above and this is what I'm seeing:
const { createCanvas } = require('canvas')
var vectorizeText = require("vectorize-text")
const width = 500
const height = 80
const canvas = createCanvas(width, height)
const context = canvas.getContext('2d')
var graph = vectorizeText("Hello world! 你好", {
//width: 500,
textBaseline: "hanging",
font: 'Sans-serif',
width,
canvas,
context,
})
var svg = ['<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="500" height="80" >']
graph.edges.forEach(function(e) {
var p0 = graph.positions[e[0]]
var p1 = graph.positions[e[1]]
svg.push('<line x1="' + p0[0] + '" y1="' + p0[1] +
'" x2="' + p1[0] + '" y2="' + p1[1] +
'" stroke-width="1" stroke="black" />')
})
svg.push("</svg>")
console.log(svg.join("")) EDIT: for those looking for a solution, I reccomend text-to-svg instead. |
The text was updated successfully, but these errors were encountered: