hsu-utils 0.0.29 → 0.0.30
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/README.md
CHANGED
@@ -52,13 +52,13 @@ yarn add hsu-utils
|
|
52
52
|
|
53
53
|
### Font
|
54
54
|
|
55
|
-
| 参数 | 说明 | 类型 | 默认值
|
56
|
-
| ------- | -------- | ------ |
|
57
|
-
| size | 字体大小 | number |
|
58
|
-
| style | 字体样式 | string | normal
|
59
|
-
| variant | 字体变体 | string | normal
|
60
|
-
| weight | 字体粗细 | string | normal
|
61
|
-
| family | 字体系列 | string |
|
55
|
+
| 参数 | 说明 | 类型 | 默认值 | 备注 |
|
56
|
+
| ------- | -------- | ------ | ---------- | ---- |
|
57
|
+
| size | 字体大小 | number | 10 | - |
|
58
|
+
| style | 字体样式 | string | normal | - |
|
59
|
+
| variant | 字体变体 | string | normal | - |
|
60
|
+
| weight | 字体粗细 | string | normal | - |
|
61
|
+
| family | 字体系列 | string | sans-serif | - |
|
62
62
|
|
63
63
|
### RenderOption
|
64
64
|
|
package/dist/hsu-utils.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*!
|
2
2
|
*
|
3
|
-
* hsu-utils v0.0.
|
3
|
+
* hsu-utils v0.0.29
|
4
4
|
*
|
5
5
|
* some front-end utils
|
6
6
|
*
|
@@ -131,7 +131,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
131
131
|
/***/ ((__unused_webpack_module, exports) => {
|
132
132
|
|
133
133
|
"use strict";
|
134
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nfunction get_string_size(str, font, letterSpacing) {\n if (font === void 0) { font = {}; }\n if (letterSpacing === void 0) { letterSpacing = 0; }\n var _a = font.style, style = _a === void 0 ? 'normal' : _a, _b = font.variant, variant = _b === void 0 ? 'normal' : _b, _c = font.weight, weight = _c === void 0 ? 'normal' : _c, _d = font.size, size = _d === void 0 ?
|
134
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nfunction get_string_size(str, font, letterSpacing) {\n if (font === void 0) { font = {}; }\n if (letterSpacing === void 0) { letterSpacing = 0; }\n var _a = font.style, style = _a === void 0 ? 'normal' : _a, _b = font.variant, variant = _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, fontFamily = _e === void 0 ? 'sans-serif' : _e;\n var canvas = document.createElement('canvas');\n var ctx = canvas.getContext('2d');\n ctx.font = \"\".concat(style, \" \").concat(variant, \" \").concat(weight, \" \").concat(size, \"px \").concat(fontFamily);\n var metrics = ctx.measureText(str);\n var width = +(+metrics.width.toFixed(2) + 0.01).toFixed(2);\n var height = +(+metrics.actualBoundingBoxAscent.toFixed(2) + +metrics.actualBoundingBoxDescent.toFixed(2)).toFixed(2);\n var _letterSpacing = (str.length > 0 ? str.length - 1 : 0) * letterSpacing;\n width += _letterSpacing;\n return { width: +width.toFixed(2), height: +height.toFixed(2) };\n}\nexports[\"default\"] = get_string_size;\n\n\n//# sourceURL=webpack://hsu-utils/./tools/GetStrSize/index.ts?");
|
135
135
|
|
136
136
|
/***/ }),
|
137
137
|
|