Skip to content

Commit 7a66d51

Browse files
committed
Add changesets
1 parent 444125e commit 7a66d51

3 files changed

Lines changed: 49 additions & 0 deletions

File tree

.changeset/engines-tight-bounds.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@embedpdf/engines': patch
3+
---
4+
5+
### Extract tight glyph bounds and font size from PDFium
6+
7+
- `readGlyphInfo` now calls `FPDFText_GetCharBox` alongside `FPDFText_GetLooseCharBox` to extract tight character bounds (closely surrounding the actual glyph shape) and maps them to device-space coordinates.
8+
- `buildRunsFromGlyphs` passes tight bounds through to each `PdfGlyphSlim` record (`tightX`, `tightY`, `tightWidth`, `tightHeight`) and stores per-run `fontSize` from `FPDFText_GetFontSize`.

.changeset/models-tight-bounds.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@embedpdf/models': patch
3+
---
4+
5+
### Tight glyph bounds and font size on run/glyph models
6+
7+
- `PdfGlyphSlim` gains optional `tightX`, `tightY`, `tightWidth`, `tightHeight` fields for tight character bounds from `FPDFText_GetCharBox` (closely surrounding the actual glyph shape, as opposed to the existing loose bounds from `FPDFText_GetLooseCharBox`).
8+
- `PdfGlyphObject` gains optional `tightOrigin` and `tightSize` fields for the same purpose at the intermediate object level.
9+
- `PdfRun` gains an optional `fontSize` field populated from `FPDFText_GetFontSize`, used for font-size-aware rectangle merging during selection.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
'@embedpdf/plugin-selection': patch
3+
---
4+
5+
### Selection plugin: Chrome PDFium parity and geometry cache eviction
6+
7+
**Double-click / triple-click selection**
8+
9+
- Double-click selects the word around the clicked glyph, triple-click selects the full visual line, matching Chromium's `PDFiumEngine::OnMultipleClick` behaviour.
10+
11+
**Drag threshold**
12+
13+
- Pointer-down no longer immediately begins a drag-selection. The pointer must move beyond a configurable `minSelectionDragDistance` (default 3 px) before selection starts, preventing accidental selections on simple clicks.
14+
15+
**Tolerance-based hit-testing with tight bounds**
16+
17+
- `glyphAt` now performs two-pass hit-testing adapted from PDFium's `CPDF_TextPage::GetIndexAtPos`: an exact-match pass followed by a tolerance-expanded nearest-neighbour pass using Manhattan distance.
18+
- Hit-testing uses tight glyph bounds (`FPDFText_GetCharBox`) instead of loose bounds (`FPDFText_GetLooseCharBox`), matching Chrome's behaviour and preventing cross-line selection jumping on short lines. Configurable via `toleranceFactor` (default 1.5).
19+
20+
**Font-size-aware rectangle merging**
21+
22+
- `shouldMergeHorizontalRects` now refuses to merge runs whose font sizes differ by more than 1.5x, preventing a large character (e.g. a heading "1") from merging into adjacent body-text lines.
23+
- `rectsWithinSlice` sub-splits runs when the horizontal gap between consecutive glyphs exceeds 2.5x the average glyph width, mirroring Chrome's `CalculateTextRunInfoAt` character-distance heuristic.
24+
25+
**Geometry cache eviction (LRU)**
26+
27+
- Added `maxCachedGeometries` config option (default 50) to bound per-document geometry memory. Least-recently-used pages are evicted when the limit is exceeded; pages with active UI registrations are pinned and never evicted.
28+
- When an evicted page scrolls back into view and falls within an active selection, its rects are lazily recomputed and pushed to the UI.
29+
30+
**Marquee / text-selection coordination**
31+
32+
- Introduced `hasTextAnchor` state so the marquee handler does not activate while the text handler has a pending anchor (before the drag threshold is met).

0 commit comments

Comments
 (0)