From 0f20c27226d7eb5f32174581d32fe187c0a97f34 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 27 Mar 2016 08:43:54 +0530 Subject: [PATCH] E-book viewer: Fix mathematics being typeset at too small a font size on windows --- resources/compiled_coffeescript.zip | Bin 104849 -> 104974 bytes src/calibre/ebooks/oeb/display/mathjax.coffee | 13 +++++++------ src/calibre/gui2/viewer/documentview.py | 3 ++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/resources/compiled_coffeescript.zip b/resources/compiled_coffeescript.zip index 3a2c4183af25c80aa1eeb998340f5477c4fc922b..bcac0cd9b71f47b737eadcc5aa12fbf8425735f6 100644 GIT binary patch delta 417 zcmbQZnXPXN+lC*@1if6VJ#P2dadYxAFo3Y^d)P_R-kG%(nFWYtebAsvWvD~0%Y zu)g^C#e3H<%IFoP7UU!*r)sFf#nquoH8<~Fdxnt#(%)}@u*(@p5 z%-GD#%)-bb#mL;y+{nbjz(h$$L23Hwsf^OolV>vOGJ|;kZ5idKzX2LHy?;8RHDfIR D!0C>v delta 295 zcmeC%!ZvX;+lC*@L;}NfJWBrLYV`0hFo3Wu0|Uc!#~F;mo8_19XX4dVsOC}tgR;b; z$^TY9-ps!GJ>z1IwTzop)}3LT+`Eo{Gv|hROw%{`GfHeey{YaIAF7Gd!>2MvvuxcA zHFf&QsfDu{neIA`(Szxs?ezX>jNVK)!lvJu#;C_Jc`_rzKc;G> z>G!5F%1p1E&NyN6{R!ODSIl5^o*doAH~qm(M&0R3GZ{sv_t`P>PVb+|=scZs2BY_6 z`Q=>tN>&O=sRkxVhK9+BCI%@fhDMeqX68ng=4lot#+Js$Cdn2_1{Ns>#z}@LN;(SD a1*bEHPnVs}$T2-+2BYJ2gPDxBjI{vIrDE>@ diff --git a/src/calibre/ebooks/oeb/display/mathjax.coffee b/src/calibre/ebooks/oeb/display/mathjax.coffee index cef4ede52d..6c24a31939 100644 --- a/src/calibre/ebooks/oeb/display/mathjax.coffee +++ b/src/calibre/ebooks/oeb/display/mathjax.coffee @@ -23,23 +23,24 @@ class MathJax this.pending_cfi = null this.hub = null - load_mathjax: (user_config) -> + load_mathjax: (user_config, is_windows) -> if this.base == null log('You must specify the path to the MathJax installation before trying to load MathJax') return null script = document.createElement('script') + scale = if is_windows then 160 else 100 script.type = 'text/javascript' script.src = 'file://' + this.base + '/MathJax.js' - script.text = user_config + ''' + script.text = user_config + (''' MathJax.Hub.signal.Interest(function (message) {if (String(message).match(/error/i)) {console.log(message)}}); MathJax.Hub.Config({ positionToHash: false, showMathMenu: false, extensions: ["tex2jax.js", "asciimath2jax.js", "mml2jax.js"], jax: ["input/TeX","input/MathML","input/AsciiMath","output/SVG"], - SVG : { linebreaks : { automatic : true } }, + SVG : { linebreaks : { automatic : true }, scale: __scale__ }, TeX: { extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"] } @@ -47,7 +48,7 @@ class MathJax MathJax.Hub.Startup.onload(); MathJax.Hub.Register.StartupHook("End", window.mathjax.load_finished); window.mathjax.hub = MathJax.Hub - ''' + ''').replace('__scale__', scale) document.head.appendChild(script) load_finished: () => @@ -58,7 +59,7 @@ class MathJax this.pending_cfi = null window.cfi.scroll_to(cfi, callback) - check_for_math: () -> + check_for_math: (is_windows) -> script = null this.math_present = false this.math_loaded = false @@ -73,7 +74,7 @@ class MathJax if script != null or document.getElementsByTagName('math').length > 0 this.math_present = true - this.load_mathjax(user_config) + this.load_mathjax(user_config, is_windows) return this.math_present after_resize: () -> diff --git a/src/calibre/gui2/viewer/documentview.py b/src/calibre/gui2/viewer/documentview.py index c82f182338..4bc7c66fad 100644 --- a/src/calibre/gui2/viewer/documentview.py +++ b/src/calibre/gui2/viewer/documentview.py @@ -258,7 +258,8 @@ class Document(QWebPage): # {{{ self.javascript('window.paged_display.read_document_margins()') self.set_bottom_padding(0) self.fit_images() - self.math_present = self.javascript('window.mathjax.check_for_math()', bool) + w = 1 if iswindows else 0 + self.math_present = self.javascript('window.mathjax.check_for_math(%d)' % w, bool) self.init_hyphenate() self.javascript('full_screen.save_margins()') if self.in_fullscreen_mode: