Skip to content

Commit 7ce64f1

Browse files
Release (#1878)
* fix: the text wrapping position is not accurate (#1876) * Version Packages (#1877) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent ae89121 commit 7ce64f1

File tree

97 files changed

+570
-94
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+570
-94
lines changed

__tests__/demos/bugfix/textWordWrap.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { Canvas, Text, Rect } from '@antv/g';
2+
import * as tinybench from 'tinybench';
23

4+
/**
5+
* @link https://github.com/antvis/G/issues/1833
6+
*/
37
export async function textWordWrap(context: { canvas: Canvas }) {
48
const { canvas } = context;
59
await canvas.ready;
@@ -105,4 +109,44 @@ export async function textWordWrap(context: { canvas: Canvas }) {
105109
canvas.appendChild(rect1);
106110
canvas.appendChild(text2);
107111
canvas.appendChild(rect2);
112+
113+
// benchmark
114+
// ----------
115+
const bench = new tinybench.Bench({
116+
name: 'canvas text benchmark',
117+
time: 100,
118+
});
119+
120+
const canvasEl = document.createElement('canvas');
121+
const testText = 'Hello, World!';
122+
bench.add('Measure the entire text at once', async () => {
123+
canvasEl.getContext('2d').measureText(testText);
124+
});
125+
bench.add('Character-by-character measurement', async () => {
126+
const ctx = canvasEl.getContext('2d');
127+
Array.from(testText).forEach((char) => {
128+
ctx.measureText(char);
129+
});
130+
});
131+
132+
const testText1 =
133+
'In G, text line break detection is currently done by iteratively measuring the width of each character and then adding them up to determine whether a line break is needed. External users may configure wordWrapWidth by directly measuring the width of the entire text. The two different text measurement methods will lead to visual inconsistencies.';
134+
bench.add('(long txt) Measure the entire text at once', async () => {
135+
canvasEl.getContext('2d').measureText(testText1);
136+
});
137+
bench.add('(long txt) Character-by-character measurement', async () => {
138+
const ctx = canvasEl.getContext('2d');
139+
Array.from(testText1).forEach((char) => {
140+
ctx.measureText(char);
141+
});
142+
});
143+
144+
await bench.run();
145+
146+
console.log(bench.name);
147+
console.table(bench.table());
148+
console.log(bench.results);
149+
console.log(bench.tasks);
150+
151+
// ----------
108152
}

__tests__/demos/event/hierarchy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Circle, Path } from '@antv/g';
1+
import { Canvas, Circle, Path } from '@antv/g';
22

3-
export async function hierarchy(context) {
3+
export async function hierarchy(context: { canvas: Canvas }) {
44
const { canvas } = context;
55
await canvas.ready;
66

packages/g-camera-api/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @antv/g-camera-api
22

3+
## 2.0.30
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [1d13497]
8+
- @antv/g-lite@2.2.11
9+
310
## 2.0.29
411

512
### Patch Changes

packages/g-camera-api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-camera-api",
3-
"version": "2.0.29",
3+
"version": "2.0.30",
44
"description": "A simple implementation of Camera API.",
55
"keywords": [
66
"antv",

packages/g-canvas/CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# @antv/g-canvas
22

3+
## 2.0.34
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [1d13497]
8+
- @antv/g-lite@2.2.11
9+
- @antv/g-plugin-canvas-path-generator@2.1.11
10+
- @antv/g-plugin-canvas-picker@2.1.13
11+
- @antv/g-plugin-canvas-renderer@2.2.13
12+
- @antv/g-plugin-dom-interaction@2.1.16
13+
- @antv/g-plugin-html-renderer@2.1.16
14+
- @antv/g-plugin-image-loader@2.1.13
15+
316
## 2.0.33
417

518
### Patch Changes

packages/g-canvas/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-canvas",
3-
"version": "2.0.33",
3+
"version": "2.0.34",
44
"description": "A renderer implemented by Canvas 2D API",
55
"keywords": [
66
"antv",

packages/g-canvaskit/CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# @antv/g-canvaskit
22

3+
## 1.0.33
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [1d13497]
8+
- @antv/g-lite@2.2.11
9+
- @antv/g-plugin-canvas-path-generator@2.1.11
10+
- @antv/g-plugin-canvas-picker@2.1.13
11+
- @antv/g-plugin-canvaskit-renderer@2.1.13
12+
- @antv/g-plugin-dom-interaction@2.1.16
13+
- @antv/g-plugin-html-renderer@2.1.16
14+
- @antv/g-plugin-image-loader@2.1.13
15+
316
## 1.0.32
417

518
### Patch Changes

packages/g-canvaskit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-canvaskit",
3-
"version": "1.0.32",
3+
"version": "1.0.33",
44
"description": "A renderer implemented by CanvasKit",
55
"keywords": [
66
"antv",

packages/g-components/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @antv/g-components
22

3+
## 2.0.27
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [1d13497]
8+
- @antv/g-lite@2.2.11
9+
310
## 2.0.26
411

512
### Patch Changes

packages/g-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-components",
3-
"version": "2.0.26",
3+
"version": "2.0.27",
44
"description": "Components for g",
55
"keywords": [
66
"antv",

packages/g-dom-mutation-observer-api/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @antv/g-dom-mutation-observer-api
22

3+
## 2.0.27
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [1d13497]
8+
- @antv/g-lite@2.2.11
9+
310
## 2.0.26
411

512
### Patch Changes

packages/g-dom-mutation-observer-api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-dom-mutation-observer-api",
3-
"version": "2.0.26",
3+
"version": "2.0.27",
44
"description": "A simple implementation of DOM MutationObserver API.",
55
"keywords": [
66
"antv",

packages/g-gesture/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @antv/g-gesture
22

3+
## 3.0.27
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [1d13497]
8+
- @antv/g-lite@2.2.11
9+
310
## 3.0.26
411

512
### Patch Changes

packages/g-gesture/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-gesture",
3-
"version": "3.0.26",
3+
"version": "3.0.27",
44
"description": "G Gesture",
55
"keywords": [
66
"antv",

packages/g-image-exporter/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @antv/g-image-exporter
22

3+
## 1.0.27
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [1d13497]
8+
- @antv/g-lite@2.2.11
9+
310
## 1.0.26
411

512
### Patch Changes

packages/g-image-exporter/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-image-exporter",
3-
"version": "1.0.26",
3+
"version": "1.0.27",
44
"description": "A image exporter for G using DOM API",
55
"keywords": [
66
"antv",

packages/g-lite/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @antv/g-lite
22

3+
## 2.2.11
4+
5+
### Patch Changes
6+
7+
- 1d13497: fix: the text wrapping position is not accurate
8+
39
## 2.2.10
410

511
### Patch Changes

packages/g-lite/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g-lite",
3-
"version": "2.2.10",
3+
"version": "2.2.11",
44
"description": "A core module for rendering engine implements DOM API.",
55
"keywords": [
66
"antv",

0 commit comments

Comments
 (0)