@leafer-ui/text 1.0.0-beta.12 → 1.0.0-beta.15

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,12 +1,15 @@
1
1
  {
2
2
  "name": "@leafer-ui/text",
3
- "version": "1.0.0-beta.12",
3
+ "version": "1.0.0-beta.15",
4
4
  "description": "@leafer-ui/text",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
7
7
  "main": "src/index.ts",
8
+ "types": "types/index.d.ts",
8
9
  "files": [
9
- "src"
10
+ "src",
11
+ "types",
12
+ "dist"
10
13
  ],
11
14
  "repository": {
12
15
  "type": "git",
@@ -19,10 +22,10 @@
19
22
  "leaferjs"
20
23
  ],
21
24
  "dependencies": {
22
- "@leafer-ui/core": "1.0.0-beta.12"
25
+ "@leafer-ui/core": "1.0.0-beta.15"
23
26
  },
24
27
  "devDependencies": {
25
- "@leafer/interface": "1.0.0-beta.12",
26
- "@leafer-ui/interface": "1.0.0-beta.12"
28
+ "@leafer/interface": "1.0.0-beta.15",
29
+ "@leafer-ui/interface": "1.0.0-beta.15"
27
30
  }
28
31
  }
@@ -1,6 +1,6 @@
1
1
  import { MathHelper, Platform } from '@leafer/core'
2
2
 
3
- import { ITextData, ITextDrawData } from '@leafer-ui/interface'
3
+ import { ITextConvertModule, ITextData, ITextDrawData } from '@leafer-ui/interface'
4
4
 
5
5
  import { createRows } from './TextRows'
6
6
  import { layoutChar } from './CharLayout'
@@ -9,7 +9,7 @@ import { clipText } from './TextClip'
9
9
  import { decorationText } from './TextDecoration'
10
10
 
11
11
 
12
- export const TextConvert = {
12
+ export const TextConvert: ITextConvertModule = {
13
13
 
14
14
  getDrawData(content: string, style: ITextData): ITextDrawData {
15
15
 
package/src/TextLayout.ts CHANGED
@@ -52,8 +52,16 @@ export function layoutText(drawData: ITextDrawData, style: ITextData): void {
52
52
  drawData.overflow = i + 1
53
53
  }
54
54
 
55
- if (row.x < bounds.x) bounds.x = row.x
56
- if (row.width > bounds.width) bounds.width = row.width
55
+ if (row.width < 0) { // letterSpacing < 0
56
+ const charWidth = row.words[0].data[0].width
57
+ const rowX = row.x + row.width
58
+ if (rowX < bounds.x) bounds.x = rowX - charWidth
59
+ if (-row.width > bounds.width) bounds.width = -row.width + style.fontSize + charWidth
60
+ } else {
61
+ if (row.x < bounds.x) bounds.x = row.x
62
+ if (row.width > bounds.width) bounds.width = row.width
63
+ }
64
+
57
65
  }
58
66
 
59
67
  bounds.y = y
@@ -0,0 +1,5 @@
1
+ import { ITextConvertModule } from '@leafer-ui/interface';
2
+
3
+ declare const TextConvert: ITextConvertModule;
4
+
5
+ export { TextConvert };