mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
E-book viewer: Fix mathematics being typeset at too small a font size on windows
This commit is contained in:
parent
1a38f03966
commit
0f20c27226
Binary file not shown.
@ -23,23 +23,24 @@ class MathJax
|
|||||||
this.pending_cfi = null
|
this.pending_cfi = null
|
||||||
this.hub = null
|
this.hub = null
|
||||||
|
|
||||||
load_mathjax: (user_config) ->
|
load_mathjax: (user_config, is_windows) ->
|
||||||
if this.base == null
|
if this.base == null
|
||||||
log('You must specify the path to the MathJax installation before trying to load MathJax')
|
log('You must specify the path to the MathJax installation before trying to load MathJax')
|
||||||
return null
|
return null
|
||||||
|
|
||||||
script = document.createElement('script')
|
script = document.createElement('script')
|
||||||
|
scale = if is_windows then 160 else 100
|
||||||
|
|
||||||
script.type = 'text/javascript'
|
script.type = 'text/javascript'
|
||||||
script.src = 'file://' + this.base + '/MathJax.js'
|
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.signal.Interest(function (message) {if (String(message).match(/error/i)) {console.log(message)}});
|
||||||
MathJax.Hub.Config({
|
MathJax.Hub.Config({
|
||||||
positionToHash: false,
|
positionToHash: false,
|
||||||
showMathMenu: false,
|
showMathMenu: false,
|
||||||
extensions: ["tex2jax.js", "asciimath2jax.js", "mml2jax.js"],
|
extensions: ["tex2jax.js", "asciimath2jax.js", "mml2jax.js"],
|
||||||
jax: ["input/TeX","input/MathML","input/AsciiMath","output/SVG"],
|
jax: ["input/TeX","input/MathML","input/AsciiMath","output/SVG"],
|
||||||
SVG : { linebreaks : { automatic : true } },
|
SVG : { linebreaks : { automatic : true }, scale: __scale__ },
|
||||||
TeX: {
|
TeX: {
|
||||||
extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"]
|
extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"]
|
||||||
}
|
}
|
||||||
@ -47,7 +48,7 @@ class MathJax
|
|||||||
MathJax.Hub.Startup.onload();
|
MathJax.Hub.Startup.onload();
|
||||||
MathJax.Hub.Register.StartupHook("End", window.mathjax.load_finished);
|
MathJax.Hub.Register.StartupHook("End", window.mathjax.load_finished);
|
||||||
window.mathjax.hub = MathJax.Hub
|
window.mathjax.hub = MathJax.Hub
|
||||||
'''
|
''').replace('__scale__', scale)
|
||||||
document.head.appendChild(script)
|
document.head.appendChild(script)
|
||||||
|
|
||||||
load_finished: () =>
|
load_finished: () =>
|
||||||
@ -58,7 +59,7 @@ class MathJax
|
|||||||
this.pending_cfi = null
|
this.pending_cfi = null
|
||||||
window.cfi.scroll_to(cfi, callback)
|
window.cfi.scroll_to(cfi, callback)
|
||||||
|
|
||||||
check_for_math: () ->
|
check_for_math: (is_windows) ->
|
||||||
script = null
|
script = null
|
||||||
this.math_present = false
|
this.math_present = false
|
||||||
this.math_loaded = false
|
this.math_loaded = false
|
||||||
@ -73,7 +74,7 @@ class MathJax
|
|||||||
|
|
||||||
if script != null or document.getElementsByTagName('math').length > 0
|
if script != null or document.getElementsByTagName('math').length > 0
|
||||||
this.math_present = true
|
this.math_present = true
|
||||||
this.load_mathjax(user_config)
|
this.load_mathjax(user_config, is_windows)
|
||||||
return this.math_present
|
return this.math_present
|
||||||
|
|
||||||
after_resize: () ->
|
after_resize: () ->
|
||||||
|
@ -258,7 +258,8 @@ class Document(QWebPage): # {{{
|
|||||||
self.javascript('window.paged_display.read_document_margins()')
|
self.javascript('window.paged_display.read_document_margins()')
|
||||||
self.set_bottom_padding(0)
|
self.set_bottom_padding(0)
|
||||||
self.fit_images()
|
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.init_hyphenate()
|
||||||
self.javascript('full_screen.save_margins()')
|
self.javascript('full_screen.save_margins()')
|
||||||
if self.in_fullscreen_mode:
|
if self.in_fullscreen_mode:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user