@openpresentation/opf-render 0.34.0 → 0.34.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.
@@ -509,7 +509,7 @@ export async function createNodeDemand(
509
509
  loaded.selection.notInstalled.push(item.package);
510
510
  notify(
511
511
  'script-font-not-installed',
512
- { package: item.package, scripts: item.scripts },
512
+ { package: item.package, version: item.version, scripts: item.scripts },
513
513
  'Install ' +
514
514
  item.package +
515
515
  '@' +
@@ -27,7 +27,8 @@ function validFamily(family) {
27
27
  }
28
28
  // The open families load with the office pack (loadFonts({pack:"office"})).
29
29
 
30
- const packFor = family => { const pack = BUNDLED_FONT_MANIFEST.packages.find(pkg=>pkg.renamedFrom?.toLowerCase()===family.toLowerCase() || pkg.faces.some(face=>face.family.toLowerCase()===family.toLowerCase()))?.pack; return pack==="open" ? "office" : pack; };
30
+ const packageFor = family => BUNDLED_FONT_MANIFEST.packages.find(pkg=>pkg.renamedFrom?.toLowerCase()===family.toLowerCase() || pkg.faces.some(face=>face.family.toLowerCase()===family.toLowerCase()));
31
+ const packFor = family => { const pack = packageFor(family)?.pack; return pack==="open" ? "office" : pack; };
31
32
  const percent = value => `${(value*100).toFixed(1)}%`;
32
33
  /** FF-31: say why a family has no face and what the caller can do, from the OPF font policy. */
33
34
  function unavailableFontError(family, style, policy) {
@@ -36,8 +37,9 @@ function unavailableFontError(family, style, policy) {
36
37
  if (!row) return new OPFFontError("font-unavailable", `No local font face for '${family}'. '${family}' is not in the OPF font policy table, so there is no declared replacement: ${hook}, add an alias, or set fallbackFamily.`, {...details, licenseClass:"unknown"});
37
38
  Object.assign(details, {licenseClass:row.licenseClass});
38
39
  if (!row.replacement) {
39
- const pack = packFor(family);
40
- return new OPFFontError("font-unavailable", `No local font face for '${family}'. '${family}' is ${row.licenseClass === "open" ? `openly licensed (${row.license})` : row.license}${pack ? `; load the '${pack}' font pack` : `; no pinned renderer pack ships it yet, so supply its font files (for example from @expo-google-fonts/${family.toLowerCase().replace(/ +/g,"-")})`}.`, {...details, ...(pack?{pack}:{})});
40
+ const pack = packFor(family), npm = pack === "scripts" ? packageFor(family) : undefined;
41
+ const how = npm ? `; install ${npm.name}@${npm.version} (an optional npm package of the 'scripts' font pack)` : pack ? `; load the '${pack}' font pack` : undefined;
42
+ return new OPFFontError("font-unavailable", `No local font face for '${family}'. '${family}' is ${row.licenseClass === "open" ? `openly licensed (${row.license})` : row.license}${how ?? `; no pinned renderer pack ships it yet, so supply its font files (for example from @expo-google-fonts/${family.toLowerCase().replace(/ +/g,"-")})`}.`, {...details, ...(pack?{pack}:{}), ...(npm?{package:npm.name, version:npm.version}:{})});
41
43
  }
42
44
  const {family:replacement, compatibility, measured} = row.replacement;
43
45
  const candidates = [replacement, ...(row.alternates ?? [])], packs = [...new Set(candidates.map(packFor).filter(Boolean))];
@@ -38,7 +38,7 @@ export interface ScriptPackOptions {
38
38
  * `harfbuzz-unavailable` when a harfbuzzjs .wasm (`file`) cannot be loaded, for example in a bundled server that did not ship it:
39
39
  * the handle then has no `subsets`, or shapes outlines with fontkit.
40
40
  */
41
- onDiagnostic?: (diagnostic: {code: string; message: string; script?: string; package?: string; scripts?: string[]; file?: string}) => void;
41
+ onDiagnostic?: (diagnostic: {code: string; message: string; script?: string; package?: string; version?: string; scripts?: string[]; file?: string}) => void;
42
42
  }
43
43
  /** A vendored face that an SVG embeds only when its text names the family (the open families and Intos), and that browser hosts load on demand from a separate hash-pinned file. */
44
44
  export interface LazyFont { readonly package: string; readonly family: string; readonly weight: number; readonly italic: boolean; /** Path relative to the package root, for example fonts/intos/Intos-Regular.ttf. */ readonly file: string; readonly sha256: string; readonly license: string; readonly renamedFrom?: string; /** Set on a host's extra lazy face (`extraLazyFonts`, `package: "host"`): where the host serves the file from. */ readonly url?: string }
@@ -109,7 +109,7 @@ async function withScripts(loaded, scripts, {presentation, onDiagnostic, renderO
109
109
  const selection = scriptSelectionOf(analyzePresentationScripts(presentation, undefined, renderOptions)), skipped = [];
110
110
  const extra = await loadPackages(notLoaded(scriptFontPackages(selection.scripts)), skipped);
111
111
  for (const script of selection.unavailable) onDiagnostic?.({code: "script-font-unavailable", script, message: `No pinned open font serves script '${script}'; that text uses the design font.`});
112
- for (const item of skipped) onDiagnostic?.({code: "script-font-not-installed", package: item.package, scripts: item.scripts, message: `Install ${item.package}@${item.version} to preview ${item.scripts.join(", ")} text with its designated open font.`});
112
+ for (const item of skipped) onDiagnostic?.({code: "script-font-not-installed", package: item.package, version: item.version, scripts: item.scripts, message: `Install ${item.package}@${item.version} to preview ${item.scripts.join(", ")} text with its designated open font.`});
113
113
  return {entries:[...loaded.entries, ...embedUsed(extra.entries)], fontFiles:[...loaded.fontFiles, ...extra.fontFiles], packages:[...(loaded.packages ?? []), ...extra.packages],
114
114
  selection:{...selection, packages: scriptFontPackages(selection.scripts).map(item => item.name).filter(name => !skipped.some(item => item.package === name)), notInstalled: skipped.map(item => item.package)}};
115
115
  }
@@ -135,7 +135,7 @@ async function completeFallback(registry, presentation, loaded, onDiagnostic, re
135
135
  const skipped = [], extra = await loadPackages([next], skipped);
136
136
  if (skipped.length) {
137
137
  selection.notInstalled.push(next.name);
138
- onDiagnostic?.({code: "script-font-not-installed", package: next.name, scripts: [...next.scripts], message: `Install ${next.name}@${next.version} for glyphs the loaded CJK faces lack.`});
138
+ onDiagnostic?.({code: "script-font-not-installed", package: next.name, version: next.version, scripts: [...next.scripts], message: `Install ${next.name}@${next.version} for glyphs the loaded CJK faces lack.`});
139
139
  continue;
140
140
  }
141
141
  registry.addFaces(embedUsed(extra.entries));
@@ -238,7 +238,7 @@ async function ensureFonts(registry, loaded, presentation, {onDiagnostic, render
238
238
  selection.packages.push(...extra.packages);
239
239
  for (const item of skipped) {
240
240
  selection.notInstalled.push(item.package);
241
- onDiagnostic?.({code: "script-font-not-installed", package: item.package, scripts: item.scripts, message: `Install ${item.package}@${item.version} to preview ${item.scripts.join(", ")} text with its designated open font.`});
241
+ onDiagnostic?.({code: "script-font-not-installed", package: item.package, version: item.version, scripts: item.scripts, message: `Install ${item.package}@${item.version} to preview ${item.scripts.join(", ")} text with its designated open font.`});
242
242
  }
243
243
  for (const script of wanted.unavailable) if (!selection.unavailable.includes(script)) {
244
244
  selection.unavailable.push(script);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpresentation/opf-render",
3
- "version": "0.34.0",
3
+ "version": "0.34.1",
4
4
  "description": "Deterministic local OPF renderer for SVG, PNG, and PDF output.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -94,7 +94,7 @@
94
94
  "fontkit": "^2.0.4",
95
95
  "harfbuzzjs": "1.6.4",
96
96
  "pako": "3.0.3",
97
- "@openpresentation/opf": "^0.34.0"
97
+ "@openpresentation/opf": "^0.34.1"
98
98
  },
99
99
  "peerDependencies": {
100
100
  "@expo-google-fonts/arimo": "0.4.3",
@@ -343,7 +343,7 @@
343
343
  "pdfjs-dist": "6.5.438",
344
344
  "playwright": "1.65.0",
345
345
  "sharp": "0.35.5",
346
- "@openpresentation/gallery": "0.34.0"
346
+ "@openpresentation/gallery": "0.34.1"
347
347
  },
348
348
  "bin": {
349
349
  "opf-preview-fonts": "./dist/preview-fonts-cli.js"
@@ -400,5 +400,5 @@
400
400
  "test:preview-a11y-browser": "node test/preview-a11y-browser.mjs",
401
401
  "test:forced-colors-browser": "node test/forced-colors-browser.mjs artifacts/forced-colors"
402
402
  },
403
- "gitHead": "8f395d3d332b48dae0b62a2f767a4153eed7ca18"
403
+ "gitHead": "4dae6c39fee0e0aa3503bceaea02b6e9f142c33f"
404
404
  }