babluboy / bookworm

A simple ebook reader for Elementary OS
GNU General Public License v3.0
1.33k stars 101 forks source link

paragraph spacing for epub books #237

Open Inc0n opened 5 years ago

Inc0n commented 5 years ago

It seems bookworm render epub ebooks with various customization but could use one more, which would help the reading if implemented, paragraph spacing.

babluboy commented 5 years ago

@k_ Thanks for your interest in Bookworm and for raising this issue.

Currently I’m showing the formatting as per the original formatting and spacing in the eBook (except PDFs). Are you suggesting that the paragraph spacing is to be increased? Can you please post a screen shot of the book where you saw this issue and is this issue consistent across many books or specific to some?

elauriault commented 5 years ago

I've also noticed this behavior after comparing with the rendered text on a kobo aura. Next, I tried opening the same file directly in bookworm and firefox. The file, which is from Ryu's Git Tutorial and the 2 screenshots are attached.

bookworm rendering:

bookworm Screenshot from 2019-03-10 13-56-26

firefox rendering:

Firefox Screenshot from 2019-03-10 13-55-52

source file :

patch-workflows.xhtml.txt

babluboy commented 5 years ago

@elauriault Thanks for this - the attached file will help me debug the issue. If Firefox is able to render the html with proper paragraph spacing, then why is bookworm (which uses webkit) failing to do so. Will look into this.

elauriault commented 5 years ago

After playing around with this for a while, I have identified at least part of the issue. CSS files are never loaded apparently because the base_uri is hardcoded to file:///. If I put the style.css or epub.css + font files at the root of the fs, they are loaded and rendered as expected. is there a specific reason for :

public const string PREFIX_FOR_FILE_URL = "file:///";

in constants.vala.in ?

I noticed it being used in contentHandler.vala which seems to be the root of the problem :

    BookwormApp.AppWindow.aWebView.load_html(bookContent, BookwormApp.Constants.PREFIX_FOR_FILE_URL);

Cheers!

babluboy commented 5 years ago

Thanks for the investigation, as far as I remember, I set the base URI to file:/// to allow webkit to resolve CSS and other files in the ebook's html to load. I was not getting the CSS to load if I set the base_uri to null. Also I have checked in a lot of books that the referenced CSS are loaded correctly, is this a specific case which is not being handled properly? Will be great to have the ebook file which causes this issue.

elauriault commented 5 years ago

I've seen it happen on occasion but css seems to be loading properly on a good portion of books. A good example is located here :

http://johnmathews.eu/Ry%E2%80%99s%20Git%20Tutorial.epub

You can easily see the problem occurring by running the following command and then navigating to the book :

strace -f -s 64 -e file com.github.babluboy.bookworm|& grep css

will show something like this :

[pid 7306] openat(AT_FDCWD, "/style.css", O_RDONLY) = -1 ENOENT (No such file or directory) [pid 7306] openat(AT_FDCWD, "/pygments.css", O_RDONLY) = -1 ENOENT (No such file or directory)

I've also found that by modifying PREFIX_FOR_FILE_URL, I could change the prefix it would look for the css files.

babluboy commented 5 years ago

@elauriault While I can view the xhtml file in the browser, I'm not able to load it into bookworm. Can you please attach the epub to this issue or email it to me at bablu.boy@gmail.com. I'm not able to download the epub from the provided link.

elauriault commented 5 years ago

Hi @babluboy ,

Here is the file from the above link.

Ry%u2019s Git Tutorial.zip