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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * hsu-utils v0.0.46
3
+ * hsu-utils v0.0.47
4
4
  *
5
5
  * some front-end utils
6
6
  *
@@ -2,7 +2,7 @@ interface Font {
2
2
  style?: string;
3
3
  weight?: string;
4
4
  size?: number;
5
- fontFamily?: string;
5
+ family?: string;
6
6
  }
7
7
  export interface LoadFontOptions {
8
8
  ctx?: CanvasRenderingContext2D;
@@ -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, fontFamily = 'sans-serif' } = font;
14
- yield document.fonts.load(`${style} ${weight} ${size}px ${fontFamily}`);
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 ${fontFamily}`;
16
+ _ctx.font = `${style} ${weight} ${size}px ${family}`;
17
17
  _ctx.fillText(text || '', -999, -999);
18
18
  yield new Promise(requestAnimationFrame);
19
19
  });
@@ -2,7 +2,7 @@ interface Font {
2
2
  style?: string;
3
3
  weight?: string;
4
4
  size?: number;
5
- fontFamily?: string;
5
+ family?: string;
6
6
  }
7
7
  export interface LoadFontOptions {
8
8
  ctx?: CanvasRenderingContext2D;
@@ -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, fontFamily, _ctx;
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.fontFamily, fontFamily = _e === void 0 ? 'sans-serif' : _e;
47
- return [4, document.fonts.load("".concat(style, " ").concat(weight, " ").concat(size, "px ").concat(fontFamily))];
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(fontFamily);
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:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hsu-utils",
3
- "version": "0.0.47",
3
+ "version": "0.0.48",
4
4
  "description": "some front-end utils",
5
5
  "repository": "git@github.com:VitaTsui/hsu-utils.git",
6
6
  "author": "VitaHsu <vitahsu7@gmail.com>",