HtmlBoxWidget: fix incorrect selection#13276
Conversation
In same cases MuPDF returns a visually single line of text as multiple lines. Merge such lines to ensure that getSelectedText works properly. See: koreader#13232 (comment)
|
Did you guess the reason for this happening ? |
The lines are added in the fz_add_stext_char_imp function. The function gets the whole span as one string but it splits the string because the gap between the words is larger than the limit. This is this comment there:
|
|
it seems this problem hasn't completely gone away. if there is extreme justification, still happens Screen.Recording.2025-07-19.at.00.47.16.mov |
|
@TnS-hun I have been trying to find a wiktionary entry that shows the same behaviour but much to my chagrin I've had no success so, here is a one entry stardict (just [Dict.zip] |
|
Using MuPDF for getting the rectangles sounds the most logical to me (barring something making that difficult). |
|
@poire-z should voice his opinions. |
that's pretty cool, thanks for doing that. Pedants like us can read in peace. ;) why couldn't the dictionary widget use crengine for html dicts as well? why do we use MuPDF? |
|
It's much simpler to massage it into this kind of little thing. |
|
Yes, MuPDF is much simpler for quick rendering of small HTML snippets to a bitmap, that's why we use it for HtmlBoxWidget. |
How did it look before ? Is it our code that is connecting (or not) the word boxes on a line? Or is it MuPDF? |
|
The MuPDF structured text API also has a number of options we don't use. |
|
Yes, the old one feels/looks better - and I don't really see how the new one (still having holes, but less, and also boxes of different heights) would help with fixing the issue ? |
I don’t know either but I'd take a properly working one with slightly uglier block selection to a nicer looking one that only sometimes works. Besides, nobody is selecting large chunks of text in the widget, there is no point. It can only do wiki/dict searches. |
|
Using MuPDF helps with the issue because it does not try use lines for drawing, so the rectangles are correct. I looked a bit into the structured text that MuPDF can provide and it has better Y coordinates, so it might be possible to get rid of the holes too. |
|
Wondering if you were able to figure something out @TnS-hun |
|
Honestly, I did not look into how MuPDF's highlighting could be improved. I think we could just use MuPDF as it is. Multiword selection is rare in the dictionary to the noncontinuous highlighting to bother anyone. |
@poire-z ? (I left that ridiculous space before the question mark just for you) |
|
Thanks for that space, but what is the question ? |
|
We were trying to solve #13276 (comment) old man 👴 ;) |
|
Oh, you were ! Good luck to you all :) (I'm not familiar with mupdf stuff to help) |
In same cases MuPDF returns a visually single line of text as multiple lines. Merge such lines to ensure that getSelectedText works properly. See: koreader#13232 (comment)





In same cases MuPDF returns a visually single line of text as multiple lines. Merge such lines to ensure that getSelectedText works properly.
See: #13232 (comment)
This change is