ice-render 1.4.0 → 1.4.2

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.
@@ -91,6 +91,15 @@ declare class ICEText extends ICEComponent {
91
91
  width: any;
92
92
  height: any;
93
93
  };
94
+ /**
95
+ * 多行文本的行距系数。
96
+ *
97
+ * 为什么不能直接用 `actualBoundingBoxAscent + Descent`(字形墨迹高度)当行距:
98
+ * 墨迹只覆盖「有笔画的部分」,拉丁字母的 cap-height 比 em 小得多 —— 14px Tahoma 的
99
+ * 墨迹高 ≈ 12px,拿它当行距时中文(墨迹接近满 em)会**上下叠在一起**,看起来像文字被压扁。
100
+ * 按字号 × 1.35 取行距更接近系统的自然行高,同时保证 ≥ 墨迹高度(不会挤)。
101
+ */
102
+ private static readonly LINE_HEIGHT_RATIO;
94
103
  /**
95
104
  * @method measureText
96
105
  *
@@ -126,6 +135,18 @@ declare class ICEText extends ICEComponent {
126
135
  private __applyMeasuredSize;
127
136
  /** DOM 降级测量:line-height 归一为 1,减少 leading 干扰(旧环境/小程序)。 */
128
137
  private __measureByDOM;
138
+ /**
139
+ * 文本的**渲染行布局**:每一行的内容与基线坐标(组件本地坐标)。
140
+ *
141
+ * 画布渲染与 SVG 导出共用这一份口径 —— 两处各算一遍必然漂移(改了对齐公式忘了另一处,
142
+ * 表现为「导出的文字整体偏移」)。返回的 `x` 是**文字左边缘**(左/居中/右对齐都按画布公式算好),
143
+ * `y` 是 baseline 位置。
144
+ */
145
+ getRenderLines(): Array<{
146
+ text: string;
147
+ x: number;
148
+ y: number;
149
+ }>;
129
150
  /**
130
151
  * @method doRender
131
152
  * @overwrite
@@ -49,6 +49,8 @@ export { default as ICELayeredLayout } from './layout/ICELayeredLayout.mjs';
49
49
  export { default as ICETheme, baseTokens, DEFAULT_THEME, DARK_THEME, registerTheme, setTheme, getTheme, STYLE_PRESETS, } from './theme/ICETheme.mjs';
50
50
  export { default as ICE } from './ICE.mjs';
51
51
  export { default as CanvasRenderer } from './renderer/CanvasRenderer.mjs';
52
+ export { exportSvg, exportSvgResult } from './export/SvgExporter.mjs';
53
+ export type { SvgExportOptions, SvgExportResult } from './export/SvgExporter.mjs';
52
54
  export { default as PluginHost } from './plugin/PluginHost.mjs';
53
55
  export type { ICEPlugin, ICEPluginTool, ICERenderHook, ICERenderFrame } from './plugin/PluginHost.mjs';
54
56
  export { default as Serializer, SERIALIZATION_VERSION } from './persistence/Serializer.mjs';
@@ -49,6 +49,8 @@ export { default as ICELayeredLayout } from './layout/ICELayeredLayout';
49
49
  export { default as ICETheme, baseTokens, DEFAULT_THEME, DARK_THEME, registerTheme, setTheme, getTheme, STYLE_PRESETS, } from './theme/ICETheme';
50
50
  export { default as ICE } from './ICE';
51
51
  export { default as CanvasRenderer } from './renderer/CanvasRenderer';
52
+ export { exportSvg, exportSvgResult } from './export/SvgExporter';
53
+ export type { SvgExportOptions, SvgExportResult } from './export/SvgExporter';
52
54
  export { default as PluginHost } from './plugin/PluginHost';
53
55
  export type { ICEPlugin, ICEPluginTool, ICERenderHook, ICERenderFrame } from './plugin/PluginHost';
54
56
  export { default as Serializer, SERIALIZATION_VERSION } from './persistence/Serializer';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "大漠穷秋",
3
3
  "name": "ice-render",
4
- "version": "1.4.0",
4
+ "version": "1.4.2",
5
5
  "description": "A canvas engine for interactive graphics.",
6
6
  "repository": {
7
7
  "type": "git",
@@ -49,7 +49,7 @@
49
49
  "pkg:lint": "publint",
50
50
  "pkg:types": "attw --pack .",
51
51
  "pkg:check": "npm run pkg:lint && npm run pkg:types",
52
- "test:visual:ci": "playwright test e2e/visual/examples-smoke.spec.ts e2e/visual/interaction.spec.ts e2e/visual/dirty-rect-pixel.spec.ts e2e/visual/viewport.spec.ts e2e/visual/alignment.spec.ts e2e/visual/hidpi.spec.ts e2e/visual/worker-perf.spec.ts",
52
+ "test:visual:ci": "playwright test e2e/visual/examples-smoke.spec.ts e2e/visual/interaction.spec.ts e2e/visual/dirty-rect-pixel.spec.ts e2e/visual/viewport.spec.ts e2e/visual/alignment.spec.ts e2e/visual/hidpi.spec.ts e2e/visual/worker-perf.spec.ts e2e/visual/svg-parity.spec.ts",
53
53
  "verify": "npm run lint && npm run types:check && npm run build && npm test -- --runInBand && npm run bench 2000 && npm run pkg:check",
54
54
  "verify:full": "npm run verify && npm run test:visual"
55
55
  },