-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Dictionary definition with mixed LTR and RTL text does not render correctly #9320
Comments
What is happening is that the definition starts with a RTL word, and there's nothing anywhere saying the full content is mainly LTR and that the paragraph should be laid out LTR. What got me a bit worried on the first screenshot is that, even though it all looks like it is rendered as a RTL paragraph, the last line is left aligned, while it should be right aligned. But it's rendered by MuPDF as it is a HTML dictionary. So, in the text rendering, indeed, the first word being RTL, and nothing anywhere saying it is a LTR definition, it makes the whole paragraph assumed to be RTL. That's the HTML output we get from the dict: So, with this, MuPDF (like our text rendering) decides the whole paragrpah is to be RTL (even if it does bad on the last line). return function(html)
-- return "<div dir='ltr'>" .. html .. "</div>" -- somehow, this does not work
return "<span dir='ltr'>" .. html .. "</span>" -- but this does
end (If you may get multiple paragraphs from the dict, you may need to tweak this microscript to split by line/para, and wrap each of them in a I'd say it's not a KOReader bug, but the HTML dict could have help itself by wrapping each result in such a |
Thanks! |
Where are these microscripts documented? Can one be used to change the font of the dictionary popup? |
@jayjf |
It is (well, a MuPDF bug). The default document direction is LTR so the wrapping you refer to is there by default for the entire document unless otherwise specified with dir=auto or dir=rtl. Even with dir=auto I don't think this would be the correct behavior due to the
Then it uses something other than MuPDF. ;-) (The most obvious guess would be Android WebView.) |
Oh, right.
May be because it handles the default direction correctly. Or it doesn't handle RTL at all. I think even with main Hebrew>He or Arabic>Ar dictionaries, that may not wrap their output in a
Only per dictionary, and for HTML dictionaries where we can indeed fix the html with a .lua script, or tweak the styles with a .css file.
See here how you could force your preferred font with the CSS: #9229 (comment) I guess you could then use: * { font-family: myLTRFont }
*[dir=rtl] { font-family: myHebrewFont } (looks like MuPDF does support |
The current version (MuPDF 1.20) behaves the same ftr. :-) |
Ok, I got the definition in my preferred font, but how about the word itself that I'm looking up, at the top of the popup. That font doesn't seem to change. |
That is part of the UI, unlike the definition which is rendered by MuPDF and that you could easily tweak. |
Dictionary definition with mixed LTR and RTL text does not render correctly
Incorrect rendering:
![incorrect](https://user-images.githubusercontent.com/109082852/178282935-41d0e554-8768-44ff-a8dd-892b370dabc6.jpg)
Correct rendering in the Alpus app for Android:
![correct](https://user-images.githubusercontent.com/109082852/178284505-63597337-1f9d-4c06-b324-9ecb16fe1e54.jpg)
The text was updated successfully, but these errors were encountered: