mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
MOBI Input: Rescale img width and height attributes that were specified in em units. Fixes #4608 (Built in viewre picture issue)
This commit is contained in:
parent
b72a0652ff
commit
e936eb0c84
@ -7,6 +7,7 @@
|
|||||||
function scale_images() {
|
function scale_images() {
|
||||||
$("img:visible").each(function() {
|
$("img:visible").each(function() {
|
||||||
var offset = $(this).offset();
|
var offset = $(this).offset();
|
||||||
|
//window.py_bridge.debug(window.getComputedStyle(this, '').getPropertyValue('max-width'));
|
||||||
$(this).css("max-width", (window.innerWidth-offset.left-5)+"px");
|
$(this).css("max-width", (window.innerWidth-offset.left-5)+"px");
|
||||||
$(this).css("max-height", (window.innerHeight-5)+"px");
|
$(this).css("max-height", (window.innerHeight-5)+"px");
|
||||||
});
|
});
|
||||||
|
@ -563,6 +563,16 @@ class MobiReader(object):
|
|||||||
recindex = attrib.pop(attr, None) or recindex
|
recindex = attrib.pop(attr, None) or recindex
|
||||||
if recindex is not None:
|
if recindex is not None:
|
||||||
attrib['src'] = 'images/%s.jpg' % recindex
|
attrib['src'] = 'images/%s.jpg' % recindex
|
||||||
|
for attr in ('width', 'height'):
|
||||||
|
if attr in attrib:
|
||||||
|
val = attrib[attr]
|
||||||
|
if val.lower().endswith('em'):
|
||||||
|
try:
|
||||||
|
nval = float(val[:-2])
|
||||||
|
nval *= 16 * (168.451/72) # Assume this was set using the Kindle profile
|
||||||
|
attrib[attr] = "%dpx"%int(nval)
|
||||||
|
except:
|
||||||
|
del attrib[attr]
|
||||||
elif tag.tag == 'pre':
|
elif tag.tag == 'pre':
|
||||||
if not tag.text:
|
if not tag.text:
|
||||||
tag.tag = 'div'
|
tag.tag = 'div'
|
||||||
|
@ -411,6 +411,7 @@ class Style(object):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def _unit_convert(self, value, base=None, font=None):
|
def _unit_convert(self, value, base=None, font=None):
|
||||||
|
' Return value in pts'
|
||||||
if isinstance(value, (int, long, float)):
|
if isinstance(value, (int, long, float)):
|
||||||
return value
|
return value
|
||||||
try:
|
try:
|
||||||
@ -447,6 +448,9 @@ class Style(object):
|
|||||||
result = value * 0.40
|
result = value * 0.40
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def pt_to_px(self, value):
|
||||||
|
return (self._profile.dpi / 72.0) * value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def fontSize(self):
|
def fontSize(self):
|
||||||
def normalize_fontsize(value, base):
|
def normalize_fontsize(value, base):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user