@leafer-ui/text 1.9.4 → 1.9.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/text",
3
- "version": "1.9.4",
3
+ "version": "1.9.6",
4
4
  "description": "@leafer-ui/text",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,10 +22,10 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/core": "1.9.4"
25
+ "@leafer/core": "1.9.6"
26
26
  },
27
27
  "devDependencies": {
28
- "@leafer/interface": "1.9.4",
29
- "@leafer-ui/interface": "1.9.4"
28
+ "@leafer/interface": "1.9.6",
29
+ "@leafer-ui/interface": "1.9.6"
30
30
  }
31
31
  }
@@ -5,21 +5,22 @@ import { ColorConvert } from '@leafer-ui/draw'
5
5
 
6
6
 
7
7
  export function decorationText(drawData: ITextDrawData, style: ITextData): void {
8
- let type: ITextDecorationType
8
+ let type: ITextDecorationType, offset = 0
9
9
  const { fontSize, textDecoration } = style
10
10
  drawData.decorationHeight = fontSize / 11
11
11
  if (isObject(textDecoration)) {
12
12
  type = textDecoration.type
13
13
  if (textDecoration.color) drawData.decorationColor = ColorConvert.string(textDecoration.color)
14
+ if (textDecoration.offset) offset = Math.min(fontSize * 0.3, Math.max(textDecoration.offset, -fontSize * 0.15))
14
15
  } else type = textDecoration
15
16
  switch (type) {
16
17
  case 'under':
17
- drawData.decorationY = [fontSize * 0.15]
18
+ drawData.decorationY = [fontSize * 0.15 + offset]
18
19
  break
19
20
  case 'delete':
20
21
  drawData.decorationY = [-fontSize * 0.35]
21
22
  break
22
23
  case 'under-delete':
23
- drawData.decorationY = [fontSize * 0.15, -fontSize * 0.35]
24
+ drawData.decorationY = [fontSize * 0.15 + offset, -fontSize * 0.35]
24
25
  }
25
26
  }