-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Font size option (user preference) does not work when defined explicitly in author-provided CSS #34
Comments
One possible fix is : each time the user change the font size and each time we load a chapter, we iterate through all CSS rules to find all font-size [xx-small,x-small,small,medium,large,x-large,xx-large] and replace them by the corresponding rem value :
However, this won't be perfect. If there is a dynamically loaded CSS or a script changing a |
Another solution would be to use – when available – the text-size-adjust https://developer.mozilla.org/en-US/docs/Web/CSS/text-size-adjust An example working on iOS and probably Android: However it seems to be only available on mobile devices, but maybe there is Mickaël Menu 2 rue du Helder - 75009 Paris, France [email protected] On Wed, Jul 9, 2014 at 3:51 PM, Éric D. [email protected] wrote:
|
Also see Bugzilla: |
Hi. I am afraid not to have an account on the bugzilla, and I don't see how to create one. Could you help me on that ? |
Could you please explain why you would need a Bugzilla account? On Monday, July 14, 2014, Éric D. [email protected] wrote:
|
I don't know, as I don't know what is on the bugzilla. You posted a reference link that I couldn't follow and that seemed to be related to the issue or its resolution. I don't have any other information : I had the assumption that the work continued there, but I may be wrong (as I don't see anything on the bugzilla). |
Ah, apologies :) Please do not worry about the Bugzilla link, this is for internal tracking Sorry for the confusion. On Monday, July 14, 2014, Éric D. [email protected] wrote:
|
I added a comment in the Git diff, as unfortunately some text elements are not resizing. See: |
Follow-up of the above comment (so we can track commits for this issue): |
Unless I am mistaken, this issue was fixed by @ryanackley 's code: Helpers.UpdateHtmlFontSize = function ($epubHtml, fontSize) {
var factor = fontSize / 100;
var win = $epubHtml[0].ownerDocument.defaultView;
var $textblocks = $('p, div, span, h1, h2, h3, h4, h5, h6, li, blockquote, td, pre', $epubHtml);
var originalLineHeight;
// need to do two passes because it is possible to have nested text blocks.
// If you change the font size of the parent this will then create an inaccurate
// font size for any children.
for (var i = 0; i < $textblocks.length; i++) {
var ele = $textblocks[i],
fontSizeAttr = ele.getAttribute('data-original-font-size');
if (!fontSizeAttr) {
var style = win.getComputedStyle(ele);
var originalFontSize = parseInt(style.fontSize);
originalLineHeight = parseInt(style.lineHeight);
ele.setAttribute('data-original-font-size', originalFontSize);
// getComputedStyle will not calculate the line-height if the value is 'normal'. In this case parseInt will return NaN
if (originalLineHeight) {
ele.setAttribute('data-original-line-height', originalLineHeight);
}
}
}
// reset variable so the below logic works. All variables in JS are function scoped.
originalLineHeight = 0;
for (var i = 0; i < $textblocks.length; i++) {
var ele = $textblocks[i],
fontSizeAttr = ele.getAttribute('data-original-font-size'),
lineHeightAttr = ele.getAttribute('data-original-line-height'),
originalFontSize = Number(fontSizeAttr);
if (lineHeightAttr) {
originalLineHeight = Number(lineHeightAttr);
}
else {
originalLineHeight = 0;
}
$(ele).css("font-size", (originalFontSize * factor) + 'px');
if (originalLineHeight) {
$(ele).css("line-height", (originalLineHeight * factor) + 'px');
}
}
$epubHtml.css("font-size", fontSize + "%");
}; Closing. |
Originally posted by
https://github.com/vincent-gros
at
readium/readium-js-viewer#47
When the CSS file including in the EPUB file has explicit font size values like:
.medium { font-size: medium; }
The font size change option doesn't work.
This issue seems to be related to some functions in lib/ReaderSetingsDialog.js.
To see the problem, I made a sample, avaiable here.
The text was updated successfully, but these errors were encountered: