SVG 2 Requirement: | Include explicit support for Web Open Font Format (WOFF). |
---|---|
Resolution: | We will mandate WOFF support in SVG 2. |
Purpose: | To allow access to full OpenType features for internationalisation and advanced typography. |
Owner: | Chris (no action) |
SVG 2 Requirement: | Mandate support for SVG Tiny fonts. |
---|---|
Resolution: | SVG 2 will mandate support for SVG Tiny fonts support, and SVG Full fonts will be specified in a separate module. |
Purpose: | Backwards compatibility for deployed content. |
Owner: | Erik (ACTION-3126), Chris (✓ ACTION-3127) |
Note: | The "separate module" is now being worked on in the SVG Glyphs for OpenType community group. |
SVG 2 Requirement: | Reference CSS3 Fonts. |
---|---|
Resolution: | SVG 2 will depend on CSS3 Fonts. |
Purpose: | Alignment with CSS 2.1 and CSS3 for Web font functionality, and to provide access to advanced typographic features of fonts. |
Owner: | Chris (ACTION-3123) |
Reliable delivery of fonts is a requirement for SVG. Designers need to create SVG content with arbitrary fonts and know that the same graphical result will appear when the content is viewed by all end users, even when end users do not have the necessary fonts installed on their computers. This parallels the print world, where the designer uses a given font when authoring a drawing for print, and the graphical content appears exactly the same in the printed version as it appeared on the designer's authoring system.
SVG utilizes the WebFonts facility defined in ([CSS3 Fonts]) as a key mechanism for reliable delivery of font data to end users. In a common scenario, SVG authoring applications generate compressed, subsetted WebFonts for all text elements used by a given SVG document fragment.
One disadvantage to the WebFont facility in the past was that specifications did not require support of particular font formats. The result was that different implementations supported different Web font formats, thereby making it difficult for Web site creators to post a single Web site using WebFonts that worked across all user agents.
SVG 2 mandates support for Web Open Font Format [WOFF], which is now supported in most user agents. Besides enabling compressed, subsetted WebFonts with accompanying metadata for clear licensing, WOFF also benefits from OpenType multilingual features and support for advanced typography. Thus, content authors can author CSS to request discretionary ligatures, swash forms, old-style figures etc. while also ensuring that a font is provided which supports those features.
In SVG 1.1, to provide a common font format for SVG that is guaranteed to be supported by all conforming SVG viewers, SVG provideed a facility to define fonts in SVG. This facility was called SVG fonts. For backwards compatibility, SVG 2 requires support for a subset of SVG Fonts, SVG Tiny Fonts, which has been widely deployed especially for mobile content.
A font description provides the bridge between an author's
font specification and the font data, which is the data needed
to format text and to render the abstract glyphs to which the
characters map — the actual scalable outlines or bitmaps. Fonts
are referenced by properties, such as the ‘font-family
’ property.
Each specified font description is added to the font database and so that it can be used to select the relevant font data. The font description contains descriptors such as the location of the font data on the Web, and characterizations of that font data. The font descriptors are also needed to match the font properties to particular font data. The level of detail of a font description can vary from just the name of the font up to a list of glyph widths.
For more about font descriptions, refer to CSS Fonts Module Level 3. [CSS3FONTS]
Font descriptions can be specified in either of the following ways:
The ‘font-face’ element corresponds directly to the @font-face facility in CSS3 Fonts ([CSS3FONTS], section 4.1). It can be used to describe the characteristics of any font, SVG font or otherwise.
When used to describe the characteristics of an SVG font contained within the same document, it is recommended that the ‘font-face’ element be a child of the ‘font’ element it is describing so that the ‘font’ element can be self-contained and fully-described. In this case, any ‘font-face-src’ elements within the ‘font-face’ element are ignored as it is assumed that the ‘font-face’ element is describing the characteristics of its parent ‘font’ element.
Attribute definitions:
font-style
’
property, except that a comma-separated list is
permitted.font-variant
’
property, except that a comma-separated list is
permitted.font-weight
’
property with three exceptions:
font-stretch
’
property except that:
CSS3 Fonts does not have a font-size descriptor.
CSS3 Fonts does not have a units-per-em descriptor.
CSS3 Fonts does not have a panose-1 descriptor.
CSS3 Fonts does not have a stemv descriptor.
CSS3 Fonts does not have a stemh descriptor.
CSS3 Fonts does not have a slope descriptor.
CSS3 Fonts does not have a cap-height descriptor.
CSS3 Fonts does not have an x-height descriptor.
CSS3 Fonts does not have an ascent descriptor.
CSS3 Fonts does not have a descent descriptor.
CSS3 Fonts does not have a widths descriptor.
CSS3 Fonts does not have a bbox descriptor.
CSS3 Fonts does not have a baseline descriptor.
CSS3 Fonts does not have a mathline descriptor.
The following elements and attributes correspond to the ‘src’ descriptor within an @font-face rule. Refer to the descriptions of the @font-face rule and 'src' descriptor in the CSS 2.1 specification ([CSS21], sections 4.1 and 4.3.)
The ‘font-face-src’ element, together with the ‘font-face-uri’ and ‘font-face-format’ elements described in the following sections, correspond to the ‘src’ descriptor within an @font-face rule. (Refer to the descriptions of the @font-face rule and 'src' descriptor in the CSS3 Fonts specification ([CSS3FONTS], sections 4.1 and 4.3.)
A ‘font-face-src’ element contains ‘font-face-uri’ and ‘font-face-name’ elements, which are used for referencing external and local fonts, respectively.
The ‘font-face-uri’ element is used within a ‘font-face-src’ element to reference a font defined inside or outside of the current SVG document.
When a ‘font-face-uri’ is referencing an SVG font, then that reference must be to an SVG ‘font’ element, therefore requiring the use of a fragment identifier [RFC3986]. The referenced ‘font’ element can be local (i.e., within the same document as the ‘font-face-uri’ element) or remote (i.e., within a different document).
Attribute definitions:
Child ‘font-face-format’ elements of a ‘font-face-uri’ element are used to specify the supported formats of the font referenced by that ‘font-face-uri’ element. They correspond to entries in a format(…) clause of the ‘src’ descriptor in an @font-face rule.
Attribute definitions:
CSS3 Fonts does not have format strings.
The ‘font-face-name’ element is used within a ‘font-face-src’ element to reference a local font by name. It corresponds to a local(…) clause in an @font-face rule ‘src’ descriptor.
Attribute definitions:
An SVG font is a font defined using SVG's ‘font’ element.
The purpose of SVG fonts is to allow for delivery of glyph outlines in display-only environments. SVG fonts that accompany Web pages must be supported only in browsing and viewing situations. Graphics editing applications or file translation tools must not attempt to convert SVG fonts into system fonts. The intent is that SVG files be interchangeable between two content creators, but not the SVG fonts that might accompany these SVG files. Instead, each content creator will need to license the given font before being able to successfully edit the SVG file. The ‘font-face-name’ element indicates the name of licensed font to use for editing.
SVG fonts contain unhinted font outlines. Because of this, on many implementations there will be limitations regarding the quality and legibility of text in small font sizes. For increased quality and legibility in small font sizes, content creators may want to use an alternate font technology, such as fonts that ship with operating systems or an alternate WebFont format.
Because SVG fonts are expressed using SVG elements and attributes, in some cases the SVG font will take up more space than if the font were expressed in a different WebFont format which was especially designed for compact expression of font data. For the fastest delivery of Web pages, content creators may want to use an alternate font technology.
A key value of SVG fonts is guaranteed availability in SVG user agents. In some situations, it might be appropriate for an SVG font to be the first choice for rendering some text. In other situations, the SVG font might be an alternate, back-up font in case the first choice font (perhaps a hinted system font) is not available to a given user.
The characteristics and attributes of SVG fonts correspond closely to the font characteristics and parameters described in the CSS Fonts Modules Level 3 specification [CSS3FONTS]. In this model, various font metrics, such as advance values and baseline locations, and the glyph outlines themselves, are expressed in units that are relative to an abstract square whose height is the intended distance between lines of type in the same type size. This square is called the em square and it is the design grid on which the glyph outlines are defined. The value of the ‘units-per-em’ attribute on the ‘font-face’ element specifies how many units the em square is divided into. Common values for other font types are, for example, 250 (Intellifont), 1000 (Type 1) and 2048 (TrueType, TrueType GX and Open-Type). Unlike standard graphics in SVG, where the initial coordinate system has the y-axis pointing downward (see The initial coordinate system), the design grid for SVG fonts, along with the initial coordinate system for the glyphs, has the y-axis pointing upward for consistency with accepted industry practice for many popular font formats.
SVG fonts and their associated glyphs do not specify bounding box information. Because the glyph outlines are expressed as SVG graphics elements, the implementation has the option to render the glyphs either using standard graphics calls or by using special-purpose font rendering technology, in which case any necessary maximum bounding box and overhang calculations can be performed from analysis of the graphics elements contained within the glyph outlines.
An SVG font can be either embedded within the same document that uses the font or saved as part of an external resource.
Here is an example of how you might embed an SVG font inside of an SVG document.
<?xml version="1.0" standalone="yes"?> <svg width="400px" height="300px" version="1.1" xmlns = 'http://www.w3.org/2000/svg'> <defs> <font id="Font1" horiz-adv-x="1000"> <font-face font-family="Super Sans" font-weight="bold" font-style="normal" units-per-em="1000" cap-height="600" x-height="400" ascent="700" descent="300" alphabetic="0" mathematical="350" ideographic="400" hanging="500"> <font-face-src> <font-face-name name="Super Sans Bold"/> </font-face-src> </font-face> <missing-glyph><path d="M0,0h200v200h-200z"/></missing-glyph> <glyph unicode="!" horiz-adv-x="300"><!-- Outline of exclam. pt. glyph --></glyph> <glyph unicode="@"><!-- Outline of @ glyph --></glyph> <!-- more glyphs --> </font> </defs> <text x="100" y="100" style="font-family: 'Super Sans', Helvetica, sans-serif; font-weight: bold; font-style: normal">Text using embedded font</text> </svg>
Here is an example of how you might use the CSS @font-face facility ([CSS3FONTS], section 4.1) to reference an SVG font which is saved in an external file. First referenced SVG font file:
<?xml version="1.0" standalone="yes"?> <svg width="100%" height="100%" version="1.1" xmlns = 'http://www.w3.org/2000/svg'> <defs> <font id="Font2" horiz-adv-x="1000"> <font-face font-family="Super Sans" font-weight="normal" font-style="italic" units-per-em="1000" cap-height="600" x-height="400" ascent="700" descent="300" alphabetic="0" mathematical="350" ideographic="400" hanging="500"> <font-face-src> <font-face-name name="Super Sans Italic"/> </font-face-src> </font-face> <missing-glyph><path d="M0,0h200v200h-200z"/></missing-glyph> <glyph unicode="!" horiz-adv-x="300"><!-- Outline of exclam. pt. glyph --></glyph> <glyph unicode="@"><!-- Outline of @ glyph --></glyph> <!-- more glyphs --> </font> </defs> </svg>
The SVG file which uses/references the above SVG font
<?xml version="1.0" standalone="yes"?> <svg width="400px" height="300px" version="1.1" xmlns = 'http://www.w3.org/2000/svg'> <defs> <style type="text/css"> @font-face { font-family: 'Super Sans'; font-weight: normal; font-style: italic; src: url("myfont.svg#Font2") format("svg") } </style> </defs> <text x="100" y="100" style="font-family: 'Super Sans'; font-weight:normal; font-style: italic">Text using referenced font</text> </svg>
The ‘font’ element defines an SVG font.
Attribute definitions:
Each ‘font’ element must have a ‘font-face’ child element which describes various characteristics of the font.
The ‘glyph’ element defines the graphics for a given glyph. The coordinate system for the glyph is defined by the various attributes in the ‘font’ element.
The graphics that make up the ‘glyph’ can be a single path data specification within the ‘d’ attribute, arbitrary SVG as content within the ‘glyph’, or both. These two alternatives are processed differently (see below).
Attribute definitions:
The graphics for the ‘glyph’ can be specified using either the ‘d’ attribute or arbitrary SVG as content within the ‘glyph’.
If the ‘d’ attribute is specified, then the path data within this attribute is processed as follows:
font-size
’ is achieved.If the ‘glyph’ has child elements, then those child elements are rendered in a manner similar to how the ‘use’ element renders a referenced symbol. The rendering effect is as if the contents of the referenced ‘glyph’ element were deeply cloned into a separate non-exposed DOM tree. Because the cloned DOM tree is non-exposed, the SVG DOM does not show the cloned instance.
For user agents that support Styling with CSS, the conceptual deep cloning of the referenced ‘glyph’ element into a non-exposed DOM tree also copies any property values resulting from the CSS cascade ([CSS21], chapter 6) on the referenced ‘glyph’ and its contents, and also applies any property values on the ‘font’ element. CSS 2.1 selectors can be applied to the original (i.e., referenced) elements because they are part of the formal document structure. CSS 2.1 selectors cannot be applied to the (conceptually) cloned DOM tree because its contents are not part of the formal document structure.
Property inheritance, however, works as if the referenced ‘glyph’ had been textually included as a deeply cloned child within the document tree. The referenced ‘glyph’ inherits properties from the element that contains the characters that correspond to the ‘glyph’. The ‘glyph’ does not inherit properties from the ‘font’ element's original parents.
In the generated content, for each instance of a given ‘glyph’, a ‘g’ is created which carries with it all property values resulting from the CSS cascade on the ‘font’ element for the referenced ‘glyph’. Within this ‘g’ is another ‘g’ which carries with it all property values resulting from the CSS cascade on the ‘glyph’ element. The original contents of the ‘glyph’ element are deep-cloned within the inner ‘g’ element.
If the ‘glyph’ has both a ‘d’ attribute and child elements, the ‘d’ attribute is rendered first, and then the child elements.
In general, the ‘d’ attribute renders in the same manner as system fonts. For example, a dashed pattern will usually look the same if applied to a system font or to an SVG font which defines its glyphs using the ‘d’ attribute. Many implementations will be able to render glyphs defined with the ‘d’ attribute quickly and will be able to use a font cache for further performance gains.
Defining a glyph by including child elements within the
‘glyph’ gives greater
flexibility but more complexity. Different fill and stroke
techniques can be used on different parts of the glyphs. For
example, the base of an "i" could be red, and the dot could be
blue. This approach has an inherent complexity with units. Any
properties specified on a text elements which represents a
length, such as the ‘stroke-width
’ property, might
produce surprising results since the length value will be
processed in the coordinate system of the glyph.
The ‘missing-glyph’ element defines the graphics to use if there is an attempt to draw a glyph from a given font and the given glyph has not been defined. The attributes on the ‘missing-glyph’ element have the same meaning as the corresponding attributes on the ‘glyph’ element.
When determining the glyph(s) to draw a given character sequence, the ‘font’ element is searched from its first ‘glyph’ element to its last in logical order to see if the upcoming sequence of Unicode characters to be rendered matches the sequence of Unicode characters specified in the ‘unicode’ attribute for the given ‘glyph’ element. The first successful match is used. Thus, the "ffl" ligature needs to be defined in the font before the "f" glyph; otherwise, the "ffl" will never be selected.
Note that any occurrences of ‘altGlyph’ take precedence over the above glyph selection rules within an SVG font.
The ‘hkern’ and ‘vkern’ elements define kerning pairs for horizontally-oriented and vertically-oriented pairs of glyphs, respectively.
Kern pairs identify pairs of glyphs within a single font
whose inter-glyph spacing is adjusted when the pair of glyphs
are rendered next to each other. In addition to the requirement
that the pair of glyphs are from the same font, SVG font
kerning happens only when the two glyphs correspond to
characters which have the same values for properties ‘font-family
’,
‘font-size
’, ‘font-style
’, ‘font-weight
’,
‘font-variant
’, ‘font-stretch
’, ‘font-size-adjust
’
and ‘font
’.
An example of a kerning pair are the letters "Va", where the typographic result might look better if the letters "V" and the "a" were rendered slightly closer together.
Right-to-left and bidirectional text in SVG is laid out in a two-step process, which is described in Relationship with bidirectionality. If SVG fonts are used, before kerning is applied, characters are re-ordered into left-to-right (or top-to-bottom, for vertical text) visual rendering order. Kerning from SVG fonts is then applied on pairs of glyphs which are rendered contiguously. The first glyph in the kerning pair is the left (or top) glyph in visual rendering order. The second glyph in the kerning pair is the right (or bottom) glyph in the pair.
For convenience to font designers and to minimize file sizes, a single ‘hkern’ and ‘vkern’ can define a single kerning adjustment value between one set of glyphs (e.g., a range of Unicode characters) and another set of glyphs (e.g., another range of Unicode characters).
The ‘hkern’ element defines kerning pairs and adjustment values in the horizontal advance value when drawing pairs of glyphs which the two glyphs are contiguous and are both rendered horizontally (i.e., side-by-side). The spacing between characters is reduced by the kerning adjustment. (Negative kerning adjustments increase the spacing between characters.)
The ‘vkern’ element defines kerning pairs and adjustment values in the vertical advance value when drawing pairs of glyphs together when stacked vertically. The spacing between characters is reduced by the kerning adjustment.
Attribute definitions:
At least one each of ‘u1’ or ‘g1’ and at least one of ‘u2’ or ‘g2’ must be provided.
The SVGFontElement interface corresponds to the ‘font’ element.
Object-oriented access to the attributes of the ‘font’ element via the SVG DOM is not available.
interface SVGFontElement : SVGElement { };
The SVGGlyphElement interface corresponds to the ‘glyph’ element.
Object-oriented access to the attributes of the ‘glyph’ element via the SVG DOM is not available.
interface SVGGlyphElement : SVGElement { };
The SVGMissingGlyphElement interface corresponds to the ‘missing-glyph’ element.
Object-oriented access to the attributes of the ‘missing-glyph’ element via the SVG DOM is not available.
interface SVGMissingGlyphElement : SVGElement { };
The SVGHKernElement interface corresponds to the ‘hkern’ element.
Object-oriented access to the attributes of the ‘hkern’ element via the SVG DOM is not available.
interface SVGHKernElement : SVGElement { };
The SVGVKernElement interface corresponds to the ‘vkern’ element.
Object-oriented access to the attributes of the ‘vkern’ element via the SVG DOM is not available.
interface SVGVKernElement : SVGElement { };
The SVGFontFaceElement interface corresponds to the ‘font-face’ element.
Object-oriented access to the attributes of the ‘font-face’ element via the SVG DOM is not available.
interface SVGFontFaceElement : SVGElement { };
The SVGFontFaceSrcElement interface corresponds to the ‘font-face-src’ element.
Object-oriented access to the attributes of the ‘font-face-src’ element via the SVG DOM is not available.
interface SVGFontFaceSrcElement : SVGElement { };
The SVGFontFaceUriElement interface corresponds to the ‘font-face-uri’ element.
Object-oriented access to the attributes of the ‘font-face-uri’ element via the SVG DOM is not available.
interface SVGFontFaceUriElement : SVGElement { };
The SVGFontFaceFormatElement interface corresponds to the ‘font-face-format’ element.
Object-oriented access to the attributes of the ‘font-face-format’ element via the SVG DOM is not available.
interface SVGFontFaceFormatElement : SVGElement { };
The SVGFontFaceNameElement interface corresponds to the ‘font-face-name’ element.
Object-oriented access to the attributes of the ‘font-face-name’ element via the SVG DOM is not available.
interface SVGFontFaceNameElement : SVGElement { };