alpha2 0.1.0 → 0.2.0

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/dist/text.d.ts CHANGED
@@ -55,12 +55,12 @@ export interface BrowserTextRequest {
55
55
  /** A CSS color (default opaque white). */
56
56
  readonly color?: string;
57
57
  /**
58
- * How emoji are drawn (default `native-color`): in the platform's color font, as text
59
- * presentation where there is one (`monochrome`), or as one U+FFFD per grapheme shown as an
60
- * emoji (`replace`), as the portable host replaces them. Symbols shown as text by default, such
61
- * as (c), stay.
58
+ * How emoji are drawn (default `color`): in the platform's color font, as text presentation
59
+ * where there is one (`monochrome`), or as one U+FFFD per grapheme shown as an emoji
60
+ * (`replace`), as the portable host replaces them. Symbols shown as text by default, such as
61
+ * (c), stay.
62
62
  */
63
- readonly emojiPolicy?: "native-color" | "monochrome" | "replace";
63
+ readonly emojiPolicy?: "color" | "monochrome" | "replace";
64
64
  }
65
65
  /** The `WasmTextRasterizer` class that `alpha2/wasm` exports. */
66
66
  export interface WasmTextRasterizerHandle {
@@ -93,20 +93,23 @@ export interface WasmTextRequest {
93
93
  /** Straight (not premultiplied), sRGB-encoded RGBA, each in `0..=255`. */
94
94
  readonly color: readonly [number, number, number, number];
95
95
  /**
96
- * What becomes of color-only emoji (default `monochrome`); `replace` draws each emoji grapheme as
97
- * one U+FFFD.
96
+ * How emoji are drawn (default `color`): a font's color glyphs (COLR, CBDT, sbix) in their own
97
+ * colors, an emoji trying the color fonts first; `monochrome` draws every glyph as an outline in
98
+ * `color`, an emoji trying the other fonts first; `replace` draws each emoji grapheme as one
99
+ * U+FFFD.
98
100
  */
99
- readonly emojiPolicy?: "monochrome" | "replace";
101
+ readonly emojiPolicy?: "color" | "monochrome" | "replace";
100
102
  }
101
103
  /**
102
104
  * The engine's portable text host (`alpha2-text`: Unicode bidirectional
103
105
  * layout and line breaking, rustybuzz shaping, `ab_glyph_rasterizer`
104
- * outlines) running in wasm.
106
+ * outlines, COLR paintings and CBDT or sbix bitmaps) running in wasm.
105
107
  *
106
108
  * It is the same code a native host rasterizes with, so with the same font bytes a browser preview
107
109
  * and a native export draw identical text; the platform's own rasterizer, {@link
108
110
  * OffscreenTextRasterizer}, does not. Fonts are caller-supplied bytes in fallback order; system
109
- * fonts are not reachable. Color emoji are drawn as outlines or replaced (`emojiPolicy`).
111
+ * fonts are not reachable. Color emoji are drawn in color from the fonts given, as outlines, or
112
+ * replaced (`emojiPolicy`).
110
113
  */
111
114
  export declare class WasmTextRasterizer {
112
115
  #private;
package/dist/text.js CHANGED
@@ -35,12 +35,13 @@ const TEXT_ALIGNS = new Set(["start", "end", "left", "right", "center"]);
35
35
  /**
36
36
  * The engine's portable text host (`alpha2-text`: Unicode bidirectional
37
37
  * layout and line breaking, rustybuzz shaping, `ab_glyph_rasterizer`
38
- * outlines) running in wasm.
38
+ * outlines, COLR paintings and CBDT or sbix bitmaps) running in wasm.
39
39
  *
40
40
  * It is the same code a native host rasterizes with, so with the same font bytes a browser preview
41
41
  * and a native export draw identical text; the platform's own rasterizer, {@link
42
42
  * OffscreenTextRasterizer}, does not. Fonts are caller-supplied bytes in fallback order; system
43
- * fonts are not reachable. Color emoji are drawn as outlines or replaced (`emojiPolicy`).
43
+ * fonts are not reachable. Color emoji are drawn in color from the fonts given, as outlines, or
44
+ * replaced (`emojiPolicy`).
44
45
  */
45
46
  export class WasmTextRasterizer {
46
47
  #handle;
@@ -163,7 +164,7 @@ export class OffscreenTextRasterizer {
163
164
  throw new Error("OffscreenCanvas 2D context is unavailable");
164
165
  probe.font = `${fontSize}px ${family}`;
165
166
  probe.textBaseline = "alphabetic";
166
- const normalizedText = normalizeEmoji(request.text, request.emojiPolicy ?? "native-color");
167
+ const normalizedText = normalizeEmoji(request.text, request.emojiPolicy ?? "color");
167
168
  const lines = wrapLines(probe, normalizedText, request.maxWidth ?? 0);
168
169
  probe.textAlign = request.align ?? "start";
169
170
  const measured = lines.map((line) => probe.measureText(line));
@@ -389,7 +390,7 @@ function isEmoji(grapheme) {
389
390
  /** A lone pictograph, with or without a presentation selector: what U+FE0E can make text. */
390
391
  const LONE_PICTOGRAPH = /^(\p{Extended_Pictographic})\ufe0f?$/u;
391
392
  function normalizeEmoji(text, policy) {
392
- if (policy === "native-color")
393
+ if (policy === "color")
393
394
  return text;
394
395
  let normalized = "";
395
396
  for (const segment of graphemes(text)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alpha2",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "license": "MIT",
5
5
  "description": "JavaScript bindings for the standalone alpha2 media engine.",
6
6
  "repository": {
Binary file
Binary file
@@ -1,8 +1,8 @@
1
1
  /* @ts-self-types="./alpha2_wasm.d.ts" */
2
- import { alpha2BitmapUploadsPremultiplied, alpha2FrameBitmap } from './snippets/alpha2-wasm-1112c60b377beee2/inline1.js';
3
- import { alpha2CopyExternalImage } from './snippets/alpha2-wasm-1112c60b377beee2/inline2.js';
4
- import * as import1 from "./snippets/alpha2-wasm-1112c60b377beee2/inline0.js"
5
- import * as import2 from "./snippets/alpha2-wasm-1112c60b377beee2/inline0.js"
2
+ import { alpha2BitmapUploadsPremultiplied, alpha2FrameBitmap } from './snippets/alpha2-wasm-632c71c93cbb7942/inline1.js';
3
+ import { alpha2CopyExternalImage } from './snippets/alpha2-wasm-632c71c93cbb7942/inline2.js';
4
+ import * as import1 from "./snippets/alpha2-wasm-632c71c93cbb7942/inline0.js"
5
+ import * as import2 from "./snippets/alpha2-wasm-632c71c93cbb7942/inline0.js"
6
6
 
7
7
 
8
8
  /**
@@ -2416,14 +2416,14 @@ function __wbg_get_imports() {
2416
2416
  __wbg_addEventListener_9534e2dc12044ee4: function() { return handleError(function (arg0, arg1, arg2, arg3) {
2417
2417
  arg0.addEventListener(getStringFromWasm0(arg1, arg2), arg3);
2418
2418
  }, arguments); },
2419
- __wbg_alpha2BitmapUploadsPremultiplied_a9d241dca37d76a0: function() { return handleError(function () {
2419
+ __wbg_alpha2BitmapUploadsPremultiplied_0c5d843c2f9131ee: function() { return handleError(function () {
2420
2420
  const ret = alpha2BitmapUploadsPremultiplied();
2421
2421
  return ret;
2422
2422
  }, arguments); },
2423
- __wbg_alpha2CopyExternalImage_5172878724d526ce: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
2423
+ __wbg_alpha2CopyExternalImage_f35a689ee6364289: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
2424
2424
  alpha2CopyExternalImage(arg0, arg1, arg2, arg3 >>> 0, arg4 >>> 0);
2425
2425
  }, arguments); },
2426
- __wbg_alpha2FrameBitmap_6ad15e76176d512b: function() { return handleError(function (arg0, arg1, arg2) {
2426
+ __wbg_alpha2FrameBitmap_bdd1fce4f80435c5: function() { return handleError(function (arg0, arg1, arg2) {
2427
2427
  const ret = alpha2FrameBitmap(arg0, arg1 >>> 0, arg2 >>> 0);
2428
2428
  return ret;
2429
2429
  }, arguments); },
@@ -4604,47 +4604,47 @@ function __wbg_get_imports() {
4604
4604
  arg0.writeTexture(arg1, getArrayU8FromWasm0(arg2, arg3), arg4, arg5);
4605
4605
  }, arguments); },
4606
4606
  __wbindgen_generic_0000000000000001: function(arg0, arg1) {
4607
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 3199, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
4607
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 3238, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
4608
4608
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_d171202afaeab6f2___convert__closures_____invoke___wasm_bindgen_d171202afaeab6f2___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_d171202afaeab6f2___JsError___true_);
4609
4609
  return ret;
4610
4610
  },
4611
4611
  __wbindgen_generic_0000000000000002: function(arg0, arg1) {
4612
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 156, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
4612
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 69, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
4613
4613
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_d171202afaeab6f2___convert__closures_____invoke___web_sys_9e2ae0ace5131457___features__gen_Event__Event______true_);
4614
4614
  return ret;
4615
4615
  },
4616
4616
  __wbindgen_generic_0000000000000003: function(arg0, arg1) {
4617
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUCompilationInfo")], shim_idx: 980, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
4617
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUCompilationInfo")], shim_idx: 1019, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
4618
4618
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_d171202afaeab6f2___convert__closures_____invoke___wasm_bindgen_d171202afaeab6f2___sys__JsNullable_wgpu_f46556a90412e4d9___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_d171202afaeab6f2___JsError___true_);
4619
4619
  return ret;
4620
4620
  },
4621
4621
  __wbindgen_generic_0000000000000004: function(arg0, arg1) {
4622
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDevice")], shim_idx: 980, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
4622
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDevice")], shim_idx: 1019, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
4623
4623
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_d171202afaeab6f2___convert__closures_____invoke___wasm_bindgen_d171202afaeab6f2___sys__JsNullable_wgpu_f46556a90412e4d9___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_d171202afaeab6f2___JsError___true__125);
4624
4624
  return ret;
4625
4625
  },
4626
4626
  __wbindgen_generic_0000000000000005: function(arg0, arg1) {
4627
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDeviceLostInfo")], shim_idx: 983, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
4627
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDeviceLostInfo")], shim_idx: 1022, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
4628
4628
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_d171202afaeab6f2___convert__closures_____invoke___wgpu_f46556a90412e4d9___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true_);
4629
4629
  return ret;
4630
4630
  },
4631
4631
  __wbindgen_generic_0000000000000006: function(arg0, arg1) {
4632
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx: 983, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
4632
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx: 1022, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
4633
4633
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_d171202afaeab6f2___convert__closures_____invoke___wgpu_f46556a90412e4d9___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__127);
4634
4634
  return ret;
4635
4635
  },
4636
4636
  __wbindgen_generic_0000000000000007: function(arg0, arg1) {
4637
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("any")], shim_idx: 980, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
4637
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("any")], shim_idx: 1019, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
4638
4638
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_d171202afaeab6f2___convert__closures_____invoke___wasm_bindgen_d171202afaeab6f2___sys__JsNullable_wgpu_f46556a90412e4d9___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_d171202afaeab6f2___JsError___true__128);
4639
4639
  return ret;
4640
4640
  },
4641
4641
  __wbindgen_generic_0000000000000008: function(arg0, arg1) {
4642
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx: 980, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
4642
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx: 1019, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
4643
4643
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_d171202afaeab6f2___convert__closures_____invoke___wasm_bindgen_d171202afaeab6f2___sys__JsNullable_wgpu_f46556a90412e4d9___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_d171202afaeab6f2___JsError___true__129);
4644
4644
  return ret;
4645
4645
  },
4646
4646
  __wbindgen_generic_0000000000000009: function(arg0, arg1) {
4647
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 158, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
4647
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 71, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
4648
4648
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_d171202afaeab6f2___convert__closures_____invoke_______true_);
4649
4649
  return ret;
4650
4650
  },
@@ -4711,8 +4711,8 @@ function __wbg_get_imports() {
4711
4711
  return {
4712
4712
  __proto__: null,
4713
4713
  "./alpha2_wasm_bg.js": import0,
4714
- "./snippets/alpha2-wasm-1112c60b377beee2/inline0.js": import1,
4715
- "./snippets/alpha2-wasm-1112c60b377beee2/inline0.js": import2,
4714
+ "./snippets/alpha2-wasm-632c71c93cbb7942/inline0.js": import1,
4715
+ "./snippets/alpha2-wasm-632c71c93cbb7942/inline0.js": import2,
4716
4716
  };
4717
4717
  }
4718
4718
 
Binary file