Skip to content

feat(plugin-zoom): add usePhysicalScaling option#671

Open
JoackimPennerup wants to merge 1 commit into
embedpdf:mainfrom
JoackimPennerup:feature/physical-scaling
Open

feat(plugin-zoom): add usePhysicalScaling option#671
JoackimPennerup wants to merge 1 commit into
embedpdf:mainfrom
JoackimPennerup:feature/physical-scaling

Conversation

@JoackimPennerup

Copy link
Copy Markdown

This PR is handles #670 as an opt-in option to the zoom plugin.

When enabled, numeric zoom values are treated as user-space/logical values and multiplied by (96/72) x devicePixelRatio to produce the effective render scale. This makes 100% zoom map to physical inches on-screen (Acrobat-style), where 1 PDF point equals roughly 1.333 CSS pixels on a 96 DPI display.

Changes:

  • ZoomPluginConfig.usePhysicalScaling?: boolean (opt-in, default false)
  • ZoomDocumentState.currentUserZoomLevel: number - user-space scale exposed for UI display (toolbar, translation strings)
  • ZoomScope.getDpr() / ZoomCapability.getDpr() - returns the active (96/72) x devicePixelRatio multiplier, or 1 when disabled
  • handleRequest splits numeric and mode paths: numeric clamps in user-space then scales by DPR; mode path returns effective scale unchanged
  • zoomIn/zoomOut/requestZoomBy operate in user-space throughout
  • handleZoomToArea clamps fit-ratio in effective-space to preserve full range
  • DPR-change listener with 150ms debounce recalculates open documents on display scale change; listener torn down in destroy()
  • Gesture utilities (pinch, wheel) convert initialZoom to user-space before computing delta, preventing double-application of the DPR factor
  • Snippet toolbar and translation strings read currentUserZoomLevel so the displayed percentage always reflects the user-space value
  • pnpm-workspace.yaml: exclude .vercel build artifacts from workspace scan

Backwards compatibility: when usePhysicalScaling is unset (default false), getDpr() returns 1 and currentUserZoomLevel === currentZoomLevel at all times, preserving bit-identical behaviour with previous releases.

When enabled, numeric zoom values are treated as user-space/logical values
and multiplied by (96/72) x devicePixelRatio to produce the effective render
scale. This makes 100% zoom map to physical inches on-screen (Acrobat-style),
where 1 PDF point equals roughly 1.333 CSS pixels on a 96 DPI display.

Changes:
- ZoomPluginConfig.usePhysicalScaling?: boolean (opt-in, default false)
- ZoomDocumentState.currentUserZoomLevel: number - user-space scale exposed
  for UI display (toolbar, translation strings)
- ZoomScope.getDpr() / ZoomCapability.getDpr() - returns the active
  (96/72) x devicePixelRatio multiplier, or 1 when disabled
- handleRequest splits numeric and mode paths: numeric clamps in user-space
  then scales by DPR; mode path returns effective scale unchanged
- zoomIn/zoomOut/requestZoomBy operate in user-space throughout
- handleZoomToArea clamps fit-ratio in effective-space to preserve full range
- DPR-change listener with 150ms debounce recalculates open documents on
  display scale change; listener torn down in destroy()
- Gesture utilities (pinch, wheel) convert initialZoom to user-space before
  computing delta, preventing double-application of the DPR factor
- Snippet toolbar and translation strings read currentUserZoomLevel so the
  displayed percentage always reflects the user-space value
- pnpm-workspace.yaml: exclude .vercel build artifacts from workspace scan

Backwards compatibility: when usePhysicalScaling is unset (default false),
getDpr() returns 1 and currentUserZoomLevel === currentZoomLevel at all
times, preserving bit-identical behaviour with previous releases.
@vercel

vercel Bot commented Jun 12, 2026

Copy link
Copy Markdown

@JoackimPennerup is attempting to deploy a commit to the OpenBook Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant