View Full Version : User Stylesheet for Adobe Digital Editions


wallcraft
09-15-2009, 12:00 AM
In What's the default ADE font? (http://www.mobileread.com/forums/showthread.php?p=587258#post587258), Peter Sorotokin mentioned that device manufacturers can override the default font (or even make it user-selectable) through a user stylesheet.

In Changing paragraph spacing in DRMed epub? (http://www.mobileread.com/forums/showthread.php?p=592004#post592004), Who are you? provided instructions for where to put a userStyle.css for the (Windows) Sony eBook Library viewer. It seems that something similar could (should) be available for all versions of ADE. However, so far only the Sony viewer is known to work this way.

In a recent post, which I can't find (so please provide a reference), someone mentioned that a @font-face can override one of the three default font-families (serif, san-serif, monospace). This provides a particularly simple application of a User Stylesheet.

I enclose the following userStyle.css: @font-face {
font-family: "Liberation Sans", sans-serif;
font-weight: normal;
font-style: normal;
src: url(res:///adobe/fonts/LiberationSans-Regular.ttf);
}
@font-face {
font-family: "Liberation Sans", sans-serif;
font-weight: bold;
font-style: normal;
src: url(res:///adobe/fonts/LiberationSans-Bold.ttf);
}
@font-face {
font-family: "Liberation Sans", sans-serif;
font-weight: normal;
font-style: italic;
src: url(res:///adobe/fonts/LiberationSans-Italic.ttf);
}
@font-face {
font-family: "Liberation Sans", sans-serif;
font-weight: bold;
font-style: italic;
src: url(res:///adobe/fonts/LiberationSans-BoldItalic.ttf);
}
@font-face {
font-family: "Liberation Serif", serif;
font-weight: normal;
font-style: normal;
src: url(res:///adobe/fonts/LiberationSerif-Regular.ttf);
}
@font-face {
font-family: "Liberation Serif", serif;
font-weight: bold;
font-style: normal;
src: url(res:///adobe/fonts/LiberationSerif-Bold.ttf);
}
@font-face {
font-family: "Liberation Serif", serif;
font-weight: normal;
font-style: italic;
src: url(res:///adobe/fonts/LiberationSerif-Italic.ttf);
}
@font-face {
font-family: "Liberation Serif", serif;
font-weight: bold;
font-style: italic;
src: url(res:///adobe/fonts/LiberationSerif-BoldItalic.ttf);
}
@font-face {
font-family: "Liberation Mono", monospace;
font-weight: normal;
font-style: normal;
src: url(res:///adobe/fonts/LiberationMono-Regular.ttf);
}
@font-face {
font-family: "Liberation Mono", monospace;
font-weight: bold;
font-style: normal;
src: url(res:///adobe/fonts/LiberationMono-Bold.ttf);
}
@font-face {
font-family: "Liberation Mono", monospace;
font-weight: normal;
font-style: italic;
src: url(res:///adobe/fonts/LiberationMono-Italic.ttf);
}
@font-face {
font-family: "Liberation Mono", monospace;
font-weight: bold;
font-style: italic;
src: url(res:///adobe/fonts/LiberationMono-BoldItalic.ttf);
} Go to C:\Program Files\Sony\Reader\Data\bin and create the path adobe\pxf\ there and put userStyle.css in there to override default epub styles. In this case only the default fonts are redefined, and all 12 .ttf files need to go in C:\Program Files\Sony\Reader\Data\bin\adobe\fonts. I got the fonts from https://fedorahosted.org/releases/l/i/liberation-fonts/liberation-fonts-ttf-1.05.1.20090721.zip. You can obviously use any fonts you have legal access to. Also, you don't need to provide bold, italic, and bolditalic versions if they are not available (or you don't want to).

The attached screenshots show TEST_defaultfonts.epub (http://www.mobileread.com/forums/showpost.php?p=590868&postcount=10) with this userStyle.css active. Unlike with the original default fonts, the Liberation fonts have explicit bold, italic, and bolditalic versions which are being correctly displayed here.

There is obviously other things that can go into userStyle.css, which has the advantage that it can be applied to all DRMed ePubs. In my opinion, all implementations of ADE should allow and document the addition of userStyle.css and user-defined fonts.

wallcraft
09-15-2009, 09:10 AM
It is also easy to switch to a sans-serif default font by using the same font for serif and sans-serif. For example, the userStyle.css: @font-face {
font-family: "Arial Black", serif, sans-serif;
font-weight: normal;
font-style: normal;
src: url(res:///adobe/fonts/Arial-Black.ttf);
} will use Arial Black for any ePub without embedded fonts.

Valloric
09-15-2009, 03:05 PM
This is very useful information. Thanks for posting it.

zelda_pinwheel
09-15-2009, 03:12 PM
excellent !! thank you, this is really great ! i'm going to do it right now. :)

zelda_pinwheel
09-15-2009, 03:27 PM
any chance this user style sheet can be added directly to the sony device, as well ?

salty-horse
09-15-2009, 04:52 PM
Zelda, I asked the same question here (http://www.mobileread.com/forums/showthread.php?p=592669) in the PRS-505 forum :)

zelda_pinwheel
09-15-2009, 04:53 PM
thanks salty-horse ! i hope we'll get an answer. :)