www.it-ebooks.info www.it-ebooks.info Matt Garrish and Markus Gylling EPUB 3 Best Practices www.it-ebooks.info ISBN: 978-1-449-32914-3 [LSI] EPUB 3 Best Practices by Matt Garrish and Markus Gylling Copyright © 2013 Matt Garrish and Markus Gylling. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://my.safaribooksonline.com). For more information, contact our corporate/ institutional sales department: 800-998-9938 or corporate@oreilly.com. Editor: Brian Sawyer Production Editor: Kristen Borg Proofreader: Kiel Van Horn Indexer: Jill Edwards Cover Designer: Karen Montgomery Interior Designer: David Futato Illustrator: Robert Romano February 2013: First Edition Revision History for the First Edition: 2013-01-23 First release See http://oreilly.com/catalog/errata.csp?isbn=9781449329143 for release details. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. EPUB 3 Best Practices, the image of a common goat, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trade‐ mark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. www.it-ebooks.info Table of Contents Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix 1. Package Document and Metadata. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Vocabularies 2 The Default Vocabulary 3 The Reserved Vocabularies 3 Using Other Vocabularies 4 The All-Powerful meta Element 5 Publication Metadata 7 The Package Document Structure 8 The metadata Element 9 Identifiers 11 Types of Titles 14 The Manifest and Spine 15 The manifest and Fallbacks 16 The spine 17 Document Metadata 19 Links and Bindings 20 Metadata for Fixed Layout Publications 22 The Container 22 2. Navigation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 The EPUB Navigation Document 26 Building a Navigation Document 29 Repeated Patterns 31 Table of Contents 35 Landmarks 41 Page List 44 Extensibility 45 iii www.it-ebooks.info Adding the Navigation Document 46 Embedding as Content 47 Hiding Lists 48 Styling Lists 49 The NCX 50 3. Content Documents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Terminology Refresher 53 XHTML 55 New in HTML5 56 EPUB Support Gotchas 62 DTDs Are Dead 63 Linking and Referencing 64 Content Chunking 67 epub:type and Structural Semantics 68 Adding Semantics 70 Multiple Semantics 72 MathML 72 SVG 78 Fixed Layouts 80 Covers 85 Styling 87 EPUB CSS Profile 88 CSS 2.1 88 CSS3 91 Ruby 96 Headers and Footers 97 Alt Style Tags 99 CSS Resets 102 Fallback Content 102 Manifest Fallbacks 103 Content Fallbacks 105 The epub:switch element 107 Bindings 112 4. Font Embedding and Licensing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 Why Embed Fonts? 118 Maybe You Shouldn’t 118 Maybe You Should 122 Font Embedding in EPUB 3 130 How to Embed Fonts 131 Add the Font to Your EPUB Package 132 iv | Table of Contents www.it-ebooks.info Include the File in the EPUB Manifest 132 Reference the Font in the EPUB CSS 133 Obfuscating Fonts 134 Subsetting a Font 137 Licensing Fonts for Embedding in EPUB 138 Use an Open Font 139 Contact the Foundry Directly 139 5. Multimedia. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 The Codec Issue 142 The Media Elements 144 Sources 145 Control 153 Posters 155 Dimensions 156 The Rest 157 Timed Tracks 157 Fallbacks 162 Alternate Content 163 Triggers 165 6. Media Overlays. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 The EPUB Spectrum 174 Overlays in a Nutshell 176 Synchronization Granularity 177 Constructing an Overlay 178 Sequences 180 Parallel Playback 181 Adding to the Container 184 Styling the Active Element 185 Structural Considerations 186 Advanced Synchronization 187 Audio Considerations 188 7. Interactivity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 First Principles: Interaction Scope and Design 192 Progressive Enhancement 192 Procedural Interaction: JavaScript 193 JavaScript in EPUB 2 193 The EPUB 3 epubReadingSystem Object 193 Inclusion Models 197 Ebook State and Storage 199 Table of Contents | v www.it-ebooks.info Identifying Scripted Content Documents 199 Animation and Graphics: Canvas 200 Best Practices in Canvas Usage 201 Canvas in a Nonscripted Reading System 202 Object 203 Other Graphical Interaction Models 204 Accessibility and Scripting Summary 204 8. Global Language Support. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 Characters and Encodings 206 Unicode 206 Declaring Encodings 207 Private Characters 208 Names 209 Specifying the Natural Language 211 Vertical Writing 212 Writing Modes 213 Page Progression Direction 215 Global Direction 220 Content Direction 221 Ruby and Emphasis Dots 222 Ruby 222 Emphasis Dots 224 Line Breaks, Word Breaks, and Hyphenation 226 Itemized Lists 227 9. Accessibility. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 Accessibility and Usability 230 Fundamentals of Accessibility 232 Structure and Semantics 233 Data Integrity 235 Separation of Style 237 Semantic Inflection 238 Language 239 Logical Reading Order 239 Sections and Headings 241 Context Changes 244 Lists 245 Tables 246 Figures 249 Images 250 SVG 253 vi | Table of Contents www.it-ebooks.info MathML 254 Footnotes 255 Page Numbering 256 Styling 258 Avoiding Conflicts 258 Color 258 Hiding Content 260 Emphasis 260 Fixed Layouts 261 Image Layouts 262 Mixed Layouts 265 Text Layouts 266 Interactive Layouts 266 Scripted Interactivity 267 Progressive Enhancement 267 WAI-ARIA 269 Canvas 280 Metadata 281 10. Text-to-Speech (TTS). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 PLS Lexicons 287 SSML 292 CSS3 Speech 297 11. Validation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303 epubcheck 304 Installing 304 Running 305 Options 308 Reading Errors 313 Beyond the Command Line 314 Web Validation 314 Graphical Interface 316 Commercial Options 316 Understanding Errors 317 Common XML Errors 318 Container Errors 321 Package Validation 323 Content Validation 326 Style 329 Scripting 329 Table of Contents | vii www.it-ebooks.info Accessibility 330 Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333 viii | Table of Contents www.it-ebooks.info [...]... publications, and the EPUB 3 revision of the specification has not deviated from this core tenet But that’s really all there is to an EPUB file under the hood If you feel comfortable with the concept of an EPUB as a predictable, discoverable container of your content, you’re ready to begin tackling the best practices The EPUB 3. 0 Specifications Although EPUB 3 aggregates a number of technologies, an EPUB is not... mainstream and accessible publishing for more than 15 years He was the chief editor of the EPUB 3 suite of specifications and has authored a number of works on EPUB 3 and accessibility, including the O’Reilly books What Is EPUB 3? and Accessible EPUB 3 He currently resides in Toronto, where he continues to work on EPUB and accessibility initiatives for the DAISY Consortium and others Markus Gylling has... instructions that ensure that an EPUB 3 compliant reading system will deliver the publication properly to the end user Before we take the lid off the box, let’s look at the basic building blocks of EPUB 3 metadata Vocabularies In order to make EPUBs easy to create, very little metadata is actually required, and the requirements are almost identical to those in EPUB 2 Like EPUB 2, EPUB 3 uses the Dublin Core... handle it, but it is too much to ask all EPUB 3 reading systems to be able to handle Plus, that standard changes frequently as more terms and features are added And EPUB 3 is not just for books; many publishers who create EPUBs don’t use ONIX at all EPUB 3 metadata, by contrast, is designed to provide a clear, consistent foundation, describing metadata that all EPUB 3 reading systems can be expected to... MARC record if you want to, for the EPUB 3 metadata itself, you need to follow EPUB 3 s rules That’s what this chapter is all about The Default Vocabulary The basic vocabulary on which EPUB 3 metadata depends is simple but powerful It provides specific, clearly defined terms that are used to describe fundamental properties of key elements: meta The workhorse of EPUB 3 metadata link Enabling the inclusion... most importantly, to the EPUB 3 spec Finally, he is particularly grateful to the excellent team who comprised the EPUB 3 Metadata Subgroup, with particular thanks to the dedicated work and invaluable con‐ tributions of Daniel Hughes and Graham Bell Makoto Murata is grateful to the members of the Enhanced Global Language Support subgroup of the EPUB 3 WG as well as the editors of W3C CSS Writing Modes and... practitioner In planning out this guide, one of the challenges was trying to keep straight where the boundaries are between EPUB 3 and the technologies it combines under its format umbrella Can a single book about EPUB 3 best practices try to detail every nuance of HTML5, CSS3, JavaScript, MathML and SVG, just to pick out some of the prime content document technologies? The answer should be obvious,... permission We appreciate, but do not require, attribution An attribution usually includes the title, author, publisher, and ISBN For example: EPUB 3 Best Practices by Matt Garrish and Markus Gylling (O’Reilly) Copyright 20 13 Matt Garrish and Markus Gylling, 978144 932 91 43. ” xiv | Preface www.it-ebooks.info If you feel your use of code examples falls outside fair use or the permission given above, feel free... will give you a condensed perspective on what an EPUB is This guide instead delves right into the EPUB container and walks you through best practices as they relate to production of your publications; you’ll find a bit of a mixture of practices and guidance on how to use EPUB technologies You don’t necessarily have to know the technology of publishing EPUBs inside and out to find value here, nor do... been involved in XML for 15 years, since he joined the W3C XML WG, which created XML 1.0 As the lead of the Enhanced Global Language Support subgroup of the EPUB 3 working group, he contributed to internationalization of EPUB 3 He is a co-chair of the Advanced/Hybrid Layouts WG of IDPF and a committee (ISO/IEC JTC1/SC34/AHG4) for the planning of EPUB standardization at ISO/IEC JTC1 He has contributed . . . 30 3 epubcheck 30 4 Installing 30 4 Running 30 5 Options 30 8 Reading Errors 31 3 Beyond the Command Line 31 4 Web Validation 31 4 Graphical Interface 31 6 Commercial. Gylling EPUB 3 Best Practices www.it-ebooks.info ISBN: 978-1-449 -32 914 -3 [LSI] EPUB 3 Best Practices by Matt Garrish and Markus Gylling Copyright © 20 13 Matt