@nmmty/lazycanvas
Version:
A simple way to interact with @napi-rs/canvas in an advanced way!
67 lines (66 loc) • 1.58 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Font = void 0;
const enum_1 = require("../../types/enum");
class Font {
family;
weight;
path;
base64;
constructor() {
this.family = "Arial";
this.weight = enum_1.FontWeight.Regular;
}
/**
* Set the font family
* @param family {string} - The `family` of the font
*/
setFamily(family) {
if (!family)
throw new Error("Family must be provided");
this.family = family;
return this;
}
/**
* Set the font weight
* @param weight {AnyWeight} - The `weight` of the font
*/
setWeight(weight) {
if (!weight)
throw new Error("Weight must be provided");
this.weight = weight;
return this;
}
/**
* Set the path of the font
* @param path {string} - The `path` of the font
*/
setPath(path) {
if (!path)
throw new Error("Path must be provided");
this.path = path;
return this;
}
/**
* Set the base64 of the font
* @param base64 {string} - The `base64` of the font
*/
setBase64(base64) {
if (!base64)
throw new Error("Base64 must be provided");
this.base64 = base64;
return this;
}
/**
* @returns {IFont}
*/
toJSON() {
return {
family: this.family,
weight: this.weight,
path: this.path,
base64: this.base64
};
}
}
exports.Font = Font;