From d3da50c11bf1b9ab6b1868e0a727f5d3a5c07c10 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 13 Sep 2020 14:44:44 +0300 Subject: force-justify longer paragraphs --- js/reader.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/js/reader.js b/js/reader.js index 7cfb2ad..ff7c3e3 100644 --- a/js/reader.js +++ b/js/reader.js @@ -5,6 +5,7 @@ const DEFAULT_FONT_SIZE = 16; const DEFAULT_FONT_FAMILY = "Georgia"; const DEFAULT_LINE_HEIGHT = 140; +const MIN_LENGTH_TO_JUSTIFY = 32; /* characters */ const Reader = { init: function() { @@ -706,9 +707,13 @@ const Reader = { //$($("#reader iframe")[0].contentDocument).find("#theme_css").text(Reader.Loader._res_data[theme_url]) $.each(window.book.rendition.getContents(), function(i, c) { - console.log('applying rendition theme', theme); + console.log('applying rendition theme', theme, 'to', c, c.document); $(c.document).find("#theme_css").text(Reader.Loader._res_data[theme_url]) + + $(c.document).find("p") + .filter((i, e) => { if ($(e).text().length >= MIN_LENGTH_TO_JUSTIFY) return e; }) + .css("text-align", "justify"); }); }); -- cgit v1.2.3