02-08-2018, 06:01 AM | #91 |
Evangelist
Posts: 444
Karma: 305160
Join Date: Aug 2015
Device: Kobo Glo HD, Kobo Aura ONE
|
mupdf's ePUB engine has several problems:
- It randomly swallows text at the end of chapters. - It consumes a gigantic amount of memory. - It doesn't hyphenate. I'm therefore in the process of writing an HTML renderer! I've already written the first, and most important, piece of the puzzle: the line breaking algorithm. |
02-08-2018, 07:07 AM | #92 | ||
Addict
Posts: 281
Karma: 7724454
Join Date: Sep 2017
Location: Bethesda, MD, USA
Device: Kobo Aura H20, Kobo Clara HD
|
Quote:
Basically, you don't know the allowed width of a given line without having already fixed the layout of the lines above it. Jonathan Kew discusses here (in the item explaining why Firefox doesn't use K-P): Quote:
You may also want to detect long paragraphs, since K-P is quadratic on the length of lines. If you can find it, P.I Cooper's article in the July 1966 Advances in Computer Typesetting discusses a way to break paragraphs into overlapping chunks to avoid degenerate behavior in long paragraphs. |
||
Advert | |
|
02-08-2018, 03:16 PM | #94 | |
Addict
Posts: 281
Karma: 7724454
Join Date: Sep 2017
Location: Bethesda, MD, USA
Device: Kobo Aura H20, Kobo Clara HD
|
Quote:
|
|
02-08-2018, 03:48 PM | #95 | |
Guru
Posts: 869
Karma: 2676800
Join Date: Aug 2008
Location: Taranaki - NZ
Device: Kobo Aura H2O, Kobo Forma
|
Quote:
Chances are especially in an ebook, a float is going to occur at the beginning of a paragraph. If the float is not moved up, then it's a simple matter of placing it before setting the rest of the paragraphs. The float will be of a fixed dimensions by this point. If the float is raised, then it becomes more complicated, and you probably have to re-break the preceding paragraph(s) one or more times until it fits. An expensive operation to be sure, but if one only has to re-break the occasional paragraph in a book, it's probably not too much of an issue. (Note, I'm not an expert on these matters, but it is of interest for me. I've long wanted to see K&P or a similar algorithm implemented in an HTML renderer for ebooks.) |
|
Advert | |
|
02-08-2018, 04:03 PM | #96 | ||
Addict
Posts: 281
Karma: 7724454
Join Date: Sep 2017
Location: Bethesda, MD, USA
Device: Kobo Aura H20, Kobo Clara HD
|
Quote:
That causes Knuth-Plass to fail: K-P is trying to use information about the current line to help inform where the line breaks should be on previous lines. But HTML/CSS needs the line break information about previous lines before it can even determine the width and height of the current line. TeX, on the other hand, places floats before they wrap the surrounding text. That allows them to know the line widths ahead of time. That issue has further discussion. The Firefox folks are familiar with TeX and would love to have better word wrapping. But it's a lot more complex problem in the case of HTML+CSS than it is in a purpose-designed typography language. Quote:
|
||
02-08-2018, 04:24 PM | #97 |
Guru
Posts: 869
Karma: 2676800
Join Date: Aug 2008
Location: Taranaki - NZ
Device: Kobo Aura H2O, Kobo Forma
|
I guess a pragmatic approach to dealing with floats (some might consider it a dirty hack, which it is) would be to lay out the offending paragraph(s) using a first fit algorithm, place the float(s) then re-layout the paragraph(s) using K&P. Sure the final layout might have the float start a line too early or late, but I wager most people would never notice...
And if dealing with floats that are meant to line up with the top of a paragraph (like drop caps) is simple enough. Place it first, use it's known height and width to feed to the K&P algorithm. Although, now that I've thought of it some more, changing the line-height mid paragraph would throw a spanner in the works now wouldn't it... Interesting problems. |
02-08-2018, 04:47 PM | #98 |
Guru
Posts: 869
Karma: 2676800
Join Date: Aug 2008
Location: Taranaki - NZ
Device: Kobo Aura H2O, Kobo Forma
|
Also note that a general use web browser like Firefox can not make any sort of assumptions about the content it handles. It must assume that a web developer will use floats everywhere, and they expect the browser to follow the CSS layout spec to the letter.
Therefore, implementing an algorithm like K&P, which may or may not be feasible to follow all the rules, would be opening up a huge can of worms that they probably don't want to deal with. An ebook renderer I feel has a much narrower scope of the content it is expected to layout. One can make (some) assumptions about content. Also every ebook renderer has its quirks, so what's another reader that doesn't quite lay out a float in the exact manner that CSS says it should be, so long as it's close enough? |
02-08-2018, 04:56 PM | #99 | |
Addict
Posts: 281
Karma: 7724454
Join Date: Sep 2017
Location: Bethesda, MD, USA
Device: Kobo Aura H20, Kobo Clara HD
|
Quote:
Of course “just” doing that may be tricky in itself. |
|
02-17-2018, 03:39 PM | #100 |
Evangelist
Posts: 444
Karma: 305160
Join Date: Aug 2015
Device: Kobo Glo HD, Kobo Aura ONE
|
I've released 0.3.5:
Plato now has an emulator based on SDL2: this greatly improves the quality of the debugging workflow. New features:
I also fixed a crash that would trigger when the search bar was closed in the absence of matches. |
03-14-2018, 05:11 PM | #101 |
Wizard
Posts: 3,489
Karma: 2914715
Join Date: Jun 2012
Device: kobo touch
|
@baskerville could you please have a look at this post concerning a problem with H2O2?
|
03-14-2018, 05:24 PM | #102 | |
Evangelist
Posts: 444
Karma: 305160
Join Date: Aug 2015
Device: Kobo Glo HD, Kobo Aura ONE
|
Quote:
Thanks for the report. |
|
03-15-2018, 05:54 AM | #103 |
Evangelist
Posts: 444
Karma: 305160
Join Date: Aug 2015
Device: Kobo Glo HD, Kobo Aura ONE
|
I've released 0.3.6.
New features:
|
03-16-2018, 07:19 PM | #104 |
Connoisseur
Posts: 74
Karma: 28960
Join Date: Oct 2017
Location: Paris
Device: KOBO Libra + H2Ov2 + Aura2
|
H2Ov2+ ksm09 + plato 0.3.6
Same result but another error in crash.log : Code:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 6, message: "No such device or address" } }', /checkout/src/libcore/result.rs:916:5 note: Run with `RUST_BACKTRACE=1` for a backtrace. |
03-17-2018, 05:46 AM | #105 | |
Evangelist
Posts: 444
Karma: 305160
Join Date: Aug 2015
Device: Kobo Glo HD, Kobo Aura ONE
|
Quote:
Code:
./plato > info.log 2>&1 || mv info.log crash.log Code:
RUST_BACKTRACE=1 ./plato > info.log 2>&1 || mv info.log crash.log |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
PocketBook-KOReader: a document reader for PDF, DJVU, EPUB, FB2, CBZ, ... (AGPLv3) | chrox | KOReader | 569 | 09-15-2024 09:13 AM |
KOReader: a document reader for PDF, DJVU, EPUB, FB2, HTML, ... (GPLv3) | hawhill | Kindle Developer's Corner | 1268 | 02-27-2024 11:49 AM |
Kindle -- KOReader: a document reader for PDF, DJVU, EPUB, FB2, HTML, ... (GPLv3) | hawhill | KOReader | 1219 | 01-27-2024 02:29 PM |
v3 vs. v3+ as a pdf/DjVu reader | hedonism_bot | HanLin eBook | 7 | 11-02-2010 08:16 PM |