oasis-editor 0.0.97 → 0.0.98

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.
@@ -8,3 +8,31 @@ export declare function resolveCanvasTextRenderMetrics(styles: {
8
8
  fontSize: number;
9
9
  baselineOffset: number;
10
10
  };
11
+ /**
12
+ * Applies the subset of OpenType-feature/typography intent that Canvas 2D can
13
+ * actually express, keeping painting consistent with the metric-only slot
14
+ * measurement (see `measureCharacterWidth`).
15
+ *
16
+ * - **Kerning (`w:kern`)** → `ctx.fontKerning`. `w:kern/@w:val` is a *minimum
17
+ * font size threshold* (stored in pt as `kerningThreshold`); kerning is active
18
+ * only when the run's size meets it. Defaulting to `"none"` keeps the painter
19
+ * aligned with the no-kerning measurement, avoiding caret/slot drift.
20
+ * - **Ligatures (`w14:ligatures`)** → `ctx.textRendering` as a *coarse, lossy
21
+ * hint* (`optimizeSpeed` suppresses, `optimizeLegibility` enables). It cannot
22
+ * distinguish standard/contextual/historical and is engine-dependent.
23
+ *
24
+ * Canvas 2D has **no** API for `w14:numForm`, `w14:numSpacing`,
25
+ * `w14:stylisticSets`, or `w14:cntxtAlts` (no `fontVariantNumeric` /
26
+ * `fontVariantLigatures` / `fontFeatureSettings`), so those remain a documented
27
+ * canvas limitation — HTML/CSS honors them via `styleCss.ts`; PDF is separate.
28
+ *
29
+ * `fontVariantCaps`, `letterSpacing`, and `fontStretch` are intentionally left
30
+ * untouched: small caps, character spacing, and character scale are already
31
+ * realized by the render-metric/slot/scale path and would double-apply here.
32
+ *
33
+ * @param fontSizePx the run's effective (unscaled) font size in px.
34
+ */
35
+ export declare function applyCanvasTextFeatureHints(ctx: CanvasRenderingContext2D, styles: {
36
+ kerningThreshold?: number | null;
37
+ ligatures?: "none" | "standard" | "contextual" | "historical" | "standardContextual" | null;
38
+ } | undefined, fontSizePx: number): void;
@@ -1,7 +1,7 @@
1
1
  import { EditorLayoutLine, EditorPageSettings, EditorParagraphNode, EditorState } from '../../core/model.js';
2
2
  import { CanvasBlockPainters } from './canvasBlockPainters.js';
3
3
 
4
- export { resolveCanvasFontFamily, resolveCanvasTextRenderMetrics, } from './canvasFontResolution.js';
4
+ export { applyCanvasTextFeatureHints, resolveCanvasFontFamily, resolveCanvasTextRenderMetrics, } from './canvasFontResolution.js';
5
5
  /**
6
6
  * Paints the floating images anchored within a paragraph, mirroring
7
7
  * `drawFloatingTextBoxesForParagraph`. Split into `behind`/`front` layers so a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oasis-editor",
3
- "version": "0.0.97",
3
+ "version": "0.0.98",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",