Skip to content
This repository has been archived by the owner on Nov 15, 2024. It is now read-only.

Commit

Permalink
fix: font wont load on certain os
Browse files Browse the repository at this point in the history
  • Loading branch information
LewdHuTao committed Apr 19, 2024
1 parent 07e5c14 commit e9f8d93
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "songcard",
"version": "1.1.4",
"version": "1.1.5",
"main": "src/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
5 changes: 5 additions & 0 deletions src/themes/classicCard.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { createCanvas, loadImage } = require("canvas");
const Jimp = require("jimp");
const path = require("path");

async function classicCard({
imageBg,
Expand All @@ -8,6 +9,10 @@ async function classicCard({
trackDuration,
trackTotalDuration,
}) {
const Canvas = require("canvas");
const fontPath = path.join(__dirname, '..', 'fonts', 'NotoSans-Regular.ttf');
Canvas.registerFont(fontPath, { family: "Noto Sans" });

const prettyMilliseconds = (await import("pretty-ms")).default;
const canvasWidth = 1200;
const canvasHeight = 400;
Expand Down
5 changes: 3 additions & 2 deletions src/themes/simpleCard.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const { createCanvas, loadImage } = require("canvas");
const Jimp = require("jimp");
const { resolve } = require("path");
const path = require("path");

async function simpleCard({ imageBg, imageText }) {
const Canvas = require("canvas");
Canvas.registerFont(resolve("./src/fonts/NotoSans-Regular.ttf"), { family: "Noto Sans" })
const fontPath = path.join(__dirname, '..', 'fonts', 'NotoSans-Regular.ttf');
Canvas.registerFont(fontPath, { family: "Noto Sans" });

const canvasWidth = 600;
const canvasHeight = 600;
Expand Down

0 comments on commit e9f8d93

Please sign in to comment.