Open iLeafSolutionsPvtLtd opened 5 years ago
@iLeafSolutionsPvtLtd Do you mean to say choosing a different font doesn't change the font of book?
Yes. Change is not getting reflected
It actually redraws the page. But change is not visible font looks similar as it was
It would be helpful if you could please fill the Issue Template, like Issue_Template_Examples.md
ok
Issue / Feature - Default fonts are not having any effect FolioReader version - 0.5.1 FolioReader Stock / Modified - Modified, But not much Android SDK - 27 Mobile / Tablet / Emulator Info - Mobile Crash / Error -
Steps to reproduce / Describe in detail - When we applied a font listed in Folio Reader has no effect at all. It looks similar as it was. Please find the implementation below: Config config = new Config() .setFont(1) .setShowTts(false) .setAllowedDirection(Config.AllowedDirection.VERTICAL_AND_HORIZONTAL) .setThemeColorRes(R.color.app_secondary_color);
ReadPosition readPosition = DbUtility.getReadPositionFromDb(LOG_TAG,
activity.getApplicationContext(), book.bookId);
FolioReader folioReader = FolioReader.get();
folioReader.setReadPositionListener(this)
.setReadPosition(readPosition)
.setConfig(config, true)
.openBook(bookPath, String.valueOf(book.bookId));
Thanks for filling the issue template.
So do you mean to say setFont()
is not showing any effect or by changing font from UI doesn't change font?
from UI
Can you please share EPUB file with us for further investigation?
Sure. will give you now
Please use this link: save this file in directory :
Issue is in OPS/styles/stylesheet.css of the above EPUB, body overrides the font-family.
Ok any workaround for it. Its better to hide that feature in such scenarios rite.
To override fonts in any epub file I did something like this. Just put this code in HtmlUtil#getHtmlContent
. Feel free to offer a better solution.
String fontFamily = null;
String fontStyle = null;
switch (config.getFont()) {
case Constants.FONT_ANDADA:
fontFamily = "andada";
fontStyle = "sans-serif";
break;
case Constants.FONT_LATO:
fontFamily = "lato";
fontStyle = "serif";
break;
case Constants.FONT_LORA:
fontFamily = "lora";
fontStyle = "serif";
break;
case Constants.FONT_RALEWAY:
fontFamily = "raleway";
fontStyle = "sans-serif";
break;
default:
// default or internal epub fonts will be used
break;
}
if (fontFamily != null) {
String[] textElements = {"p", "span", "h1", "h2", "h3", "h4", "h5", "h6"};
String fontFamilyStyle = "{font-family:\"{font family}\", {font style} !important;}"
.replace("{font family}", fontFamily)
.replace("{font style}", fontStyle);
cssPath = cssPath + "\n<style>\n";
for (String e : textElements) {
cssPath = cssPath + " " + e + " " + fontFamilyStyle + "\n";
}
cssPath = cssPath + "</style>";
}
@hrishikesh-kadam The solution @egidijusk posted worked for me as well. Could this solution be merged in?
Hi, The default fonts available in Folio Reader seem like not having much effect. Andada, Lato, Lora all look same. I tried your sample app, everyting is fine in it. Any help would be appreciated