ztxkutils 2.10.66-36 → 2.10.66-38

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.
Files changed (2) hide show
  1. package/dist/print.js +5 -2
  2. package/package.json +1 -1
package/dist/print.js CHANGED
@@ -71,6 +71,7 @@ function getTextDimensions(text, fontSize) {
71
71
  tempElement.style.whiteSpace = 'nowrap'; // 防止文本换行影响宽度测量
72
72
  tempElement.style.fontSize = fontSize;
73
73
  tempElement.style.fontFamily = '微软雅黑';
74
+ tempElement.style.padding = '50px 10px';
74
75
  // 插入到body中
75
76
  document.body.appendChild(tempElement);
76
77
  // 获取元素的宽高
@@ -80,8 +81,8 @@ function getTextDimensions(text, fontSize) {
80
81
  document.body.removeChild(tempElement);
81
82
  // 返回测量结果
82
83
  return {
83
- width: width > 340 ? 340 : width,
84
- height: height > 200 ? 200 : height,
84
+ width: width > 520 ? 520 : width < 240 ? 240 : width,
85
+ height: height > 200 ? 200 : height < 100 ? 100 : height,
85
86
  };
86
87
  }
87
88
  /**
@@ -106,11 +107,13 @@ function createWaterHandle(obj) {
106
107
  var canvas = document.createElement('canvas');
107
108
  // 如何计算水印的大小。创建一个元素插入到body中,获取到宽高后移除
108
109
  var _b = getTextDimensions(waterText, fontSize || '18px'), textWidth = _b.width, textHeight = _b.height;
110
+ // 之前的宽度是文本长度 * 22
109
111
  var defaultCanvasWidth = waterText
110
112
  ? waterText.length > 10
111
113
  ? textWidth
112
114
  : 240
113
115
  : 240;
116
+ // 之前的高度是文本长度 * 9
114
117
  var defaultCanvasHeight = waterText
115
118
  ? waterText.length > 10
116
119
  ? textHeight
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkutils",
3
- "version": "2.10.66-36",
3
+ "version": "2.10.66-38",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",