Search code examples
javascriptepub.js

epub.js set font size


I'm using epub.js to render .epub books, but I cant set fonSize in some ebooks, it wont override existing classes with the font-size already set on the ebook;

I read the documentation and the issues.

Here is the source

<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/epubjs/dist/epub.min.js"></script>

I tried to set the fontsize with this but neither works in a epub that have font-size already set :

rendition = book.renderTo("viewer", { width: "100%", height: "100%" }); rendition.themes.fontSize("200%"); //this dont work rendition.themes.default({ "body": { "font-size": "30px"}}); //this dont work

The solution is to loop each child class and reset to desired size. I dont know how to do this.

Can anyone point me to the right diretion? How can I set the font size?


Solution

  • Solved with:

     rendition.themes.default({ "p": { "font-size": "medium !important"}})