View Full Version : Removing Font and Margin Overrides


anamardoll
06-06-2011, 09:40 PM
Complete newbie to the epub forum here. Hi. :)

(Please don't kill me with sheep. :o)

I'm really liking my new Sony reader, but I'm astounded to see that there's a high variation in embedded fonts and margin sizes in my epub collection.

I'm kind of a control freak, so I'd like to strip out the embedded fonts on all my books and force them to conform to my device-font. And while I'm at it, I wouldn't mind ripping out the predefined margins, because some of my books have a wasted inch of space or more. Ick.

I know just enough about epubs to turn the .epub extension into a .zip extension and look at the .css file. That is it. I know what CSS looks like, but have no idea what does what or what I need to change, etc.

So...

1. Is there a program (Sigil? Calibre?) that will let me change my epubs or do I have to modify them through the zip file --> css method?

2. What piece of code is in the epubs to override my device fonts and what should I change it to so that it will stop overriding my device?

3. Same question, but about margins: how do I modify them?

4. Is there a way (please dear god, let there be a way) to automate this for my 350+ epubs or must I do all this by hand?

Thank you in advance. :o

Toxaris
06-07-2011, 03:11 AM
Perhaps Calibre can do something with the conversion from epub to epub, I don't know. I don't like the code from Calibre...

The fonts are the most easy to remove. Just load the epub in Sigil and remove the font-face and font-family references. That should take care of that.

Margins are a bit more difficult. Margins can be set on many levels, @page, body, paragraph and so on. Just search on 'margin-' in the CSS and you schould be able to get most. However, take in mind that no margins at all is not always pleasant to read. That depends on the book.
Then of course there can be internal stylesheets in each xhtml file. There also references to the font and margins can be set.

Many ways to do things and I thing that in your collection all methods are used. That makes is more difficult to automate things. Again, perhaps you can use Calibre conversion.

anamardoll
06-07-2011, 08:33 AM
Apparently, there is a Calibre plugin for removing the default fonts, so I was able to get that to work, yay. :)

I'm still running into weirdness on the new font, though. The old, font-embedded books look different from the new, non-font-embedded books, even when using the same font (Charis). The font on the reader looks super-bold and thick.

The CSS for my reader font is:

@font-face {
font-family: "Charis";
font-weight: normal;
font-style: normal;
src: url(res:///Data/fonts/Charis-Regular.ttf);
}

@font-face {
font-family: "Charis";
font-weight: bold;
font-style: normal;
src: url(res:///Data/fonts/Charis-Bold.ttf);
}

@font-face {
font-family: "Charis";
font-weight: normal;
font-style: italic;
src: url(res:///Data/fonts/Charis-Italic.ttf);
}

@font-face {
font-family: "Charis";
font-weight: bold;
font-style: italic;
src: url(res:///Data/fonts/Charis-BoldItalic.ttf);
}

body {
font-family: "Charis", serif;
/* line-height: 150% */
}

.calibre {
font-family: "Charis", serif;
/* line-height: 150% */
}


The CSS from the embedded-font (back when it was embedded) was (snippet):

.calibre {
background-color: #FFF;
display: block;
font-family: "Charis";
font-size: 1em;
line-height: 1.2;
margin-bottom: 0;
margin-left: 5pt;
margin-right: 5pt;
margin-top: 0;
padding-left: 0;
padding-right: 0;
text-align: center
}


I'm not sure I know enough about CSS to get the new font to behave like the old ones did. I've tried adding the font-size / line-height lines to my CSS, but nothing changed. I'd like uniformity across my books. :o

shall1028
06-08-2011, 01:09 PM
I'm kind of a control freak, so I'd like to strip out the embedded fonts on all my books and force them to conform to my device-font. And while I'm at it, I wouldn't mind ripping out the predefined margins, because some of my books have a wasted inch of space or more. Ick.

I suppose that old-fashioned "processed dead tree carcass" books must just send you into apoplectic fits. A good sharp knife or guillotine cutter can help trim away the excess paper to solve the margin problem. You could copy out the contents of every book to a blank notebook in your own handwriting to solve the font problem. :)

anamardoll
06-08-2011, 01:27 PM
I suppose that old-fashioned "processed dead tree carcass" books must just send you into apoplectic fits. A good sharp knife or guillotine cutter can help trim away the excess paper to solve the margin problem. You could copy out the contents of every book to a blank notebook in your own handwriting to solve the font problem. :)

Actually, I have stopped reading books for having un-readable fonts. It's rare, but it does happen. :chinscratch:

I don't feel the flaws of the old system should carry over to the new system. We have the technology for user-defined fonts, so there's no reason not to employ it wherever possible. :)

Toxaris
06-08-2011, 02:09 PM
Sometimes a writer has a specific meaning for using a font. Actually, in my library almost no book has build in fonts from the start.

anamardoll
06-08-2011, 02:29 PM
Sometimes a writer has a specific meaning for using a font. Actually, in my library almost no book has build in fonts from the start.

I've had several library books come with embedded fonts -- they are almost always Charis, so I imagine the culprit is the publisher trying to standardize rather than the author wanting a certain effect. :)

I'm not immune to the argument that the author should have a say in how their product is presented, but font-choice is so personal. If you look at our Sans Serif / Serif poll, you'll see that some people find one or the other to be ABSOLUTELY EYES-BLEEDING UNREADABLE. Furthermore, there is some evidence that different disabilities (like dyslexia) may respond differently to certain fonts.

Given all that, I think it's perfectly acceptable that the author, well, not get to mandate what font their work is read in. They're welcome to make a suggestion, but personal need trumps authorial rights in this case, I think. :)

thydere
06-09-2011, 02:33 AM
Another solution that might help is to look at rules containing 'font-weight' entries in the produced css - not in the @font-face rules but in general. If some are set to bold/bolder then that might explain the problems you're describing - if so either delete them or set their values to 'normal'.

It's also possible that your html contains inconvenient presentation markup (b, em, h...), although I doubt that since - in my experience - Calibre handles everything with css.

If you completely remove the css stylesheet and still have boldness problems then thats a good indicator that either the markup or - as Toxaris mentioned - inline stylesheets are to blame.

To get rid of the former you could always override the default element rendering by inserting a
b, em {font-weight: normal; font-style: normal;}
rule into your css - although that would pretty much contradict every usage of those elements, even in cases where their rendering is intended :(.

For the later have a look at the html files and search for elements which contain style="..." attributes.


Finally there's always the option to convert your book using Stanza Desktop - though I would only recommend that as a fallback option since Stanza rigorously removes all presentational markup (i.e. no italics, bold, etc. anymore).

DiapDealer
06-09-2011, 08:13 AM
The sad--but honest--news is that there will be no easy automated process that will work for all 350+ of your books. The good news is: once you start rooting around in the CSS and html, it will become easier to spot patterns and methods that people use to put their epubs together. It will get increasingly easier to achieve exactly what you want with practice. But I would never attempt to "fix" 350+ epubs... I only attempt to fix the one I'm reading right now. ;)

anamardoll
06-09-2011, 10:20 AM
The sad--but honest--news is that there will be no easy automated process that will work for all 350+ of your books. The good news is: once you start rooting around in the CSS and html, it will become easier to spot patterns and methods that people use to put their epubs together. It will get increasingly easier to achieve exactly what you want with practice. But I would never attempt to "fix" 350+ epubs... I only attempt to fix the one I'm reading right now. ;)

That's a shame. :(

It really should be possible to automate the process - there's a finite number of ways to set margins, font, and font size in code, so automating a search-and-change process should not be impossible.

Just needs someone who understands the code first. :smack:

Jellby
06-09-2011, 11:09 AM
It really should be possible to automate the process - there's a finite number of ways to set margins, font, and font size in code, so automating a search-and-change process should not be impossible.

But some margins are useful, and others are not. For instance, having a margin above and below a poetry fragment or an illustration is good, but the same margin for every paragraph might not be your cup of tea (it's not mine).

And then, what if the code has this:

.text { margin: 1em 0; }

<p class="text">Some normal text</p>

<div class="text"><img src="image.png" alt=""/></div>

<p class="text">More normal text</p>

and that's even allowing that paragraphs are marked with <p> and other blocks with <div>, which is often not the case...

anamardoll
06-09-2011, 12:35 PM
I'm more interested in tweaking the left/right side margins -- several books on my reader look like this tiny little median of text with two large highways of blank space on either side. :angry:

JSWolf
06-09-2011, 07:16 PM
body {
display: block;
font-family: "Charis", serif;
line-height: 1.1em
margin-bottom: 0;
margin-left: 0;
margin-right: 0;
margin-top: 0;
widows: 0;
orphans: 0
}

There is your body code. For me, I prefer no margins on my 650.

anamardoll
06-09-2011, 07:32 PM
Thank you -- I'll try that tonight. :)