Friday, June 14, 2013

Font Units in EPUB

Doubtless, this subject has probably been answered in many EPUB discussions. Still, the question as to what font unit of measurement to use in creating an EPUB is generally unanswered. Unlike in print, the variety of font units in EPUB files is sophisticated. In my opinion, the best way to determine what font unit to use in EPUB is to answer WHY we use it.

In print, font unit problem is not an issue. Units such as inches (in), centimeters (cm), points (pt), and picas (p) are absolute values. Points are the most common in print when setting font sizes and has probably become the standard through many years.

Absolute values are units that are independent from any other relationships. For example, a 12 points font size will always be 12 points.

The problem of font size in EPUBs is due to difference in size and resolution of various screens. Screen fonts use relative values such as pixels (px), ems (em), and percent (%). I think, as of this writing, no standard for font unit in EPUB has been established YET.

Relative values are units dependent from/to a relationship. If a font size for example is in pixels, it is relative (or dependent) to screen resolution. An em is relative to the default font size provided by a browser or ereader (usually 12pt = 16px in browsers).

EPUB is quite new and like its print counterpart, it’ll take time before a standard can be set. EPUBs whether we like or not, are web pages inside a .zip file and therefore can have quite similarly the rules of typography in web design.

Ems versus Pixels

An article in About.com under web design entitled Using Points, Pixels, Ems, or Percentages for CSS Fonts tackles the use of relative units in Cascading Style Sheets (CSS). The concepts presented by the author Jennifer Kyrnin can be applied to EPUB development.

Jennifer’s article focused on “ems” and “pixels” and explained when to use one over the other. She stated two rules of thumb that concerned “accessibility” versus “control”.

Accessibility

If accessibility is your biggest concern, then you should use ems. Ems are sized so that the font size is relative to the parent element. In the case of most Web pages, this is the body element - and so the font is sized relative to the standard size of the browser.

Using ems as your font size measurement ensures that your pages will be accessible to most browsers and platforms. Plus, if your readers choose to change the default font size on the fly, your page will scale to that new size. …

Control

If control over the look of your Web page is your biggest concern, then you should use pixels. Pixels are the standard unit of measure for screens and monitors, and fonts will be more precisely the size you want on the screen.

Pixels are the measure of resolution, and the resolution of your customers' monitors can affect the readability of your type. For example, most Windows machines are set at 96 dpi, while most Macintosh machines are set at 72 dpi. So, a font set at 72px will be 1 inch (approximately) tall on a Macintosh and three quarters of an inch tall on a Windows machine. Also, some OS's (most often Linux and Unix) can make fonts extremely jagged and hard to read if they try to scale the font sizes from the pixel sizes embedded on the OS. …

—Jennifer Kyrnin

If we pick which rule of thumb applies in creating EPUB files, “accessibility” is the answer. Accessibility is the reason ereaders have font size controls and also the reason why EPUBs are mostly reflowable.

Ereader manufacturers have also provided font guidelines for EPUB developers.

Amazon, Apple, and Barnes & Nobles (B&N) Font Guidelines

Amazon Font Guideline

The Amazon Kindle Publishing Guidelines prohibits developers in setting font size for Amazon format ebooks. Though the Kindle ereaders don’t fully support EPUB, the rules in the guideline aids in EPUB to Kindle format file conversion.

Apple/iBookstore Font Guideline

The iBookstore Asset Guide (downloadable if you sign up for an iTunes Connect account) instructs developers to use em or px for font sizes but also imposes that body fonts or main text should be left alone or should be set to 1em (which also means set to 100%).

B&N PubIt! Font Guideline

It’s unclear why B&N did not include font size specification in there EPUB Format Guide. Subliminally, they must have meant that EPUB developers should not set any font sizes.

Obviously, these three guidelines fairly instruct EPUB developers not to set font sizes, implying that the device should be the one to set the font size. This would seem practical but is somehow limiting for EPUB developers.

Export to EPUB Features of DTP Applications

Well-known desktop publishing applications such as InDesign, QuarkXPress, and MS Word have export to EPUB features and most of them set the font sizes to em units. Printed books that were exported from these applications have helped in spreading of EPUBs that used em for font sizes.

A CSS generated by InDesign CS5

What About Percent?

The third unit, the percentage, though rarely mentioned plays a big part in web design when it comes to CSS reset. CSS reset can also be applied in EPUB development. The HTML5 Doctor CSS Reset is good for EPUB since it hasn’t stripped out the font-style and font-weight values of the <i> and <b> HTML tags. If you want to dive into knowing what CSS reset is, visit the article What Is A CSS Reset.

Percent is also used on drop caps and certain margins in EPUB. The best practice I can think of in using percentage is to first set all HTML tags to a font size of 100%. This will override the browser’s or ereader’s default font size for all tags (this is how the CSS reset works). Then use em units to set the font size for each HTML tag that you’ll use in the EPUB.

So why not use percentage for font sizes all the way? For one reason, we haven’t seen much EPUB files that used percentage to set the font sizes. Second reason, the em unit is used by desktop publishing applications as the unit of measure for font size. We might as well tag along in the use of em rather than use percent and wonder if we did the right thing.

Conclusion

To sum up, it seems that manufacturers don’t want EPUB developers to mess with font size in EPUB. But if we ever do need to set font sizes, let’s take note of WHY we should use a certain unit of measure.

Ems

  • Used for accessibility (in web design)
  • Used mostly by desktop publishing applications in export to EPUB feature

Pixels

  • Used for control (in web design)

Percent

  • Least used in EPUB font size

The em unit had the greatest fanbase for font size in EPUB. Perhaps sooner or later, this will be the standard in EPUB development.

The story doesn’t end here though. Not all devices are friendly in the use of em. I believe the e-ink Kindles are somewhat not fond of em units for font size and prefer pixels.

With all these observations, I therefore conclude that we should use em as unit of measure for font-size in EPUB development. If you have any other ideas as to what unit to use, please do share. Your ideas will be greatly appreciated.

P.S.

After checking how some mainstream ereaders support font units for screen, I've come up with the following output.

The Nook Color and Nook HD uses Adobe RMSDK (Reader Mobile Software Development Kit) which explains why they had the same behavior as Adobe Digital Editions (please excuse the misspell on Adobe Digital Editions in the table).

No comments: