Skip to content

feat(preview): take resolveFamily in renderSlideToImage / renderSlideToRgba - #486

Merged
baseballyama merged 1 commit into
mainfrom
feat/preview-raster-resolve-family
Oct 25, 2026
Merged

baseballyama merged 1 commit into
mainfrom
feat/preview-raster-resolve-family

Conversation

@baseballyama

Copy link
Copy Markdown
Member

Why

The PNG path (@office-kit/pptx-preview/node) maps every authored font name through substituteFamily. A caller that measures a deck's font with its own face — e.g. a buildFontkitMeasurer alias from the template's font (Meiryo) to a face in fontFiles — gets lines wrapped for that face but painted in Carlito, so measured and drawn line breaks disagree. renderSlideSvg already takes resolveFamily; rasterize didn't forward it.

What

  • RenderImageOptions.resolveFamily?: RenderSlideOptions['resolveFamily'] (same type as the SVG option, optional like the other fields), forwarded to renderSlideSvg.
  • Order with eastAsianFamily (fix(preview): draw bold Japanese text with the bold face in PNG renders #481): East Asian characters take eastAsianFamily (the first kana face in fontFiles); the rest of the run takes the resolveFamily result. Fixed by a test.
  • Unset → identical output (tested byte-for-byte against passing substituteFamily), so the fidelity baseline should not move.
  • README section + minor changeset.

Tests

test/preview-raster-resolve-family.test.ts

  • a Meiryo run resolved to a loaded family draws a wider ink bbox (and a different ink count) than the Carlito default; uses bundled Liberation Mono as the stand-in so CI needs no extra font
  • the measurer receives the resolved family
  • unset equals substituteFamily, byte-identical PNG
  • with both options, CJK pieces are in eastAsianFamily and Latin pieces in the resolved family (SVG + measurer)

Both raster tests fail when the forwarding line is removed.

Copilot AI balanced review requested due to automatic review settings October 25, 2026 07:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@baseballyama
baseballyama merged commit bfeebf5 into main Oct 25, 2026
16 checks passed
@baseballyama
baseballyama deleted the feat/preview-raster-resolve-family branch October 25, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants