mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Transfer to @napi-rs/canvas again (this time w/ line breaks)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const { registerFont } = require('canvas');
|
||||
const { GlobalFonts } = require('@napi-rs/canvas');
|
||||
const weights = {
|
||||
100: 'thin',
|
||||
200: 'extraLight',
|
||||
@@ -28,12 +28,12 @@ module.exports = class Font {
|
||||
register() {
|
||||
if (this.registered) return null;
|
||||
this.registered = true;
|
||||
return registerFont(this.path, { family: this.filenameNoExt, style: this.style, weight: this.weight });
|
||||
return GlobalFonts.registerFromPath(this.path, this.filenameNoExt);
|
||||
}
|
||||
|
||||
toCanvasString(size, shouldDoFallbacks = true) {
|
||||
const shouldFall = shouldDoFallbacks ? `, ${this.fallbacks.join(', ')}` : '';
|
||||
return `${this.style} ${this.weight} ${size}px ${this.filenameNoExt}${shouldFall}`;
|
||||
return `${size}px ${this.filenameNoExt}${shouldFall}`;
|
||||
}
|
||||
|
||||
get filenameNoExt() {
|
||||
|
||||
Reference in New Issue
Block a user