Skip to content

Commit 211b913

Browse files
committed
fix: enhance font loading with existence check and logging
1 parent 3534104 commit 211b913

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

shared/features/thumbnail/canvasFactory.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-disable @typescript-eslint/no-var-requires */
2+
import { console } from 'inspector';
23
import type Path from 'path';
34

45
import type NapiRs from '@napi-rs/canvas';
@@ -45,10 +46,21 @@ if (typeof document === 'undefined') {
4546
const saveToImage = (canvas: NapiRs.Canvas) => canvas.encode('png');
4647

4748
const useFont = () => {
48-
GlobalFonts.registerFromPath(
49-
getPath('assets/fonts/Lato-Regular.ttf').toString(),
50-
'Lato',
51-
);
49+
const path = getPath('assets/fonts/Lato-Regular.ttf').toString();
50+
console.log('Font path: ', path);
51+
52+
// ensure the file exists
53+
Bun.file(path)
54+
.exists()
55+
.then((exists) => {
56+
if (exists) {
57+
console.log('Font file exists');
58+
} else {
59+
console.error('Font file does not exist at path: ', path);
60+
}
61+
});
62+
63+
GlobalFonts.registerFromPath(path, 'Lato');
5264
};
5365

5466
let noteBlockImage: Promise<any>;

0 commit comments

Comments
 (0)