Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve text selection accuracy by using the real font family #19230

Closed
wants to merge 1 commit into from

Conversation

ouchuan
Copy link

@ouchuan ouchuan commented Dec 16, 2024

Enhanced the text layer creation process by using the real font family instead of the fallback font name. This change ensures that text selection is more accurate.

fixes: #19207

Enhanced the text layer creation process by using the real font family
instead of the fallback font name. This change ensures that text selection
is more accurate.

fixes: mozilla#19207
@@ -66,10 +66,12 @@ class FontLoader {
}

clear() {
for (const nativeFontFace of this.nativeFontFaces) {
Copy link
Author

Choose a reason for hiding this comment

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

Since we need the original font to create a text layer, we need to preserve the font face here.
This may increase memory usage but can improve rendering speed when resizing, as we don’t need to load the font again.

@Snuffleupagus
Copy link
Collaborator

Sorry, but unfortunately this isn't a correct solution since it'll first of all not work correctly for non-embedded fonts.
Even for embedded fonts this will probably not work correctly in general, since there's no guarantee that the font actually contains all the glyphs needed in the textLayer (consider e.g. ligatures and other combined glyphs).
Also, given the glyph re-mapping that's done during the PDF.js font parsing this might to lead to incorrect copy-and-paste results.

Thanks for the patch, but unfortunately this is a much more complicated topic than it may seem at first glance (since I recall seeing a WIP patch by @calixteman some time back).

@ouchuan
Copy link
Author

ouchuan commented Dec 16, 2024

ok. thanks for your explanation

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.

[Bug]: Scroll to search result doesn't take into account text layer horizontal scaling
2 participants