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

Add text corresponding to layouted glyph #729

Merged
merged 3 commits into from
Mar 29, 2024

Conversation

LaurenzV
Copy link
Contributor

What do you think of this? I basically adapted it from https://github.com/typst/typst/blob/105d7156f8f9d95e16b3eefdf0fa97e5be7fbe5b/crates/typst/src/layout/inline/shaping.rs#L729-L733

I also checked and I've managed to get copyable text to work (in svg2pdf), I also tried it with other scripts (like Arabic) and it seems to work!

@LaurenzV
Copy link
Contributor Author

Umm... I have no idea why Qt is failing?

@RazrFalcon
Copy link
Owner

Yep, it's unrelated. I guess it fails to download the Qt version I need. Ignore it.

As for the patch, yes, Arabic/Hebrew is the first thing you should test. Zalgo as well.

I think the old code was able to get char by byte_idx, but not the whole string/cluster. Allocating the whole string for each span might be a bit expensive, but I guess it's fine for now. We could use Box<str> as an optimization here.

@LaurenzV
Copy link
Contributor Author

Yup, Hebrew seems to work as well. Not so much for zalgo (as in, it renders correctly, but copy-pasting results in more or less garbage), but it also doesn't work when exporting the SVG to PDF via Chrome, so I don't think this is worth investigaging...

@RazrFalcon RazrFalcon merged commit ee3a7e3 into RazrFalcon:master Mar 29, 2024
2 of 3 checks passed
@RazrFalcon
Copy link
Owner

Thanks!

@LaurenzV LaurenzV deleted the glyph-text-2 branch March 29, 2024 20:33
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.

None yet

2 participants