Repository navigation
Store annotation geometry as f32 pdf-graphics types - #564
Merged
Merged
Conversation
Annotation Core kept its geometry in f64 while the renderer and viewport work in f32, so every projection narrowed rectangles, points, and quads back to f32 and pdf-graphics carried f64 copies of the Rect, Point, Quad, and Polyline methods only for this crate. Annotation geometry is now read from the PDF as f32: rectangles, points, quads, polylines, line endpoints, difference rectangles, border widths and dashes, and font sizes. Opacity, border-effect intensity, action duration, and destination coordinates stay f64. The f64 geometry methods are folded into the f32 impls and the narrowing helpers are gone. Difference rectangles and the insets derived from them are Rects, and AnnotationEntry exposes its bounds, origin, size, and transform as Rect, Point, Size, and Transform instead of bare arrays. The browser contract and the JS that reads the entry size follow the new shapes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conformance readsDocuments that Safe-PDF reads differently from the base commit, compared with PDFium. A read pdf.js corpus1008 documents compared with Regressions
840 documents of the PDFium corpus read as on Details are in the job summaries of the workflow run. Rerun a case locally with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Annotation Core kept its geometry in
f64while the renderer and viewport work inf32, so every projection narrowed rectangles, points, and quads back tof32.pdf-graphicsalso carriedf64copies of theRect,Point,Quad, andPolylinemethods only for this crate.f32: rectangles, points, quads, polylines, line endpoints, difference rectangles, border widths and dashes, and font sizes. Opacity, border-effect intensity, action duration, and destination coordinates stayf64.pdf-graphics: thef64geometry methods are folded into thef32impls (Rect::union/translate/clamp_translation,Point::is_finite/translate,Quad::bounds/is_convex,Polyline::vertex_bounds/squiggle), and the narrowing helpers are removed.Rect::is_validnow also rejects rectangles whose width or height overflows.SizeandTransformgain the optional serde and TypeScript derives./RDdifference rectangles and theBoxAnnotation/FreeTextStyleinsets derived from them areRects.AnnotationEntryexposesbounds,origin,size, andtransformasVec<Rect>,Point,Size, andTransform.css_matrixcomposes withTransform::post_concatenatedinstead of multiplying the matrices by hand.SourceAnnotation::contentsstays; it supplies the text of text notes, free text, popups, and the projection text fallback.Browser contract
annotation_contract.tsis regenerated:difference_rect,insets, and the entry'sbounds,origin,size, andtransformare now objects instead of number tuples. The JS that readentry.sizeby index now useswidthandheight.Test plan
cargo check --workspace --all-targets,cargo fmt --checkcargo clippy --all --workspace, excludingpdf-conformancecargo test -p pdf-graphics -p pdf-annotation-core -p pdf-web -p pdf-documentcargo xtask annotation-types --checkcargo xtask web-canvas --profile debugpdf-conformancetests, because their Skia build downloads a prebuilt binary. The crate compiles.🤖 Generated with Claude Code