@openpresentation/opf-render 0.35.0 → 0.36.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.
@@ -56,7 +56,9 @@ export function reserveAxisTitles(c, spec, titles) {
56
56
  /**
57
57
  * Draw the axis titles after the chart: the bottom title centered under the plot, the left title rotated 270 degrees
58
58
  * (reading upwards, as PowerPoint draws a vertical axis title) and centered on the plot. `c.plotArea` is the plot the
59
- * renderer laid out; without one the title centers on the reserved band.
59
+ * renderer laid out; without one the title centers on the reserved band. A bar chart drawn on a table's rows (LH-115, `c.alignedRows`)
60
+ * has a plot shorter than its box: its bottom title sits right under the tick labels (core keeps the chart's parts together around the
61
+ * rows, as PowerPoint sets an axis title beside its axis), not at the foot of the box.
60
62
  */
61
63
  export function drawAxisTitles(c) {
62
64
  if (!c.axisTitleBands?.length) return;
@@ -65,7 +67,9 @@ export function drawAxisTitles(c) {
65
67
  const path = `${c.path}.axisTitles.${axis}`;
66
68
  if (side === "bottom") {
67
69
  const span = plot ? { x: plot.x, width: plot.width } : { x: inner.x, width: inner.width };
68
- const rect = { x: span.x, y: outer.y + outer.height - c.lineHeight, width: span.width, height: c.lineHeight };
70
+ const foot = outer.y + outer.height - c.lineHeight;
71
+ const y = c.alignedRows && plot ? Math.min(foot, plot.y + plot.height + (c.valueAxisHidden ? 0 : c.lineHeight)) : foot;
72
+ const rect = { x: span.x, y, width: span.width, height: c.lineHeight };
69
73
  c.text(text, rect, path, "center");
70
74
  } else {
71
75
  const span = plot ? { y: plot.y, height: plot.height } : { y: inner.y, height: inner.height };
package/dist/fonts.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { TextMeasurement, TextStyle, ScriptRole } from "@openpresentation/opf/composition";
1
+ import type { ResolvedScriptFonts, TextMeasurement, TextStyle, ScriptRole } from "@openpresentation/opf/composition";
2
2
  import type { FontPolicyEntry } from "@openpresentation/opf/font-policy";
3
3
  import type { LazyFont } from "./fonts-node.js";
4
4
  import type {ToSvgOptions} from "./svg.js";
@@ -124,7 +124,7 @@ export interface ScriptFontProfile {
124
124
  heading?: ScriptFontSlots; body?: ScriptFontSlots;
125
125
  supplement?: { script: string; heading: string; body: string };
126
126
  script?: string; bcp47?: string; lang?: string; direction?: "ltr" | "rtl"; rtl?: boolean;
127
- languageSource?: "document" | "option" | "default"; scriptRole?: ScriptRole; serif?: boolean;
127
+ languageSource?: ResolvedScriptFonts["languageSource"]; scriptRole?: ScriptRole; serif?: boolean;
128
128
  }
129
129
  export interface ScriptRun { text: string; script: string; role: ScriptRole }
130
130
  export interface PlannedRun { text: string; family: string; own: boolean; stack?: string[] }
@@ -1,3 +1,4 @@
1
+ import {svgHslStopsToSrgb} from '@openpresentation/opf/composition';
1
2
  import {OPFRenderError} from './svg.js';
2
3
  import {isConverterMissing,loadConverter} from './converters.js';
3
4
 
@@ -37,16 +38,29 @@ export async function prepareRasterImages(svg, {nestedSvg} = {}) {
37
38
  return output + svg.slice(end);
38
39
  }
39
40
 
41
+ // The HSL stop forms resvg reads as a browser does (measured with resvg 2.6.2): an integer hue without a unit, integer
42
+ // percentages, commas or spaces between them and an optional alpha number after a fourth comma. resvg draws every other valid
43
+ // form black or not at all (the slash alpha, number-only, a hue unit, decimals, a percentage alpha), so only those are converted:
44
+ // a form resvg draws keeps its bytes and its pixels (resvg truncates where the conversion rounds, a one-level difference).
45
+ const RESVG_HSL = /^hsla?\(\s*[+-]?\d+\s*(?:,\s*|\s+)\d+%\s*(?:,\s*|\s+)\d+%\s*(?:,\s*(?:\d+(?:\.\d*)?|\.\d+)\s*)?\)$/i;
46
+
40
47
  // An SVG picture that draws text is rendered to PNG here (transparent, up to 4x its size) so its text uses the render's fonts;
41
- // one without text stays vector for resvg.
48
+ // one without text stays vector for resvg. Either way the HSL gradient stops resvg cannot read are first converted to sRGB
49
+ // (opf#1438, the conversion the PPTX export applies), so the PNG draws what a browser draws. A picture with nothing to convert
50
+ // keeps its bytes.
42
51
  async function prepareSvgImage(uri, nestedSvg) {
43
- if (!nestedSvg) return null;
44
52
  const comma = uri.indexOf(',');
45
53
  const header = uri.slice(0, comma), data = uri.slice(comma + 1);
46
- const text = /;base64$/i.test(header) ? Buffer.from(decodeURIComponent(data).replace(/\s/g, ''), 'base64').toString('utf8') : decodeURIComponent(data);
47
- if (!/<(?:[A-Za-z_][\w.-]*:)?text[\s>/]/.test(text)) return null;
48
- // A document resvg cannot read stays as it is: resvg then draws nothing for it, as for any broken picture.
49
- try { return 'data:image/png;base64,' + Buffer.from(await nestedSvg(text)).toString('base64'); } catch { return null; }
54
+ let source;
55
+ try {
56
+ source = /;base64$/i.test(header) ? Buffer.from(decodeURIComponent(data).replace(/\s/g, ''), 'base64').toString('utf8') : decodeURIComponent(data);
57
+ } catch { return null; }
58
+ const text = svgHslStopsToSrgb(source, {keep: value => RESVG_HSL.test(value)});
59
+ if (nestedSvg && /<(?:[A-Za-z_][\w.-]*:)?text[\s>/]/.test(text)) {
60
+ // A document resvg cannot read stays as it is: resvg then draws nothing for it, as for any broken picture.
61
+ try { return 'data:image/png;base64,' + Buffer.from(await nestedSvg(text)).toString('base64'); } catch { return null; }
62
+ }
63
+ return text === source ? null : 'data:image/svg+xml;base64,' + Buffer.from(text, 'utf8').toString('base64');
50
64
  }
51
65
 
52
66
  async function prepareRasterImage(uri) {
package/dist/shapes.js CHANGED
@@ -2,7 +2,7 @@
2
2
  //
3
3
  // A shape block (core ComposedItem.shape) is drawn from core's evaluated geometry (SH-01 presetGeometry, in slide coordinates):
4
4
  // each path filled in its DrawingML mode (norm, or the fill shaded by lighten, lightenLess, darken and darkenLess) and stroked where
5
- // the path takes the line, in order; then the text, fitted by core in shape.textArea; then the effects (SH-03's effectsSvg through drawEffects) wrap the outline and the text. The
5
+ // the path takes the line, all fills before all lines (renderShapeBlock says why); then the text, fitted by core in shape.textArea; then the effects (SH-03's effectsSvg through drawEffects) wrap the outline and the text. The
6
6
  // whole drawing turns about the frame's center (rotate) and mirrors (flip); the text turns with it but is not mirrored, and a vertical
7
7
  // flip turns it upside down, as PowerPoint draws it. The PPTX export writes the same shape natively (opf-pptx src/shape-blocks.js).
8
8
  //
@@ -254,6 +254,13 @@ export function renderShapeBlock(item, helpers) {
254
254
  const id = `${helpers.idPrefix}-shape-${item.path.replace(/[^A-Za-z0-9]+/g, "-")}`, box = shape.box, defs = [], parts = [];
255
255
  const effects = drawEffects(shape, id, helpers);
256
256
  if (effects.defs) defs.push(effects.defs);
257
+ // Paint order of a preset's paths: every path's fill first, in path order, then every path's line, in path order. A later path's
258
+ // fill never covers an earlier path's line. ECMA-376 (Part 1, 20.1.9.15 path) gives each path its own fill and stroke but no paint
259
+ // order across paths; this is the order PowerPoint 365 draws (qualification deck coverage-shape-presets): chartX, chartStar and
260
+ // chartPlus list their lines first (fill="none") and the square after them (stroke="false"), and PowerPoint and Keynote draw the lines
261
+ // over the square (slide 16); cloudCallout's overlapping bubbles each show their whole outline through the next one's fill (slide 10).
262
+ // Of the 187 presets drawn with their defaults only these four change; in every other one the lines are already the last paths.
263
+ const lines = [];
257
264
  shape.paths.forEach((path, index) => {
258
265
  const fill = fillPaint(shape.fill, path.fill, `${id}-fill-${index}`, box, helpers, shape, path);
259
266
  if (fill.defs) defs.push(fill.defs);
@@ -271,9 +278,10 @@ export function renderShapeBlock(item, helpers) {
271
278
  // A sketched line (core stroke.sketched) is drawn along its sketched outline, as PowerPoint draws it.
272
279
  const stroke = strokeElements(shape.stroke, shape.stroke.sketched?.lines[index] ?? path.d, `${id}-line-${index}`, { box, closed, ends: path.ends, helpers });
273
280
  if (stroke.defs) defs.push(stroke.defs);
274
- parts.push(stroke.elements);
281
+ lines.push(stroke.elements);
275
282
  }
276
283
  });
284
+ parts.push(...lines);
277
285
  const cx = box.x + box.width / 2, cy = box.y + box.height / 2;
278
286
  const turn = shape.rotate ? `rotate(${number(shape.rotate)} ${number(cx)} ${number(cy)})` : "";
279
287
  const mirror = shape.flipH || shape.flipV ? `translate(${number(cx)} ${number(cy)}) scale(${shape.flipH ? -1 : 1} ${shape.flipV ? -1 : 1}) translate(${number(-cx)} ${number(-cy)})` : "";
package/dist/svg.js CHANGED
@@ -1710,11 +1710,11 @@ function renderTimeline(item, box, bound, options) {
1710
1710
  if(!layout)throw new OPFRenderError('missing-timeline-layout','Timeline rendering requires a coordinated core build with shared timeline geometry.',{path:item.path});
1711
1711
  const scale=Math.min(bound.design.dimensions.width,bound.design.dimensions.height)/720;
1712
1712
  const background=bound.design.backgroundColor??bound.design.colors.background;
1713
- const children=[tag('line',{...HIDDEN,...layout.connector,stroke:bound.design.colors.border,'stroke-width':3*scale,...traceAttrs(options,item.path)})];
1713
+ const children=[tag('line',{...HIDDEN,...layout.connector,stroke:bound.design.colors.border,'stroke-width':layout.lineWidth??3*scale,...traceAttrs(options,item.path)})];
1714
1714
  for(const range of layout.ranges??[])children.push(tag('rect',{...HIDDEN,x:stableNumber(range.box.x),y:stableNumber(range.box.y),width:stableNumber(range.box.width),height:stableNumber(range.box.height),fill:bound.design.colors.primary,'fill-opacity':.32,stroke:background,'stroke-width':stableNumber(2*scale),...traceAttrs(options,range.path),...(options.trace?{'data-opf-timeline-range':range.eventIndex}:{})}));
1715
1715
  for(const link of layout.rangeLinks??[])children.push(tag('line',{...HIDDEN,x1:stableNumber(link.x1),y1:stableNumber(link.y1),x2:stableNumber(link.x2),y2:stableNumber(link.y2),stroke:bound.design.colors.border,'stroke-width':stableNumber(scale),...traceAttrs(options,link.path),...(options.trace?{'data-opf-timeline-range-link':link.eventIndex}:{})}));
1716
1716
  // LH-121: the connector up to the current event in the primary color, over the border-colored rest.
1717
- if(layout.progress)children.push(tag('line',{...HIDDEN,...layout.progress,stroke:bound.design.colors.primary,'stroke-width':3*scale,...traceAttrs(options,item.path),...(options.trace?{'data-opf-timeline-progress':'true'}:{})}));
1717
+ if(layout.progress)children.push(tag('line',{...HIDDEN,...layout.progress,stroke:bound.design.colors.primary,'stroke-width':layout.lineWidth??3*scale,...traceAttrs(options,item.path),...(options.trace?{'data-opf-timeline-progress':'true'}:{})}));
1718
1718
  // FA-11: status colors come from the deck (core's timelineMarkerShapes / timelineTextColor); a marker with no status draws the plain primary circle.
1719
1719
  const statusColors={background,primary:bound.design.colors.primary,text:bound.design.colors.text,mutedText:bound.design.colors.mutedText};
1720
1720
  for(const marker of layout.markers){
@@ -2309,7 +2309,8 @@ function trimRichLineEdges(line,textMeasurement) {
2309
2309
  if(!changed)return null;
2310
2310
  let x=0;
2311
2311
  for(const fragment of fragments){fragment.x=x;x+=fragment.width;}
2312
- return {...line,fragments,width:x};
2312
+ // The trimmed line is its glyphs: no whitespace hangs from it any more.
2313
+ return {...line,fragments,width:x,hang:undefined,advance:undefined};
2313
2314
  }
2314
2315
 
2315
2316
  function richLineContext(value,fit,bound,config) {
@@ -2346,8 +2347,12 @@ function renderRichLines(value,fit,box,bound,config) {
2346
2347
  const {edgeTrim,line,placed,baseline}=richLineGeometry(sourceLine,lineIndex,fit,box,bound,alignment,rtl,config.options.textMeasurement);
2347
2348
  const lineHasTab=line.fragments.some(fragment=>fragment.kind==='tab');
2348
2349
  const flow=naturalFlow&&!lineHasTab;
2349
- const offset=alignment==='right'?box.width-line.width:alignment==='center'?(box.width-line.width)/2:0;
2350
- const originX=placed?placed.x+(edgeTrim?sourceLine.width-line.width:0):box.x+offset;
2350
+ // Whitespace that hangs at a soft wrap (core's RichTextLine.hang) takes no room: the line is aligned by its glyphs and its text,
2351
+ // whitespace included, reaches past them on its end side (the left of a right-to-left line). Core placed a measured line so already.
2352
+ // `span` is the advance of the text the line draws, from originX.
2353
+ const hang=line.hang>0?line.hang:0,span=hang?line.advance:line.width,glyphs=span-hang,hangLead=rtl?hang:0;
2354
+ const offset=(alignment==='right'?box.width-glyphs:alignment==='center'?(box.width-glyphs)/2:0)-hangLead;
2355
+ const originX=placed?placed.x+(edgeTrim?(sourceLine.hang>0?sourceLine.advance:sourceLine.width)-line.width:0):box.x+offset;
2351
2356
  const firstFragment=line.fragments[0];
2352
2357
  const renderFragment=(fragment,asFlow,edges={})=>{
2353
2358
  const run=fragment.run;
@@ -2356,7 +2361,7 @@ function renderRichLines(value,fit,box,bound,config) {
2356
2361
  // quantization drift. Height and baseline retain the selected font size.
2357
2362
  // A right-to-left line places its fragments from the right edge (FF-19).
2358
2363
  // Estimated (natural-flow) lines keep logical order; the browser reorders them.
2359
- const fragmentX=rtl&&!naturalFlow?line.width-fragment.x-fragment.width:fragment.x;
2364
+ const fragmentX=rtl&&!naturalFlow?span-fragment.x-fragment.width:fragment.x;
2360
2365
  const position=asFlow?{'baseline-shift':fragment.baselineShift?stableNumber(-fragment.baselineShift):undefined}:{x:stableNumber(originX+fragmentX),y:stableNumber(baseline+fragment.baselineShift)};
2361
2366
  // A link run is drawn as PowerPoint draws one: underlined, in the scheme hyperlink color unless the run sets its own color.
2362
2367
  const linked = fragment.kind !== 'marker' && typeof run.link === 'string' && LINK_URL.test(run.link);
@@ -2420,7 +2425,8 @@ function renderRichLines(value,fit,box,bound,config) {
2420
2425
  // A flowing right-to-left line is one isolate across its fragments.
2421
2426
  const fragments=line.fragments.map((fragment,index)=>renderFragment(fragment,flow,flow?{first:rtl&&!index,last:rtl&&index===line.fragments.length-1}:{}));
2422
2427
  if(!flow)return fragments.join('\n');
2423
- const x=alignment==='right'?box.x+box.width:alignment==='center'?box.x+box.width/2:box.x;
2428
+ const factor=alignment==='right'?1:alignment==='center'?.5:0;
2429
+ const x=(alignment==='right'?box.x+box.width:alignment==='center'?box.x+box.width/2:box.x)+hang*(rtl?factor-1:factor);
2424
2430
  const first=line.fragments[0];
2425
2431
  return tag('text',{x:stableNumber(x),y:stableNumber(baseline),'text-anchor':alignment==='right'?'end':alignment==='center'?'middle':'start','xml:space':'preserve','font-family':fontStack(first?.style.fontFamily??config.fontFamily,bound.design.fontScheme.type),'font-size':stableNumber(first?.fontSize??fit.fontSize),'font-weight':first?.style.fontWeight??config.fontWeight??400,'font-style':first?.style.italic?'italic':undefined,[NO_POLICY_FEATURES]:true},fragments.join(''));
2426
2432
  });
@@ -2430,7 +2436,9 @@ function renderRichLines(value,fit,box,bound,config) {
2430
2436
  if(index){const newline=/^(\r\n|\r|\n)/.exec(whole.slice(cursor));if(newline)cursor+=newline[0].length;}
2431
2437
  const start=cursor;cursor+=(fit.lines[index]??'').length;
2432
2438
  const alignment=lineAlignment(index);
2433
- const offset=alignment==='right'?box.width-line.width:alignment==='center'?(box.width-line.width)/2:0;
2439
+ // The line's start: its glyphs aligned, any whitespace hanging at its wrap after them (as drawn above).
2440
+ const glyphs=line.hang>0?line.advance-line.hang:line.width,hangLead=line.hang>0&&fit.directions?.[index]==='rtl'?line.hang:0;
2441
+ const offset=(alignment==='right'?box.width-glyphs:alignment==='center'?(box.width-glyphs)/2:0)-hangLead;
2434
2442
  const placed=fit.placement?.lines[index];
2435
2443
  return {start,end:cursor,x:placed?.x??box.x+offset,y:placed?.y??box.y+line.y,height:placed?.height??line.height,
2436
2444
  ...(naturalFlow&&line.fragments.some(fragment=>fragment.kind==='tab')?{spacing:'natural-chunks-estimated-tabs'}:{})};
@@ -2475,7 +2483,15 @@ function renderTextBox(text, box, bound, config) {
2475
2483
  // The line's paragraph decides its direction: source offsets when layout has them, else the next match.
2476
2484
  const found=sourceLine?sourceLine.start:source.indexOf(line,cursor),lineStart=found>=0?found:cursor;cursor=lineStart+line.length;
2477
2485
  const rtl=fit.directions?fit.directions[index]==='rtl':boxRtl(lineStart);
2478
- const origin=placed?.x??x-(sourceLine?.width??0)*factor;
2486
+ // Whitespace that hangs at a soft wrap (core's TextLineSource.hang) takes no room: the glyphs are aligned and the text, its
2487
+ // whitespace included, reaches past them on the line's end side (the right of a left-to-right line, the left of a right-to-left
2488
+ // one). Core placed a measured line so already (placed.x, placed.width); `shift` is how far the text's anchor is from the glyphs'.
2489
+ const hang=placed?placed.hang??0:sourceLine?.hang>0?sourceLine.hang:0,lineRtl=placed?fit.directions?.[index]==='rtl':rtl;
2490
+ // A right-to-left line is drawn without its hanging whitespace, by its glyphs (below), as its native paragraph is anchored.
2491
+ const hangShift=lineRtl?0:hang*factor,hangLead=lineRtl?hang:0;
2492
+ const origin=placed?.x??x-((sourceLine?.advance??sourceLine?.width??0)-hang)*factor-hangLead;
2493
+ // The anchor point of the glyphs (the box edge or center), which an editor lays its input on.
2494
+ const glyphAnchor=placed?placed.x+hangLead+(placed.width-hang)*factor:x;
2479
2495
  const tabs=sourceLine?.segments.some(segment=>segment.kind==='tab');
2480
2496
  let content,family,positioned=false,trimWidth=0,sizeAdjust,shift=0;
2481
2497
  if(tabs) content=sourceLine.segments.map(segment=>{
@@ -2494,8 +2510,12 @@ function renderTextBox(text, box, bound, config) {
2494
2510
  else {
2495
2511
  // PowerPoint ignores whitespace at either edge of a right-aligned right-to-left line (the glyph edge stays on the box edge, native check
2496
2512
  // 2026-10-02), so a soft-wrapped line that keeps its trailing space, or a leading space, draws without it (RR-05).
2497
- const edge=rtl&&alignment==='right'?/^(\s*)([\s\S]*?)(\s*)$/.exec(line):null,trimmed=edge&&edge[2]&&(edge[1]||edge[3])?edge:null;
2498
- if(trimmed){const measureEdge=textWidthMeasurer(style,config.options.textMeasurement);trimWidth=measureEdge(trimmed[1],size)+measureEdge(trimmed[3],size);}
2513
+ // A right-to-left line of any other alignment draws without the whitespace that hangs at its wrap too: the SVG sets it in an isolate
2514
+ // in a left-to-right text, where trailing whitespace would go to the right (Unicode bidi L1), while core and PowerPoint hang it on
2515
+ // the line's left; the glyphs are drawn where core aligned them (glyphAnchor).
2516
+ const edge=rtl&&alignment==='right'?/^(\s*)([\s\S]*?)(\s*)$/.exec(line):rtl&&hang>0?/^()([\s\S]*?)(\s*)$/.exec(line):null,trimmed=edge&&edge[2]&&(edge[1]||edge[3])?edge:null;
2517
+ // The whitespace that hangs at the wrap is core's measured hang (the advance its placement leaves for it).
2518
+ if(trimmed){const measureEdge=textWidthMeasurer(style,config.options.textMeasurement);trimWidth=measureEdge(trimmed[1],size)+(placed&&hang&&trimmed[3]?hang:measureEdge(trimmed[3],size));}
2499
2519
  ({content,family,positioned=false,sizeAdjust,baselineShift:shift=0}=scriptLine(styledText(trimmed?trimmed[2]:line,style),style,bound,type,{rtl,placement:placed?.width>0?{x:placed.x+trimWidth,width:placed.width-trimWidth,fontSize:size}:undefined,fontSize:size}));
2500
2520
  }
2501
2521
  // Positioned script runs carry their own x and textLength (FF-19).
@@ -2511,8 +2531,9 @@ function renderTextBox(text, box, bound, config) {
2511
2531
  // rasterizer, so the line starts there instead of hanging from its middle or end. Estimated widths keep the anchor: the shaper's
2512
2532
  // width differs from core's there, and the anchor keeps the edge.
2513
2533
  const exactStart=!start&&factor>0&&style.tracking<0&&!rtl&&!trimWidth&&!!config.options.textMeasurement?.measure&&(placed?.width>0||sourceLine?.width>0);
2534
+ const hung=!start&&hangShift!==0;
2514
2535
  return tag("text", {
2515
- x: stableNumber(tabs||exactStart?origin:positioned?placed.x:placed?placed.x+placed.width*factor:x), y: stableNumber((placed?.baseline??startY + index * fit.lineHeight) - shift * size),
2536
+ x: stableNumber(tabs||exactStart?origin:positioned?placed.x:trimWidth?glyphAnchor:placed?placed.x+placed.width*factor:x+hangShift), y: stableNumber((placed?.baseline??startY + index * fit.lineHeight) - shift * size),
2516
2537
  "text-anchor": start||exactStart?'start':anchor, "font-family": family ?? fontStack(style.fontFamily, type),
2517
2538
  "font-size": stableNumber(adjustedFontSize(size,sizeAdjust)), "font-weight": style.fontWeight, "font-style": style.italic ? "italic" : undefined, fill: config.fill,
2518
2539
  // LH-32: an eyebrow (the tag, a label core sets as one) draws its capitals with core's letter spacing, as core measured it, at its
@@ -2524,7 +2545,13 @@ function renderTextBox(text, box, bound, config) {
2524
2545
  ...(config.options.trace&&sourceLine?{'data-opf-source-start':sourceOffset+sourceLine.start,'data-opf-source-end':sourceOffset+sourceLine.end,'data-opf-source-next-start':sourceOffset+sourceLine.nextStart,'data-opf-line-boundary':sourceLine.boundary}:{}),
2525
2546
  // opf#1322: a line that starts at core's x still says how it is aligned and where its anchor point is (text-anchor no longer does):
2526
2547
  // an editor lays its input over the line from them, and a reader of the SVG compares them with the native export.
2527
- ...(exactStart?{'data-opf-anchor':anchor,'data-opf-anchor-x':stableNumber(placed?placed.x+placed.width*factor:x)}:{}),
2548
+ // A line whose whitespace hangs at its wrap is anchored past its glyphs' anchor point, which these name the same way (the anchor of its
2549
+ // glyphs, where an editor's input, which hangs the whitespace too, has its own), and data-opf-hang says how far from it the anchor of
2550
+ // the text, whitespace included, is (where the native export anchors its paragraph): `hang` times the alignment factor. A
2551
+ // right-to-left line is drawn and exported by its glyphs and names nothing.
2552
+ // A traced drawing names them for every such line; an untraced one only where it names the anchor anyway (a line that starts at x).
2553
+ ...(exactStart||hung&&config.options.trace?{'data-opf-anchor':anchor,'data-opf-anchor-x':stableNumber(glyphAnchor)}:{}),
2554
+ ...(hung&&(exactStart||config.options.trace)?{'data-opf-hang':stableNumber(hangShift)}:{}),
2528
2555
  }, content);
2529
2556
  });
2530
2557
  return tag("g", { ...traceAttrs(config.options, config.path),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpresentation/opf-render",
3
- "version": "0.35.0",
3
+ "version": "0.36.0",
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": "^3.0.0",
95
95
  "harfbuzzjs": "1.6.4",
96
96
  "pako": "3.0.3",
97
- "@openpresentation/opf": "^0.35.0"
97
+ "@openpresentation/opf": "^0.36.0"
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.35.0"
346
+ "@openpresentation/gallery": "0.36.0"
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": "7697b266464772a98b57070b0937938d3a12852d"
403
+ "gitHead": "293d956a9933a75859970ff8e633d18ea1652d49"
404
404
  }