@openmaic/renderer 0.0.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.
Files changed (65) hide show
  1. package/DESIGN.md +247 -0
  2. package/FONTS.md +90 -0
  3. package/LICENSE +21 -0
  4. package/README.md +217 -0
  5. package/dist/SlideCanvas.d.ts +40 -0
  6. package/dist/SlideElement.d.ts +14 -0
  7. package/dist/chunks/BaseCodeElement-Bh-Bfdz6.js +1742 -0
  8. package/dist/chunks/BaseCodeElement-Bh-Bfdz6.js.map +1 -0
  9. package/dist/chunks/SlideCanvas-BwlcjqMl.js +469 -0
  10. package/dist/chunks/SlideCanvas-BwlcjqMl.js.map +1 -0
  11. package/dist/context.d.ts +25 -0
  12. package/dist/effects/HighlightOverlay.d.ts +7 -0
  13. package/dist/effects/LaserOverlay.d.ts +7 -0
  14. package/dist/effects/SpotlightOverlay.d.ts +7 -0
  15. package/dist/effects/ZoomWrapper.d.ts +9 -0
  16. package/dist/effects/index.d.ts +4 -0
  17. package/dist/elements/chart/BaseChartElement.d.ts +6 -0
  18. package/dist/elements/chart/Chart.d.ts +13 -0
  19. package/dist/elements/chart/chartOption.d.ts +15 -0
  20. package/dist/elements/code/BaseCodeElement.d.ts +6 -0
  21. package/dist/elements/image/BaseImageElement.d.ts +13 -0
  22. package/dist/elements/image/ImageOutline.d.ts +5 -0
  23. package/dist/elements/image/clipPaths.d.ts +13 -0
  24. package/dist/elements/image/useClipImage.d.ts +10 -0
  25. package/dist/elements/image/useFilter.d.ts +4 -0
  26. package/dist/elements/index.d.ts +14 -0
  27. package/dist/elements/index.js +10 -0
  28. package/dist/elements/index.js.map +1 -0
  29. package/dist/elements/latex/BaseLatexElement.d.ts +5 -0
  30. package/dist/elements/line/BaseLineElement.d.ts +6 -0
  31. package/dist/elements/line/LinePointMarker.d.ts +11 -0
  32. package/dist/elements/shape/BaseShapeElement.d.ts +5 -0
  33. package/dist/elements/shape/GradientDefs.d.ts +9 -0
  34. package/dist/elements/shape/PatternDefs.d.ts +6 -0
  35. package/dist/elements/shared/ElementOutline.d.ts +7 -0
  36. package/dist/elements/shared/useElementFill.d.ts +4 -0
  37. package/dist/elements/shared/useElementFlip.d.ts +3 -0
  38. package/dist/elements/shared/useElementOutline.d.ts +7 -0
  39. package/dist/elements/shared/useElementShadow.d.ts +4 -0
  40. package/dist/elements/table/BaseTableElement.d.ts +6 -0
  41. package/dist/elements/table/StaticTable.d.ts +6 -0
  42. package/dist/elements/table/tableUtils.d.ts +5 -0
  43. package/dist/elements/text/BaseTextElement.d.ts +6 -0
  44. package/dist/elements/video/BaseVideoElement.d.ts +13 -0
  45. package/dist/hooks/useSlideBackgroundStyle.d.ts +5 -0
  46. package/dist/hooks/useViewportSize.d.ts +27 -0
  47. package/dist/index.d.ts +9 -0
  48. package/dist/index.js +33 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/snapshot/index.d.ts +46 -0
  51. package/dist/snapshot/index.js +347 -0
  52. package/dist/snapshot/index.js.map +1 -0
  53. package/dist/styles.d.ts +12 -0
  54. package/dist/types/effects.d.ts +25 -0
  55. package/dist/types/index.d.ts +2 -0
  56. package/dist/types/index.js +2 -0
  57. package/dist/types/index.js.map +1 -0
  58. package/dist/utils/cn.d.ts +2 -0
  59. package/dist/utils/element.d.ts +21 -0
  60. package/dist/utils/geometry.d.ts +19 -0
  61. package/font-licenses/ARPHIC-PL.txt +58 -0
  62. package/font-licenses/OFL.txt +101 -0
  63. package/font-licenses/ZcoolHappy-LICENSE.txt +16 -0
  64. package/fonts.css +45 -0
  65. package/package.json +94 -0
@@ -0,0 +1,347 @@
1
+ import { createElement } from 'react';
2
+ import { flushSync } from 'react-dom';
3
+ import { createRoot } from 'react-dom/client';
4
+ import html2canvas from 'html2canvas-pro';
5
+ import { S as SlideCanvas } from '../chunks/SlideCanvas-BwlcjqMl.js';
6
+ import 'react/jsx-runtime';
7
+ import 'motion/react';
8
+ import '@openmaic/dsl';
9
+ import '../chunks/BaseCodeElement-Bh-Bfdz6.js';
10
+ import 'tinycolor2';
11
+ import 'echarts/core';
12
+ import 'echarts/charts';
13
+ import 'echarts/components';
14
+ import 'echarts/renderers';
15
+
16
+ const DEFAULT_VIEWPORT_RATIO = 0.5625;
17
+ const DEFAULT_TIMEOUT_MS = 5000;
18
+ /**
19
+ * Render a `Slide` to a PNG image.
20
+ *
21
+ * Throws if called outside a browser (no `document` / `window`), if React
22
+ * fails to mount, or if html2canvas-pro hits a CORS-tainted canvas (cross-
23
+ * origin `<img>` without permissive headers will block the snapshot).
24
+ */
25
+ async function slideToPng(slide, options = {}) {
26
+ if (typeof document === 'undefined') {
27
+ throw new Error('slideToPng requires a browser environment');
28
+ }
29
+ const width = options.width ?? slide.viewportSize ?? 1280;
30
+ const viewportRatio = slide.viewportRatio ?? DEFAULT_VIEWPORT_RATIO;
31
+ const height = Math.round(width * viewportRatio);
32
+ const backgroundColor = options.backgroundColor ?? '#ffffff';
33
+ const pixelRatio = options.pixelRatio ?? window.devicePixelRatio ?? 1;
34
+ const format = options.format ?? 'blob';
35
+ const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
36
+ const debugVisibleMs = options.debugVisibleMs ?? 0;
37
+ // Off-screen container sized exactly to the slide so SlideCanvas's
38
+ // fit-to-container math collapses to a 1:1 native render (no scale, no
39
+ // centering offset). `position: absolute` (not fixed) + far-left offset
40
+ // keeps the element in layout but out of the viewport; some browsers
41
+ // skip paint for `position: fixed` elements outside the viewport, which
42
+ // breaks the snapshot.
43
+ const container = document.createElement('div');
44
+ container.style.cssText = [
45
+ 'position: absolute',
46
+ 'left: -99999px',
47
+ 'top: 0',
48
+ `width: ${width}px`,
49
+ `height: ${height}px`,
50
+ 'pointer-events: none',
51
+ `background-color: ${backgroundColor}`,
52
+ ].join('; ');
53
+ document.body.appendChild(container);
54
+ let root = null;
55
+ try {
56
+ root = createRoot(container);
57
+ // flushSync forces the initial commit to happen synchronously instead of
58
+ // being deferred by React 18's scheduler. Without it, the next RAFs can
59
+ // fire before the first render lands and the snapshot captures an empty
60
+ // container.
61
+ flushSync(() => {
62
+ root.render(createElement(SlideCanvas, { slide, chrome: false }));
63
+ });
64
+ // Give the SlideCanvas's ResizeObserver-driven `useViewportSize` a few
65
+ // frames to fire and write `fitScale`. Default state already paints at
66
+ // 1:1, but waiting avoids a flash of unscaled content when the slide
67
+ // viewportSize differs from the container.
68
+ await nextFrame();
69
+ await nextFrame();
70
+ // Explicitly force-load every (style, weight, family) the slide actually
71
+ // uses BEFORE snapshotting. `document.fonts.ready` alone is racy: it can
72
+ // resolve before the off-screen render has triggered a self-hosted woff2
73
+ // fetch, so html2canvas captures a fallback face. For mixed CJK+Latin text
74
+ // the fallback's Latin/digit advance widths differ from the intended font,
75
+ // shifting number/English runs (seen on cold single-slide exports). Loading
76
+ // each face up front makes the capture deterministic regardless of warmup.
77
+ if (document.fonts && typeof document.fonts.load === 'function') {
78
+ const fontSpecs = new Set();
79
+ container.querySelectorAll('*').forEach((el) => {
80
+ if (!el.textContent || !el.textContent.trim())
81
+ return;
82
+ const cs = getComputedStyle(el);
83
+ if (!cs.fontFamily)
84
+ return;
85
+ fontSpecs.add(`${cs.fontStyle} ${cs.fontWeight} 16px ${cs.fontFamily}`);
86
+ });
87
+ await Promise.race([
88
+ Promise.all([...fontSpecs].map((spec) => document.fonts.load(spec).catch(() => undefined))),
89
+ new Promise((resolve) => setTimeout(resolve, timeoutMs)),
90
+ ]);
91
+ }
92
+ await Promise.race([
93
+ Promise.all([
94
+ document.fonts ? document.fonts.ready : Promise.resolve(),
95
+ ...Array.from(container.querySelectorAll('img')).map((img) => {
96
+ if (img.complete && img.naturalWidth > 0)
97
+ return Promise.resolve();
98
+ return new Promise((resolve) => {
99
+ const done = () => resolve();
100
+ img.addEventListener('load', done, { once: true });
101
+ img.addEventListener('error', done, { once: true });
102
+ });
103
+ }),
104
+ ]),
105
+ new Promise((resolve) => setTimeout(resolve, timeoutMs)),
106
+ ]);
107
+ // html2canvas-pro can't draw <video> elements (it ignores the `poster`
108
+ // attribute and renders nothing for an undecoded source), so a video that
109
+ // shows fine on the live canvas comes out白板 in the PNG. Convert every
110
+ // <video> in the throwaway off-screen tree into an <img> of its poster
111
+ // (or current decoded frame) BEFORE the snapshot so html2canvas captures
112
+ // the same preview frame the canvas shows.
113
+ await Promise.all(Array.from(container.querySelectorAll('video')).map((video) => replaceVideoWithFrame(video)));
114
+ // html2canvas-pro doesn't implement CSS `filter` functions (brightness /
115
+ // contrast / saturate / opacity etc.), so PowerPoint picture corrections —
116
+ // washout via <a:lum bright/contrast> and transparency via <a:alphaModFix>
117
+ // — show on the live canvas but vanish from the exported PNG (the image
118
+ // comes out fully saturated/opaque). Bake each filtered <img> into its
119
+ // pixels with a Canvas2D pass (ctx.filter, which Chrome does support)
120
+ // BEFORE the snapshot so html2canvas captures the corrected bitmap.
121
+ await Promise.all(Array.from(container.querySelectorAll('img')).map((img) => bakeImageFilter(img)));
122
+ // html2canvas-pro also ignores CSS masks, so the soft-edge feather
123
+ // (a:softEdge) set by BaseImageElement vanishes from the PNG. Bake the same
124
+ // feather (two destination-in alpha gradients) into the pixels.
125
+ await Promise.all(Array.from(container.querySelectorAll('img[data-soft-edge]')).map((img) => bakeImageSoftEdge(img)));
126
+ if (process.env.NODE_ENV !== 'production') {
127
+ // eslint-disable-next-line no-console
128
+ console.debug('[slideToPng] container ready', {
129
+ innerHTMLLength: container.innerHTML.length,
130
+ imgCount: container.querySelectorAll('img').length,
131
+ size: `${width}x${height}`,
132
+ });
133
+ }
134
+ // Target the inner SlideCanvas root so html2canvas-pro's bounding-box
135
+ // calculation matches the slide exactly (otherwise the outer container's
136
+ // padding/margin assumptions can leave white edges).
137
+ const target = container.firstElementChild ?? container;
138
+ const canvas = await html2canvas(target, {
139
+ backgroundColor,
140
+ width,
141
+ height,
142
+ scale: pixelRatio,
143
+ useCORS: true,
144
+ // Skip walking the page's stylesheets; the cloned DOM already inherits
145
+ // computed styles. This also avoids CORS errors when the document has
146
+ // cross-origin stylesheets.
147
+ foreignObjectRendering: false,
148
+ logging: false,
149
+ // html2canvas-pro's CJK text measurement can mis-position full-width
150
+ // punctuation (e.g. `(`/`)` get pushed past the cell boundary and
151
+ // appear clipped). Force neutral kerning + feature settings on the
152
+ // cloned tree so each glyph advances at its natural width.
153
+ onclone: (clonedDoc) => {
154
+ const style = clonedDoc.createElement('style');
155
+ style.textContent = `
156
+ .slide-renderer-cell-text,
157
+ .slide-renderer-cell-text *,
158
+ .slide-renderer-prose,
159
+ .slide-renderer-prose * {
160
+ font-kerning: none !important;
161
+ font-feature-settings: normal !important;
162
+ font-variant-east-asian: normal !important;
163
+ text-rendering: geometricPrecision !important;
164
+ }
165
+ `;
166
+ clonedDoc.head.appendChild(style);
167
+ },
168
+ });
169
+ if (format === 'blob') {
170
+ return await canvasToBlob(canvas);
171
+ }
172
+ return canvas.toDataURL('image/png');
173
+ }
174
+ finally {
175
+ if (debugVisibleMs > 0) {
176
+ // Temporarily show the container on-screen so the caller can compare
177
+ // what was captured vs the on-page render.
178
+ container.style.left = '0';
179
+ container.style.top = '0';
180
+ container.style.zIndex = '99999';
181
+ container.style.border = '4px dashed magenta';
182
+ await new Promise((r) => setTimeout(r, debugVisibleMs));
183
+ }
184
+ // Defer unmount one tick so React doesn't warn about unmounting during
185
+ // a commit phase (the html2canvas promise can still be mid-render in
186
+ // dev mode).
187
+ if (root) {
188
+ const r = root;
189
+ setTimeout(() => r.unmount(), 0);
190
+ }
191
+ setTimeout(() => container.remove(), 0);
192
+ }
193
+ }
194
+ function nextFrame() {
195
+ return new Promise((resolve) => requestAnimationFrame(() => resolve()));
196
+ }
197
+ /**
198
+ * Replace a <video> with an <img> showing its poster (or, if no poster is set,
199
+ * its current decoded frame drawn onto a canvas). Copies the video's inline
200
+ * style so layout is unchanged, then waits for the <img> to load so the
201
+ * subsequent html2canvas pass captures it. No-ops if there's nothing to draw.
202
+ */
203
+ async function replaceVideoWithFrame(video) {
204
+ const parent = video.parentElement;
205
+ if (!parent)
206
+ return;
207
+ let imgSrc = video.poster || video.getAttribute('poster') || null;
208
+ // No poster but the source decoded → grab the current frame.
209
+ if (!imgSrc && video.readyState >= 2 && video.videoWidth > 0) {
210
+ try {
211
+ const frame = document.createElement('canvas');
212
+ frame.width = video.videoWidth;
213
+ frame.height = video.videoHeight;
214
+ frame.getContext('2d')?.drawImage(video, 0, 0);
215
+ imgSrc = frame.toDataURL('image/png');
216
+ }
217
+ catch {
218
+ // CORS-tainted frame — leave imgSrc null and bail below.
219
+ }
220
+ }
221
+ if (!imgSrc)
222
+ return;
223
+ const img = document.createElement('img');
224
+ img.src = imgSrc;
225
+ img.style.cssText = video.style.cssText;
226
+ if (!img.style.width)
227
+ img.style.width = '100%';
228
+ if (!img.style.height)
229
+ img.style.height = '100%';
230
+ if (!img.style.objectFit)
231
+ img.style.objectFit = 'contain';
232
+ await new Promise((resolve) => {
233
+ if (img.complete && img.naturalWidth > 0)
234
+ return resolve();
235
+ img.addEventListener('load', () => resolve(), { once: true });
236
+ img.addEventListener('error', () => resolve(), { once: true });
237
+ });
238
+ parent.replaceChild(img, video);
239
+ }
240
+ /**
241
+ * Bake an <img>'s CSS `filter` into its bitmap. html2canvas-pro ignores the
242
+ * `filter` property, so without this any brightness/contrast/saturate/opacity
243
+ * applied by the renderer (PPT lum/alphaModFix corrections) is lost in the PNG.
244
+ * Draws the image through a Canvas2D `ctx.filter` pass, swaps the src for the
245
+ * baked PNG, and clears the inline filter so the value isn't double-applied.
246
+ * No-ops when there's no filter, the image hasn't decoded, or the canvas is
247
+ * CORS-tainted (export would throw — leave the original img untouched).
248
+ */
249
+ async function bakeImageFilter(img) {
250
+ const filter = (img.style.filter || '').trim();
251
+ if (!filter || filter === 'none')
252
+ return;
253
+ if (!img.complete || img.naturalWidth === 0)
254
+ return;
255
+ try {
256
+ const canvas = document.createElement('canvas');
257
+ canvas.width = img.naturalWidth;
258
+ canvas.height = img.naturalHeight;
259
+ const ctx = canvas.getContext('2d');
260
+ if (!ctx)
261
+ return;
262
+ ctx.filter = filter;
263
+ ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
264
+ const baked = canvas.toDataURL('image/png');
265
+ img.style.filter = '';
266
+ await new Promise((resolve) => {
267
+ img.addEventListener('load', () => resolve(), { once: true });
268
+ img.addEventListener('error', () => resolve(), { once: true });
269
+ img.src = baked;
270
+ });
271
+ }
272
+ catch {
273
+ // CORS-tainted source or unsupported ctx.filter — keep the original <img>.
274
+ }
275
+ }
276
+ /**
277
+ * Bake the soft-edge feather (a:softEdge) into an <img>'s bitmap. html2canvas-pro
278
+ * ignores CSS masks, so the feather BaseImageElement applies is lost in the PNG.
279
+ * The feather radius is read from `data-soft-edge` (px in the element's displayed
280
+ * box) and scaled to the image's natural pixels. Two `destination-in` linear
281
+ * gradient passes multiply the alpha down to 0 within `r` of each edge (corners
282
+ * get both axes), matching the live CSS mask. No-ops on undecoded/ CORS-tainted
283
+ * images or zero radius.
284
+ */
285
+ async function bakeImageSoftEdge(img) {
286
+ const rCss = parseFloat(img.dataset.softEdge || '');
287
+ if (!rCss || rCss <= 0)
288
+ return;
289
+ if (!img.complete || img.naturalWidth === 0)
290
+ return;
291
+ const displayedW = img.offsetWidth || img.naturalWidth;
292
+ const scale = img.naturalWidth / displayedW;
293
+ const w = img.naturalWidth;
294
+ const h = img.naturalHeight;
295
+ const r = Math.min(rCss * scale, w / 2, h / 2);
296
+ if (r <= 0)
297
+ return;
298
+ try {
299
+ const canvas = document.createElement('canvas');
300
+ canvas.width = w;
301
+ canvas.height = h;
302
+ const ctx = canvas.getContext('2d');
303
+ if (!ctx)
304
+ return;
305
+ ctx.drawImage(img, 0, 0, w, h);
306
+ ctx.globalCompositeOperation = 'destination-in';
307
+ const stops = (g, extent) => {
308
+ const f = r / extent;
309
+ g.addColorStop(0, 'rgba(0,0,0,0)');
310
+ g.addColorStop(f, 'rgba(0,0,0,1)');
311
+ g.addColorStop(1 - f, 'rgba(0,0,0,1)');
312
+ g.addColorStop(1, 'rgba(0,0,0,0)');
313
+ return g;
314
+ };
315
+ const gh = stops(ctx.createLinearGradient(0, 0, w, 0), w);
316
+ ctx.fillStyle = gh;
317
+ ctx.fillRect(0, 0, w, h);
318
+ const gv = stops(ctx.createLinearGradient(0, 0, 0, h), h);
319
+ ctx.fillStyle = gv;
320
+ ctx.fillRect(0, 0, w, h);
321
+ const baked = canvas.toDataURL('image/png');
322
+ img.removeAttribute('data-soft-edge');
323
+ img.style.maskImage = '';
324
+ img.style.webkitMaskImage = '';
325
+ await new Promise((resolve) => {
326
+ img.addEventListener('load', () => resolve(), { once: true });
327
+ img.addEventListener('error', () => resolve(), { once: true });
328
+ img.src = baked;
329
+ });
330
+ }
331
+ catch {
332
+ // CORS-tainted source — keep the original <img>.
333
+ }
334
+ }
335
+ function canvasToBlob(canvas) {
336
+ return new Promise((resolve, reject) => {
337
+ canvas.toBlob((blob) => {
338
+ if (blob)
339
+ resolve(blob);
340
+ else
341
+ reject(new Error('slideToPng: canvas.toBlob returned null'));
342
+ }, 'image/png');
343
+ });
344
+ }
345
+
346
+ export { slideToPng };
347
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/snapshot/index.ts"],"sourcesContent":["'use client';\n\n/**\n * Off-screen Slide → PNG renderer.\n *\n * Mounts the given `Slide` into an off-screen container at its native pixel\n * size, waits for fonts + images to settle, then snapshots the DOM via\n * `html2canvas-pro`. Returns the rendered output as a Blob (default) or a\n * `data:image/png;base64,...` string.\n *\n * Why html2canvas-pro and not html-to-image: the latter uses an SVG\n * `<foreignObject>` + Image decode path. Fonts inside the foreignObject\n * load asynchronously and the snapshot fires before woff2 decode finishes,\n * so text is laid out in the fallback font (visible as different word-wrap\n * positions vs the on-screen canvas). html2canvas-pro walks the DOM and\n * draws to a canvas directly, inheriting the parent document's font\n * registry, so text wraps identically.\n *\n * Use cases: visual regression baselines (compare with the source PPT's\n * own PNG export), user-triggered \"export slide as image\", CI snapshot\n * jobs. Caller does not need a live `<SlideCanvas>` mounted in the UI.\n */\n\nimport { createElement } from 'react';\nimport { flushSync } from 'react-dom';\nimport { createRoot, type Root } from 'react-dom/client';\nimport html2canvas from 'html2canvas-pro';\nimport { SlideCanvas } from '../SlideCanvas';\nimport type { Slide } from '@openmaic/dsl';\n\nexport interface SlideToPngOptions {\n /**\n * Output pixel width. Defaults to the slide's native `viewportSize`\n * (e.g. 1280 for a 16:9 widescreen deck). Height is derived from\n * `viewportRatio`.\n */\n width?: number;\n /**\n * Multiplier on output resolution. Default tracks `window.devicePixelRatio`\n * (typically 2 on retina displays) so the exported PNG is as sharp as\n * the on-screen canvas. Pass 1 for a lighter file at the cost of\n * sub-pixel clarity.\n */\n pixelRatio?: number;\n /**\n * Background color filled behind the slide. Defaults to white. Pass\n * 'transparent' to keep the slide's own background only.\n */\n backgroundColor?: string;\n /**\n * Output format. 'blob' yields a `Blob` suitable for `URL.createObjectURL`\n * + download; 'dataUrl' yields a `data:image/png;base64,...` string.\n */\n format?: 'blob' | 'dataUrl';\n /**\n * Settle timeout in milliseconds. The snapshot waits for `document.fonts.ready`\n * and every `<img>` inside the container to load (or error) before\n * capturing — but won't wait longer than this. Defaults to 5000.\n */\n timeoutMs?: number;\n /**\n * Debug only — render the off-screen container on-screen for the given\n * number of milliseconds after snapshot so you can visually confirm what\n * was captured. Do not use in production.\n */\n debugVisibleMs?: number;\n}\n\nconst DEFAULT_VIEWPORT_RATIO = 0.5625;\nconst DEFAULT_TIMEOUT_MS = 5000;\n\n/**\n * Render a `Slide` to a PNG image.\n *\n * Throws if called outside a browser (no `document` / `window`), if React\n * fails to mount, or if html2canvas-pro hits a CORS-tainted canvas (cross-\n * origin `<img>` without permissive headers will block the snapshot).\n */\nexport async function slideToPng(\n slide: Slide,\n options: SlideToPngOptions = {},\n): Promise<Blob | string> {\n if (typeof document === 'undefined') {\n throw new Error('slideToPng requires a browser environment');\n }\n\n const width = options.width ?? slide.viewportSize ?? 1280;\n const viewportRatio = slide.viewportRatio ?? DEFAULT_VIEWPORT_RATIO;\n const height = Math.round(width * viewportRatio);\n const backgroundColor = options.backgroundColor ?? '#ffffff';\n const pixelRatio = options.pixelRatio ?? window.devicePixelRatio ?? 1;\n const format = options.format ?? 'blob';\n const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const debugVisibleMs = options.debugVisibleMs ?? 0;\n\n // Off-screen container sized exactly to the slide so SlideCanvas's\n // fit-to-container math collapses to a 1:1 native render (no scale, no\n // centering offset). `position: absolute` (not fixed) + far-left offset\n // keeps the element in layout but out of the viewport; some browsers\n // skip paint for `position: fixed` elements outside the viewport, which\n // breaks the snapshot.\n const container = document.createElement('div');\n container.style.cssText = [\n 'position: absolute',\n 'left: -99999px',\n 'top: 0',\n `width: ${width}px`,\n `height: ${height}px`,\n 'pointer-events: none',\n `background-color: ${backgroundColor}`,\n ].join('; ');\n document.body.appendChild(container);\n\n let root: Root | null = null;\n try {\n root = createRoot(container);\n // flushSync forces the initial commit to happen synchronously instead of\n // being deferred by React 18's scheduler. Without it, the next RAFs can\n // fire before the first render lands and the snapshot captures an empty\n // container.\n flushSync(() => {\n root!.render(createElement(SlideCanvas, { slide, chrome: false }));\n });\n\n // Give the SlideCanvas's ResizeObserver-driven `useViewportSize` a few\n // frames to fire and write `fitScale`. Default state already paints at\n // 1:1, but waiting avoids a flash of unscaled content when the slide\n // viewportSize differs from the container.\n await nextFrame();\n await nextFrame();\n\n // Explicitly force-load every (style, weight, family) the slide actually\n // uses BEFORE snapshotting. `document.fonts.ready` alone is racy: it can\n // resolve before the off-screen render has triggered a self-hosted woff2\n // fetch, so html2canvas captures a fallback face. For mixed CJK+Latin text\n // the fallback's Latin/digit advance widths differ from the intended font,\n // shifting number/English runs (seen on cold single-slide exports). Loading\n // each face up front makes the capture deterministic regardless of warmup.\n if (document.fonts && typeof document.fonts.load === 'function') {\n const fontSpecs = new Set<string>();\n container.querySelectorAll<HTMLElement>('*').forEach((el) => {\n if (!el.textContent || !el.textContent.trim()) return;\n const cs = getComputedStyle(el);\n if (!cs.fontFamily) return;\n fontSpecs.add(`${cs.fontStyle} ${cs.fontWeight} 16px ${cs.fontFamily}`);\n });\n await Promise.race([\n Promise.all([...fontSpecs].map((spec) => document.fonts.load(spec).catch(() => undefined))),\n new Promise<void>((resolve) => setTimeout(resolve, timeoutMs)),\n ]);\n }\n\n await Promise.race([\n Promise.all([\n document.fonts ? document.fonts.ready : Promise.resolve(),\n ...Array.from(container.querySelectorAll('img')).map((img) => {\n if (img.complete && img.naturalWidth > 0) return Promise.resolve();\n return new Promise<void>((resolve) => {\n const done = () => resolve();\n img.addEventListener('load', done, { once: true });\n img.addEventListener('error', done, { once: true });\n });\n }),\n ]),\n new Promise<void>((resolve) => setTimeout(resolve, timeoutMs)),\n ]);\n\n // html2canvas-pro can't draw <video> elements (it ignores the `poster`\n // attribute and renders nothing for an undecoded source), so a video that\n // shows fine on the live canvas comes out白板 in the PNG. Convert every\n // <video> in the throwaway off-screen tree into an <img> of its poster\n // (or current decoded frame) BEFORE the snapshot so html2canvas captures\n // the same preview frame the canvas shows.\n await Promise.all(\n Array.from(container.querySelectorAll('video')).map((video) => replaceVideoWithFrame(video)),\n );\n\n // html2canvas-pro doesn't implement CSS `filter` functions (brightness /\n // contrast / saturate / opacity etc.), so PowerPoint picture corrections —\n // washout via <a:lum bright/contrast> and transparency via <a:alphaModFix>\n // — show on the live canvas but vanish from the exported PNG (the image\n // comes out fully saturated/opaque). Bake each filtered <img> into its\n // pixels with a Canvas2D pass (ctx.filter, which Chrome does support)\n // BEFORE the snapshot so html2canvas captures the corrected bitmap.\n await Promise.all(\n Array.from(container.querySelectorAll('img')).map((img) => bakeImageFilter(img)),\n );\n\n // html2canvas-pro also ignores CSS masks, so the soft-edge feather\n // (a:softEdge) set by BaseImageElement vanishes from the PNG. Bake the same\n // feather (two destination-in alpha gradients) into the pixels.\n await Promise.all(\n Array.from(container.querySelectorAll<HTMLImageElement>('img[data-soft-edge]')).map((img) =>\n bakeImageSoftEdge(img),\n ),\n );\n\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.debug('[slideToPng] container ready', {\n innerHTMLLength: container.innerHTML.length,\n imgCount: container.querySelectorAll('img').length,\n size: `${width}x${height}`,\n });\n }\n\n // Target the inner SlideCanvas root so html2canvas-pro's bounding-box\n // calculation matches the slide exactly (otherwise the outer container's\n // padding/margin assumptions can leave white edges).\n const target = (container.firstElementChild as HTMLElement | null) ?? container;\n\n const canvas = await html2canvas(target, {\n backgroundColor,\n width,\n height,\n scale: pixelRatio,\n useCORS: true,\n // Skip walking the page's stylesheets; the cloned DOM already inherits\n // computed styles. This also avoids CORS errors when the document has\n // cross-origin stylesheets.\n foreignObjectRendering: false,\n logging: false,\n // html2canvas-pro's CJK text measurement can mis-position full-width\n // punctuation (e.g. `(`/`)` get pushed past the cell boundary and\n // appear clipped). Force neutral kerning + feature settings on the\n // cloned tree so each glyph advances at its natural width.\n onclone: (clonedDoc) => {\n const style = clonedDoc.createElement('style');\n style.textContent = `\n .slide-renderer-cell-text,\n .slide-renderer-cell-text *,\n .slide-renderer-prose,\n .slide-renderer-prose * {\n font-kerning: none !important;\n font-feature-settings: normal !important;\n font-variant-east-asian: normal !important;\n text-rendering: geometricPrecision !important;\n }\n `;\n clonedDoc.head.appendChild(style);\n },\n });\n\n if (format === 'blob') {\n return await canvasToBlob(canvas);\n }\n return canvas.toDataURL('image/png');\n } finally {\n if (debugVisibleMs > 0) {\n // Temporarily show the container on-screen so the caller can compare\n // what was captured vs the on-page render.\n container.style.left = '0';\n container.style.top = '0';\n container.style.zIndex = '99999';\n container.style.border = '4px dashed magenta';\n await new Promise((r) => setTimeout(r, debugVisibleMs));\n }\n // Defer unmount one tick so React doesn't warn about unmounting during\n // a commit phase (the html2canvas promise can still be mid-render in\n // dev mode).\n if (root) {\n const r = root;\n setTimeout(() => r.unmount(), 0);\n }\n setTimeout(() => container.remove(), 0);\n }\n}\n\nfunction nextFrame(): Promise<void> {\n return new Promise((resolve) => requestAnimationFrame(() => resolve()));\n}\n\n/**\n * Replace a <video> with an <img> showing its poster (or, if no poster is set,\n * its current decoded frame drawn onto a canvas). Copies the video's inline\n * style so layout is unchanged, then waits for the <img> to load so the\n * subsequent html2canvas pass captures it. No-ops if there's nothing to draw.\n */\nasync function replaceVideoWithFrame(video: HTMLVideoElement): Promise<void> {\n const parent = video.parentElement;\n if (!parent) return;\n\n let imgSrc: string | null = video.poster || video.getAttribute('poster') || null;\n\n // No poster but the source decoded → grab the current frame.\n if (!imgSrc && video.readyState >= 2 && video.videoWidth > 0) {\n try {\n const frame = document.createElement('canvas');\n frame.width = video.videoWidth;\n frame.height = video.videoHeight;\n frame.getContext('2d')?.drawImage(video, 0, 0);\n imgSrc = frame.toDataURL('image/png');\n } catch {\n // CORS-tainted frame — leave imgSrc null and bail below.\n }\n }\n if (!imgSrc) return;\n\n const img = document.createElement('img');\n img.src = imgSrc;\n img.style.cssText = video.style.cssText;\n if (!img.style.width) img.style.width = '100%';\n if (!img.style.height) img.style.height = '100%';\n if (!img.style.objectFit) img.style.objectFit = 'contain';\n\n await new Promise<void>((resolve) => {\n if (img.complete && img.naturalWidth > 0) return resolve();\n img.addEventListener('load', () => resolve(), { once: true });\n img.addEventListener('error', () => resolve(), { once: true });\n });\n\n parent.replaceChild(img, video);\n}\n\n/**\n * Bake an <img>'s CSS `filter` into its bitmap. html2canvas-pro ignores the\n * `filter` property, so without this any brightness/contrast/saturate/opacity\n * applied by the renderer (PPT lum/alphaModFix corrections) is lost in the PNG.\n * Draws the image through a Canvas2D `ctx.filter` pass, swaps the src for the\n * baked PNG, and clears the inline filter so the value isn't double-applied.\n * No-ops when there's no filter, the image hasn't decoded, or the canvas is\n * CORS-tainted (export would throw — leave the original img untouched).\n */\nasync function bakeImageFilter(img: HTMLImageElement): Promise<void> {\n const filter = (img.style.filter || '').trim();\n if (!filter || filter === 'none') return;\n if (!img.complete || img.naturalWidth === 0) return;\n\n try {\n const canvas = document.createElement('canvas');\n canvas.width = img.naturalWidth;\n canvas.height = img.naturalHeight;\n const ctx = canvas.getContext('2d');\n if (!ctx) return;\n ctx.filter = filter;\n ctx.drawImage(img, 0, 0, canvas.width, canvas.height);\n const baked = canvas.toDataURL('image/png');\n\n img.style.filter = '';\n await new Promise<void>((resolve) => {\n img.addEventListener('load', () => resolve(), { once: true });\n img.addEventListener('error', () => resolve(), { once: true });\n img.src = baked;\n });\n } catch {\n // CORS-tainted source or unsupported ctx.filter — keep the original <img>.\n }\n}\n\n/**\n * Bake the soft-edge feather (a:softEdge) into an <img>'s bitmap. html2canvas-pro\n * ignores CSS masks, so the feather BaseImageElement applies is lost in the PNG.\n * The feather radius is read from `data-soft-edge` (px in the element's displayed\n * box) and scaled to the image's natural pixels. Two `destination-in` linear\n * gradient passes multiply the alpha down to 0 within `r` of each edge (corners\n * get both axes), matching the live CSS mask. No-ops on undecoded/ CORS-tainted\n * images or zero radius.\n */\nasync function bakeImageSoftEdge(img: HTMLImageElement): Promise<void> {\n const rCss = parseFloat(img.dataset.softEdge || '');\n if (!rCss || rCss <= 0) return;\n if (!img.complete || img.naturalWidth === 0) return;\n\n const displayedW = img.offsetWidth || img.naturalWidth;\n const scale = img.naturalWidth / displayedW;\n const w = img.naturalWidth;\n const h = img.naturalHeight;\n const r = Math.min(rCss * scale, w / 2, h / 2);\n if (r <= 0) return;\n\n try {\n const canvas = document.createElement('canvas');\n canvas.width = w;\n canvas.height = h;\n const ctx = canvas.getContext('2d');\n if (!ctx) return;\n ctx.drawImage(img, 0, 0, w, h);\n ctx.globalCompositeOperation = 'destination-in';\n\n const stops = (g: CanvasGradient, extent: number) => {\n const f = r / extent;\n g.addColorStop(0, 'rgba(0,0,0,0)');\n g.addColorStop(f, 'rgba(0,0,0,1)');\n g.addColorStop(1 - f, 'rgba(0,0,0,1)');\n g.addColorStop(1, 'rgba(0,0,0,0)');\n return g;\n };\n const gh = stops(ctx.createLinearGradient(0, 0, w, 0), w);\n ctx.fillStyle = gh;\n ctx.fillRect(0, 0, w, h);\n const gv = stops(ctx.createLinearGradient(0, 0, 0, h), h);\n ctx.fillStyle = gv;\n ctx.fillRect(0, 0, w, h);\n\n const baked = canvas.toDataURL('image/png');\n img.removeAttribute('data-soft-edge');\n img.style.maskImage = '';\n (img.style as unknown as Record<string, string>).webkitMaskImage = '';\n await new Promise<void>((resolve) => {\n img.addEventListener('load', () => resolve(), { once: true });\n img.addEventListener('error', () => resolve(), { once: true });\n img.src = baked;\n });\n } catch {\n // CORS-tainted source — keep the original <img>.\n }\n}\n\nfunction canvasToBlob(canvas: HTMLCanvasElement): Promise<Blob> {\n return new Promise((resolve, reject) => {\n canvas.toBlob((blob) => {\n if (blob) resolve(blob);\n else reject(new Error('slideToPng: canvas.toBlob returned null'));\n }, 'image/png');\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAoEA,MAAM,sBAAsB,GAAG,MAAM;AACrC,MAAM,kBAAkB,GAAG,IAAI;AAE/B;;;;;;AAMG;AACI,eAAe,UAAU,CAC9B,KAAY,EACZ,UAA6B,EAAE,EAAA;AAE/B,IAAA,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;AACnC,QAAA,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC;IAC9D;IAEA,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC,YAAY,IAAI,IAAI;AACzD,IAAA,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,IAAI,sBAAsB;IACnE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,aAAa,CAAC;AAChD,IAAA,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,SAAS;IAC5D,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,MAAM,CAAC,gBAAgB,IAAI,CAAC;AACrE,IAAA,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,MAAM;AACvC,IAAA,MAAM,SAAS,GAAG,OAAO,CA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,QAAA,GAAG,CAAC,SAAS,GAAG,EAAE;QAClB,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAExB,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC;AAC3C,QAAA,GAAG,CAAC,eAAe,CAAC,gBAAgB,CAAC;AACrC,QAAA,GAAG,CAAC,KAAK,CAAC,SAAS,GAAG,EAAE;AACvB,QAAA,GAAG,CAAC,KAA2C,CAAC,eAAe,GAAG,EAAE;AACrE,QAAA,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,KAAI;AAClC,YAAA,GAAG,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAC7D,YAAA,GAAG,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAC9D,YAAA,GAAG,CAAC,GAAG,GAAG,KAAK;AACjB,QAAA,CAAC,CAAC;IACJ;AAAE,IAAA,MAAM;;IAER;AACF;AAEA,SAAS,YAAY,CAAC,MAAyB,EAAA;IAC7C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAI;AACrC,QAAA,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,KAAI;AACrB,YAAA,IAAI,IAAI;gBAAE,OAAO,CAAC,IAAI,CAAC;;AAClB,gBAAA,MAAM,CAAC,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;QACnE,CAAC,EAAE,WAAW,CAAC;AACjB,IAAA,CAAC,CAAC;AACJ;;;;"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Package-level CSS rules that can't be expressed inline (descendant selectors,
3
+ * keyframes, pseudo-classes). Rendered once via `<style>` at the top of
4
+ * `<SlideCanvas>` so the package stays self-contained without Tailwind.
5
+ *
6
+ * The `.slide-renderer-prose` rules are intentionally minimal "browser-default
7
+ * resets" — they un-do the user-agent stylesheet (1em <p> margin, KaTeX block
8
+ * margin) so the slide JSON is the single source of truth. They do not
9
+ * positively style anything; spacing comes from the data via the
10
+ * `--paragraphSpace` CSS variable, which is unset when undefined in data.
11
+ */
12
+ export declare const SLIDE_RENDERER_STYLES = "\n.slide-renderer-prose p {\n margin-top: 0;\n margin-bottom: var(--paragraphSpace, 0);\n}\n.slide-renderer-prose p:last-child {\n margin-bottom: 0;\n}\n.slide-renderer-prose .katex-display {\n margin: 0 !important;\n}\n/* Table cell inner container \u2014 matches the classroom (Vue) .cell-text design:\n tight base line-height, and a small spacing between adjacent <p> siblings\n so multi-paragraph cells don't collapse into a single visual block. The\n <p> margin reset above sets the baseline to 0; this rule re-adds spacing\n only between adjacent siblings, leaving the first/last paragraph flush. */\n.slide-renderer-cell-text p + p {\n margin-top: 0.4em;\n}\n@keyframes slide-renderer-pulse {\n 50% { opacity: 0.5; }\n}\n@keyframes slide-renderer-ping {\n 75%, 100% { transform: scale(2); opacity: 0; }\n}\n@keyframes slide-renderer-code-cursor-blink {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0; }\n}\n.slide-renderer-pulse {\n animation: slide-renderer-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n}\n.slide-renderer-ping {\n animation: slide-renderer-ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;\n}\n";
@@ -0,0 +1,25 @@
1
+ export interface LaserEffectOptions {
2
+ elementId: string;
3
+ color?: string;
4
+ duration?: number;
5
+ }
6
+ export interface SpotlightEffectOptions {
7
+ elementId: string;
8
+ }
9
+ export interface HighlightEffectOptions {
10
+ elementId: string;
11
+ color?: string;
12
+ opacity?: number;
13
+ borderWidth?: number;
14
+ animated?: boolean;
15
+ }
16
+ export interface ZoomEffectOptions {
17
+ elementId: string;
18
+ scale: number;
19
+ }
20
+ export interface SlideEffects {
21
+ laser?: LaserEffectOptions;
22
+ spotlight?: SpotlightEffectOptions;
23
+ highlight?: HighlightEffectOptions;
24
+ zoom?: ZoomEffectOptions;
25
+ }
@@ -0,0 +1,2 @@
1
+ export * from '@openmaic/dsl';
2
+ export * from './effects';
@@ -0,0 +1,2 @@
1
+ export * from '@openmaic/dsl';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import { type ClassValue } from 'clsx';
2
+ export declare function cn(...inputs: ClassValue[]): string;
@@ -0,0 +1,21 @@
1
+ import type { PPTElement, PPTLineElement } from '@openmaic/dsl';
2
+ interface RotatedElementData {
3
+ left: number;
4
+ top: number;
5
+ width: number;
6
+ height: number;
7
+ rotate: number;
8
+ }
9
+ export declare const getRectRotatedRange: (element: RotatedElementData) => {
10
+ xRange: number[];
11
+ yRange: number[];
12
+ };
13
+ export declare const getElementRange: (element: PPTElement) => {
14
+ minX: number;
15
+ maxX: number;
16
+ minY: number;
17
+ maxY: number;
18
+ };
19
+ export declare const getTableSubThemeColor: (themeColor: string) => string[];
20
+ export declare const getLineElementPath: (element: PPTLineElement) => string;
21
+ export {};
@@ -0,0 +1,19 @@
1
+ import type { PPTElement } from '@openmaic/dsl';
2
+ /**
3
+ * Percentage-based geometry (0-100 coordinate system)
4
+ * Used by spotlight/laser overlays for responsive positioning.
5
+ */
6
+ export interface PercentageGeometry {
7
+ x: number;
8
+ y: number;
9
+ w: number;
10
+ h: number;
11
+ centerX: number;
12
+ centerY: number;
13
+ }
14
+ export declare function getElementPercentageGeometry(element: PPTElement, viewportSize?: number): PercentageGeometry | null;
15
+ export declare function findElementGeometry(elements: PPTElement[], elementId: string, viewportSize?: number): PercentageGeometry | null;
16
+ export declare function findNearestCorner(geometry: PercentageGeometry): {
17
+ x: number;
18
+ y: number;
19
+ };
@@ -0,0 +1,58 @@
1
+ ARPHIC PUBLIC LICENSE
2
+
3
+ Copyright (C) 1999 Arphic Technology Co., Ltd.
4
+ 11Fl. No.168, Yung Chi Rd., Taipei, 110 Taiwan
5
+ All rights reserved except as specified below.
6
+
7
+ Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is forbidden.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your freedom to share and change it. By contrast, the ARPHIC PUBLIC LICENSE specifically permits and encourages you to use this software, provided that you give the recipients all the rights that we gave you and make sure they can get the modifications of this software.
12
+
13
+ Legal Terms
14
+
15
+ 0. Definitions:
16
+ Throughout this License, "Font" means the TrueType fonts "AR PL Mingti2L Big5", "AR PL KaitiM Big5" (BIG-5 character set) and "AR PL SungtiL GB", "AR PL KaitiM GB" (GB character set) which are originally distributed by Arphic, and the derivatives of those fonts created through any modification including modifying glyph, reordering glyph, converting format, changing font name, or adding/deleting some characters in/from glyph table.
17
+
18
+ "PL" means "Public License".
19
+
20
+ "Copyright Holder" means whoever is named in the copyright or copyrights for the Font.
21
+
22
+ "You" means the licensee, or person copying, redistributing or modifying the Font.
23
+
24
+ "Freely Available" means that you have the freedom to copy or modify the Font as well as redistribute copies of the Font under the same conditions you received, not price. If you wish, you can charge for this service.
25
+
26
+ 1. Copying & Distribution
27
+ You may copy and distribute verbatim copies of this Font in any medium, without restriction, provided that you retain this license file (ARPHICPL.TXT) unaltered in all copies.
28
+
29
+ 2. Modification
30
+ You may otherwise modify your copy of this Font in any way, including modifying glyph, reordering glyph, converting format, changing font name, or adding/deleting some characters in/from glyph table, and copy and distribute such modifications under the terms of Section 1 above, provided that the following conditions are met:
31
+
32
+ a) You must insert a prominent notice in each modified file stating how and when you changed that file.
33
+
34
+ b) You must make such modifications Freely Available as a whole to all third parties under the terms of this License, such as by offering access to copy the modifications from a designated place, or distributing the modifications on a medium customarily used for software interchange.
35
+
36
+ c) If the modified fonts normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the Font under these conditions, and telling the user how to view a copy of this License.
37
+
38
+ These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Font, and can be reasonably considered independent and separate works in themselves, then this License and its terms, do not apply to those sections when you distribute them as separate works. Therefore, mere aggregation of another work not based on the Font with the Font on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
39
+
40
+ 3. Condition Subsequent
41
+ You may not copy, modify, sublicense, or distribute the Font except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Font will automatically retroactively void your rights under this License. However, parties who have received copies or rights from you under this License will keep their licenses valid so long as such parties remain in full compliance.
42
+
43
+ 4. Acceptance
44
+ You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to copy, modify, sublicense or distribute the Font. These actions are prohibited by law if you do not accept this License. Therefore, by copying, modifying, sublicensing or distributing the Font, you indicate your acceptance of this License and all its terms and conditions.
45
+
46
+ 5. Automatic Receipt
47
+ Each time you redistribute the Font, the recipient automatically receives a license from the original licensor to copy, distribute or modify the Font subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
48
+
49
+ 6. Contradiction
50
+ If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Font at all. For example, if a patent license would not permit royalty-free redistribution of the Font by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Font.
51
+
52
+ If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
53
+
54
+ 7. NO WARRANTY
55
+ BECAUSE THE FONT IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE FONT, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS OR OTHER PARTIES PROVIDE THE FONT "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE FONT IS WITH YOU. SHOULD THE FONT PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
56
+
57
+ 8. DAMAGES WAIVER
58
+ UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, IN NO EVENT WILL ANY COPYRIGHTT HOLDERS, OR OTHER PARTIES WHO MAY COPY, MODIFY OR REDISTRIBUTE THE FONT AS PERMITTED ABOVE, BE LIABLE TO YOU FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR EXEMPLARY DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE FONT (INCLUDING BUT NOT LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA OR PROFITS; OR BUSINESS INTERRUPTION), EVEN IF SUCH HOLDERS OR OTHER PARTIES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.