-
-
Notifications
You must be signed in to change notification settings - Fork 158
Dynamic spreads in fixed-layout and smart spreads in comic-books #69
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
base: main
Are you sure you want to change the base?
Conversation
|
Another benefit of this mode is that if the comic contains a double page spread, it will serve as an anchor that conveys the comic creator's intent for whether subsequent pages should slot into I haven't made any changes to the documentation yet since I don't know if you want to keep this or if you want to make any changes in how it's enabled/the interface for the book sections. |
|
If you're getting the dimensions for every page before rendering anything, there shouldn't be any need for changing the renderer. You should be able just specify the And to avoid having to do this every time, a better approach might be to cache the dimensions, or the resulting spreads, somewhere in your application. One can even put the spreads in a package document, that is, basically converting the book into EPUB. |
|
So you don't want the feature in foliate at all? |
|
No, what I mean is that if it's something that is done completely before the book is rendered, then you should be able to add it without touching For the same reason, there shouldn't be any need to add the attribute to One option might be to beef up the Another option would be to simply say that if you need to access advanced options, you need to make your own equivalent of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ESLint found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
7a27ce9 to
6d7027b
Compare
|
Changed based on my interpretation of what you said. In this commit:
This seems fairly clean (only changes in 2 files, spreads are calculated beforehand and use pageSpread), extendable, and doesn't force people to keep a copy of the whole With this solution, there is no change in how |
|
It does seem much cleaner. It just occurred to me, however, that you can actually do it after the book object is created, and even externally, by directly mutating the sections. That could be a way of loading the spreads from cache, if you want, similar to generating locations in Epub.js. There's also the possibility of enabling/disabling it even after the book is opened, without having to reload everything, though you'd need to call Another thing to consider is how to support dynamically overriding the spreads and the page progression direction. Probably, you'd need to implement that in the same place where you're re-spreading the book smartly. It's not clear to me, though, if one goes down that route, what it should look like. Probably, there needs to be an interface between the renderer and the book implementation after all. So I'm thinking perhaps attributes on the renderer element, something like |
|
Are you sure about the design this time? Also I believe the direction should be implicit from the standard HTML attribute |
Not really, which is why I used "probably", "perhaps", "It's not clear to me..." and so on in my comment. The main reason for this is that Foliate and foliate-js have been developed mainly for reflowable EPUBs. Fixed-layout is something of an after thought, and non-EPUB/Kindle fixed-layout even more so. So the whole thing is quite poorly thought out and worked out in general compared to the paginator.
I guess you're right. Currently, it would only work for books that are rendered LTR by default, though, because RTL books (when the book object has the |
|
So to be clear, the only page direction issue to be corrected (in the current implementation) would be, specifically, fixed layout EPUBs with embedded RTL in HTML "rtl" mode? Since comic books and pdfs don't have built in reading direction, so they're always "default" (ltr). |
|
I made a test epub to look into this. Unfortunately I'm not sure how to properly read the epub (if it's at all possible) to correctly lay out the pages such that these attributes would always work. For example, is it safe to assume that the designer of the pub intended the first page to always be recto (absent a toggle like your proposed odd-page-verso)? Having something like this: <meta property="rendition:layout">pre-paginated</meta>
<meta property="rendition:orientation">landscape</meta>
<meta property="rendition:spread">landscape</meta><spine toc="ncx" page-progression-direction="rtl">
<itemref idref="CoverPage_xhtml" properties="rendition:spread-landscape page-spread-left"/>
<itemref idref="section-0001_xhtml" properties="rendition:spread-landscape page-spread-right"/>
<itemref idref="section-0001_b_xhtml" properties="rendition:spread-landscape page-spread-left"/>
...
</spine>As a human I can tell that CoverPage is supposed to be on the left, then a page break, then the other two are part of the same spread. But how can the reader tell it's not supposed to create a spread with CoverPage on the left and section-0001 on the right? We need to make an assumption about recto and verso, right? Then the way foliate currently behaves has the opposite issue. If CoverPage is tagged as right and section-0001 is tagged as left it aggregates them together even though that's not necessarily desirable. It's complicated to me because epubs themselves are assigning fixed positions to the pages in their metadata instead of reading direction based positions. So the only solution I can see that will make everything work is:
Respreading logic can stay within the renderer. I think it's enough to expose it so it can be called if someone wants to make changes to the spread property in each section after the initial loading. Smart spreads would remain outside the renderer and interface with the renderer through the spread attribute. |
|
I guess instead of always assuming odd page recto, we can make it a little smarter by assuming odd page verso if the first listed page is right in rtl or if the first listed page is left in ltr... |
…ute in foliate-view to options when calling open().
6d7027b to
048cc9e
Compare
048cc9e to
c856eb8
Compare
|
Now fixes #66 . After taking some time today to wrap my head around this I believe this solution is working correctly in all cases (I haven't spotted any issues so far). These changes may modify previous foliate behavior. Specifically, it's not possible in this version to fill in a spread "out of order" when compared to the book's (not HTML's) Notable changes and other notes
The
...however, they still may be flipped (left to right and right to left) if I didn't add this yet, but it might also be interesting to have an attribute that inhibits the book's synthetic spreads entirely and "forces" the renderer to use its page progression direction assumptions on all pages. |
|
Sorry for the late reply.
My understanding is that this is indeed the expected behavior if the page progression is RTL. If the page progression is LTR, on the other hand, it should create a new spread.
Do you have an example? I believe this is already how it behaves. If it doesn't, it would indeed be a bug.
My idea was that rather than always forcing it, it would be something like a hint for when no information is available. The spreads in EPUB, for example, should probably not be overridden. So the idea was that only the Book object knows whether the spreads it gives are "true spreads" or merely guesses that can be influenced by the hint. The same applies to the page progression direction. Another idea that just occurred to me is that perhaps ideally the control should flow from the Book object to the renderer because conceptually, what the user is really doing is modifying the book's contents on the fly. This can be implemented as a custom event on the Book object (perhaps its Alternatively, and more simply, there would be an
The Given this, the |
This adds
<foliate-view smart>that makes use of agetDimensions()asynchronous method that may be present in book sections. Currently, comic-book adds this method for JPG, PNG, GIF and WEBP pages as long as thesmartattribute is set.The purpose of smart spreads mode is to use the aspect ratio of a page to determine whether it should be placed in the
centerposition of a spread rather thanleftorright. This allows double page spreads in comics to fill the entire viewport even when there is enough space for two pages.Before:
After:
I made this an attribute because of course there is a performance tradeoff. The getDimensions code in comic-book efficiently reads the dimensions of the pages from their headers without loading the entire file. However, all pages must still be extracted from the zip on load for this to work.
I'm not caching the pages themselves because I want low memory devices to be able to free up the memory used by each page when loading the next one during the dimensions extraction.