View Full Version : EPUB without fonts


roger64
10-11-2012, 11:53 AM
Hi

I am used to produce EPUB with embedded fonts. I would like to add EPUB without fonts. It's easy to suppress any information about font-family. But for styles, if I wish to give a clean EPUB without font, I need to transform the small-caps styles to reduced capitals styles.

This must be done for paragraph and character styles (spans), probably best in Sigil.

Has somebody any advice to make this transcription automatic?

JSWolf
10-11-2012, 12:07 PM
Hi

I am used to produce EPUB with embedded fonts. I would like to add EPUB without fonts. It's easy to suppress any information about font-family. But for styles, if I wish to give a clean EPUB without font, I need to transform the small-caps styles to reduced capitals styles.

This must be done for paragraph and character styles (spans), probably best in Sigil.

Has somebody any advice to make this transcription automatic?

You have to do it by hand. You have to retype the letters in uppercase. Then apply a span with a class that uses a 75% smaller size.

in CSS...

.smallcaps {
font-size: .75em
}

in the XML...

<p>Here are some <span class="smallcaps">SMALLCAPS</span> for your enjoyment</p>

Jellby
10-11-2012, 12:50 PM
It becomes interesting when you have MIXED CASE smallcaps...

Usually, it's not critical to have the letters shown as actual smallcaps, in those cases I just set the conditional styles (ADE only) to use bold (for instance) instead of smallcaps. Readers that support smallcaps will ignore the ADE-only style, and when (if) ADE supports smallcaps I'll simply remove the conditional styles.

roger64
10-11-2012, 02:16 PM
@JSWolf.

This is the downside of small-caps... You can't easily get rid of them...:blink:

@Jellby

I have still things to learn to understand your reply. Yes, I enjoy using - sparingly - these mixed case words with true small-caps. And the nicest they are, the hardest to go...

How do you write your mixed case word without true small-caps? Do you need four spans to describe: mixed case? One for M, one for ixed, one for C, one for ase?

JSWolf
10-11-2012, 03:43 PM
M<span class="smallcaps">ixed</span> C<span class="smallcaps">ase</span>

That's how you do mixed case smallcaps when simulating them. Just two spans are needed in Jellby's example.

roger64
10-11-2012, 03:55 PM
M<span class="smallcaps">ixed</span> C<span class="smallcaps">ase</span>.

OK. Thanks.

mmat1
10-11-2012, 04:28 PM
OK. Thanks.

should read:
M<span class="fakesmallcaps">IXED</span> C<span class="fakesmallcaps">ASE</span>

(with CSS: .fakesmallcaps { font-size: 0.7em } )

roger64
10-11-2012, 10:59 PM
M<span class="fakesmallcaps">IXED</span> C<span class="fakesmallcaps">ASE</span>

(with CSS: .fakesmallcaps { font-size: 0.7em } )

Thanks for this.

I have a shortcut. I will leave my CSS style-sheet as it is except for this change: search for the small-cap font
font-family:'Linux Libertine O C';
and replace it with:
font-size:0.7em;

I'll have to process one style after another because I need to check if there is no other font-size specified. And rewrite the text inside in capitals.

For mixed cases though, I should have to parse manually the occurences in the xhtml files and correct them... I think I will probably forget them and leave everything as a fake small-cap... :-)

Jellby
10-12-2012, 03:29 AM
That's risky, the "text-transform" property is not in the ePub spec, some readers may support it though (I'm not sure about ADE, but I believe it doesn't?)

roger64
10-12-2012, 10:59 AM
That's risky, the "text-transform" property is not in the ePub spec, some readers may support it though (I'm not sure about ADE, but I believe it doesn't?)

I just came about to realize it. You are right again. It does not work. I have to write manually in capitals as mmat said...

I correct my previous message

JSWolf
10-12-2012, 08:10 PM
should read:
M<span class="fakesmallcaps">IXED</span> C<span class="fakesmallcaps">ASE</span>

(with CSS: .fakesmallcaps { font-size: 0.7em } )

.75em is fine and .smallcaps is also fine. No need to make it .7em and no need to use .fakesmallcaps.

roger64, do use .75em if you want your smallcaps and not .7em.

frostschutz
10-12-2012, 09:02 PM
http://wiki.mobileread.com/wiki/EPubHacks also contains some suggestions about small caps.

Seems to me though as if there just isn't a good solution.

My current calibre settings would filter your smallcaps hack right out. There are too many books with whacky font sizes defined in them - on Smashwords probably because they use Word/DOC as a source? - so font size is one of the properties I filter out when converfixing books.

JSWolf
10-12-2012, 09:52 PM
http://wiki.mobileread.com/wiki/EPubHacks also contains some suggestions about small caps.

Seems to me though as if there just isn't a good solution.

My current calibre settings would filter your smallcaps hack right out. There are too many books with whacky font sizes defined in them - on Smashwords probably because they use Word/DOC as a source? - so font size is one of the properties I filter out when converfixing books.

ePub > ePub in Calibre can be a really bad idea. Don't do it. Power up Sigil and fix the ePub from there. Besides, if the ePub is made correctly, there's no need to ePub > ePub.

As for the smallcaps using a font size being a hack, it's how nearly all ePub do it. So if you ePub > ePub all of you do ruin some things like smallcaps.

mmat1
10-13-2012, 03:08 AM
.75em is fine and .smallcaps is also fine. No need to make it .7em and no need to use .fakesmallcaps.

roger64, do use .75em if you want your smallcaps and not .7em.

0.7, 0.75 or 0.8; this doesn't make much difference, it's just a matter of personal taste. How to name the class is of minor interest. I just used a quite common term, which is pretty selfexplaining.

The point is, that the letters within the <span> MUST be converted to uppercase (Look at your example a few messages above (#5)). This is the major difference between small caps (Font) and fakesmallcaps.

JSWolf
10-13-2012, 01:51 PM
When I have an ePub that has enough instances of smallcaps, I do convert them to lowercase and use a real smallcaps font. Definitely looks better. I use Charis SIL most of the time and I have a smallcaps version.

Jellby
10-14-2012, 03:39 AM
0.7, 0.75 or 0.8; this doesn't make much difference, it's just a matter of personal taste.

It's rather a matter of the font used (which is a matter of personal taste, if the device allows it). The height of smallcaps should be the same as the height of lowercase letters, and the ratio lowercase/uppercase varies from font to font. Nevertheless some fonts (like the Kp-fonts (http://www.ctan.org/pkg/kpfonts) package, for LaTeX) provide at least two smallcap sizes, so I guess there's still some personal taste involved after all.

mmat1
10-14-2012, 09:06 AM
The height of smallcaps should be the same as the height of lowercase letters, and the ratio lowercase/uppercase varies from font to font.
Yes, that's right, Thanks for mentioning this ...

roger64
10-14-2012, 12:21 PM
... The height of smallcaps should be the same as the height of lowercase letters, and the ratio lowercase/uppercase varies from font to font. ...

Jellby has a knack for it... I love that. :)

Could you give an example? How to assess exactly the height of lowercase letters? (real smallcpas and fake ones). Is this something other than the font-size?

If we select fonts from the same family, can we be confident that the same percentage (or em?) will apply for both?* Shall we use em preferably than %?

* Except your example above.

mmat1
10-14-2012, 01:24 PM
Jellby has a knack for it.
That's without a doubt :book2:

Could you give an example? How to assess exactly the height of lowercase letters? (real smallcpas and fake ones). Is this something other than the font-size?


That should be no problem. Make a sample-ebook with some variants in steps of 0.05 to find a proper font size with your reader. The problem is that other readers are maybe make a slight difference in rendering. You can post a sample book and ask others to test it with their readers.

The huge problem is probably:

You have:
<p><span class="LinLibSC">Text to transform into Fake-Caps</span></p>

You need:
<p>T<span class="fc">EXT</span> <span class="fc">TO</span> <span class="fc">TRANSFORM</span> <span class="fc">INTO</span> F<span class="fc">AKE</span>-C<span class="fc">APS</span></p>

Actually I don't know how to transform that with regex etc.

Jellby
10-14-2012, 01:56 PM
Could you give an example? How to assess exactly the height of lowercase letters? (real smallcpas and fake ones). Is this something other than the font-size?

Yes, the font-size is usually the height of uppercase letters, or something similar. Depending on how the font is designed, the actual letters may be smaller or larger than their "frame" (which is what the font-size actually controls).

But for lowercase letters, every font has a different look and proportion. The only good way of getting the right size for smallcaps is by visual judgement, and you can't know which font the book will be read with!

If we select fonts from the same family, can we be confident that the same percentage (or em?) will apply for both?* Shall we use em preferably than %?

If with the same family you mean the same name and only varying in their bold/italic character, then yes, their proportions should be all the same (assuming it's seriously designed). If they're just "similar" fonts, their proportions would be similar, but not the same.

About using em or %, they're equivalent, I believe.

I guess you could use "font-size: 1ex" (the ex unit is supposed to be approximately the height of lowercase letters), but I don't think it is correctly defined in most fonts, and I wouldn't rely on it being correctly used by rendering engines... I haven't really tried it, though.

roger64
10-14-2012, 05:23 PM
Thanks for these explanations. I am sometimes facing practical problems like this one:

This is the printed text, using smallcaps: screenshot smallcap on the left. We can see that capitals have the height of lowercase letters.

This is the copy made with fake caps: screenshot fake which uses a simple code which looks clean, but it's not smallcaps and it's not quite right:
<p class="Corpspetit">LE MUSÉE NOIR <i>(Robert Laffont, 1946).</i></p>

Corpspetit uses font-size:0.75em which applies for everything inside but I do not get with the fake capitals "the height of lowercase letters". I think I should probably have added to this code a special 0.75em span for the fake?

I wonder how to write it with smallcaps.... Either the italics are too small or too big. I need a paragraph to wrap the line of code and inside a span for the smallcap. For smallcaps I usually write in the span the font-family. Should I also add a font-size:0.75em?

roger64
10-14-2012, 05:36 PM
mistake

JSWolf
10-14-2012, 05:47 PM
Is smallcaps a percecnt of the capitol or is that again based on the font in use?

derangedhermit
10-15-2012, 01:07 AM
Is smallcaps a percecnt of the capitol or is that again based on the font in use?
Smallcaps are the same height as the x-height. The x-height is the height of a lower case "x". They picked a specific letter since, especially with serif typefaces, the x usually has nice flat tops and bottoms, while many other letters, like c-e-m-n-o-s...often differ a bit from the x-height, usually a smidgen higher on the top of a hump like in the letter "o".

X-height is a font metric, one of many, that is inside every opentype font file.

It can't be a % of cap height since the ratio x-height/cap-height varies. Modern fonts for screen use typically have larger design for x-height than traditional print typefaces (e.g. Georgia or Verdana v. Times Roman), in an effort to increase readability.

Cap height is not necessarily the same as the value for 1em, either. An em also includes lower case ascenders (usually higher than caps), descenders, and maybe more space, so that if tight line spacing is acceptable, no leading is needed.

"Em" used to be a horizontal measurement - the width of a capital M. But that's usually pretty square anyway, and now it's used for vertical height. Anyway, that's where "em dash" (and "en dash") comes from: a dash the width of the letter.

Even if one gets caps set to x-height, the text will still not look right. They will be too light/thin, and the spacing will be off. I haven't experimented, but a bold at 0.4-0.6 em might look closer to right than a regular weight - a semi-bold probably will. You really need the smallcap glyphs, either from a separate font file or, preferably, as a feature in the original font.

derangedhermit
10-15-2012, 01:31 AM
Thanks for these explanations. I am sometimes facing practical problems like this one:
<p class="Corps"><span class="Corpspetit">LE MUSÉE NOIR</span><i>(Robert Laffont, 1946).</i></p>From the screenshot it looks more like 0.4-0.6 than 0.75em.

roger64
10-15-2012, 01:45 AM
Smallcaps are the same height as the x-height. The x-height is the height of a lower case "x"....

X-height is a font metric, one of many, that is inside every opentype font file.

It can't be a % of cap height since the ratio x-height/cap-height varies....

Cap height is not necessarily the same as the value for 1em, either.

"Em" used to be a horizontal measurement - the width of a capital M.



@derangedhermit

Thanks a lot for stressing clearly these main points and commenting them. So, as far as height is concerned, we have better check visually after every font change.

It seems that, finally, after losing some time on it, I got some acceptable results for fake and true smallcaps.

To put them on equal footing, I choose a 92% font-size for the paragraph and then
- uppercase with 0.75em for the fake ('Serif' font)
- lowercase for the true ('Linux Libertine')

These values above could be further tweaked but I dare not. :)

From left to right: fake, true, printed.

Jellby
10-15-2012, 04:39 AM
While faked smallcaps look "wrong" generally (because they are too thin), they have a couple of advantages:

- It's easy to have them in different styles (italic, bold), while true smallcaps are often not available in some of them.

- They can look better when combined in with numbers (as in acronyms like P2P or B3LYP), although some true smallcaps may have matching numbers too.

But they also have another disadvantage:

- The markup is hideous, even more so if you want to be careful with the spaces (note that the spacing is the "fake" example is too tight), because these are not equivalent:

<span class="smallcap">TWO WORDS</span>
<span class="smallcap">TWO</span> <span class="smallcap">WORDS</span>

the space in the first case will be 75% of a normal space, in the second case it will be a normal space.

roger64
10-15-2012, 09:09 AM
the space in the first case will be 75% of a normal space, in the second case it will be a normal space.

I really have to train my eye. I did not notice any tight spacing for the fake. Is there any reason for this? And is it coming from a special entity using 0.75em?

And now I understand why my converter uses separate spans (like in your previous second example), and also separate figures, while, to make the code look cleaner, I bundle all these separate spans into one... I was thinking it was a mistake. ;-)

Jellby
10-15-2012, 11:45 AM
I really have to train my eye. I did not notice any tight spacing for the fake. Is there any reason for this? And is it coming from a special entity using 0.75em?

You probably don't notice because it's the right space for uppercase letters, but everything scaled down to 75%. With true smallcaps, however, only the letters are scaled down (sort of), but spaces remain the normal size. It's probably more noticeable in a text with mixed normal and smallcaps pieces. Make it more extreme:

<span style="font-size:20%">THIS IS A TEST</span>
<span style="font-size:20%">THIS</span> <span style="font-size:20%">IS</span> <span style="font-size:20%">A</span> <span style="font-size:20%">TEST</span>

and you'll see the difference in spacing.

roger64
10-15-2012, 11:56 AM
Indeed. I learnt something. I should have thought: "Everything is scaled down to 75%" Thanks.

http://img15.hostingpics.net/pics/838001test.png (http://www.hostingpics.net/viewer.php?id=838001test.png)