The span font sizes are in page units and the transform is only set when the
span is rotated, skewed or scaled, which makes the layout cheaper.
The free highlight box comes from the editor layer: with the pre-standard CSS
zoom (Chrome < 128, Safari 18), the zoomed text layer client rect is scaled.
Given that page-editing will change the pageNumber mapping, we cannot keep the `pageNumberToDestHash` Map since that may cause the `currentOutlineItem` functionality to highlight the wrong outline-item.
Additionally, ensure that the `#getPageNumberToDestHash` method will always resolve its capability since previously e.g. closing of a document could leave promises pending indefinitely.
Restore the saved page dimensions, origin, and rotation when the page
layer is absent. Adjust positions for zoom-dependent drawing padding
and replay moves without clamping again.
Use each editor's current page rotation to convert drag deltas and
remap its position through screen coordinates when switching pages.
Update the page origin, preserve the editor's size, and compensate for
rotation changes where supported. Reject pages that are too small.
The pairs adjusted the same way are kerned in the generated font, so the
characters of a span stay at their PDF position. The highlights are painted
with a box shadow to avoid breaking the kerning.
For PDFs with more than `PagesCountLimit.FORCE_LAZY_PAGE_INIT` pages, currently set at 5000, pages are initialized lazily to improve performance.
This causes finding/highlighting of the current outline-item to not work correctly, hence we need to fallback to the `getPageIndex` API-method.
**Steps to reproduce:**
- Open a PDF with more than 5000 pages, e.g. https://www.cs.princeton.edu/courses/archive/fall19/cos217/reading/ArmArchitectureReferenceManual.pdf#pagemode=outline
- Goto the last page.
- Click on the "Find Current Outline Item" button.
**Expected behaviour:**
The *last* outline-item is scrolled into view and highlighted.
**Actual behaviour:**
The *first* outline-item is highlighted, when testing in `master`.
A function-based shading was sampled at one step per user-space unit of
its own matrix, so a unit domain scaled up by the CTM, a form matrix or
a pattern matrix was drawn with a single cell.
The sampling grid is now computed from the transform the shading is
painted with, and the generated meshes are cached per grid size.
The setFillColorN/setStrokeColorN cases are merged so the base transform
is only passed in one place.
The software mesh rasterizer now clamps triangles to the canvas, so
pixels on the right edge no longer wrap into the next row.
It fixes#22616.
With worker-rendering enabled this option is not needed, hence move it to a shadowed getter in `BasePDFPageView` and remove it from various viewer-components respectively the `AppOptions`.
Annotation text and the highlight intersector now use the glyph runs too, so
the old item builder in the evaluator is gone.
Also make debugTextLayerFonts a getDocument option, and copy-all split the
text like the text layer.
Group glyphs with the same baseline, font and transform into runs. Infer
word spaces from the positions and tracking within each run, and split
runs into spans at wide gaps.
Compute span advances in the worker from the generated font metrics so
the text layer can lay out simple spans without measuring them. Find
uses the same extracted items as the text layer.
Probe the installed substitute in the worker and cache coverage for each requested glyph. Generate the fallback when a glyph is missing or coverage cannot be verified.
The text is in visual order, so e.g. a ')' at an RTL level is a '(' in the
logical text. A glyph is only mirrored when its shape, from the glyph names or
the cmap of the font or else from the encoding, is its ToUnicode character,
since a ToUnicode map can already give the logical one.
Also stop removing '<' and '>', a leftover from 2012.
The hand-written ranges gave a wrong class to many characters (e.g. ₪, €,
punctuation, Hebrew presentation forms, U+FEFF), hence a wrong reordering in
the text layer and in find. The table is generated from DerivedBidiClass.txt,
and surrogate pairs are now kept together.
- Encode the advances which don't fit in the font with the smallest power of
two scale, and fit even a single glyph of such a font.
- Express the advances and space gaps of a font sized by its bbox in the em of
the span, whose height is the bbox height.
- Keep the baseline of a drawing on an edge of the bbox, and don't flip the
bbox twice when the span height already carries the flip.
- Measure the inferred spaces in the em of the text state which moved the
text, and skip the gaps whose em is unknown.
Closing/switching the document in the viewer will cause multiple
tasks to fail. Other code paths already have
`if (pdfDocument !== this.pdfDocument) return;` checks to know if the
document has been changed after an async step, but it was missing in
some places leading to errors being logged in the console.
This commit adds the check in those places.