Quote:
Originally Posted by politicorific
I've searched and searched and yet have not been able to come up with definitive answers to using SVG in epub files. I feel as though I've learned a lot about svg these past couple weeks, but still some answers elude me. Is there a guide to inline svg and epub files?
|
Nothing EPUB-specific that I know of, but there isn't really anything EPUB-specific about SVG. All the information out there about including SVG inline in XHTML should apply.
Quote:
Originally Posted by politicorific
First must I use only one style or the other?
|
I'm afraid I don't follow...
Quote:
Originally Posted by politicorific
Which fonts should I be using? Which fonts are monospace (important for my drawings since the numbers must line up vertically.) Minion Pro is an Open Font, but isn't monospace, Lucida Sans is - is there a list of Open Fonts which are monospace?
|
I assume by "Open Font" you mean "OpenType font." In any case, that's a feature of the font, and is entirely up to you, assuming that you are embedding the fonts. The EPUB spec doesn't require reader applications to make any particular fonts available, so if you need font with particular properties, the only way to ensure they are present is to embed them.
That said, you don't need to use monospace fonts to ensure text alignment. Just construct your SVG so that the numbers are aligned.
Quote:
Originally Posted by politicorific
How do I preserve whitespace?
|
As far as I know, you don't. If you need pieces of text placed at particular points, place them there using separate SVG text elements.
Quote:
Originally Posted by politicorific
I have tried several different places to preserve whitespace. "xml:space= "preserve" doesn't seem to be doing anything. Neither does the "pre:" tag, nor does placing a [code] or [pre] tag before the [svg] tag.
|
The XHTML and CSS containing the SVG affects only the placement and size of the box in which the SVG is rendered.
Quote:
Originally Posted by politicorific
I have defined my xml doctype to be strict.
|
That's actually incorrect. The XHTML doctypes specify only XHTML elements, which means that including SVG elements makes the document invalid. If you're using inline SVG, you can't declare a doctype. As a side-effect this means that you can't use any of the HTML character entities -- just include the characters themselves directly and encode as UTF-8 or UTF-16 (as the EPUB spec requires).
Quote:
Originally Posted by politicorific
Also I've seen some epub files use "<svg:svg xxx> <svg:text> </svg:text>" instead of "<svg> <text></text> </svg>" Is there a difference?
|
Namespaced XML differentiates different "applications" or "vocabularies" by giving each element a "fully-qualified name" consisting of a "namespace" and a "local name." For the SVG element <svg/> the namespace is "http://www.w3.org/2000/svg" and the local name is "svg". This is unwieldy to write out all the time, so the spec allows documents to declare "namespace prefixes," which are human-readable shorthand for a namespace. Your snippet contains xmlns:svg="http://www.w3.org/2000/svg" which declares the prefix 'svg' as referring to the SVG namespace for that element and for all of it's descendants. This means you have to use <svg:svg/> and <svg:text/>. If you used just <svg/> then you'd be saying "the element in the default namespace with the local name 'svg'" (you'll usually have already declared the default namespace as XHTML). If you instead have xmlns="http://www.w3.org/2000/svg" on your SVG <svg/> elements, then you're re-defining the default namespace for that element and all its descendents, in which case you need to use just <svg/> and <text/> -- in that case the svg: prefix is undeclared and <svg:svg/> doesn't refer to anything the parser knows about.
Quote:
Originally Posted by politicorific
Dimensions - should I be using % or px for the viewbox? I'm defining my columns to be about 350 pixels since the paragraphs are very short. If I define my drawings in pixels will it cause problems with reflow/zoom? For example will it keep the drawing the same size or cut parts off?
|
You should rarely use pixels for anything -- those are purely a feature of the particular device and its resolution. Use % to specify a proportion of the viewable area or 'pt' to specify an actual physical dimension. For viewBox though, the units are the SVG internal scalable units, and those aren't really related to what happens in actual rendering. You just use viewBox to specify what viewport you want on the drawing, then use the size of the XHTML+CSS rendering box to specify it's actual placement and size in rendering.