@openpresentation/opf-pptx 0.22.0 → 0.22.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 (2) hide show
  1. package/dist/index.js +11 -11
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -52,7 +52,7 @@ import { prepareSvg, svgDataUriBytes, svgRasterScale, svgBlipRelationship, attac
52
52
  import { chartPaletteSchemes, applyChartSchemeColors } from './chart-scheme-colors.js';
53
53
  import { rasterMetadata, pictureTransform, normalizeImageOrientation } from './image-geometry.js';
54
54
  import {
55
- catalogRecords, chartPaletteForFill, chartSeriesPalette, codeHighlightBands, codeHighlightColors, codeHighlightLines, codeLineNumbers, codeLineRuns, codeSyntaxPaletteForScheme, composeSlide,
55
+ catalogRecords, chartPaletteForFill, chartSeriesPalette, chartTextSize as coreChartTextSize, codeHighlightBands, codeHighlightColors, codeHighlightLines, codeLineNumbers, codeLineRuns, codeSyntaxPaletteForScheme, composeSlide,
56
56
  ENGINE_DEFAULT_FONT_SCHEME, defaultSlideBackground, fitImage, fitText, layoutTable, layoutWatermark, metricTrendMark, resolveCanvasDimensions, resolveColorRoles, resolveFontFamilies,
57
57
  resolveChartColors, resolveReference, resolveScriptFonts, resolveTextStyle, textColorForFill, textWidthMeasurer, timelineMarkerShapes, timelineTextColor, tokenizeCode
58
58
  } from "@openpresentation/opf/composition";
@@ -2695,17 +2695,17 @@ async function addLogo(slide, presentation, logo, slideIndex, slideContext, cont
2695
2695
  slide.addImage({...resolved, objectName: logoName(), ...region, altText: assetAlt(logo.source, presentation) ?? 'Logo'});
2696
2696
  }
2697
2697
 
2698
- // FF-62: chart text is one size. The preview draws every chart label (axis, legend, data label) at
2699
- // max(14, composition.minFontSize ?? 16) px scaled by the slide's shorter side over 720 px (renderer charts.js, `fontPx`),
2700
- // the readability floor: 12 pt on a 13.33 x 7.5 in slide. The export writes that size, in hundredths of a point (DrawingML `sz`).
2701
- // RR-16: core composes every font size on PowerPoint's 0.01 pt grid (1/75 px), so the preview draws the grid size, not the raw
2702
- // product: the floor rounds up (core `snapFontSizeUp`) and an unfloored request of 14 px rounds down (`snapFontSizeDown`).
2703
- // Math.round differed from the preview by 0.01 pt on slide sizes whose scale is not a whole number (A4, Letter, 16:10).
2704
- function chartTextSize(context) {
2698
+ // FF-62, RR-90: chart text is one size, core's `chartTextSize` for the chart's box: 20 px at the 1280 x 720 reference (15 pt on a 13.33 x 7.5 in
2699
+ // slide), shrunk only when the box is small (at most 1/18 of its height and 1/30 of its width, whole pixels) and never below
2700
+ // `composition.minFontSize` (default 16), scaled by the slide's shorter side over 720 px. The preview (opf-render charts.js) and core's value-axis
2701
+ // density call the same function with the same inputs, so the axis core composed matches the text drawn. The export writes the size in hundredths
2702
+ // of a point (DrawingML `sz`) on core's 0.01 pt grid, as core composes every font size (RR-16): the request rounds down, never below the
2703
+ // grid-rounded floor (core `gridFontSize`, `snapFontSizeUp(floor)` against `snapFontSizeDown(request)`).
2704
+ function chartTextHundredths(context, region) {
2705
2705
  const scale = Math.min(context.dimensions.widthInches, context.dimensions.heightInches) * 96 / 720;
2706
2706
  const floor = context.composition?.minFontSize ?? 16;
2707
- const hundredths = Math.max(14, floor) * scale * 75;
2708
- return floor >= 14 ? Math.ceil(hundredths - 1e-6) : Math.floor(hundredths + 1e-6);
2707
+ const px = coreChartTextSize({width: region.w * 96, height: region.h * 96, scale, minFontSize: floor});
2708
+ return Math.max(Math.ceil(floor * scale * 75 - 1e-6), Math.floor(px * scale * 75 + 1e-6));
2709
2709
  }
2710
2710
 
2711
2711
  // Every c:txPr of a generated classic chart carries the chart text size: PptxGenJS writes no size on the legend (PowerPoint's
@@ -2739,7 +2739,7 @@ function addChartPayload(slide, chart, region, context, options = {}, path = "ch
2739
2739
  const fill = {color:normalizeHex(panelFill),transparency};
2740
2740
  const objectName = `OPF chart ${context.chartHeadings.size + 1}`;
2741
2741
  const circular = chartData.type === 'pie' || chartData.type === 'doughnut';
2742
- const textSize = chartTextSize(context);
2742
+ const textSize = chartTextHundredths(context, region);
2743
2743
  // RR-54: the columns' number formats (Excel codes per exported series) for the caches, labels, value axis and workbook.
2744
2744
  // The value axis shows the first plotted series' format (General when it has none), as the preview does.
2745
2745
  // A combo chart's secondary value axis shows its first series' format (FA-15).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpresentation/opf-pptx",
3
- "version": "0.22.0",
3
+ "version": "0.22.1",
4
4
  "description": "Pure local OPF to PPTX export and PPTX to OPF import tooling.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -66,7 +66,7 @@
66
66
  "dependencies": {
67
67
  "@node-projects/jszip": "4.3.0",
68
68
  "@openpresentation/gallery": "^3.0.0",
69
- "@openpresentation/opf": "^0.22.1",
69
+ "@openpresentation/opf": "^0.22.2",
70
70
  "@rgrove/parse-xml": "4.2.3",
71
71
  "fast-xml-parser": "^5.8.0",
72
72
  "fflate": "^0.8.3",
@@ -74,7 +74,7 @@
74
74
  "sharp": "0.35.5"
75
75
  },
76
76
  "peerDependencies": {
77
- "@openpresentation/opf-render": "^0.22.1"
77
+ "@openpresentation/opf-render": "^0.22.2"
78
78
  },
79
79
  "peerDependenciesMeta": {
80
80
  "@openpresentation/opf-render": {
@@ -98,7 +98,7 @@
98
98
  "@expo-google-fonts/roboto": "0.4.3",
99
99
  "@expo-google-fonts/roboto-mono": "0.4.2",
100
100
  "@expo-google-fonts/tinos": "0.4.2",
101
- "@openpresentation/opf-render": "0.22.1",
101
+ "@openpresentation/opf-render": "0.22.2",
102
102
  "@resvg/resvg-js": "2.6.2",
103
103
  "esbuild": "0.28.2",
104
104
  "playwright": "1.64.0"