@aseity/igrid-react 0.4.0 → 0.4.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @aseity/igrid-react
2
2
 
3
+ ## 0.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Prevent text strokes from being clipped in short rows and correct raised text when the font box is taller than the row. Keep visible glyphs inside the row while preserving normal alignment in taller rows.
8
+ - Synchronize the exact engine dependency to `@aseity/igrid-engine@0.4.1`.
9
+
3
10
  ## 0.4.0
4
11
 
5
12
  ### Minor Changes
package/dist/text.js CHANGED
@@ -35,10 +35,32 @@ export function drawText(context, list, index) {
35
35
  : vertical === 1
36
36
  ? y + (height - blockHeight) / 2
37
37
  : y + height - blockHeight - 1;
38
+ let firstBaseline = top + ascent;
39
+ if (blockHeight > height - 2) {
40
+ const ink = lines.flatMap((line, lineIndex) => line
41
+ .filter((segment) => !segment.spacing && segment.text.trim())
42
+ .map((segment) => {
43
+ context.font = segment.font;
44
+ const metrics = context.measureText(segment.text);
45
+ return {
46
+ top: lineIndex * lineHeight - metrics.actualBoundingBoxAscent,
47
+ bottom: lineIndex * lineHeight + metrics.actualBoundingBoxDescent,
48
+ };
49
+ }));
50
+ if (ink.length) {
51
+ const inkTop = Math.min(...ink.map((bounds) => bounds.top));
52
+ const inkBottom = Math.max(...ink.map((bounds) => bounds.bottom));
53
+ const spare = height - (inkBottom - inkTop);
54
+ if (spare >= 0) {
55
+ const inset = Math.min(1, spare / 2);
56
+ firstBaseline = Math.max(y + inset - inkTop, Math.min(firstBaseline, y + height - inset - inkBottom));
57
+ }
58
+ }
59
+ }
38
60
  const [left, right] = list.text_bounds.subarray(index * 2, index * 2 + 2);
39
61
  context.save();
40
62
  context.beginPath();
41
- context.rect(left + 1, y + 1, Math.max(0, right - left - 2), Math.max(0, height - 2));
63
+ context.rect(left + 1, y, Math.max(0, right - left - 2), Math.max(0, height));
42
64
  context.clip();
43
65
  context.textAlign = "left";
44
66
  context.textBaseline = "alphabetic";
@@ -49,7 +71,7 @@ export function drawText(context, list, index) {
49
71
  : horizontal === 2
50
72
  ? x + (width - lineWidth) / 2
51
73
  : x + padding;
52
- const baseline = top + lineIndex * lineHeight + ascent;
74
+ const baseline = firstBaseline + lineIndex * lineHeight;
53
75
  for (const segment of line) {
54
76
  context.font = segment.font;
55
77
  context.fillStyle = segment.color;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aseity/igrid-react",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -11,7 +11,7 @@
11
11
  "./styles.css": "./dist/style.css"
12
12
  },
13
13
  "dependencies": {
14
- "@aseity/igrid-engine": "0.4.0",
14
+ "@aseity/igrid-engine": "0.4.1",
15
15
  "echarts": "6.1.0"
16
16
  },
17
17
  "peerDependencies": {