Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 05-04-2013, 06:46 PM   #1
mattcurtis
Book Lover, Dev of Hyphen
mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.
 
mattcurtis's Avatar
 
Posts: 59
Karma: 2013886
Join Date: Apr 2013
Device: iPhone (Hyphen)
When displaying ePubs, what is the best way to display user font-size, color, etc.?

A lot of ePubs specify things like font-size, paragraph spacing, line-height, and font color via stylesheets. I'm developing a reader, and I'm wondering what is the recommended way of overriding those ePub-set styles and displaying a user's custom display settings. Besides inserting something like:

Code:
* { color: #usercolor; }
p { color: #usercolor; }
body { color: #usercolor; }
Are there any recommended techniques for this? Thanks.
mattcurtis is offline   Reply With Quote
Old 05-05-2013, 03:14 AM   #2
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
Dependes on your reader. Some can, others can't. Otherwise you can change it in the ePUB itself, but I would not recommend that.
Toxaris is offline   Reply With Quote
Advert
Old 05-05-2013, 08:28 AM   #3
AlPe
Digital Amanuensis
AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.
 
AlPe's Avatar
 
Posts: 727
Karma: 1446357
Join Date: Dec 2011
Location: Turin, Italy
Device: Several eReaders and tablets
Assuming that you are using an already existing engine to render the XHTML pages, what you should do is patching the source code of the pages extracted from the EPUB container, before passing them to the renderer.

In general, this will require analyzing the CSS cascade, the XHTML of the page (style can be defined both in <head> and inline), etc. Wherever needed, you must change/add your own style definitions for the various elements, according to your user-generated settings.

It is a pretty complicate endeavour, but a simple start consists in injecting the user-generated settings as last <style> element in the head of the XHTML page. This overrides CSS declarations, but it might be overridden by inline style statemets. However this technique should probably suffice for a vast majority of eBooks.
AlPe is offline   Reply With Quote
Old 05-11-2013, 01:46 AM   #4
dgatwood
Curmudgeon
dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.
 
dgatwood's Avatar
 
Posts: 629
Karma: 1623086
Join Date: Jan 2012
Device: iPad, iPhone, Nook Simple Touch
The approach I would tend to take is this:

1. If the user doesn't request a style override, use the publisher's style as-is.
2. If the user asks for a typical style override, inject a new style tag after the last one in the document, then walk each stylesheet in the order in which they appear (not including the one you just inserted). For each CSS rule in the book's stylesheets:

a. Create a new rule set in your custom stylesheet with the same selector.
b. Inspect each declaration within that rule, and if there is a conflicting declaration in the book's stylesheet that is not marked !important, insert your own declaration inside the rule set you just created.
c. If there is a conflicting declaration that is marked !important, don't try to override it.

Repeat until you have processed every stylesheet in the book.

3. If the user asks for a "sudo" style override, either disable the book's stylesheet outright and substitute your own, or follow the steps for #2, but override the !important styles, too. Please be judicious in deciding when it is appropriate to do this, though. This really only makes sense if you're basically overriding everything—font face, font size, line height, margins (and particularly negative margins), padding, etc. and setting everything to the defaults. If you leave almost any book-specific styling in place, you'll almost invariably break things.
dgatwood is offline   Reply With Quote
Old 05-17-2013, 01:06 AM   #5
mattcurtis
Book Lover, Dev of Hyphen
mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.
 
mattcurtis's Avatar
 
Posts: 59
Karma: 2013886
Join Date: Apr 2013
Device: iPhone (Hyphen)
Quote:
Originally Posted by dgatwood View Post
The approach I would tend to take is this:

1. If the user doesn't request a style override, use the publisher's style as-is.
2. If the user asks for a typical style override, inject a new style tag after the last one in the document, then walk each stylesheet in the order in which they appear (not including the one you just inserted). For each CSS rule in the book's stylesheets:

a. Create a new rule set in your custom stylesheet with the same selector.
b. Inspect each declaration within that rule, and if there is a conflicting declaration in the book's stylesheet that is not marked !important, insert your own declaration inside the rule set you just created.
c. If there is a conflicting declaration that is marked !important, don't try to override it.

Repeat until you have processed every stylesheet in the book.

3. If the user asks for a "sudo" style override, either disable the book's stylesheet outright and substitute your own, or follow the steps for #2, but override the !important styles, too. Please be judicious in deciding when it is appropriate to do this, though. This really only makes sense if you're basically overriding everything—font face, font size, line height, margins (and particularly negative margins), padding, etc. and setting everything to the defaults. If you leave almost any book-specific styling in place, you'll almost invariably break things.
Excellent answers I'm getting! Thank you.

Question: wouldn't number 2 override headers? Would you say it's a good idea for my selector for the user's font size target paragraph tags, instead of body?
mattcurtis is offline   Reply With Quote
Advert
Old 05-17-2013, 04:09 PM   #6
William Ockham
Enthusiast
William Ockham can illuminate an eclipseWilliam Ockham can illuminate an eclipseWilliam Ockham can illuminate an eclipseWilliam Ockham can illuminate an eclipseWilliam Ockham can illuminate an eclipseWilliam Ockham can illuminate an eclipseWilliam Ockham can illuminate an eclipseWilliam Ockham can illuminate an eclipseWilliam Ockham can illuminate an eclipseWilliam Ockham can illuminate an eclipseWilliam Ockham can illuminate an eclipse
 
Posts: 36
Karma: 8164
Join Date: Jul 2012
Device: Kindle Keyboard
No, don't do this. What you are asking is how to be non-compliant with the spec. To quote from the 2.01 version of the spec:

This specification assumes the use of selectors (see http://www.w3.org/TR/REC-CSS2/selector.html), cascade, and inheritance (see http://www.w3.org/TR/CSS2/cascade.html) be consistent with the definitions in the CSS2 Specification. For example, the CSS2 Specification defines !important rules (see http://www.w3.org/TR/CSS2/cascade.html#important-rules) to create a balance of power between author and user style sheets.

Use the cascade. No special effort required.
William Ockham is offline   Reply With Quote
Old 05-20-2013, 07:16 PM   #7
AlPe
Digital Amanuensis
AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.
 
AlPe's Avatar
 
Posts: 727
Karma: 1446357
Join Date: Dec 2011
Location: Turin, Italy
Device: Several eReaders and tablets
BTW, how many reading systems actually support (the required) oeb-page-head and oeb-page-foot ?

If a RS lets the user choose to override something, I do not see it as a problem, as soon as it is not the default (and only) behavior.
AlPe is offline   Reply With Quote
Old 05-24-2013, 10:37 AM   #8
mattcurtis
Book Lover, Dev of Hyphen
mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.mattcurtis ought to be getting tired of karma fortunes by now.
 
mattcurtis's Avatar
 
Posts: 59
Karma: 2013886
Join Date: Apr 2013
Device: iPhone (Hyphen)
Quote:
Originally Posted by William Ockham View Post
No, don't do this. What you are asking is how to be non-compliant with the spec. To quote from the 2.01 version of the spec:

This specification assumes the use of selectors (see http://www.w3.org/TR/REC-CSS2/selector.html), cascade, and inheritance (see http://www.w3.org/TR/CSS2/cascade.html) be consistent with the definitions in the CSS2 Specification. For example, the CSS2 Specification defines !important rules (see http://www.w3.org/TR/CSS2/cascade.html#important-rules) to create a balance of power between author and user style sheets.

Use the cascade. No special effort required.
I'm probably going to give this a shot, and see if other methods are required.
mattcurtis is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change font size and font style? butterbescotch Sigil 20 09-06-2013 08:22 PM
Determine font and font size on incoming epub? peaceridge Calibre 4 01-30-2012 03:35 PM
Greek not displaying properly in Calibre-created epubs Priscillux Recipes 3 11-13-2011 04:40 PM
Displaying Book Details display in main window pnwuser Library Management 3 01-25-2011 12:46 PM
PRS-300 Med font size too big, but small font size too small eli2k Sony Reader 4 05-28-2010 09:47 AM


All times are GMT -4. The time now is 10:33 AM.


MobileRead.com is a privately owned, operated and funded community.