hsu-utils 0.0.47 → 0.0.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es/LoadFont/index.d.ts
CHANGED
package/es/LoadFont/index.js
CHANGED
|
@@ -10,10 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
export default function loadFont(options) {
|
|
11
11
|
return __awaiter(this, void 0, void 0, function* () {
|
|
12
12
|
const { ctx, font = {}, text } = options;
|
|
13
|
-
const { style = 'normal', weight = 'normal', size = 10,
|
|
14
|
-
yield document.fonts.load(`${style} ${weight} ${size}px ${
|
|
13
|
+
const { style = 'normal', weight = 'normal', size = 10, family = 'sans-serif' } = font;
|
|
14
|
+
yield document.fonts.load(`${style} ${weight} ${size}px ${family}`);
|
|
15
15
|
const _ctx = ctx || document.createElement('canvas').getContext('2d');
|
|
16
|
-
_ctx.font = `${style} ${weight} ${size}px ${
|
|
16
|
+
_ctx.font = `${style} ${weight} ${size}px ${family}`;
|
|
17
17
|
_ctx.fillText(text || '', -999, -999);
|
|
18
18
|
yield new Promise(requestAnimationFrame);
|
|
19
19
|
});
|
package/lib/LoadFont/index.d.ts
CHANGED
package/lib/LoadFont/index.js
CHANGED
|
@@ -38,17 +38,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
function loadFont(options) {
|
|
40
40
|
return __awaiter(this, void 0, void 0, function () {
|
|
41
|
-
var ctx, _a, font, text, _b, style, _c, weight, _d, size, _e,
|
|
41
|
+
var ctx, _a, font, text, _b, style, _c, weight, _d, size, _e, family, _ctx;
|
|
42
42
|
return __generator(this, function (_f) {
|
|
43
43
|
switch (_f.label) {
|
|
44
44
|
case 0:
|
|
45
45
|
ctx = options.ctx, _a = options.font, font = _a === void 0 ? {} : _a, text = options.text;
|
|
46
|
-
_b = font.style, style = _b === void 0 ? 'normal' : _b, _c = font.weight, weight = _c === void 0 ? 'normal' : _c, _d = font.size, size = _d === void 0 ? 10 : _d, _e = font.
|
|
47
|
-
return [4, document.fonts.load("".concat(style, " ").concat(weight, " ").concat(size, "px ").concat(
|
|
46
|
+
_b = font.style, style = _b === void 0 ? 'normal' : _b, _c = font.weight, weight = _c === void 0 ? 'normal' : _c, _d = font.size, size = _d === void 0 ? 10 : _d, _e = font.family, family = _e === void 0 ? 'sans-serif' : _e;
|
|
47
|
+
return [4, document.fonts.load("".concat(style, " ").concat(weight, " ").concat(size, "px ").concat(family))];
|
|
48
48
|
case 1:
|
|
49
49
|
_f.sent();
|
|
50
50
|
_ctx = ctx || document.createElement('canvas').getContext('2d');
|
|
51
|
-
_ctx.font = "".concat(style, " ").concat(weight, " ").concat(size, "px ").concat(
|
|
51
|
+
_ctx.font = "".concat(style, " ").concat(weight, " ").concat(size, "px ").concat(family);
|
|
52
52
|
_ctx.fillText(text || '', -999, -999);
|
|
53
53
|
return [4, new Promise(requestAnimationFrame)];
|
|
54
54
|
case 2:
|