-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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 element to text layer even if width === 0 #7130
Conversation
Some browsers render certain special characters with width 0, others with strictly positive width. (For example, the Greek Delta, Δ, has width 0 in Google Chrome, and a positive width in Firefox.) The `if` clause in operation so far results in different text layer DOM trees for different browsers. This commit fixes that by adding the elements independently of their width.
Can you provide test PDF? (For verification) It will be nice to include that as text layer test. |
Thanks for the swift reply! I suppose any paper with math with do, but the bug was dicovered with http://arxiv.org/pdf/1603.04246v1.pdf. |
I'm a bit confused about this PR. First of all, I wonder why the The provided file seems to have been made with LaTeX, so I'm attaching a reduced test case that I made myself that can be included in this patch if you can reproduce the issue with this file too: The LaTeX source, for those interested, is: \documentclass{article} \usepackage[a4paper,margin=2.5cm]{geometry} \begin{document} \huge{$\Delta$} \end{document} |
It was introduced by |
Thanks @timvandermeij for the comments.
The <div style="left: 491.912px; top: 1323.33px; font-size: 16.6043px; font-family: monospace;">1</div>
<div class="endOfContent"></div> Firefox: <div style="left: 143.017px; top: 117.739px; font-size: 34.4375px; font-family: monospace;">�</div>
<div style="left: 491.912px; top: 1323.33px; font-size: 16.6043px; font-family: monospace;">1</div>
<div class="endOfContent"></div> (The |
/botio-linux preview |
From: Bot.io (Linux)ReceivedCommand cmd_preview from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/04f19be6c3ac3a2/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/04f19be6c3ac3a2/output.txt Total script time: 1.00 mins Published |
/botio test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://107.22.172.223:8877/d08f109d8de2ff5/output.txt |
From: Bot.io (Linux)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/a5c104438626c30/output.txt |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/d08f109d8de2ff5/output.txt Total script time: 20.49 mins
|
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/a5c104438626c30/output.txt Total script time: 22.77 mins
|
@yurydelendik Could you review this PR? |
I agree with the change, but it's too fragile. I see whitespace check above, so we somewhat safe from regressions in most of the cases. It might be hard to add a test case since it's different across browsers/platforms. Thank you for the patch. |
Some browsers render certain special characters with width 0, others with strictly positive width. (For example, the Greek Delta, Δ, has width 0 in Google Chrome, and a positive width in Firefox.) The
if
clause in operation so far results in different text layer DOM trees for different browsers.This commit fixes that by adding the elements independently of their width.
For the background:
This bug was discovered when using https://github.com/timdown/rangy, a tool to create and find text ranges in a DOM tree, used primarily for adding annotations.
This change is