-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Rendering errors (<chem> and <math>) #1182
Comments
We are aware of such issues. Most of maths and chem scripts can be converted to GIF though. But some are not passing our LaTeX parser. Any help is welcome, I bet Wikimedia is using specific modules for that. You can find more info on #1096. |
Oh well, I was expecting such problems.. Formulae are always a problem. Unfortunately, readers don’t usually use MathJax or MathML (although that should work in EPUB3). So transformation is always a big issue, especially since devices have such differing display ppi, making small images often absolutely illegible. Are you actually using (La)TeX to produce the GIFs? Their quality is not too good, I wonder if we could eventually switch to 8-bit transparent PNGs instead, to get a little better output. Anyone knows how good that is supported on readers? (Just tried a few, scrapping all metadata inside, and saving as 8-bit grayscale+alpha PNG, they aren’t that much bigger. Example: 194 bytes → 209 bytes.) |
Actually I think Kobo does only support GIFs. I need to check again though. |
dictgen mentions GIF and JPG https://pgaskin.net/dictutil/dictgen/ |
"azide" is new but the others math expression errors are known: #1096 A way to debug, add "-d -1" and print the exception
|
I just tested and PNGs works. Not sure exactly what sort of PNG it is... I just changed ebook-reader-dict/wikidict/utils.py Line 498 in 794a723
and ebook-reader-dict/wikidict/utils.py Line 503 in 794a723
and replaced "gif" by "png". Then created a en dict with only "graph" as a word:
Resulting dictionary in kobo format: dicthtml-en-en.zip (3,939 bytes) With gif: dicthtml-en-en.zip (4,047 bytes) Tested on Kobo Aura with latest firmware 4.31.19086 |
Sounds great, thanks for testing. Must get a Kobo soon… What imaging lib does it use? Maybe we can find out more (like how to specify 8-bit greyscale, alpha, no metadata) to keep them small. I wonder if we could even make it use an SVG. That would be the best (scalable). Some experimenting to do here, I guess. |
I was also curious if svg could be used on Kobo. And it can ! dvioptions = [ "-d -1", ]
with BytesIO() as buf, BytesIO() as im:
preview(
f"${expr}$",
output="svg",
viewer="BytesIO",
outputbuffer=buf,
dvioptions=dvioptions,
packages=tuple(packages),
)
buf.seek(0)
raw = buf.read()
return f'<img style="{IMG_CSS}" src="data:image/svg+xml;base64,{b64encode(raw).decode()}"/>' |
Ooooohhhh I am in love with SVG! Why did not we try sooner? :D |
If going the SVG way, we need also to check what is the output when PyGlossary handles the word, and how it looks finally (cc @Moonbase59). Could you share the StarDict file @lasconic? |
Looking again at examples, GIF & PNG seem so archaic now :o |
unfortunately pyglossary is not happy:
|
Actually the error is present on the main branch too, meaning it is not SVG-related. |
WOW! Thanks so much for trying and the screenshot comparisons. We should generate something and post it to MobileRead and/or E-Reader Forum maybe, to get some other actual users try it. The SVG looks so much better, and hopefully on any device… |
Probably need to talk to @ilius to support writing lots of small SVGs instead ;-) Plus, of course, not destroy anything that might be in a real dictionary, like JPG/PNG images (as are in real dicts: Cambridge has lots of JPGs, German Duden even has PDFs). We just might—in the ffar future—wish to include images from Wiktionary, after all… |
Converting a bitmap format (like png or gif) to SVG (salable vector graphics) is not on the cards, really. |
Depends … where do you convert from? The svg would be there already in the dict, base64-encoded. Could that not just be taken and written out? See #1182 (comment) Of course trying to convert a raster image to SVG makes no sense. |
Let's move the conversation to #1183. It is starting to be hard to follow :) |
Note from @BoboTiG: issue tightly coupled to #1183, interesting details can be found there too.
I did a fresh download and render of the EN wiktionary today, and got the following errors:
The text was updated successfully, but these errors were encountered: