01-08-2012, 09:14 PM | #1 |
Wannabe Connoisseur
Posts: 425
Karma: 2516674
Join Date: Apr 2011
Location: Geelong, Australia
Device: Kobo Libra 2, Kobo Aura 2, Sony PRS-T1, Sony PRS-350, Palm TX
|
Changing fonts and CSS on PRS-T1 like PRS+?
I thought it was worth making a separate thread about trying to find a way to create a PRS+ like "User CSS" for the T1. There's been a little discussion in the PRS+ thread at here, here and here, but no real progress unfortunately.
In the last PRS+ post I listed, I said: I've found a file on the reader called /system/lib/libreadercore.so. Inside that, there is the text res:///userStyle.css. I've tried putting a userStyle.css in / (the root directory), /data, /system and /mnt/sdcard and none of these appear to work. I've pulled apart /system/app/EbookReader.apk and system/app/EbookReader.odex but these don't seem to reference CSS much - it looks like everything is handled in /system/lib/libreadercore.so. I'll dig around in there a bit more... Following on from that and using some tools Morkl posted here I've further pulled apart the EbookReader.apk and EbookReader.odex files and found a reference to a method called getDocumentCSS() which looks like it builds up @font-face statements based on the current font. Unfortuantely I can't see an easy way to override anything yet. One thing I have found is that there are multiple places in the EbookReader files where the list of fonts is hard coded (Amasis, FrutigerNeue, PalatinoNova, ReallyNo2, UniversNext, Verdana), and that Japanese models have an extra two hard coded fonts (Mincho and Gothic). It really looks like there's no way to add extra fonts to the current Sony reader app without a lot of work. Looks like it's back to digging inside of /system/lib/libreadercore.so which isn't as easy as looking inside the apk/odex files. Cheers, Simon. |
01-09-2012, 04:47 PM | #2 |
Connoisseur
Posts: 62
Karma: 36180
Join Date: Dec 2011
Location: US East Coast
Device: Kobo Aura HD, Kindle 4, Sony PRS-T1 (formerly PRS-500 & 505), iPad Air
|
Maybe this will also help to solve the problem of the bold/italics disappearing when you select a different font in the Sony default reader app? Without the bold/italics fix, the font selection feature is basically useless. The fact that Sony even mentions this bug in the manual is just mind-boggling.
|
01-10-2012, 07:22 AM | #3 | |
Wannabe Connoisseur
Posts: 425
Karma: 2516674
Join Date: Apr 2011
Location: Geelong, Australia
Device: Kobo Libra 2, Kobo Aura 2, Sony PRS-T1, Sony PRS-350, Palm TX
|
Quote:
As you say, that Sony mentions this as a bug means that something isn't working as expected, and it really shouldn't be too hard to do right (at Sony's end). Cheers, Simon. |
|
01-11-2012, 12:20 PM | #4 | |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
Quote:
Good luck with your digging |
|
01-13-2012, 03:29 PM | #5 |
Bookmaker
Posts: 416
Karma: 2143650
Join Date: Sep 2010
Device: Cybook Opus
|
Yes, finding a simple fix for this would win you many kudos.
|
01-14-2012, 05:55 PM | #6 |
Connoisseur
Posts: 80
Karma: 68347
Join Date: Oct 2009
Location: Sweden
Device: PRS-T1
|
These are the @font-face directives that the Sony software generates for Amasis:
Code:
@font-face{ font-family: serif; font-style:normal; font-weight:normal; src: url(res:///ebook/fonts/AmasisMTW1G.otf);} @font-face{ font-family: serif; font-variant:small-caps; src: url(res:///ebook/fonts/AmasisMTW1G.otf);} @font-face{ font-family: serif; font-style:italic; font-weight:normal; src: url(res:///ebook/fonts/AmasisMTW1G-Italic.otf);} @font-face{ font-family: serif; font-style:normal; font-weight:bold; src: url(res:///ebook/fonts/AmasisMTW1G-Bold.otf);} @font-face{ font-family: serif; font-style:italic; font-weight:bold; src: url(res:///ebook/fonts/AmasisMTW1G-BoldItalic.otf);} @font-face{ font-family: sans-serif; font-style:normal; font-weight:normal; src: url(res:///ebook/fonts/AmasisMTW1G.otf);} @font-face{ font-family: sans-serif; font-variant:small-caps; src: url(res:///ebook/fonts/AmasisMTW1G.otf);} @font-face{ font-family: sans-serif; font-style:italic; font-weight:normal; src: url(res:///ebook/fonts/AmasisMTW1G-Italic.otf);} @font-face{ font-family: sans-serif; font-style:normal; font-weight:bold; src: url(res:///ebook/fonts/AmasisMTW1G-Bold.otf);} @font-face{ font-family: sans-serif; font-style:italic; font-weight:bold; src: url(res:///ebook/fonts/AmasisMTW1G-BoldItalic.otf);} Code:
@font-face{ font-family: serif; font-variant:small-caps; src: url(res:///ebook/fonts/AmasisMTW1G.otf);} and/or @font-face{ font-family: sans-serif; font-variant:small-caps; src: url(res:///ebook/fonts/AmasisMTW1G.otf);} In the meantime, here is a EbookReader.apk with the small-caps bits removed: http://morkl.se/reader/readermod_v1.zip (has its own package name, so it installs as normal APK and the stock reader does not need to be removed) I tested it with a sample document and all the internal fonts seem to work with bold/italics, via the font selector. |
01-14-2012, 06:40 PM | #7 |
Addict
Posts: 238
Karma: 6875
Join Date: Feb 2009
Location: Netherlands
Device: Kindle PW2
|
Awesome! Great job Morkl, on this as well as on your homescreen mod! Some karma coming your way
I am no css expert, but I see nothing wrong with the small-caps definitions. So my guess would be that the reader lib itself can't actually handle small-caps in @font-face (which seems silly, but I have no better explanation). By the way, how did you get it to log the css? I wanted to try that myself, but I didn't see what I could do with LogAdapter.debug right away. Last edited by quisvir; 01-14-2012 at 06:46 PM. |
01-14-2012, 06:53 PM | #8 |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
@Morkl
Someone should correct me if I'm wrong, but to the best of my knowledge the ADE reading app doesn't support the @font-face font-variant:small-caps option. This may be because the current epub standard doesn't include support either. That being the case, I'm not sure it's fixable other than by removing the small-caps items as you've done. Just so I fully understand, I need to root my T1 to do this and your mod becomes a second reading app? Suppose I decided I will never use any of the 3 sans-serif fonts (Frutiger, Univers, Verdana). Might it be possible to create a modified apk which substitutes the @font-faces of 3 of my own font choices pointing to external fonts stored in /fonts in internal memory by using url(res:///ebook/fonts/../../mnt/sdcard/fonts/mycustom.otf). Then I would be able to access my custom fonts via the Frutiger, Univers, Verdana standard options. Or am I being over-hopeful Well done to you for tracking down the problem. Last edited by jackie_w; 01-14-2012 at 07:04 PM. Reason: error |
01-14-2012, 06:56 PM | #9 | |
Guru
Posts: 868
Karma: 2676800
Join Date: Aug 2008
Location: Taranaki - NZ
Device: Kobo Aura H2O, Kobo Forma
|
Quote:
|
|
01-14-2012, 10:05 PM | #10 | |
Connoisseur
Posts: 62
Karma: 36180
Join Date: Dec 2011
Location: US East Coast
Device: Kobo Aura HD, Kindle 4, Sony PRS-T1 (formerly PRS-500 & 505), iPad Air
|
This is a great progress!! Thanks!
Quote:
"Like other shorthands, using ‘font-variant’ resets all font feature properties to their initial values." So maybe this is why including font-variant in the @font-face rule breaks all other definitions? Does the small-cap text display correctly without the css lines above? Last edited by soseono; 01-14-2012 at 10:15 PM. |
|
01-14-2012, 10:12 PM | #11 |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
I think the current readers only support CSS 2
|
01-15-2012, 05:58 AM | #12 |
Wannabe Connoisseur
Posts: 425
Karma: 2516674
Join Date: Apr 2011
Location: Geelong, Australia
Device: Kobo Libra 2, Kobo Aura 2, Sony PRS-T1, Sony PRS-350, Palm TX
|
Awesome indeed Morkl!
The holy grail would be to find something that works without rooting, but rooting is so easy and it looks like these font issues can be fixed (relatively?) easily by modifying the Sony apps. Do you know anything about dissecting shared libraries? /system/lib/libreadercore.so contains a reference to res:///userStyle.css, but I haven't yet been able to figure out how that is used. Cheers, Simon. |
01-15-2012, 08:40 AM | #13 | |||||
Connoisseur
Posts: 80
Karma: 68347
Join Date: Oct 2009
Location: Sweden
Device: PRS-T1
|
Quote:
Quote:
I used android.util.Log and watched the system log to get the data. Quote:
Quote:
That is correct, root is required. I could make a package that just replaces the stock reader app, but the installation process would be the same as rooting, so depending on why one avoids rooting it might not make a difference. Still, would this be of use? Custom fonts is next on the agenda Quote:
I'll take a look at libreadercore.so if I find a nice arm disassembler (the more can be done without rooting the better, i reckon), but for now I'll see to putting some kind of custom CSS option that is injected in the Reader app along with the custom fonts settings. |
|||||
01-15-2012, 10:02 AM | #14 | |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
Quote:
Code:
@import url(res:///ebook/fonts/../../mnt/sdcard/css/my.css); |
|
01-15-2012, 03:58 PM | #15 |
Bookmaker
Posts: 416
Karma: 2143650
Join Date: Sep 2010
Device: Cybook Opus
|
So, seriously? This fixes the reader italics bug?
More importantly YOU FIXED THE GODDAMN BUG BY CHANGING TWO LINES OF CODE AND SONY HASN'T FIXED IT THEMSELVES YET???!???one!? EDIT: Also I fear it crashed shortly after I started fiddling with it, so it might not be there quite yet. Last edited by Rand Brittain; 01-15-2012 at 04:10 PM. |
Tags |
css, fonts |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
PRS-350 Changing Fonts in PRS+ | spacebrew | Sony Reader Dev Corner | 31 | 08-24-2012 06:29 AM |
PRS-350 PRS 350 & PRS+: Changing LRF-fonts permanently | Analogus | Sony Reader Dev Corner | 21 | 11-08-2011 11:55 AM |
Am i doing it right?PRS+ and CSS forced Epub fonts via Calibre | melkorbauglir | Sony Reader | 20 | 07-29-2011 10:09 AM |
How does the fonts of PRS-350 and PRS-650 compare to each other? | lkkmaths | Sony Reader | 16 | 04-08-2011 07:43 PM |
Changing text size and fonts with PRS 505 | levi_john | Sony Reader | 1 | 01-20-2009 03:25 AM |