From SVG

This page is an archive of the previous Group's wiki from http://www.w3.org/Graphics/SVG/Group/wiki.

Test Coverage for SVG Tiny 1.2 Chapter 17: Fonts



 - is a comment or note
  is an assertion or feature that is fully covered in the test suite
 # is an assertion or feature that is partially or not covered in the test suite

17.1 Introduction

 - no tests
 - this section could usefully be marked as informative

17.2 Overview of SVG fonts


 An SVG font is a font defined using SVG's 'font' element.
 - tested by many existing tests

- Graphics editing applications or file translation tools must not attempt to convert SVG fonts into system fonts.
 - not a viewer conformance requirement

# The value of the units-per-em attribute on the 'font' element specifies how many units the em square is divided into.
 - New test fonts-overview-201-t.svg has three fonts, each with a single glyph; the em squares are a range of different sizes: 10, 1000, 100,000. AndrewE points out that 100,000 is outside the 16bit fp range for tiny, so a different value should be used.

- test now fixed to use 10,000 not 100,000

 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.
 - already covered by many existing tests; glyphs are not upside down
 An SVG font can be either embedded within the same document that uses the font or saved as part of an external resource.
 - many, but specifically tests for the later section, fonts-elem-01 tests an internal font and fonts-elem-03 tests the same font externally.

17.3 The 'font' element


 horiz-origin-x = "<number>"
   The X-coordinate in the font coordinate system of the origin of a glyph to be used when drawing horizontally oriented text. (Note that the origin applies to all glyphs in the font.) If the attribute is not specified, the effect is as if a value of "0" were specified.
 - fonts-elem-05.svg
 horiz-adv-x = "<number>"
   The default horizontal advance after rendering a glyph in horizontal orientation. Glyph widths are required to be non-negative, even if the glyph is typically rendered right-to-left, as in Hebrew and Arabic scripts. If the attribute is not specified, the effect is as if a value of "0" was specified.
 - fonts-elem-06.avg
 - "are required to be" sounds like content conformance. However the spec does not say what an renderer should do if it finds negative advance.

 - Each 'font' element must have a 'font-face' child element which describes various characteristics of the font.
  - content conformance, not viewer.

17.4 The 'glyph' element


 The graphics that make up the 'glyph' consist of a single path data specification within the d attribute (and then, later). The definition of the outline of a glyph, using the same syntax as for the d attribute on a 'path' element. See Path data.
 - tested by many in general

# Need tests to ensure all the path commands are implemented, ie not just cubics or quadratics. copy from path tests.

 unicode = "<string>"
   One or more characters indicating the sequence of characters which corresponds to this glyph. If a single character is provided, then this glyph corresponds to the given Unicode character. If multiple characters are provided, then this glyph corresponds to the given sequence of Unicode characters. One use of a sequence of characters is ligatures.
 - text-intro-06-t.svg tests mandatory arabic ligatures
 - text-text-06-t.svg tests x/y positioning of ligatures

# add a test with an ae ligature, plus an a and an e glyph.

# glyph-name = "<list-of-string>"
   An optional name for the glyph. Glyph names should be unique within a font.
 - If they are not unique, the content is still conformant and there is no noticeable affect on implementations, which rarely use the glyph-name attribute in normal useage anyway
 - The glyph names can be referenced in kerning  definitions.
 - Test glyph names referenced in kerning.
 - Test with duplicate glyph names, which are used in kerning?

 arabic-form = "initial | medial | terminal | isolated" For Arabic glyphs, indicates which of the four possible forms this glyph represents.
 - fonts-glyph-02-t.svg tests arabic-form

# If arabic-form is not specified for a glyph that requires it, the glyph is taken to be the isolated form and the initial, medial, and terminal forms will render with missing-glyph unless separately specified.
 - needs a test, copy from fonts-glyph-02-t.svg and delete the arabic-form attribute.

 lang = "%LanguageCodes;"
   The attribute value is a comma-separated list of language tags as defined in IETF Best Current Practice 47 [BCP 47]. For XML content, the glyph can be used if the xml:lang attribute exactly matches one of the languages given in the value of this parameter, or if the xml:lang attribute exactly equals a prefix of one of the languages given in the value of this parameter such that the first tag character following the prefix is "-". If the attribute is not specified, then the glyph can be used in all languages.
 - fonts-glyph-03-t.svg tests lang, including subtags.
 horiz-adv-x = "<number>"
   The horizontal advance after rendering the glyph in horizontal orientation. 
 - tested by multiple tests

# If the attribute is not specified, the effect is as if the attribute were set to the value of the font's horiz-adv-x attribute.
 - new test, use an existing font as a basis, make two copies of the font, delete one h-a-x on glyph and put that value on font element instead for one of them. then overlap the text; layout should be the same.

# The resulting, transformed path specification is rendered as if it were a 'path' element, using the styling properties that apply to the characters which correspond to the given glyph, and ignoring any styling properties specified on the 'font' element or the 'glyph' element.
 - test with styling properties on the font and glyph element (invalid test)
 - test with font and path, set thick dashed stroke on both, look the same

17.5 The 'missing-glyph' element


# The 'missing-glyph'  element defines a graphic 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.
 - partly tested; add a test with an unusual (eg, private use area) character, and an svg font that does not cover it, but does have a missing-glyph. However, note that any missing glyph can be used; it does not have to be the one from this font.

17.6 Glyph selection rules


 When determining the glyph(s) to draw a given character sequence, the 'font' element must be 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 must be used. Thus, if an "ffl" ligature is defined in the font after the "f" glyph, it will not be used.
 - fonts-glyph-04-t.svg tests this same case (ffl)

# however, I did make a pair of prettier tests, fonts-glyph-201-t.svg, with an fj ligature and fonts-glyph-202-t.svg to test longest substring matching; partly to show why custom ligatures are needed.

17.7 The 'hkern' element


- there is only a single kern test in the 1.2T test suite, fonts-kern-01-t.svg

# 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' and 'font-weight'.
 - that sounds conformance-like, but I can't see how kerning could be specified for dissimilar values of anything other than font-size. It says font, not font-family.
 - needs a test to ensure that kerning is disabled by a tspan that changes the font size.
 - need a test that has font1 with glyph-name g1 and font2 with glyph-name g2, plus a g1 to g2 kern pair; test is passed if its not applied.

# 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.
 - needs a test where kern pairs are specified for characters which are adjacent in logical order in the test string, but not in visual order. Test is passed if the kern is not applied.
 - needs a test where kern pairs are specified for characters which are not adjacent in logical order in the test string, but are in visual order. Test is passed if the kern *is* applied.

 For convenience to font designers and to minimize file sizes, a single 'hkern' can define a single kerning adjustment value between one set of glyphs (sequences and/or ranges of Unicode characters) and another set of glyphs (e.g., another range of Unicode characters).
 - fonts-kern-01-t.svg tests that list syntax, given in more detail below.

 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.
 - "pairs of glyphs which" is poor grammar. 'contiguous' is a bit vague; 'adjacent in visual order' seems better.
 - Negative kerning adjustments increase the spacing between characters.
 - fonts-kern-01-t.svg tests negative kerns.

- u1 = "[<character> | <urange> ] [, [<character> | <urange>] ]* "
 character, urange, "urange comma urange", "character comma character"
 - fonts-kern-01-t.svg.
# "urange comma character" and "character comma urange" are as yet untested.

# Comma is the separator character; thus, to kern a comma, specify the comma as part of a range of Unicode characters or as a glyph name using the g1 attribute
 - test that (and test that u1="," does not kern)

 g1 = "<list-of-string>"
 - fonts-kern-01-t.svg tests single strings and lists of strings.

 The total set of possible first glyphs in the kerning pair is the union of glyphs specified by the u1 and g1 attributes.
 - fonts-kern-01-t.svg

# All glyphs with the given glyph name are included in the set.
 - Need test with duplicate glyph-name attrs to be  sure all of them are kerned, not just (say) the first one.

17.8 Describing a font


# 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.
 - Ned a test that has font-face as child of font, plus a src pointing to another font, which must not be used as src is ignored.
 - Comma-separated values and the 'all' keyword are not tested for font descriptors. Test for font-style and font-weight (ie the two thatalso correspond to properties)
 - Unicode-range is not tested. have a test where a font has characters used by the test string, but unicode-range says not to use them. have font-family property with two (local, svg) fonts, so the second one matches on those excluded characters.
 - The 'informative' values that do not correspond to font properties are not tested and in some cases (eg Panose) are difficult to test. They are just metadata.
 - matching on most font selectors is already covered - font-family, font-weight

# For horizontally oriented glyph layouts, indicates the alignment coordinate for glyphs to achieve XXX baseline alignment. The value is an offset in the font coordinate system.
 - test several fonts with unusual values for baselines; and test which has to line up.

# underline-position = "<number>"
   The ideal position of an underline within the font coordinate system.
 - SVGT1.2 lacks text-decoration property, so the underline etc can't be tested directly from SVGT 1.2 (but can be tested by other languages, such as SVGF 1.1 or XHTML+CSS) using an SVGT 1.2 font.

A 'font-face-src' element contains a 'font-face-uri' element. The 'font-face-src' element is used for referencing fonts defined elsewhere.
 - tested by many tests, but specifically by fonts-elem-03.svg.
 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 (see [IRI]). 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).
 - tested by fonts-elem-01.svg and fonts-elem-03.svg.