我是靠谱客的博主 单薄钻石,最近开发中收集的这篇文章主要介绍精图规范1.0----10 文本 Text10 文本 Text,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

previous next   contents   elements   attributes   properties   index  


04 September 2001

10 文本 Text

 

内容 Contents

  • 10.1 引言 Introduction
  • 10.2 字符及其相应的图元 Characters and their corresponding glyphs
  • 10.3 字体、字体属性表和基线  Fonts, font tables and baselines
  • 10.4 文本元素'text'  The 'text' element
  • 10.5 文本片段修饰元素 'tspan'  The 'tspan' element
  • 10.6 文本引用元素 'tref' The 'tref' element
  • 10.7 文本布局 Text layout
    • 10.7.1 文本布局概述 Text layout introduction
    • 10.7.2 设置内部书写方向 Setting the inline-progression-direction
    • 10.7.3 文本实现中图元的方向 Glyph orientation within a text run
    • 10.7.4 双向文本 Relationship with bidirectionality
  • 10.8 文本渲染次序 Text rendering order
  • 10.9对齐属性 Alignment properties
    • 10.9.1 文本对齐属性 Text alignment properties
    • 10.9.2 基线对齐属性 Baseline alignment properties
  • 10.10 字体挑选属性 Font selection properties
  • 10.11 空白属性 Spacing properties
  • 10.12 文本修饰 Text decoration
  • 10.13 路径文本 Text on a path
    • 10.13.1 路径文本概述 Introduction to text on a path
    • 10.13.2 文本路径元素 'textPath'  The 'textPath' element
    • 10.13.3 路径文本的布局规则 Text on a path layout rules
  • 10.14 备用图元 Alternate glyphs
  • 10.15 空白字符处理 White space handling
  • 10.16 文本的选择和剪贴板操作 Text selection and clipboard operations
  • 10.17 文档对象模型接口 DOM interfaces

 

 

10.1 引言 Introduction

作为精图文档片段的一部分进行渲染的文本通过使用文本元素 'text' 来进行说明。在文本元素 'text' 中的将被绘制的字符按照XML字符数据 [XML10] 的表示方法表示。Text that is to be rendered as part of anSVG document fragment is specified using the'text' element. The characters to be drawn areexpressed as XML character data [XML10]inside the'text'element.

精图的文本元素 'text' 按照其它图形元素的渲染方法进行渲染。因此, 坐标系变换, 绘制, 剪裁 和 蒙版 等特征可依照与应用于各种形状 如路径 和 长方形相同的方式应用到文本元素 'text'中。SVG's 'text'elements are rendered like other graphics elements. Thus, coordinate system transformations,painting,clipping and masking features apply to'text' elements inthe same way as they apply toshapes such as paths and rectangles.

每个文本元素 'text' 产生一个将被渲染的单一的文本字符串。精图并不自动进行折行和断词处理. 为了达到多行文本的效果,可以使用下列方法之一:  Each 'text'element causes a single string of text to be rendered. SVG performs noautomatic line breaking or word wrapping. To achieve the effect of multiplelines of text, use one of the following methods:

  • 创作者或者创作软件包需要事先计算折行的位置并使用多个文本元素 'text'  (每一行一个文本元素).The author or authoring package needs to pre-compute the line breaks and use multiple'text' elements (one for each line of text).
  • 创作者或者创作软件包需要事先计算折行的位置并使用单个文本元素 'text' ,而此文本元素具有一个或多个文本块子元素 'tspan' ,这些文本块子元素具有属性 x, y, dx 和 dy 的适当值,它们用来设置新行中的字符的新的起始位置. (这种方法允许用户进行多行的文本选择 -- 参见 文本选择和剪贴板操作.) The author or authoring package needs to pre-compute the line breaks and use a single'text' element with one or more 'tspan' child elements with appropriate values for attributes x, y, dx and dy to set new start positions for those characters which start new lines. (This approach allows user text selection across multiple lines of text -- seeText selection and clipboard operations.)
  • 将要渲染的文本用另一个XML命名空间如 XHTML [XHTML] 通过使用外部对象元素'foreignObject' 进行内联嵌入. (注意: 此方法的精确语义此时不被完全定义.) Express the text to be rendered in another XML namespace such as XHTML [XHTML] embedded inline within a'foreignObject' element. (Note: the exact semantics of this approach are not completely defined at this time.)

在文本元素'text' 中的文本串既可以按照直线也可以沿着路径元素'path' 的轮廓线进行渲染.对于直线上的文本或者路径上的文本精图支持下列国际文本处理特性:SVG supports the following international text processingfeatures for both straight line text and text on a path: The text stringswithin'text'elements can be rendered in a straight line or rendered along the outline of a'path' element. SVG supports the followinginternational text processing features for both straight line text and text ona path:

  • 文本的水平和垂直方向 horizontal and vertical orientation of text
  • 从左到右或者双向文本(即, 混合右到左以及左到右的文本的语言, 如阿拉伯语和希伯来语) left-to-right or bidirectional text (i.e., languages which intermix right-to-left and left-to-right text, such as Arabic and Hebrew)
  • 当使用 精图字体 时, 相应于 阿拉伯语 和 汉语 文本的当前形状的正确的图元将被自动选择。    when SVG fonts are used, automatic selection of the correct glyph corresponding to the current form forArabic and Han text

(关于直线文本的布局规则在文本布局中描述. 而路径上的文本的布局规则在路径上的文本的布局规则描述.) (The layout rules forstraight line text are described in Text layout. Thelayout rules for text on a path are described in Texton a path layout rules.)

因为精图文本是以XML字符数据 [XML10]打包的: Because SVG text is packaged as XML characterdata [XML10]:

  • 在精图内容中的文本对于弱视群体是易于阅读的(参见 易访问性支持)  Text data in SVG content is readily accessible to the visually impaired (seeAccessibility Support)
  • 在很多浏览的场合, 用户可以查找和选择文本串并且复制所选定的文本串到系统剪贴板 (参见 文本选择和剪贴板操作 )In many viewing scenarios, the user will be able to search for and select text strings and copy selected text strings to the system clipboard (seeText selection and clipboard operations)
  • 与XML兼容的环球网搜索引擎查找精图内容中的文本串,只需按照其它XML文档中进行搜索的方式进行搜索,而无须进行额外的工作。XML-compatible Web search engines will find text strings in SVG content with no additional effort over what they need to do to find text strings in other XML documents

通过 基于用户所选的语言替换不同的文本串,可以实现多种语言的精图内容.Multi-languageSVG content is possible by substitutingdifferent text strings based on the user's preferred language.

基于易访问的原因,建议包含在文档中的文本有适当的语义标记表明其作用。 更多的内容请参见 精图易访问性指南. For accessibility reasons, it is recommended that text which is included in adocument have appropriate semantic markup to indicate its function. SeeSVGaccessibility guidelines for more information.

 

10.2 字符及其相应的图元 Characters and their corresponding glyphs

在 XML [XML10]中, 文本内容是通过 XML字符序列来定义的, 而每个字符通过一个特定的统一的字符编码标准 [UNICODE]中的编码来确定的. 另一方面,字体由一套图元以及与之相关的信息例如字体属性表 组成. 一个图元是一个或多个字符(或者同理一个字符的部分)的表现形式. 每一图元由某类标识符(某些情况下为字符串, 其它情况下为数值) 以及此图元的用于渲染的绘制指令构成. In XML [XML10], textual content is defined interms of a sequence of XML characters, where eachcharacter is defined by a particular Unicode code point [UNICODE]. Fonts,on the other hand, consists of a collection of glyphsand other associated information, such asfonttables. A glyph is a presentable form of one or more characters (or a partof a character in some cases). Each glyph consists of some sort of identifier(in some cases a string, in other cases a number) along with drawinginstructions for rendering that particular glyph.

在很多情况下, 存在统一字符编码(即, 统一字符编码点)到字体中的图元的一一映射关系. 例如, 通常针对拉丁语言(这里术语拉丁用于表示有字母表的欧洲语言如英语类似于并且或者从拉丁语派生的语言)字体的设计包含标准 ASCII字符(即, A-到-Z, a-到-z, 0-到-9, 外加ASCII中各种标点符号字符)所对应的图元 . 于是, 在大部分情况下, 字符串 "XML", 它由三个 统一字符编码字符构成, 将通过三个分别对应于 "X", "M" 和 "L"的图元来渲染.     In many cases, there is a one-to-onemapping of Unicode characters (i.e., Unicode code points) to glyphs in a font.For example, it is common for a font designed for Latin languages (where the termLatin is used for European languages such as English with alphabetssimilar to and/or derivative to the Latin language) to contain a single glyphfor each of the standard ASCII characters (i.e., A-to-Z, a-to-z, 0-to-9, plusthe various punctuation characters found in ASCII). Thus, in most situations,the string "XML", which consists of three Unicode characters, wouldbe rendered by the three glyphs corresponding to "X", "M"and "L", respectively.

但是在某些特殊情况下, 统一字符编码字符与图元并不存在一一映射关系. 下面为一些不为一一映射关系的情形:  In variousother cases, however, there is not a strict one-to-one mapping of Unicodecharacters to glyphs. Some of the circumstances when the mapping is notone-to-one:

  • 连字 - 为了排字有最好的视觉效果, 常常希望将某些特定字符序列作为单一的图元进行渲染. 例如单词 "office". 很多字体会定义一个连字"ffi". 当对单词 "office"进行渲染时, 有时用户代理会对连字"ffi"所对应的图元进行渲染而不对三个字符所对应的各自的图元(即, "f", "f" 和 "i") 进行渲染. 于是, 对于连字, 多个统一字符编码字符映射到单个图元. (注意某些语言特定的渲染方式, 对于某些字符的组合必须使用连字.)  Ligatures - For best looking typesetting, it is often desirable that particular sequences of characters are rendered as a single glyph. An example is the word "office". Many fonts will define an "ffi" ligature. When the word "office" is rendered, sometimes the user agent will render the glyph for the "ffi" ligature instead of rendering distinct glyphs (i.e., "f", "f" and "i") for each of the three characters. Thus, for ligatures, multiple Unicode characters map to a single glyph. (Note that for proper rendering of some languages, ligatures are required for certain character combinations.)
  • 合字 - 在很多情况下, 常用的装饰符例如变音符号会作为一个特殊的图元在一种字体中只存储一次,然后通过与一个或多个其它图元进行组合生成所期望的字符. 例如, 可以这样,某个字体引擎可以通过先渲染字符 e  的图元然后渲染 ´ (重音符号) 图元使得重音符号出现在 e 的上方来实现对字符 é 的渲染. 此时, 单个统一字符编码字符被映射为多个图元. Composite characters - In various situations, commonly used adornments such as diacritical marks will be stored once in a font as a particular glyph and then composed with one or more other glyphs to result in the desired character. For example, it is possible that a font engine might render the é character by first rendering the glyph for e and then rendering the glyph for ´ (the accent mark) such that the accent mark will appear over the e. In this situation, a single Unicode character maps to multiple glyphs.
  • 图元置换 - 某些排印系统检查文本内容的性质,在不同的情况下选用不同的图元. 例如, 在阿拉伯语中, 同一统一字符编码字符可以渲染成四种不同的图元,依赖于这种因素如此字符是否出现在草写连结字符序列的开头、末尾或中间等. 标点符号字符根据内部书写方向(例如, 水平或者垂直)将使用不同的图元. 此时, 单个统一字符编码字符被映射为多个图元中的一个图元.   Glyph substitution - Some typography systems examine the nature of the textual content and utilize different glyphs in different circumstances. For example, in Arabic, the same Unicode character might render as any of four different glyphs, depending on such factors as whether the character appears at the start, the end or the middle of a sequence of cursively joined characters. Different glyphs might be used for a punctuation character depending on inline-progression-direction (e.g., horizontal vs. vertical). In these situations, a single Unicode character might map to one of several alternative glyphs.
  • 在某些语言中, 字符的特定序列将被转换成多个图元使得特定字符的某些部分在一个图元中而此字符的剩余部分在另一个图元中. In some languages, particular sequences of characters will be converted into multiple glyphs such that parts of a particular character are in one glyph and the remainder of that character is in another glyph.
  • 二选一图元规范 - 精图包含一种机制使得作者可以明确指定统一字符编码的特定字符序列按照某一特定的图元进行渲染 . (参见 二选一图元.) 当使用这种机制时多个统一字符编码字符序列被映射为单一的图元. Alternative glyph specification - SVG contains a facility for the author to explicitly specify that a particular sequence of Unicode characters is to be rendered using a particular glyph. (SeeAlternate glyphs.) When this facility is used, multiple Unicode characters map to a single glyph.

在很多情况下, 将字符映射为图元的算法依赖于特定的系统, 这导致在不同的用户环境中文本的渲染效果可能是不同的(通常为少许的不同) . 如果精图的作者要求对字体和图元作出精确的选择, 那么建议所需的字体(仅此给定文档所需要包含的潜在的图元子集) 要么作为精图字体 嵌入精图文档中或者作为 环球网字体 按照精图相同的环球网位置进行传送.  In manysituations, the algorithms for mapping from characters to glyphs are system-dependent,resulting in the possibility that the rendering of text might be (usuallyslightly) different when viewed in different user environments. If the authorof SVG content requires precise selection of fonts and glyphs, then therecommendation is that the necessary fonts (potentially subsetted to includeonly the glyphs needed for the given document) be available either asSVG fonts embeddedwithin the SVG content or as WebFonts posted at thesame Web location as the SVG content.

贯穿本章, 术语字符等价于 XML [XML10]中字符的定义. Throughout this chapter,the term character shall be equivalent to thedefinition of a character in XML [XML10].

10.3字体、字体属性表和基线 Fonts, font tables and baselines

一种字体是由一套图元以及在某些媒体中如何运用这些图元来表示字符所需的必要信息(字体属性表)组成. 一套图元以及其相应的字体属性表的组合称之为字体数据. 字体属性表包含将字符映射为图元所必需的信息 , 以及确定图元区域的尺寸及位置的信息. 每一个字体属性表由一个或多个字体特性如粗体和字型组成. A font consists of a collection of glyphs together with theinformation (the font tables) necessary to use those glyphs to presentcharacters on some medium. The combination of the collection of glyphs and thefont tables is called thefont data. The font tables include theinformation necessary to map characters to glyphs, to determine the size ofglyph areas and to position the glyph area. Each font table consists of one ormore font characteristics, such as the font-weight and font-style.

几何字体特征按照基于EM方框的坐标系统来表示的. (EM 是对字体中的图元的一种相对测量; 参见 CSS2 em 平方.) 方框 1 EM 高 和 1 EM 宽被称为设计空间. 这种空间通过细分EM到一定数目的 units-per-em 给出一种几何坐标. The geometric fontcharacteristics are expressed in a coordinate system based on the EM box. (TheEM is a relative measure of the height of the glyphs in the font; seeCSS2 em square.) Thebox 1 EM high and 1 EM wide is called thedesign space. This space isgiven a geometric coordinates by sub-dividing the EM into a number ofunits-per-em.

注记:Units-per-em是一种字体特性。其典型的值为1000 或 2048。Note: Units-per-em is a fontcharacteristic. A typical value for units-per-EM is 1000 or 2048.

EM 方框的坐标空间被称之为设计空间坐标系. 对于可缩放字体而言, 用于绘制图元的曲线和直线使用这种坐标系来表示. Thecoordinate space of the EM box is called thedesign space coordinate system.For scalable fonts, the curves and lines that are used to draw a glyph arerepresented using this coordinate system.

注记: 在最多的时候, 在这种坐标系中点 (0,0) 位于 EM 方框的左边, 但不在左下角. 大写罗马字母的底部的 Y 坐标为零. 并且小写罗马字母的下部具有负的坐标值. Note: Mostoften, the (0,0) point in this coordinate system is positioned on the left edgeof the EM box, but not at the bottom left corner. The Y coordinate of thebottom of a roman capital letter is usually zero. And the descenders onlowercase roman letters have negative coordinate values.

精图假定字体属性表至少要提供三种字体特性: 一个上距, 一个下距和一套基线表. 上距为字体的 (0,0)点到 EM 方框的顶部的距离; 而下距为字体的 (0,0)点到 EM 方框的底部的距离. 基线表将在下面解释. SVG assumes that thefont tables will provide at least three font characteristics: an ascent, adescent and a set of baseline-tables. The ascent is the distance to the top ofthe EM box from the (0,0) point of the font; the descent is the distance to thebottom of the EM box from the (0.0) point of the font. The baseline-table is explainedbelow.

注记: 在一个开式的字体内, 对于水平书写模式而言, 上距和下距由 OS/2表中的 sTypoAscender项和 sTypoDescender项给定. 对于垂直书写模式而言, 下距 (此时为 (0,0)点到图元的左边的距离) 通常为零因为 (0,0)点在左边. 上距要么为 1 em 要么由开式基表中表意字顶部基线值来确定. Note:Within an OpenType font, for horizontal writing-modes, the ascent and descentare given by the sTypoAscender and sTypoDescender entries in the OS/2 table.For vertical writing-modes, the descent (the distance, in this case from the(0,0) point to the left edge of the glyph) is normally zero because the (0,0)point is on the left edge. The ascent for vertical writing-modes is either 1 emor is specified by the ideographic top baseline value in the OpenType Basetable for vertical writing-modes.

在水平书写模式中, 给定文本的图元按照每个图元的一个特定的点来进行安置, 这个点称为对齐点, 它与此文本中的其它图元的对齐点进行对齐. 不同类型文字的图元,例如,西文、北印和中文文本, 以具有各自代表性的图元的不同点来进行对齐. 例如, 西文图元按大写字母的底部对齐, 北印图元按照接近图元的顶部的一个水平笔划进行对齐而中文图元要么按照图元的底部或中心进行对齐. 在一种文字和具有相同字体尺寸的一行文本中,按照内部的书写方向一系列对齐点所定义的几何线称为基线. 西文和大多数别的字母和音节图元按照一种 "字母" 基线对齐, 而北印图元按照 "悬挂" 基线进行对齐而中文图元按照一种 "表意"基线进行对齐. In horizontalwriting-modes, the glyphs of a given script are positioned so that a particularpoint on each glyph, the alignment-point,is aligned with the alignment-points of the other glyphs in that script. Theglyphs of different scripts, for example, Western, Northern Indic andFar-Eastern scripts, are typically aligned at different points on the glyph.For example, Western glyphs are aligned on the bottoms of the capital letters,northern indic glyphs are aligned at the top of a horizontal stroke near thetop of the glyphs and far-eastern glyphs are aligned either at the bottom orcenter of the glyph. Within a script and within a line of text having a singlefont-size, the sequence of alignment-points defines, in the inline-progression-direction, a geometric line called a baseline. Western andmost other alphabetic and syllabic glyphs are aligned to an"alphabetic" baseline, the northern indic glyphs are aligned to a"hanging" baseline and the far-eastern glyphs are aligned to an"ideographic" baseline.

一个 基线表指定一个或多个基线在设计空间坐标系中的位置. 基线表的作用在于当不同的文字被混合安置在同一文本行上时易于对齐.因为期望的相对对齐方式依赖于在一行( 或一块)中的哪种文字具有主导地位,所以对于每一种文字可以有不同的基线表.另外, 对于水平书写方向和垂直书写方向需要不同的对齐位置. 因此, 字体有一套基线表t: 通常, 一个或更多用于水平书写模式,零个或多个用于垂直模式. Abaseline-tablespecifies the position of one or more baselines in the design space coordinatesystem. The function of the baseline table is to facilitate the alignment ofdifferent scripts with respect to each other when they are mixed on the sametext line. Because the desired relative alignments may depend on which scriptis dominant in a line (or block), there may be a different baseline table foreach script. In addition, different alignment positions are needed forhorizontal and vertical writing modes. Therefore, the font may have a set ofbaseline tables: typically, one or more for horizontal writing-modes and zeroor more for vertical writing-modes.

注记: 某些字体也许其基线表上没有取值. 当一个字体不提供基线表时,建议试探地给其赋予一个近似地基线表. Note: Some fonts may not have values for the baseline tables. Heuristics aresuggested for approximating the baseline tables when a given font does notsupply baseline tables.

精图进一步假定一种字体的字体数据中的每一个图元具有两种宽度值, 两种对齐基线和两个对齐点, 一个用于水平书写模式 而另一个用于垂直书写模式. (即使只指定一种宽度, 对于垂直书写模式而言这一宽度将用在垂直方向上.) 图元所属的文本确定了用来对齐图元的对齐基线. 对齐点的内建书写方向 位于图元的起始边. SVG further assumesthat for each glyph in the font data for a font, there are two width values,two alignment-baselines and two alignment-points, one each for horizontalwriting-modes and the other for vertical writing-modes. (Even though it isspecified as a width, for vertical writing-modes the width is used in thevertical direction.) The script to which a glyph belongs determines analignment-baseline to which the glyph is to be aligned. Theinline-progression-directionposition of the alignment-point is on the start-edge of the glyph.

与基线相关的属性在下面的 基线对齐属性 中描述.Properties related tobaselines are described below under Baselinealignment properties.

除了上面所要求地一些字体特性外, 某种字体也许提供替换和定位表用来格式化重新排列组合和定位一系列图元生成一个或多个合成图元. 合成也许同连字一样简单, 也许和北印文的音节一样复杂, 这种北印文的音节由多个辅音和元音图元组成,通常会进行某些重新排列. In addition to the font characteristics required above, a font mayalso supply substitution and positioning tables that can be used by a formatterto re-order, combine and position a sequence of glyphs to make one or morecomposite glyphs. The combination may be as simple as a ligature, or as complexas an indic syllable which combines, usually with some re-ordering, multipleconsonants and vowel glyphs.

10.4 文本元素'text'  The 'text' element

文本元素'text'定义一种由文本组成的图形元素. 在文本元素'text'中的 XML [XML10] 字符数据, 依照相关的属性和性质以及字体本身内的字符到图元的映射关系,规定被渲染的图元. (参见字符及其相应的图元.)文本元素'text'上的属性和性质表示这种事情如书写方向、字体规格以及规定如何正确对字符进行渲染的绘制属性.本章以后的章节描述文本特有的属性和性质,特别是文本布局 和 双向性. The 'text' element defines a graphics elementconsisting of text. The XML [XML10]character data within the 'text' element, alongwith relevant attributes and properties and character-to-glyph mapping tableswithin the font itself, define the glyphs to be rendered. (See Charactersand their corresponding glyphs.) The attributes and properties on the 'text' element indicate such things as the writingdirection, font specification and painting attributes which describe howexactly to render the characters. Subsequent sections of this chapter describethe relevant text-specific attributes and properties, particulartext layout and bidirectionality.

由于对文本元素 'text' 的渲染采用与其它图形元素相同的渲染方法, 所有应用到 形状 如 路径 和 长方形 的同一 坐标系变换、绘制、剪裁 和蒙版 特性同样也应用到文本元素 'text'. Since 'text' elements are rendered using the same renderingmethods as other graphics elements, all of the samecoordinate systemtransformations, painting,clipping andmasking features thatapply to shapessuch as paths and rectanglesalso apply to 'text' elements.

可以对文本使用色彩渐变、模式填充、路径剪裁、蒙版或滤镜. 当这些工具的某一种被用于文本时,关键字 objectBoundingBox  (参见对象边界方框单元)被用来说明相对于"对象边界方框"的一种图形效果, 则对象边界方框单元在所有情况下按照整个文本元素'text' 进行计算, 即使不同的效果用于此文本元素'text'中的不同的文本块元素'tspan' 同样如此. It is possible to apply a gradient, pattern, clipping path, maskor filter to text. When one of these facilities is applied to text and keyword objectBoundingBox is used (seeObject boundingbox units) to specify a graphical effect relative to the "objectbounding box", then the object bounding box units are computed relative tothe entire 'text' element in all cases, evenwhen different effects are applied to different'tspan' elements within the same 'text' element.

文本元素 'text' 在初始当前文本位置上渲染它的第一个图元(在双向性 重新排列之后) , 而初始当前文本位置由此文本元素 'text' 的 x 和 y 属性所确定(也许由于性质 'text-anchor' 的取值, 出现一个文本路径元素 'textPath' 包含第一个字符, 并且/或者 在一个 'tspan', 'tref' 或'altGlyph' 元素的x, y, dx 或 dy 属性 中包含第一个字符等原因会导致相应的调整). 在相应于给定的字符的图元被渲染之后, 当前文本位置被更新以对应于下一个字符. 在最简单的情况下, 新的当前文本位置为前一个当前文本位置加上图元的增量值 (水平或垂直). 请参见文本布局 关于图元安置和图元增量的情况. The 'text' element renders its first glyph (after bidirectionalityreordering) at the initial current textposition, which is established by the x and y attributes on the 'text'element (with possible adjustments due to the value of the'text-anchor' property, the presence of a 'textPath' element containing the firstcharacter, and/or an x, y, dx or dy attributes on a 'tspan', 'tref' or 'altGlyph' element which contains the firstcharacter). After the glyph(s) corresponding to the given character is(are)rendered, the current text position is updated for the next character. In thesimplest case, the new current text position is the previous current textposition plus the glyphs' advance value (horizontal or vertical). Seetext layout for adescription of glyph placement and glyph advance.

 
<!ENTITY % textExt "" >
<!ELEMENT text (#PCDATA|desc|title|metadata|
                tspan|tref|textPath|altGlyph|a|animate|set|
                animateMotion|animateColor|animateTransform
                %geExt;%textExt;)* >
<!ATTLIST text
  %stdAttrs;
  %testAttrs;
  %langSpaceAttrs;
  externalResourcesRequired %Boolean; #IMPLIED
  class %ClassList; #IMPLIED
  style %StyleSheet; #IMPLIED
  %PresentationAttributes-Color;
  %PresentationAttributes-FillStroke;
  %PresentationAttributes-FontSpecification;
  %PresentationAttributes-Graphics;
  %PresentationAttributes-TextContentElements;
  %PresentationAttributes-TextElements;
  transform %TransformList; #IMPLIED
  %graphicsElementEvents;
  x %Coordinates; #IMPLIED
  y %Coordinates; #IMPLIED
  dx %Lengths; #IMPLIED
  dy %Lengths; #IMPLIED
  rotate %Numbers; #IMPLIED
  textLength %Length; #IMPLIED
  lengthAdjust (spacing|spacingAndGlyphs) #IMPLIED >

属性定义 Attributedefinitions:

x = "<坐标值>+"

如果提供单一的<坐标值> , 那么此值所表示新的绝对 X 坐标指定用于渲染此元素或任何子元素的第一个字符所对应的图元的当前文本位置 .If a single <coordinate>is provided, then the value represents the new absolute X coordinate for thecurrent textposition for rendering the glyphs that correspond to the first characterwithin this element or any of its descendants.
如果提供了由逗号或空格分隔的<n>个 <坐标> 列表, 那么这些值所表示新的绝对 X 坐标指定用于渲染此元素或任何子元素的第 <n> 个字符所对应的每个图元的当前文本位置.  If a comma- or space-separated list of <n><coordinate>sis provided, then the values represent new absolute X coordinates for thecurrent textposition for rendering the glyphs corresponding to each of the first<n> characters within this element or any of its descendants.
至于额外的处理规则, 参见文本块元素 'tspan' 的属性x 的描述. For additional processing rules, refer to the description of thex attribute on the 'tspan' element.
如果不设置此属性,则其效果等同于设置此属性的值为"0"效果.If the attribute is not specified, the effect is as if a value of"0" were specified.
Animatable:yes.

y = "<坐标值>+"

在此元素内的字符所对应图元的绝对 Y 坐标的相应列表. 针对属性 'y'的处理规则与针对属性 'x' 的一致. The corresponding list of absolute Y coordinates for the glyphscorresponding to the characters within this element. The processing rules forthe 'y' attribute parallel the processing rulesfor the'x' attribute.
如果不设置此属性,则其效果等同于设置此属性的值为 "0"效果.If the attribute is not specified, the effect is as if a value of"0" were specified.
Animatable:yes.

dx = "<长度值>+"

此元素或其子孙中的字符相对当前文本位置 沿着x-轴的偏移量 . Shifts in thecurrent textposition along the x-axis for the characters within this element or any ofits descendants.
参见对文本块元素 'tspan' 的属性dx 的描述.Refer to the description of thedx attribute on the 'tspan' element.
如果不设置此元素或其子元素的此属性,则不会出现沿着x-轴的偏移量.Ifthe attribute is not specified on this element or any of its descendants, nosupplemental shifts along the x-axis will occur.
Animatable:yes.

dy = "<长度值>+"

此元素或其子孙中的字符相对当前文本位置 沿着y-轴的偏移量 . Shifts in thecurrent textposition along the y-axis for the characters within this element or any ofits descendants.
参见对文本块元素 'tspan' 的属性dy 的描述.Refer to the description of thedy attribute on the 'tspan' element.
如果不设置此元素或其子元素的此属性,则不会出现沿着y-轴的偏移量.If the attribute is not specified on this element or any of its descendants, nosupplemental shifts along the y-axis will occur.

Animatable:yes.

rotate = "<number>+"

在当前文本位置 周围作用于对应于此元素中的每一字符的所有图元的附加旋转. Thesupplemental rotation about thecurrent textposition that will be applied to all of the glyphs corresponding to each characterwithin this element.
参见对文本块元素 'tspan' 的属性rotate 的描述.Refer to the description of therotate attribute on the 'tspan' element.
如果不设置此元素或其子元素的此属性,则不会出现附加旋转.If the attribute is not specified on this element or any of itsdescendants, no supplemental rotations will occur.
Animatable:yes (non-additive, 'set' and 'animate' elements only).

textLength = "<长度值>"

此文本元素中对应于所有字符数据的增量的总和的作者的计算值, 包括图元(水平或垂直)的增量值, 考虑性质 'kerning', 'letter-spacing' 和 'word-spacing' 的效果以及由于文本块元素'tspan' 的属性dx 和 dy 所作的调整. 此值用于校准用户代理的计算与作者的计算. The author's computation of the total sum of all of the advancevalues that correspond to character data within this element, including theadvance value on the glyph (horizontal or vertical), the effect of properties'kerning', 'letter-spacing' and 'word-spacing' and adjustments due to attributes dx and dy on 'tspan' elements. This value is used to calibratethe user agent's own calculations with that of the author.
这个属性的目的在于允许作者使得在任何 双向重新排列 之后的依照可见的渲染次序, 将对应于此元素的第一和最后一个被渲染的图元进行精确的对齐; 于是, 对于最后渲染的字符而言 (在任何 双向重新排列 之后的依照可见的渲染次序), 当用户代理确定适当的数量以便对文本串进行适当伸缩满足textLength 的长度时,正常图元增量之外的附加内部字符之间的空白增量将被忽略(在大多数情况下). The purpose of this attribute is to allow the author to achieve exactalignment, in visual rendering order after anybidirectionalreordering, for the first and last rendered glyphs that correspond to thiselement; thus, for the last rendered character (in visual rendering order afteranybidirectionalreordering), any supplemental inter-character spacing beyond normal glyphadvances are ignored (in most cases) when the user agent determines theappropriate amount to expand/compress the text string to fit within a length oftextLength.
一种负值是一种错误(参见 错误处理).Anegative value is an error (see Errorprocessing).
如果不设置此属性,其效果相当于作者的计算与用户代理的计算完全相等时所出现的情况; 于是,无须此时进行进一步的调整. If the attribute is not specified, the effect is as if theauthor's computation exactly matched the value calculated by the user agent;thus, no advance adjustments are made.
Animatable:yes.

lengthAdjust ="spacing|spacingAndGlyphs"

表示调整的类型,此类型使用户代理将按照属性textLength 的值安排文本的渲染长度. Indicates the typeof adjustments which the user agent shall make to make the rendered length ofthe text match the value specified on the textLengthattribute.
spacing 表示只对增量值进行调整. 图元本身不进行伸缩. spacing indicates that only theadvance values are adjusted. The glyphs themselves are not stretched orcompressed.
spacingAndGlyphs 表示增量值将进行调整并且图元也要在一个轴上(即, 与内部书写方向平行的方向)进行伸缩. spacingAndGlyphsindicates that the advance values are adjusted and the glyphs themselvesstretched or compressed in one axis (i.e., a direction parallel to theinline-progression-direction).
用户代理要能确定文本串的正确起始和终止位置, 但是中间图元的位置是不可预测的,因为用户代理为了平衡正确起始和终止位置和最佳的排印它会调用高级的算法伸缩文本串. The user agent is required to achieve correct start and endpositions for the text strings, but the locations of intermediate glyphs arenot predictable because user agents might employ advanced algorithms to stretchor compress text strings in order to balance correct start and end positioningwith optimal typography.
注意, 对于包含 <n> 个字符的文本串来说, 对于增量值的调整常常仅对 <n-1> 个字符进行 (参见对属性 textLength 的描述), 而图元的伸缩则针对所有 <n> 个字符进行. Note that, for a text string that contains <n> characters,the adjustments to the advance values often occur only for <n-1>characters (see description of attributetextLength), whereas stretching or compressing ofthe glyphs will be applied to all <n> characters.
如果不设置此属性,其效果相当于设置了空白值. If the attribute is not specified, the effect is as a value of spacing were specified.
Animatable:yes.

其它地方已经定义的属性 Attributes defined elsewhere:

%stdAttrs;,%testAttrs;,%langSpaceAttrs;,externalResourcesRequired,class,style, %PresentationAttributes-Color;,%PresentationAttributes-FillStroke;,%PresentationAttributes-FontSpecification;,%PresentationAttributes-Graphics;,%PresentationAttributes-TextContentElements;,%PresentationAttributes-TextElements;,transform,%graphicsElementEvents;.

在下面的例子text01包含文本串"Hello, out there"它将使用以蓝色填充的Verdana字体渲染到绘制区域.Example text01 below contains the text string"Hello, out there" which will be rendered onto the canvas using theVerdana font family with the glyphs filled with the color blue.

 
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="10cm" height="3cm" viewBox="0 0 1000 300"
     xmlns="http://www.w3.org/2000/svg">
  <desc>Example text01 - 'Hello, out there' in blue</desc>
 
  <text x="250" y="150" 
        font-family="Verdana" font-size="55" fill="blue" >
    Hello, out there
  </text>
 
  <!-- Show outline of canvas using 'rect' element -->
  <rect x="1" y="1" width="998" height="298"
        fill="none" stroke="blue" stroke-width="2" />
</svg>

Example text01

View this exampleas SVG (SVG-enabled browsers only)

 

10.5 文本片段修饰元素 'tspan'  The 'tspan' element

在一个文本元素 'text' 内,包含在文本块元素 'tspan' 中的文本和字体的性质以及当前文本位置 能够根据绝对或相对坐标进行调整. Within a'text' element,text and font properties and the current textposition can be adjusted with absolute or relative coordinate values byincluding a 'tspan' element.

 
<!ENTITY % tspanExt "" >
<!ELEMENT tspan (#PCDATA|desc|title|metadata|tspan|tref|altGlyph|a|animate|set|animateColor
                %tspanExt;)* >
<!ATTLIST tspan
  %stdAttrs;
  %testAttrs;
  %langSpaceAttrs;
  externalResourcesRequired %Boolean; #IMPLIED
  class %ClassList; #IMPLIED
  style %StyleSheet; #IMPLIED
  %PresentationAttributes-Color;
  %PresentationAttributes-FillStroke;
  %PresentationAttributes-FontSpecification;
  %PresentationAttributes-Graphics;
  %PresentationAttributes-TextContentElements;
  %graphicsElementEvents;
  x %Coordinates; #IMPLIED
  y %Coordinates; #IMPLIED
  dx %Lengths; #IMPLIED
  dy %Lengths; #IMPLIED
  rotate %Numbers; #IMPLIED
  textLength %Length; #IMPLIED
  lengthAdjust (spacing|spacingAndGlyphs) #IMPLIED >

属性定义 Attributedefinitions:

x = "<坐标值>+"

如果提供单一的<坐标值> , 那么此值所表示新的绝对 X 坐标指定用于渲染此元素或任何子元素的第一个字符所对应的图元的当前文本位置 .Ifa single <coordinate>is provided, then the value represents the new absolute X coordinate for thecurrent textposition for rendering the glyphs that correspond to the first characterwithin this element or any of its descendants.
如果提供了由逗号或空格分隔的<n>个 <坐标> 列表, 那么这些值所表示新的绝对 X 坐标指定用于渲染此元素或任何子元素的第 <n> 个字符所对应的每个图元的当前文本位置. If a comma- or space-separated list of <n><coordinate>sis provided, then the values represent new absolute X coordinates for thecurrent textposition for rendering the glyphs corresponding to each of the first<n> characters within this element or any of its descendants.
如果提供比字符还多的<坐标值> , 则多余的<坐标值> 将不会影响图元的位置.If more <coordinate>sare provided than characters, then the extra <coordinate>swill have no effect on glyph positioning.
如果字符数大于 <坐标值>的个数, 那么对于每个多余的字符而言: (a) 如果上级文本元素 'text' 或者文本块元素'tspan' 通过属性x 对于给定的字符设置了一个绝对 X 坐标  , 则此绝对 X 坐标作为此字符的起始 X 坐标 (最近的上级优先考虑), 否则 (b) 给定的字符所对应的图元渲染的起始 X 坐标 为当前文本元素'text' 的最近进行渲染的图元所导出的 当前文本位置 的 X 坐标. If more characters existthan <coordinate>s,then for each of these extra characters: (a) if an ancestor 'text' or 'tspan' element specifies an absolute Xcoordinate for the given character via an xattribute, then that absolute X coordinate is used as the starting X coordinatefor that character (nearest ancestor has precedence), else (b) the starting Xcoordinate for rendering the glyphs corresponding to the given character is theX coordinate of the resultingcurrent textposition from the most recently rendered glyph for the current 'text' element.
如果不设置此属性: (a) 如果一个上级文本元素 'text' 或者文本块元素'tspan' 通过属性x 为给定的字符设置了绝对 X 坐标 , 则此绝对 X 坐标作为此字符的起始 X 坐标 (最近的上级优先考虑), 否则 (b) 给定的字符所对应的图元渲染的起始 X 坐标 为当前文本元素'text' 的最近进行渲染的图元所导出的当前文本位置 的 X 坐标. If the attribute is notspecified: (a) if an ancestor'text' or 'tspan' element specifies an absolute Xcoordinate for a given character via an xattribute, then that absolute X coordinate is used (nearest ancestor hasprecedence), else (b) the starting X coordinate for rendering the glyphscorresponding to a given character is the X coordinate of the resulting current textposition from the most recently rendered glyph for the current 'text' element.
Animatable:yes.

y = "<坐标值>+"

在此元素内的字符所对应图元的绝对 Y 坐标的相应列表. 针对属性 'y'的处理规则与针对属性 'x' 的一致. The corresponding list of absolute Y coordinates for the glyphs correspondingto the characters within this element. The processing rules for the 'y' attribute parallel the processing rules for the'x' attribute.
Animatable:yes.

dx = "<长度值>+"

如果提供单一的<长度值> , 那么此值表示用于渲染此元素或任何子元素的第一个字符所对应的图元相对于当前文本位置新的相对 X 坐标.而此当前文本位置指的是在渲染第一个字符所对应的图元之前沿着当前用户坐标系的x-轴平移的<长度值>.If a single <length>is provided, this value represents the new relative X coordinate for thecurrent textposition for rendering the glyphs corresponding to the first characterwithin this element or any of its descendants. Thecurrent textposition is shifted along the x-axis of the current user coordinate systemby<length>before the first character's glyphs are rendered.
如果提供了由逗号或空格分隔的<n>个 <长度值> 列表, 那么这些值表示用于渲染此元素或任何子元素的第 <n>个字符所对应的图元相对于当前文本位置新的相对 X 坐标.而此当前文本位置指的是在渲染第 <n> 个字符所对应的图元之前沿着当前用户坐标系的x-轴平移的 <长度值>.If a comma- or space-separated list of <n> <length>sis provided, then the values represent incremental shifts along the x-axis forthecurrenttext position before rendering the glyphs corresponding to the first<n> characters within this element or any of its descendants. Thus,before the glyphs are rendered corresponding to each character, thecurrent textposition resulting from drawing the glyphs for the previous characterwithin the current'text' element is shifted along the X axis of thecurrent user coordinate system by<length>.
如果提供比字符还多的<长度值> , 则多余的<长度值> 将不会影响图元的位置.If more <length>sare provided than characters, then any extra <length>swill have no effect on glyph positioning.
如果字符数大于 <长度值> 的个数, 那么对于每个多余的字符而言: (a) 如果上级文本元素 'text' 或者文本块元素'tspan' 通过属性dx 对于给定的字符设置了一个相对 X 坐标  , 则当前文本位置为沿着当前用户坐标系的x-轴平移此数值所得出的值 (最近的上级优先考虑), 否则 (b)沿着当前用户坐标系的x-轴的平移不会出现 .If more charactersexist than <length>s,then for each of these extra characters: (a) if an ancestor 'text' or 'tspan' element specifies a relative X coordinatefor the given character via a dx attribute, thenthecurrenttext position is shifted along the x-axis of the current user coordinatesystem by that amount (nearest ancestor has precedence), else (b) no extrashift along the x-axis occurs.
如果不设置此属性:(a) 如果上级文本元素 'text' 或者文本块元素'tspan' 通过属性dx 对于给定的字符设置了一个相对 X 坐标  , 则当前文本位置为沿着当前用户坐标系的x-轴平移此数值所得出的值 (最近的上级优先考虑), 否则 (b)沿着当前用户坐标系的x-轴的平移不会出现 .If the attribute isnot specified: (a) if an ancestor'text' or 'tspan' element specifies a relative X coordinatefor a given character via a dx attribute, then thecurrenttext position is shifted along the x-axis of the current user coordinatesystem by that amount (nearest ancestor has precedence), else (b) no extrashift along the x-axis occurs.
Animatable:yes.

dy = "<length>+"

在此元素内的字符所对应图元的相对 Y 坐标的相应列表. 针对属性 'dy' 的处理规则与针对属性 'dx' 的一致.The corresponding list of relative Y coordinates for the characterswithin the 'tspan' element. The processingrules for the 'dy' attribute parallel theprocessing rules for the'dx' attribute.
Animatable:yes.

rotate = "<number>+"

在当前文本位置 周围作用于对应于此元素中的每一字符的所有图元的附加旋转.Thesupplemental rotation about thecurrent textposition that will be applied to all of the glyphs corresponding to eachcharacter within this element.
如果提供了由逗号或空格分隔的<n>个 <number>列表, 那么第一个 <number>所表示用于渲染此元素或任何子元素的第 一个字符所对应的每个图元的附加旋转, 第二个 <number>所表示用于渲染此元素或任何子元素的第二个字符所对应的每个图元的附加旋转, 等等. If a comma- or space-separated list of<number>sis provided, then the first <number>represents the supplemental rotation for the glyphs corresponding to the firstcharacter within this element or any of its descendants, the second<number>represents the supplemental rotation for the glyphs that correspond to thesecond character, and so on.
如果提供比字符还多的 <number>, 则多余的 <number> 将被忽略.If more <number>sare provided than there are characters, then the extra <number>swill be ignored.
如果字符数大于<number>的个数, 那么对于每个多余的字符而言: (a) 如果上级文本元素'text' 或者文本块元素'tspan' 通过属性rotate 对于给定的字符设置了附加旋转  ,则此附加旋转作用于给定的字符 (最近的上级优先考虑), 否则 (b)附加旋转不会出现 .If more characters areprovided than<number>s,then for each of these extra characters: (a) if an ancestor 'text' or 'tspan' element specifies a supplemental rotationfor the given character via a rotate attribute,then the given supplemental rotation is applied to the given character, else(b) no supplemental rotation occurs.
如果不设置此属性: (a) 如果一个上级文本元素 'text' 或者文本块元素'tspan' 通过属性rotate 为给定的字符设置了附加旋转, 则此附加旋转将作用于此字符 (最近的上级优先考虑), 否则 (b) 附加旋转不会出现 . If the attribute isnot specified: (a) if an ancestor'text' or 'tspan' element specifies a supplemental rotationfor a given character via a rotate attribute, thenthe given supplemental rotation is applied to the given character (nearestancestor has precedence), else (b) no supplemental rotation occurs.
这种附加旋转并不与图元渲染改变当前文本位置的规则发生冲突并且是对路径上的文本和'水平方向的图元' 或者 '垂直方向的图元'所导致的旋转的补充. This supplementalrotation has no impact on the rules by whichcurrent textposition is modified as glyphs get rendered and is supplemental to anyrotation due totexton a path and to 'glyph-orientation-horizontal' or 'glyph-orientation-vertical'.
Animatable:yes (non-additive, 'set' and 'animate' elements only).

textLength = "<长度值>"

此文本元素中对应于所有字符数据的增量的总和的作者的计算值, 包括图元(水平或垂直)的增量值, 考虑性质 'kerning', 'letter-spacing' 和 'word-spacing' 的效果以及由于文本块元素'tspan' 的属性dx 和 dy 所作的调整. 此值用于校准用户代理的计算与作者的计算.The author's computation of the total sum of all of the advancevalues that correspond to character data within this element, including theadvance value on the glyph (horizontal or vertical), the effect of properties'kerning', 'letter-spacing' and 'word-spacing' and adjustments due to attributes dx and dy on this 'tspan' element or any descendants. This value isused to calibrate the user agent's own calculations with that of the author.
这个属性的目的在于允许作者使得在任何 双向重新排列 之后的依照可见的渲染次序, 将对应于此元素的第一和最后一个被渲染的图元进行精确的对齐; 于是, 对于最后渲染的字符而言 (在任何 双向重新排列 之后的依照可见的渲染次序), 当用户代理确定适当的数量以便对文本串进行适当伸缩满足textLength 的长度时,正常图元增量之外的附加内部字符之间的空白增量将被忽略(在大多数情况下).The purpose of this attribute is to allow the author to achieve exactalignment, in visual rendering order after anybidirectionalreordering, for the first and last rendered glyphs that correspond to thiselement; thus, for the last rendered character (in visual rendering order afteranybidirectionalreordering), any supplemental inter-character spacing beyond normal glyphadvances are ignored (in most cases) when the user agent determines theappropriate amount to expand/compress the text string to fit within a length oftextLength.
如果一给定的元素及其上级都设置了属性 textLength , 则此元素上的所有字符数据的调整只由此元素的 textLength 的值来控制, 可能的副作用是此元素的内容的调整比率与共享相同上级的其它内容的调整比率不同. 用户代理必须假定在同一上级下的其它内容的整个增量值为上级增量值与此元素的增量值之差. If attribute textLength is specifiedon a given element and also specified on an ancestor, the adjustments on allcharacter data within this element are controlled by the value of textLength on this element exclusively, with thepossible side-effect that the adjustment ratio for the contents of this elementmight be different than the adjustment ratio used for other content that sharesthe same ancestor. The user agent must assume that the total advance values forthe other content within that ancestor is the difference between the advancevalue on that ancestor and the advance value for this element.
一种负值是一种错误(参见 错误处理).Anegative value is an error (see Errorprocessing).
如果不设置此属性,其效果相当于作者的计算与用户代理的计算完全相等时所出现的情况; 于是,无须此时进行进一步的调整.If the attribute is not specified anywhere within a'text' element, the effect is as if the author'scomputation exactly matched the value calculated by the user agent; thus, noadvance adjustments are made.
Animatable:yes.

其它地方已经定义的属性 Attributes defined elsewhere:

%stdAttrs;,%langSpaceAttrs;,class,%graphicsElementEvents;,%testAttrs;,externalResourcesRequired,style,%PresentationAttributes-Color;,%PresentationAttributes-FillStroke;,%PresentationAttributes-FontSpecification;,%PresentationAttributes-Graphics;,%PresentationAttributes-TextContentElements;,lengthAdjust.

在精密排印的场合文本块元素'tspan'的属性 x, y, dx, dy 和 rotate 是有用的,因为这时要求对单个图元进行精确的安置. 这些属性对于字符之间的位置较小的或者较大的调整是有用的, 如移动 当前文本位置 到一个新的位置以便达到文本换行的视觉效果. 多行的文本元素 'text' 可以为文本的每行定义不同的文本块元素'tspan', 并使用属性 x, y, dx 和 dy 定义每个文本块元素'tspan'的位置. (这种方法的一个最大优点是用户可以进行多行的文本选定.) Thex, y, dx, dy and rotate on the 'tspan'element are useful in high-end typography scenarios where individual glyphsrequire exact placement. These attributes are useful for minor positioningadjustments between characters or for major positioning adjustments, such asmoving the currenttext position to a new location to achieve the visual effect of a new lineof text. Multi-line'text' elements are possible by definingdifferent 'tspan' elements for each line oftext, with attributesx, y, dx and/or dy defining the position of each 'tspan'. (An advantage of such an approach is thatusers will be able to perform multi-linetext selection.)

在需要微量位置调整的高级排字控制这种情况下,精图内容设计者需要保证必要的字体对所有文档浏览器是可用的 (例如, 以精图字体的形式将必要的字体数据打包或者存放在精图内容相同的位置上的另一种选择WebFont 格式)并且使得浏览软件将按照期望的方式处理这种字体(哪怕各种系统之间的功能、特性以及字体布局机制存在较大的差异). 如果精图内容中包含必须通过一套特殊的浏览软件进行处理的特殊字体的属性值x, y, dx 或者 dy ,如果这些要求之一未得到满足,则文本的显示效果较差. In situations where micro-level positioning adjustment arenecessary for advanced typographic control, the SVG content designer needs toensure that the necessary font will be available for all viewers of thedocument (e.g., package up the necessary font data in the form of an SVG fontor an alternative WebFontformat which is stored at the same Web site as the SVG content) and that theviewing software will process the font in the expected way (the capabilities,characteristics and font layout mechanisms vary greatly from system to system).If the SVG content contains x, y, dx or dy attribute values which are meant to correspond toa particular font processed by a particular set of viewing software and eitherof these requirements is not met, then the text might display with poor quality.

下面为包含一个数值列表的属性 x, y, dx, dy 和 rotate 的附加规则: The following additional rules apply to attributes x, y, dx, dy and rotate when they contain a list of numbers:

  • 当单一的XML字符映照到单一的图元时 - 此时, 属性 x, y, dx, dy and rotate 的第i个值用于对应于第i个字符的相应图元. When a single XML character maps to a single glyph - In this case, the i-th value for thex, y, dx, dy and rotate attributes is applied to the glyph that corresponds to the i-th character.
  • 当单一的 XML字符映照到多个的图元时 (例如, 当把重音图元加到一个底部图元的顶部时) - 此时, 属性 x, y, dx 和 dy 的第i个值在渲染第一个图元之前被使用(即, 调整 当前文本位置 ). 相应于第i个 rotate 值的旋转变换应用于这些图元 相应于这一字符在组基上的内部图元预先值(即, 此旋转值创建一个新的旋转坐标系, 而对应于字符的图元被渲染到此旋转坐标系).When a single XML character maps to multiple glyphs (e.g., when an accent glyph is placed on top of a base glyph) - In this case, the i-th value for thex, y, dx and dy values are applied (i.e., the current text position is adjusted) before rendering the first glyph. The rotation transformation corresponding to the i-throtate value is applied to the glyphs and to the inter-glyph advance valuescorresponding to this character on a group basis (i.e., the rotation value creates a temporary new rotated coordinate system, and the glyphs corresponding to the character are rendered into this rotated coordinate system).
  • 当多个的XML字符映照到单一的图元时 (例如, 当使用连字时) - 假定第i个和第i+1个XML字符映照到单个图元. 此时, 属性 x, y, dx, dy 和 rotate 的第i个值都被用于渲染此图元. 而属性 x, y, dx, dy 和 rotate 的第i+1个值将被忽略(除非: 列表中最后的 rotate 值将仍然用于随后的字符), 而 dx 和 dy 被用于随后的 XML 字符 (即, 第 (i+2)个 字符), 如果存在, 则在渲染与此字符相关的第一个图元之前根据给定的数量变换 当前文本位置 . When multiple XML characters map to a single glyph (e.g., when a ligature is used) - Suppose that the i-th and (i+1)-th XML characters map to a single glyph. In this case, the i-th value for thex, y, dx, dy and rotate attributes all apply when rendering the glyph. The (i+1)-th values, however, forx, y and rotate are ignored (exception: the final rotate value in the list would still apply to subsequent characters), whereas thedx and dy are applied to the subsequent XML character (i.e., the (i+2)-th character), if one exists, by translating thecurrent text position by the given amounts before rendering the first glyph associated with that character.
  • 当字符和图元之间为多对多的关系时(例如, 当三个字符映照为二个图元时, 比如当第一个图元表示第一个字符和第二个字符的一半, 而第二个图元表示第二个字符的一半加上第三个字符) - 假设第i, 第(i+1) 和 第(i+2)个 XML 字符映照到两个图元. 此时, x, y, dx and dy 值的第 i个值在渲染第一个图元之前被使用 (即, 当前文本位置 被调整) . 对应于第i个 rotate 值的旋转变换既用于这两个图元也用于此群组中第一个图元的进一步的值(即, 此旋转值创建一个新的临时旋转坐标系, 而此两个图元被渲染到这一临时旋转坐标系). 而对于属性x, y 和 rotate 的第 (i+1)个和第(i+2)个值不被使用(例外: 列表中最后的 rotate 值将仍然用于随后的字符), 而 属性 dx 和 dy 的 第(i+1)个和第(i+2)个值被用于随后的 XML 字符 (即, 第(i+3)个字符), 如果存在, 则在渲染与此字符相关的第一个图元之前根据给定的数量变换当前文本位置 .       When there is a many-to-many mapping of characters to glyphs (e.g., when three characters map to two glyphs, such as when the first glyph expresses the first character and half of the second character, and the second glyph expresses the other half of the second character plus the third character) - Suppose that the i-th, (i+1)-th and (i+2)-th XML characters map to two glyphs. In this case, the i-th value for thex, y, dx and dy values are applied (i.e., the current text position is adjusted) before rendering the first glyph. The rotation transformation corresponding to the i-throtate value is applied to both the two glyphs and the glyph advance values for the first glyph on a group basis (i.e., the rotation value creates a temporary new rotated coordinate system, and the two glyphs are rendered into the temporary rotated coordinate system). The (i+1)-th and (i+2)-th values, however, for the x, y and rotate attributes are not applied (exception: the final rotate value in the list would still apply to subsequent characters), whereas the (i+1)-th and (i+2)-th values for thedx and dy attributes are applied to the subsequent XML character (i.e., the (i+3)-th character), if one exists, by translating thecurrent text position by the given amounts before rendering the first glyph associated with that character.
  • 与 双向性 的关系 - 正如下面对双向性 的讨论, 文本的布局是按两步进行处理的, 这里任何双向文本先重新排列为从左到右的字符串, 然后按照此重新排列文本字符串进行文本布局. 无论何时在一个文本块元素 'tspan' 中的字符数据被重新排列, 而在 x, y, dx, dy 和 rotate 中的相应元素也被重新排列以便维持其对应关系. 例如, 假定有下列文本块元素 'tspan':  Relationship to bidirectionality - As described below in the discussion on bidirectionality, text is laid out in a two-step process, where any bidirectional text is first re-ordered into a left-to-right string, and then text layout occurs with the re-ordered text string. Whenever the character data within a 'tspan' element is re-ordered, the corresponding elements within the x, y, dx, dy and rotate are also re-ordered to maintain the correspondence. For example, suppose that you have the following 'tspan' element:
·                 
·                <tspan dx="11 12 13 14 15 0 21 22 23 0 31 32 33 34 35 36">Latin and Hebrew</span>

并且词 "Hebrew" 将按照从右到左的方式进行绘制. 首先, 字符数据和 dx 中的相应列表值将被重新排列, 即文本串将变成 "Latin and werbeH" 并且属性dx 的列表将变成 "11 12 13 14 15 0 21 22 23 0 36 35 34 33 32 31". 在这一重新排列之后, 相应于字符的图元将使用标准的从左到右的布局规则来定位. and that the word "Hebrew" will be drawn right-to-left. First, thecharacter data and the corresponding values in thedx list will be reordered, such that the text stringwill be "Latin and werbeH" and the list of values for thedx attribute will be "11 12 13 14 15 0 21 22 230 36 35 34 33 32 31". After this re-ordering, the glyphs corresponding tothe characters will be positioned using standard left-to-right layout rules.

 下面的一些例子说明对文本块元素'tspan' 的基本使用. The following examples show basic use of the 'tspan' element.

例子 tspan01 使用一个文本块元素 'tspan' 以便说明单词 "not" 使用粗体并且使用红色填充.Example tspan01 uses a 'tspan'element to indicate that the word "not" is to use a bold font andhave red fill.

 
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="10cm" height="3cm" viewBox="0 0 1000 300"
     xmlns="http://www.w3.org/2000/svg">
  <desc>Example tspan01 - using tspan to change visual attributes</desc>
 
  <g font-family="Verdana" font-size="45" >
    <text x="200" y="150" fill="blue" >
      You are
        <tspan font-weight="bold" fill="red" >not</tspan>
      a banana.
    </text>
  </g>
 
  <!-- Show outline of canvas using 'rect' element -->
  <rect x="1" y="1" width="998" height="298"
        fill="none" stroke="blue" stroke-width="2" />
</svg>

Example tspan01

View this exampleas SVG (SVG-enabled browsers only)
 

例子 tspan02 使用文本块元素'tspan' 的属性 dx 和 dy 来对一个文本元素'text' 中的特定文本字符串分别在水平方向和垂直方向上对当前文本位置 进行调整.Exampletspan02 uses the dx and dy attributes on the 'tspan'element to adjust the current textposition horizontally and vertically for particular text strings within a'text' element.

 
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="10cm" height="3cm" viewBox="0 0 1000 300"
     xmlns="http://www.w3.org/2000/svg">
  <desc>Example tspan02 - using tspan's dx and dy attributes 
        for incremental positioning adjustments</desc>
 
  <g font-family="Verdana" font-size="45" >
    <text x="200" y="150" fill="blue" >
      But you
        <tspan dx="2em" dy="-50" font-weight="bold" fill="red" >
          are
        </tspan>
        <tspan dy="100">
           a peach!
        </tspan>
    </text>
  </g>
 
  <!-- Show outline of canvas using 'rect' element -->
  <rect x="1" y="1" width="998" height="298"
        fill="none" stroke="blue" stroke-width="2" />
</svg>

Example tspan02

View this exampleas SVG (SVG-enabled browsers only)
 

例子 tspan03 使用文本块元素 'tspan' 的属性 x 和 y 对每个将被渲染的图元设置一个新的绝对当前文本位置 . 例子说明在一个单一的文本元素'text' 的文本可以显示成两行. 因为两行文本都在同一个文本元素 'text' 中, 故如果用户代理支持 文本选择和剪贴板操作的话,用户便能够选定两行文本并复制它们到系统剪贴板中. Example tspan03 uses the x and y attributes on the 'tspan'element to establish a new absolute current textposition for each glyph to be rendered. The example shows two lines of textwithin a single'text' element. Because both lines of text arewithin the same 'text' element, the user will be able to selectthrough both lines of text and copy the text to the system clipboard in useragents that supporttextselection and clipboard operations,

 
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="10cm" height="3cm" viewBox="0 0 1000 300"
     xmlns="http://www.w3.org/2000/svg">
  <desc>Example tspan03 - using tspan's x and y attributes 
        for multiline text and precise glyph positioning</desc>
 
  <g font-family="Verdana" font-size="45" >
    <text fill="rgb(255,164,0)" >
      <tspan x="300 350 400 450 500 550 600 650" y="100">
        Cute and
      </tspan>
      <tspan x="375 425 475 525 575" y="200">
         fuzzy
      </tspan>
    </text>
  </g>
 
  <!-- Show outline of canvas using 'rect' element -->
  <rect x="1" y="1" width="998" height="298"
        fill="none" stroke="blue" stroke-width="2" />
</svg>

Example tspan03

View this exampleas SVG (SVG-enabled browsers only)
 

10.6 文本引用元素 'tref' The 'tref' element

一个 'text' 的文本内容要么为字符数据直接嵌入文本元素'text' 要么为一个引用元素的字符数据内容, 这里引用由一个引用元素'tref'来设置. The textual content for a'text' can be either character data directlyembedded within the 'text' element or the character data content of areferenced element, where the referencing is specified with a 'tref' element.

 
<!ENTITY % trefExt "" >
<!ELEMENT tref (desc|title|metadata|animate|set|animateColor
                %trefExt;)* >
<!ATTLIST tref
  %stdAttrs;
  %xlinkRefAttrs;
  xlink:href %URI; #REQUIRED
  %testAttrs;
  %langSpaceAttrs;
  externalResourcesRequired %Boolean; #IMPLIED
  class %ClassList; #IMPLIED
  style %StyleSheet; #IMPLIED
  %PresentationAttributes-Color;
  %PresentationAttributes-FillStroke;
  %PresentationAttributes-FontSpecification;
  %PresentationAttributes-Graphics;
  %PresentationAttributes-TextContentElements;
  %graphicsElementEvents;
  x %Coordinates; #IMPLIED
  y %Coordinates; #IMPLIED
  dx %Lengths; #IMPLIED
  dy %Lengths; #IMPLIED
  rotate %Numbers; #IMPLIED
  textLength %Length; #IMPLIED
  lengthAdjust (spacing|spacingAndGlyphs) #IMPLIED >

属性定义 Attributedefinitions:

xlink:href = "<uri>"

由URIreference 指向的在一段精图文档片段内元素或片段的字符数据内容将被用作这一引用元素'tref'的字符数据. AURI referenceto an element/fragment within an SVG document fragment whose character datacontent shall be used as character data for this 'tref'element.
Animatable:yes.

其它地方已经定义的属性 Attributes defined elsewhere:

%stdAttrs;,%xlinkRefAttrs;,%testAttrs;,%langSpaceAttrs;,externalResourcesRequired,class,style, %PresentationAttributes-Color;,%PresentationAttributes-FillStroke;,%PresentationAttributes-FontSpecification;,%PresentationAttributes-Graphics;,%PresentationAttributes-TextContentElements;,%graphicsElementEvents;,x,y,dx,dy,rotate,textLength,lengthAdjust.

在一个引用元素内的所有字符数据, 包括括在附加标记内的字符数据, 将被渲染. All character data withinthe referenced element, including character data enclosed within additionalmarkup, will be rendered.

属性 x, y, dx, dy 和 rotate 与文本块元素'tspan' 的相应属性具有相同的意义. 所使用的属性就像此引用元素 'tref'被一个具有引用字符数据(剥离了所有附加标记)的假定文本块元素 'tspan'代替一样.Thex, y, dx, dy and rotate attributes have the same meanings as for the 'tspan' element. The attributes are applied as ifthe 'tref' element was replaced by a 'tspan' with the referenced character data (strippedof all supplemental markup) embedded within the hypothetical 'tspan' element.

例子 tref01 说明了如何从一个不同的元素中引用字符数据如一个给定文本块元素'tspan'的字符数据. 第一个文本元素'text'  (其 id="ReferencedText") 将不被绘制因为它是一个引用元素 'defs' 的一部分. 第二个文本元素 'text' 绘制字符串"Inline character data". 第三个文本元素 'text' 绘制字符串"Reference character data" 因为它包含一个指向元素"ReferencedText"的引用的引用元素'tref' , 而此元素的字符数据为"Referencedcharacter data". Example tref01 shows howto use character data from a different element as the character data for agiven 'tspan' element. The first'text' element (withid="ReferencedText") will not draw because it is part of a'defs' element. The second 'text' element draws the string "Inlinecharacter data". The third 'text' element draws the string "Referencecharacter data" because it includes a 'tref'element which is a reference to element "ReferencedText", and thatelement's character data is "Referenced character data".

 
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="10cm" height="3cm" viewBox="0 0 1000 300"
     xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <defs>
    <text id="ReferencedText">
      Referenced character data
    </text>
  </defs>
  <desc>Example tref01 - inline vs reference text content</desc>
 
  <text x="100" y="100" font-size="45" fill="blue" >
    Inline character data
  </text>
  <text x="100" y="200" font-size="45" fill="red" >
    <tref xlink:href="#ReferencedText"/>
  </text>
 
  <!-- Show outline of canvas using 'rect' element -->
  <rect x="1" y="1" width="998" height="298"
        fill="none" stroke="blue" stroke-width="2" />
</svg>

Example tref01

View this exampleas SVG (SVG-enabled browsers only)

 

10.7 文本布局 Text layout

10.7.1 文本布局概述 Text layout introduction

本节描述精图支持的文本布局特征,这其中包括支持各种各样国际书写方向,比如从左到右(例如, 拉丁文本)和双向 (例如, 希伯来文或阿拉伯文)和垂直方向(例如, 亚洲文本)。本节所描述的假定为直线文本(即, 文本相对当前用户坐标系要么严格水平要么严格垂直). 而随后的章节将描述关于路径上的文本的补充布局规则。This section describesthe text layout features supported by SVG, which includes support for variousinternational writing directions, such as left-to-right (e.g., Latin scripts)and bidirectional (e.g., Hebrew or Arabic) and vertical (e.g., Asian scripts).The descriptions in this section assume straight line text (i.e., text that iseither strictly horizontal or vertical with respect to the current usercoordinate system). Subsequent sections describe the supplemental layout rulesfortext on apath.

精图不提供自动的折行或断词,这使得精图中国际文本的布局相对于支持多行文本块的格式的语言而言是比较简单的。  SVG does not provide for automatic line breaks or wordwrapping, which makes internationalized text layout for SVG relatively simplerthan it is for languages which support formatting of multi-line text blocks.

对于每个文本'text' 元素,精图用户代理确定当前的参考方向.对于标准水平或垂直文本(即, 非路径上的文本) ,参考方向是指向当前用户坐标系  的Y轴负无穷的向量方向。(注意: 在初始坐标系中, 参考方向向上.)   对于路径上的文本而言,在每个字符上都会重新设置参考方向。For each 'text' element, the SVG user agent determines thecurrent reference orientation. For standardhorizontal or vertical text (i.e., no text-on-a-path), the referenceorientation is the vector pointing towards negative infinity in Y within thecurrent user coordinate system. (Note: in the initialcoordinate system, the reference orientation is up.) For text on a path,the reference orientation is reset with each character.

根据参考方向和特性'writing-mode'的值,精图用户代理确定当前内部-书写-方向. 对于从左到右的文本,内部书写方向指向与参考方向矢量按顺时针方向旋转90度的方向。对于从右到左的文本,内部书写方向指向与参考方向矢量按逆时针方向旋转90度的方向。对于从上到下的文本,内部书写方向指向与参考方向矢量旋转180度的方向。Basedon the reference orientation and the value for property'writing-mode', the SVG user agent determines thecurrent inline-progression-direction. Forleft-to-right text, the inline-progression-direction points 90 degreesclockwise from the reference orientation vector. For right-to-left text, theinline progression points 90 degrees counter-clockwise from the referenceorientation vector. For top-to-bottom text, the inline-progression-directionpoints 180 degrees from the reference orientation vector.

根据参考方向和特性'writing-mode'的值,精图用户代理确定当前块-书写-方向.对于从左到右和从右到左文本,块-书写-方向指向与参考方向向量180度的方向因为只有两种水平'writing-mode' 为lr-tb 和 rl-tb可用. 对于从上到下文本,块-书写-方向总是指向与参考方向向量逆时针方向90度的方向因为只有一种从上到下'writing-mode' 为tb-rl可用。Based on the reference orientationand the value for property'writing-mode', the SVG user agent determines thecurrent block-progression-direction. Forleft-to-right and right-to-left text, the block-progression-direction points180 degrees from the reference orientation vector because the only availablehorizontal'writing-mode's are lr-tband rl-tb. For top-to-bottom text, theblock-progression-direction always points 90 degrees counter-clockwise from thereference orientation vector because the only available top-to-bottom'writing-mode' is tb-rl.

由于特性'baseline-shift'取值为正移动方向是朝向基线表 移动的方向. 移动方向是这样朝着在父级基线表内最上面的项移动基线表的一种正值.  The shift direction is the direction towards which thebaselinetable moves due to positive values for property 'baseline-shift'. The shift direction is such that apositive value shifts the baseline table towards the topmost entry in theparent'sbaseline table.

在处理一给定的文本'text' 元素时,精图用户代理保持当前文本位置的轨迹。初始的当前文本位置由文本 'text' 元素的属性x 和y确定。In processing a given 'text' element, the SVG user agent keeps track ofthe current text position. The initial current textposition is established by thex and y attributes on the 'text' element.

在每当构造一个图元之后将对当前文本位置进行调整确定一个用于渲染下一个图元新的当前文本位置。针对当前文本位置的调整是基于当前的内部-书写-方向,相对正被渲染的图元的图元方向特定图元的增量值,当前字体字距调整表和各种各样属性和特性的当前值,比如空白特性 和在'text','tspan', 'tref' 或'altGlyph' 元素上的任何x,y, dx 和 dy 属性。如果一个图元不提供相对当前图元方向的显式增量值,那么将使用一种合适的近似值。对于竖式文本而言,一种推荐的近似值是图元的上升和下降的和。另一种可用于水平和垂直文本的图元增量值的推荐的近似值为一种em的尺寸(参见units-per-em).Thecurrent text position is adjusted after each glyph to establish a new currenttext position at which the next glyph shall be rendered. The adjustment to thecurrent text position is based on the currentinline-progression-direction,glyph-specific advance values corresponding to theglyphorientation of the glyph just rendered, kerning tables in the font and thecurrent values of various attributes and properties, such as thespacingproperties and any x, y, dx and dy attributes on 'text', 'tspan', 'tref' or 'altGlyph' elements. If a glyph does not provideexplicit advance values corresponding to the currentglyphorientation, then an appropriate approximation should be used. For verticaltext, a suggested approximation is the sum of the ascent and descent values forthe glyph. Another suggested approximation for an advance value for bothhorizontal and vertical text is the size of an em (see units-per-em).

对于每个将被渲染的图元,精图用户代理确定在图元上一个适当的对齐-点,此图元将被严格安放在当前文本位置上。对齐-点由图元本身的图元小室度量,当前内部-书写-方向 和相对于内部-书写-方向的图元方向 所决定。对于用的最多的拉丁文本(即,'writing-mode:lr', 'text-anchor:start', 和 'alignment-baseline:baseline')图元中对齐-点为图元小室的左边缘(或某些其它图元特定 x-轴坐标表示一种左边的原点)与图元的拉丁基线之交。对于很多从上到下的垂直文本布局的情形,参考点要么为一个基于字体的一套垂直基线的图元特定的原点或者为图元中心与其顶线 (参见 [CSS2-topline]关于顶线的定义)的交. 如果一个图元不提供相对当前图元方向的显式增量值,那么将使用一种合适的近似值, 比如图元的左边缘与图元的适当的水平基线的交或者图元的上边缘与图元的适当的垂直基线的交. 如果基线表不可用,用户代理将构建反应通常实际的基线表.      For each glyph to be rendered, theSVG user agent determines an appropriate alignment-pointon the glyph which will be placed exactly at the current text position. Thealignment-point is determined based on glyph cell metrics in the glyph itself,the currentinline-progression-directionand the glyphorientation relative to the inline-progression-direction. For most uses ofLatin text (i.e.,'writing-mode:lr', 'text-anchor:start', and 'alignment-baseline:baseline') the alignment-pointin the glyph will be the intersection of left edge of the glyph cell (or someother glyph-specific x-axis coordinate indicating a left-side origin point)with the Latin baseline of the glyph. For many cases with top-to-bottomvertical text layout, the reference point will be either a glyph-specificorigin point based on the set of vertical baselines for the font or theintersection of the center of the glyph with itstop line (see [CSS2-topline] fora definition oftop line). If a glyph does not provide explicit originpoints corresponding to the currentglyphorientation, then an appropriate approximation should be used, such as theintersection of the left edge of the glyph with the appropriate horizontalbaseline for the glyph or intersection of the top edge of the glyph with the appropriatevertical baseline. If baseline tables are not available, user agents shouldestablish baseline tables that reflect common practice.

对于当前文本位置的调整量要么为绝对位置调整量 要么为 相对位置调整量. 绝对位置调整量在下列情形中出现:   Adjustments to thecurrent text position are either absolute positionadjustments or relative position adjustments.An absolute position adjustment occurs in the following circumstances:

  • 在文本'text' 元素的开始   At the start of a'text' element
  • 在每个文本路径'textPath' 元素的开始   At the start of each'textPath' element
  • 对于在具有显式指定x 或y 属性值的 'text', 'tspan', 'tref' 和 'altGlyph' 元素中的每个字符 For each character within a 'text', 'tspan', 'tref' and 'altGlyph' element which has an x or y attribute value assigned to it explicitly

所有其它当前文本位置的调整量为相对位置调整量。 All other position adjustments to the current text position are relativeposition adjustments.

每个绝对位置调整量定义了一个新的文本块。 绝对位置调整量按下列方式影响文本布局:   Each absolute position adjustment defines a new text chunk. Absolute position adjustments impact textlayout in the following ways:

  • 只有当可以映照到一个连字的一组字符都在此相同的文本块上时连字才出现。Ligatures only occur when a set of characters which might map to a ligature are all in the same text chunk.
  • 每个文本块表示文本一个分开的块此块根据特性 'text-anchor' 的值进行相应的排列。Each text chunk represents a separate block of text for alignment due to'text-anchor' property values.
  • 由于双向性 而进行的字符的重新安排仅在一个文本块中进行。在跨文本块之间发生重新安排。Reordering of characters due tobidirectionality only occurs within a text chunk. Reordering does not happen across text chunks.

下列额外的规则用于连字格式:Thefollowing additional rules apply to ligature formation:

  • 正如在[CSS2-spacing]一样,当两个字符之间的合成空白与其缺省空白不同时,用户代理不应该使用连字;于是如果特性'kerning'或'letter-spacing'的值不是缺省值时,用户代理不应该使用连字。As in [CSS2-spacing], when the resultant space between two characters is not the same as the default space, user agents should not use ligatures; thus, if there are non-default values for properties 'kerning' or 'letter-spacing', the user agent should not use ligatures.
  • 对应于在不同的DOM文本节点上的字符的图元不能使用连字;于是,被标记分开的字符不应该使用连字。Ligature formation should not be enabled for the glyphs corresponding to characters within different DOM text nodes; thus, characters separated by markup should not use ligatures.
  • 正如上面所说,对应于不同文本块的字符的图元不应该使用连字格式。As mentioned above, ligature formation should not be enabled for the glyphs corresponding to characters within different text chunks.

10.7.2 设置内部书写方向 Setting theinline-progression-direction

特性 'writing-mode' 指定文本 'text' 元素的初始的内部书写方向为从左到右, 从右到左, 或者从上到下. 特性 'writing-mode' 只能用于文本 'text' 元素上; 对于 'tspan', 'tref', 'altGlyph' 和'textPath' 这些子元素此特性将被忽略. (注意内部书写方向能够在文本'text' 元素内发生改变因为双向性算法和特性'direction' 和'unicode-bidi'. 关于双向性文本的更多信息, 参见与双向性的关系.)     The 'writing-mode' property specifies whether theinitial inline-progression-direction for a'text' element shall be left-to-right,right-to-left, or top-to-bottom. The 'writing-mode'property applies only to'text' elements; the property is ignored for 'tspan', 'tref', 'altGlyph' and 'textPath' sub-elements. (Note that theinline-progression-direction can change within a'text' element due to the Unicode bidirectionalalgorithm and properties 'direction' and 'unicode-bidi'. For more on bidirectional text, see Relationshipwith bidirectionality.)

'writing-mode'

Value:  

lr-tb | rl-tb | tb-rl | lr | rl | tb | inherit

Initial:  

lr-tb

Applies to:  

'text' elements

Inherited:  

yes

Percentages:  

N/A

Media:  

visual

Animatable:  

no

lr-tb | lr

设置初始内部书写方向为从左到右,就像通常大多数拉丁式文档所设置的方向一样。对于大多数字符,当前文本位置 是在每个图元被渲染之后从左到右进行增加的. (当包含服从Unicode双向性算法的字符的字符数据时, 文本增量规则更加复杂. 参见与双向性的关系.).    Sets the initial inline-progression-direction to left-to-right, as is common inmost Latin-based documents. For most characters, thecurrent text positionis advanced from left to right after each glyph is rendered. (When thecharacter data includes characters which are subject to the Unicodebidirectional algorithm, the text advance rules are more complex. SeeRelationshipwith bidirectionality).

rl-tb | rl

设置初始内部书写方向为从右到左,就像通常阿拉伯或希伯来文本所设置的方向一样。(参见 与双向性的关系.). Sets the initial inline-progression-direction to right-to-left, as is common inArabic or Hebrew scripts. (SeeRelationshipwith bidirectionality.)

tb-rl | tb

设置初始内部书写方向为从上到下,就像通常某些亚洲文本所设置的方向一样,比如中文和日文。虽然没有象水平方式出现得那么频繁,但是这种形式的垂直布局也出现在拉丁式文档中,特别在表格的行或列的标题上。在大多数情况下,垂直基线贯穿进行排列的每个图元的中间。Sets the initial inline-progression-direction to top-to-bottom, asis common in some Asian scripts, such as Chinese and Japanese. Though hardly asfrequent as horizontal, this type of vertical layout also occurs in Latin baseddocuments, particularly in table column or row labels. In most cases, thevertical baselines running through the middle of each glyph are aligned.

10.7.3 文本实现中图元的方向 Glyph orientation within a text run

在某些情况下,要求改变字符序列相对于内部书写方向的方向。这种要求特别用于远东亚洲文档的垂直布局,而这种文档当中夹杂着拉丁文本时,拉丁文本有时水平显示有时垂直显示。In some cases, it is required to alter the orientation of a sequenceof characters relative to the inline-progression-direction. The requirement isparticularly applicable to vertical layouts of East Asian documents, wheresometimes narrow-cell Latin text is to be displayed horizontally and othertimes vertically.

两个特性控制相对于两种可能的内部书写方向的参考方向的图元方向。当内部书写方向为垂直时'glyph-orientation-vertical'控制图元方向。当内部书写方向为水平时'glyph-orientation-horizontal' 控制图元方向。Two properties controlthe glyph orientation relative to the reference orientation for each of the twopossible inline-progression-directions. 'glyph-orientation-vertical'controls glyph orientation when the inline-progression-direction is vertical. 'glyph-orientation-horizontal' controls glyphorientation when the inline-progression-direction is horizontal.

'glyph-orientation-vertical'

Value:  

auto | <angle> | inherit

Initial:  

auto

Applies to:  

text content elements

Inherited:  

yes

Percentages:  

N/A

Media:  

visual

Animatable:  

no

auto

·   满宽的表意字和满宽拉丁文将被设置为与图元方向具有0度的方向。Fullwidthideographic and fullwidth Latin text will be set with a glyph-orientation of0-degrees.

具有交替的水平和垂直的表意字的标点符号和其它表意字符将使用图元的垂直形式。Ideographic punctuation and other ideographic characters havingalternate horizontal and vertical forms will use the vertical form of theglyph.

·   不满宽的文本将被设置为与图元方向具有90度的方向。Textwhich is not fullwidth will be set with a glyph-orientation of 90-degrees.

这种改变方向的规则只适用于第一级非表意文本。所有进一步书写方式的嵌套或双向处理将基于第一级的旋转。This reorientation rule applies only to the first-level non-ideographictext. All further embedding of writing-modes or bidi processing will be basedon the first-level rotation.

注意: NOTE:

o      这等价于设置非表意文本串水平遵从双向规则,然后将内部区域(图元方向的每一改变的一种区域) 的结果序列顺时针旋转90度。This is equivalent to havingset the non-ideographic text string horizontally honoring the bidi-rule, thenrotating the resultant sequence of inline-areas (one area for each change ofglyph direction) 90-degrees clockwise.

注意在这种"旋转"方式的文本设置中也许包括连字或别的图元组合和针对语言和文本的通常的重新排序。 (这种"旋转" 表示形式不会废止自动连字或类似上下文驱动的变更.) Itshould be noted that text set in this "rotated" manner may containligatures or other glyph combining and reordering common to the language andscript. (This "rotated" presentation form does not disable auto-ligatureformation or similar context-driven variations.)

o      确定哪些字符将进行自动旋转可能依赖于特定的用户代理。此决定基于国家、语言、文本、字符特性、字体和字符上下文之间的复杂的相互作用。建议参考Unicode TR 11和各种JIS或者其它国家标准。The determination of which characters should be auto-rotated mayvary across user agents. The determination is based on a complex interactionbetween country, language, script, character properties, font, and charactercontext. It is suggested that one consult the Unicode TR 11 and the various JISor other national standards.

<angle>

角度的值限制在0, 90, 180, 和 270度。用户代理将角度值调整为最接近的允许值。The value of the angle is restricted to 0, 90, 180, and 270 degrees.The user agent shall round the value of the angle to the closest of thepermitted values.
值 0deg表示将所有图元顶部设置为朝向参考方向的方向。值 90deg表示与参考方向顺时针旋转90度的方向。A value of 0deg indicates that all glyphs are set with the top ofthe glyphs oriented towards thereferenceorientation. A value of 90deg indicates anorientation of 90 degrees clockwise from thereferenceorientation.

这一特性只用于在一个垂直 'writing-mode'下的文本的书写   This property is applied only to text written in avertical'writing-mode'.

当每个图元被渲染时图元的方向影响当前文本位置的增量。当内部书写方向为垂直并且'glyph-orientation-vertical'的方向角结果为180度的倍数时,那么当前文本位置按照图元的垂直度量进行增加。否则,如果'glyph-orientation-vertical'的方向角结果不是180度的倍数时,那么当前文本位置按照图元的水平度量进行增加。Theglyph orientation affects the amount that the current text position advances aseach glyph is rendered. When the inline-progression-direction is vertical andthe 'glyph-orientation-vertical' results in anorientation angle that is a multiple of 180 degrees, then the current textposition is incremented according to the vertical metrics of the glyph.Otherwise, if the 'glyph-orientation-vertical'results in an orientation angle that is not a multiple of 180 degrees, then thecurrent text position is incremented according to the horizontal metrics of theglyph.

在本节中的文本布局图使用下列符号:Thetext layout diagrams in this section use the following symbols:

-宽室图元(例如 汉字):表示文本在渲染时的第n个图元 wide-cell glyph (e.g. Han)which is the n-th glyph in the text run
-窄室图元(例如 拉丁字符):表示文本在渲染时的第n个图元 narrow-cell glyph (e.g.Latin) which is then-th glyph in the text run

在上图中的上列符号的方向对应于它们打算表示的Unicode字符当在用户代理中准备进行渲染的方向。在图中的图元之间的间距除非有意改变通常为符号再加一个点。The orientation which the above symbols assume in the diagramscorresponds to the orientation that the Unicode characters they represent areintended to assume when rendered in the user agent. Spacing between the glyphsin the diagrams is usually symbolic, unless intentionally changed to make apoint.

下面的图解释了'glyph-orientation-vertical'的不同用法。左图显示当拉丁字符的特性'glyph-orientation-vertical'设置为auto 或 90时宽室表意图元与窄室拉丁图元的结果。右图显示当拉丁字符的特性'glyph-orientation-vertical'设置为0时宽室表意图元与窄室拉丁图元的结果。The diagramsbelow illustrate different uses of 'glyph-orientation-vertical'.The diagram on the left shows the result of the mixing of full-widthideographic glyphs with narrow-cell Latin glyphs when 'glyph-orientation-vertical'for the Latin characters is either auto or 90. The diagram on the right show the result of mixingfull-width ideographic glyphs with narrow-cell Latin glyphs when Latin glyphsare specified to have a 'glyph-orientation-vertical'of 0.

                  

'glyph-orientation-horizontal'

Value:  

<angle> |inherit

Initial:  

0deg

Applies to:  

text content elements

Inherited:  

yes

Percentages:  

N/A

Media:  

visual

Animatable:  

no

<angle>

角度的值限制在0, 90, 180, 和 270度。用户代理将角度值调整为最接近的允许值。The value of the angle is restricted to 0, 90, 180, and 270 degrees.The user agent shall round the value of the angle to the closest of thepermitted values.
值 0deg表示将所有图元顶部设置为朝向参考方向的方向。值 90deg表示与参考方向顺时针旋转90度的方向。A value of 0deg indicates that all glyphs are set with the top ofthe glyphs oriented towards thereferenceorientation. A value of 90deg indicates anorientation of 90 degrees clockwise from thereferenceorientation.

这一特性只用于在一个水平 'writing-mode'下的文本的书写   This property is applied only to text written in ahorizontal'writing-mode'.

当每个图元被渲染时图元的方向影响当前文本位置的增量。当参考方向为水平并且'glyph-orientation-horizontal'的方向角结果为180度的倍数时,那么当前文本位置按照图元的水平度量进行增加。否则,如果'glyph-orientation-horizontal'的方向角结果不是180度的倍数时,那么当前文本位置按照图元的垂直度量进行增加。Theglyph orientation affects the amount that the current text position advances aseach glyph is rendered. When the reference orientation direction is horizontaland the 'glyph-orientation-horizontal' results inan orientation angle that is a multiple of 180 degrees, then the current textposition is incremented according to the horizontal metrics of the glyph.Otherwise, if the 'glyph-orientation-horizontal'results in an orientation angle that is not a multiple of 180 degrees, then thecurrent text position is incremented according to the vertical metrics of theglyph.

10.7.4 与双向性的关系 Relationship withbidirectionality

在某些文本中的字符是从右到左书写的。在某些文档中,特别是那些用阿拉伯或希伯来文书写的文本,和在某些混合语言上下文中,在一行当中的文本可能呈现混合的方向性。这种现象称之为双向性,或简短地 "bidi" 。   The characters in certain scripts are written fromright to left. In some documents, in particular those written with the Arabicor Hebrew script, and in some mixed-language contexts, text in a single linemay appear with mixed directionality. This phenomenon is calledbidirectionality, or "bidi" for short.

Unicode 标准 ([UNICODE],章节 3.11) 为文本的合适的双向性定义了一种复杂的算法. 此算法由基于字符特性的隐含部分和针对嵌入和覆盖的显式控制两部分组成. 精图用户代理当确定一文本'text' 元素中的字符的布局时应用这一双向性算法. 特性 'direction' 和'unicode-bidi' 允许作者取代从内容字符继承的方向性从而显式地控制文档语言的元素和属性如何映照到这一算法 . 对于那些与内部书写方向正交的图元,这两个特性是可以使用的.         The Unicodestandard ([UNICODE],section 3.11) defines a complex algorithm for determining the properdirectionality of text. The algorithm consists of an implicit part based oncharacter properties, as well as explicit controls for embeddings andoverrides. The SVG user agent applies this bidirectional algorithm whendetermining the layout of characters within a 'text' element. The 'direction' and 'unicode-bidi' properties allow authors to overridethe inherent directionality of the content characters and thus explicitlycontrol how the elements and attributes of a document language map to thisalgorithm. These two properties are applicable to all characters who glyphs areperpendicular to the inline-progression-direction.

在大多数情况下, [UNICODE]提供的双向算法自动产生期望的结果,并且完全取代此算法通常是相当的复杂。因此在大多数情况下劝阻作者不要为这些特性指派特定的值。In most cases, the bidirectional algorithm from [UNICODE] producesthe desired result automatically, and overriding this algorithm properly isusually quite complex. Therefore, in most cases, authors are discouraged fromassigning values to these properties.

可以在"级联样式表 (CSS) 级别2"规范 [CSS2-direction]中找到双向性更完整的讨论。A more completediscussion of bidirectionality can be found in the "Cascading Style Sheets(CSS) level 2" specification [CSS2-direction].

双向文本的处理模型如下所述. 用户代理处理按逻辑顺序(即, 出现在原始文档内的字符的顺序, 要么通过直接的包含或者通过一个引用 'tref' 元素间接引用)提供的字符 .用户代理确定一组独立的文本块,而这每个文本块上将应用Unicode双向性算法. 每个 文本块 代表文本的一个独立的块. 另外, 由于对特性'glyph-orientation-horizontal' 或'glyph-orientation-vertical'的处理所导致的图元方向的改变会进一步细分独立的文本块. 在处理Unicode双向性算法和每个独立文本块上的特性'direction' 和'unicode-bidi' 之后, 用户代理现在获得了一个可以从左到右进行渲染的重新定序的字符列表. 在字符被重新定序的同时, 在 'tspan' 和'tref' 元素上的属性dx,dy 和 rotate   也被重新定序以便保持原来字符和属性值之间的对应关系. 然而字距调整或连字处理也许与字符相关的, 首选的模型是在字符串被重新定序之后再处理字符或图元的组合之间出现的字距调整和连字.                    The processing model for bidirectional text is as follows. The user agentprocesses the characters which are provided in logicalorder (i.e., the order the characters appear in the original document,either via direct inclusion or via indirect reference due a'tref' element). The user agent determines theset of independent blocks within each of which it should apply the Unicodebidirectional algorithm. Eachtext chunkrepresents an independent block of text. Additionally, any change in glyphorientation due to processing of properties'glyph-orientation-horizontal' or 'glyph-orientation-vertical' will subdivide theindependent blocks of text further. After processing the Unicode bidirectionalalgorithm and properties'direction' and 'unicode-bidi' on each of the independent textblocks, the user agent will have a potentially re-ordered list of characterswhich are now in left-to-right rendering order. Simultaneous with re-orderingof the characters, thedx, dy and rotate attributes on the 'tspan' and 'tref' elements are also re-ordered to maintainthe original correspondence between characters and attribute values. Whilekerning or ligature processing might be font-specific, the preferred model isthat kerning and ligature processing occurs between combinations of charactersor glyphs after the characters have been re-ordered.

'direction'

Value:  

ltr | rtl | inherit

Initial:  

ltr

Applies to:  

text content elements

Inherited:  

yes

Percentages:  

N/A

Media:  

visual

Animatable:  

no

此特性指定文本的基础书写方向和针对Unicode双向算法的嵌入和覆盖(参见 'unicode-bidi')的方向。为了对特性'direction' 产生任何影响,特性'unicode-bidi' 的值必须为 'embed' 或 'bidi-override'.   This property specifies the base writingdirection of text and the direction of embeddings and overrides (see 'unicode-bidi') for the Unicode bidirectionalalgorithm. For the 'direction' property to haveany effect, the'unicode-bidi' property's value must be 'embed' or'bidi-override'.

除了在此规范中提供的附加信息外,此特性的正式定义出现在 [CSS2-direction]中. Except for anyadditional information provided in this specification, the normative definitionof the property is in [CSS2-direction].

特性'direction'只用于方向与内部-书写-方向正交的图元,它包含水平方向的拉丁或阿拉伯文本这种通常情况和相对于一个从上到下内部书写方向顺时针旋转90度的狭窄的小室拉丁或阿拉伯字符的这种情况。The 'direction' property applies onlyto glyphs oriented perpendicular to the inline-progression-direction,which includes the usual case of horizontally-oriented Latin or Arabic text andthe case of narrow-cell Latin or Arabic characters rotated 90 degrees clockwiserelative to a top-to-bottom inline-progression-direction.

'unicode-bidi'

Value:  

normal | embed | bidi-override | inherit

Initial:  

normal

Applies to:  

text content elements

Inherited:  

no

Percentages:  

N/A

Media:  

visual

Animatable:  

no

除了在此规范中提供的附加信息外,此特性的正式定义出现在 [CSS2-unicode-bidi]中.  Except for anyadditional information provided in this specification, the normative definitionof the property is in [CSS2-unicode-bidi].

10.8 文本渲染次序 Text rendering order

在一个文本 'text' 元素内的字符所关联的图元按照文档中字符的逻辑顺序进行渲染,而不考虑为了实现双向性所需要进行的重定序。于是,对于视觉上从右到左的文本,最右边的字符所对应的图元在与其它字符相对应的图元之前被渲染。The glyphs associated with the characters within a'text' element are rendered in the logical orderof the characters in the original document, independent of any re-orderingnecessary to implement bidirectionality. Thus, for text that goes right-to-leftvisually, the glyphs associated with the rightmost character are renderedbefore the glyphs associated with the other characters.

另外,每个独特的图元在下一个图元得以渲染之前进行所有的渲染(即, 按照特性 'fill' 和'stroke'所指定方式进行填充和描边) 。Additionally,each distinct glyph is rendered in its entirety (i.e., it is filled and strokedas specified by the 'fill' and 'stroke' properties) before the next glyph getsrendered.

 

10.9 对齐特性 Alignment properties

10.9.1 文本对齐特性 Text alignment properties

 特性'text-anchor'被用来相对于一给定点对文本串进行对齐(开始-, 中间- 或 结束-对齐)   The 'text-anchor' property is used to align(start-, middle- or end-alignment) a string of text relative to a given point.

特性 'text-anchor' 用于一给定文本 'text' 元素中的每个独立的文本块. 每个文本块有一个初始的当前文本位置, 它表示用户坐标系中的点,此点由文本'text'元素的属性x 和y的应用所产生 (依赖于上下文),  在一个 'tspan', 'tref' 或'altGlyph' 元素上的任何x 或 y 的属性值直接指派给在文本块中的第一个渲染字符, 或者确定一个文本路径 'textPath' 元素的初始当前文本位置 .        The 'text-anchor' property is applied to each individualtext chunk withina given 'text' element. Each text chunk has an initialcurrent text position, which represents the point in the user coordinate systemresulting from (depending on context) application of thex and y attributes on the 'text' element, any x or y attribute values on a 'tspan', 'tref' or 'altGlyph' element assigned explicitly to thefirst rendered character in a text chunk, or determination of the initialcurrent text position for a'textPath' element.

'text-anchor'

Value:  

start | middle | end | inherit

Initial:  

start

Applies to:  

text content elements

Inherited:  

yes

Percentages:  

N/A

Media:  

visual

Animatable:  

yes

值具有下列意义:  Valueshave the following meanings:

start

被渲染的字符被对齐使得文本串的开始处位于初始的当前文本位置。对于常常水平渲染的拉丁文或阿拉伯文,这等同于左对齐。对于具有垂直主文本方向的亚洲文本,这等同于上对齐。The rendered characters are aligned such that the start of the textstring is at the initial current text position. For Latin or Arabic, which isusually rendered horizontally, this is comparable to left alignment. For Asiantext with a vertical primary text direction, this is comparable to topalignment.

middle

被渲染的字符被对齐使得文本串的中部处位于当前文本位置。(对于 路径上的文本,概念上说文本串首先被安置在直线上。在文本串的开始处和文本串的结束处之间的中点被确定. 然后, 文本串被映照到此路径上,而此路径的中点置于当前文本位置上.)  The rendered characters are aligned such that the middle of the text string isat the current text position. (Fortext on a path,conceptually the text string is first laid out in a straight line. The midpointbetween the start of the text string and the end of the text string isdetermined. Then, the text string is mapped onto the path with this midpointplaced at the current text position.)

end

被渲染的字符被对齐使得文本串的结束处位于初始的当前文本位置。对于平常方向的拉丁文,这等同于右对齐。The rendered characters are aligned such that the end of the textstring is at the initial current text position. For Latin text in its usualorientation, this is comparable to right alignment.

10.9.2 基线对齐特性 Baseline alignmentproperties

基线对齐和基线表可以在以前的字体, 字体表和基线中找到。An overview of baselinealignment and baseline tables can be found above inFonts, fonttables and baselines.

国际文本的特征之一是在不同的文本中的图元具有不同放入基线 (不同的对齐点)。例如水平书写的表意文本比如汉字、片假名、平假名和Hangul,对齐出现在接近图元的底部的基线;而对于基于字母的文本,比如拉丁文、斯拉夫文、希伯来文、阿拉伯文,按照大多数图元的底部进行对齐,而有些图元部分在基线的下面;印度语系的文本按接近图元的顶部进行对齐。  One of the characteristics of international text is thatthere are different baselines (different alignment points) for glyphs indifferent scripts. For example, in horizontal writing, ideographic scripts,such as Han Ideographs, Katakana, Hiragana, and Hangul, alignment occurs with abaseline near the bottoms of the glyphs; alphabetic based scripts, such asLatin, Cyrillic, Hebrew, Arabic, align a point that is the bottom of mostglyphs, but some glyphs descend below the baseline; and Indic based scripts arealigned at a point that is near the top of the glyphs.

当一行文本中混合了各种不同的文本时,必须做必要的调整以保证在不同文本中的图元能够相互正确地对齐。OpenType [OPENTYPE]字体基线表 (BASE) [OPENTYPE-BASETABLE]规定了替换基线与当前基线的偏移量.       When different scripts are mixed on a line of text, an adjustment must be madeto ensure that the glyphs in the different scripts are aligned correctly withone another. OpenType [OPENTYPE]fonts have a Baseline table (BASE) [OPENTYPE-BASETABLE]that specifies the offsets of the alternative baselines from the currentbaseline.

精图使用一种类似的基线表模型假定一种文本(具有相同的字体尺寸) 在一个文本 'text'元素的处理期间是"支配运行"的,即所有其它基线是相对于此支配运行文本进行定义的。具有支配运行的文本的基线称之为支配基线。因此,例如,如果支配基线为字母基线,那么对于替换基线比如表意基线或印度基线而言在基线表中存在一种偏移量。对于某些使用了数学字体的数学基线也存在偏移量。注意对于水平和垂直书写方向而言存在分开的基线表。在这些水平或垂直书写方向上的表中的偏移量可以是不同的。SVG uses a similar baseline table model that assumes one script (atone font-size) is the "dominant run" during processing of a element;that is, all other baselines are defined in relation to this dominant run. Thebaseline of the script with the dominant run is called the dominant baseline. So, for example, if the dominantbaseline is the alphabetic baseline, there will be offsets in the baselinetable for the alternate baselines, such as the ideographic baseline and theIndic baseline. There will also be an offset for the math baseline which isused for some math fonts. Note that there are separate baseline tables forhorizontal and vertical writing-modes. The offsets in these tables may bedifferent for horizontal and vertical writing.

在文本 'text' 元素处理开始时所建立的基线表称之为支配基线表。The baseline tableestablished at the start of processing of a'text' element is called the dominant baseline table.

因为特性'font-family'的值是字体的列表,为了确保一种对基线表的一致的选择,我们在一个字体列表中定义挂名字体作为此字体列表中的第一种其图元可用的字体。这是能够对于遇到的每一个字符都包含相应的图元的第一个字体。(对于这种定义,如果进行字体替换或此字体被合成时图元数据被假定是现成的.) 这一定义保证了将被使用的字体和基线表的选择与内容是不相关的。  Because the value of the 'font-family' property is a list of fonts, to insure aconsistent choice of baseline table we define thenominal font in afont list as the first font in the list for which a glyph is available. This isthe first font that could contain a glyph for each character encountered. (Forthis definition, glyph data is assumed to be present if a font substitution ismade or if the font is synthesized.) This definition insures a contentindependent determination of the font and baseline table that is to be used.

在文本 'text' 元素上的特性'font-size' 确定了支配基线表字体尺寸.   The valueof the'font-size' property on the 'text' element establishes the dominant baseline table font size.

模型假定每个图元具有一种'alignment-baseline' 值此值规定了对齐图元所用的基线. ('在OpenType 基线表描述中alignment-baseline'被称之为 "BaselineTag" .) 特性'alignment-baseline'  的初始值使用与给定图元相关的基线标识符. 'alignment-baseline' 的各种取值对于那些关于文本成员是模糊的比如 "*"是可能有用的.    The model assumes that each glyph has a 'alignment-baseline' value whichspecifies the baseline with which the glyph is to be aligned. (The'alignment-baseline' is called the "Baseline Tag" in the OpenTypebaseline table description.) The initial value of the'alignment-baseline' property uses the baselineidentifier associated with the given glyph. Alternate values for'alignment-baseline' can be useful for glyphs such as a"*" which are ambiguous with respect to script membership.

模型假设将被绘制的图元的字体也具有一种基线表,字体基线表. 此基线表具有从点(0,0)到所知道的字体的每个基线的以为units-per-em单位的偏移量. 特别, 它具有从图元的点(0,0) 到由'alignment-baseline'所指定的基线的偏移量.    The model assumes that the font from which the glyph is drawn also has abaseline table, the font baseline table. Thisbaseline table has offsets in units-per-em from the (0,0) point to each of thebaselines the font knows about. In particular, it has the offset from theglyph's (0,0) point to the baseline identified by the 'alignment-baseline'.

在基线表中的偏移量值是按照EM的百分比单位即 "design units"来表示的 . CSS 调用这些 "units-per-em" [CSS2-UNITSPEREM].于是, 当前的'font-size' 用来确定从支配基线到调整基线的实际偏移量.       The offset values in thebaseline table are in "design units" which means fractional units ofthe EM. CSS calls these "units-per-em" [CSS2-UNITSPEREM].Thus, the current 'font-size' is used to determine the actual offset fromthe dominant baseline to the alternate baselines.

图元被对齐使得由它的'alignment-baseline'所指定的基线与支配基线表中相同名字的基线进行对齐。Theglyph is aligned so that its baseline identified by its 'alignment-baseline' isaligned with the baseline with the same name from the dominant baseline table.

从祖先的支配基线到由指定的基线之间的偏移量通过支配基线表和支配基线表字体尺寸来计算。字体基线表和可用于图元的字体尺寸用来计算从指定的基线到图元的点 (0,0)的偏移量。第二种偏移值从第一种偏移值中减掉得到在平移方向中的点(0,0)的位置。两种偏移量通过由基线表乘以适当的字体尺寸所得出的基线值相乘来计算。  The offset from the dominant baseline of the parent to thebaseline identified by the 'alignment-baseline' is computed using the dominantbaseline table and dominant baseline table font size. The font baseline tableand font size applicable to the glyph are used to compute the offset from theidentified baseline to the (0,0) point of the glyph. This second offset issubtracted from the first offset to get the position of the (0,0) point in theshift direction.Both offsets are computed by multiplying the baseline value from the baselinetable times the appropriate font size value.

如果'alignment-baseline'指定支配基线,那么第一种偏移量为零并且图元与此支配基线对齐;否则图元与所选的替换基线对齐。If the 'alignment-baseline' identifies the dominant baseline, thenthe first offset is zero and the glyph is aligned with the dominant baseline;otherwise, the glyph is aligned with the chosen alternate baseline.

在此规范中使用下列基线标识符。其中一些由包含在一种如在[XSLdescription of Fonts and Font Data]中所描述的字体中的基线表所确定。其它的由如下所述的其它字体特征来计算。  Thebaseline-identifiers below are used in this specification. Some of these aredetermined by baseline-tables contained in a font as described in[XSL description ofFonts and Font Data]. Others are computed from other fontcharacteristics as described below.

alphabetic

这指定由大多数字母和音节文本所使用的基线。这些文本包括但不限于许多西方的、南印度的、南亚(非-表意)文本。This identifies the baselineused by most alphabetic and syllabic scripts. These include, but are notlimited to, many Western, Southern Indic, Southeast Asian (non-ideographic)scripts.

ideographic

这指定由表意文本所使用的基线。由于历史的原因,这种基线位于表意EM框的底部而不在表意EM框的中心。参见"central"基线。表意文本包括中文、日文、朝鲜文和越南文。This identifies the baseline used by ideographic scripts. Forhistorical reasons, this baseline is at the bottom of the ideographic EM boxand not in the center of the ideographic EM box. See the "central"baseline. The ideographic scripts include Chinese, Japanese, Korean, andVietnamese Chu Nom.

hanging

这指定由某些印度文所使用的基线。这些文本包括梵文、果鲁穆奇文和孟加拉文。This identifies the baseline used by certain Indic scripts. Thesescripts include Devanagari, Gurmukhi and Bengali.

mathematical

这指定由数学符号所使用的基线。This identifies the baseline used by mathematical symbols.

central

这指定一种位于EM框中心的计算基线。这种基线位于 text-before-edge和text-before-edge基线的中间。This identifies a computed baseline that is at the center of the EMbox. This baseline lies halfway between the text-before-edge andtext-after-edge baselines.

注意:NOTE:

对于表意字体而言,这种基线常常用于对齐图元;它是表意基线的一种代替基线。For ideographic fonts, this baseline is often used to align theglyphs; it is an alternative to the ideographic baseline.

middle

这指定一种在shift-direction上与alphabetic基线的偏移量为字体特征x-height的1/2的基线。这一基线的位置可以从字体数据中得到,或者对于具有"x-height"字体特征的字体来说,可以使用"x-height"的1/2 来计算。如果缺乏这些信息,基线的位置可以由"central"基线来近似。This identifies a baseline that is offset from the alphabeticbaseline in theshift-direction by 1/2 the value of the x-height fontcharacteristic. The position of this baseline may be obtained from the fontdata or, for fonts that have a font characteristic for "x-height", itmay be computed using 1/2 the "x-height". Lacking either of thesepieces of information, the position of this baseline may be approximated by the"central" baseline.

text-before-edge

这指定 EM 框的前-边。这一基线的位置可以通过基线表来指定或通过计算得到。Thisidentifies the before-edge of the EM box. The position of this baseline may bespecified in the baseline-table or it may be calculated.

注意:NOTE:

这一基线的位置通常在高于x小写字母的顶部或附近,但是它也许不包含所有可能出现在图元上方的重音。对于这些字体"ascent"字体特征的值被使用。对于表意字体,这一基线的位置通常在"ideographic"基线上在shift-direction. 上1个EM处。但是,某些表意字体在内部书写方向上具有减少的宽度允许较紧的设置。当设计用于垂直书写模式的字体用于水平书写模式时,"text-before-edge"基线也许比 text-after-edge基线少1 EM。Theposition of this baseline is normally around or at the top of the ascenders,but it may not encompass all accents that can appear above a glyph. For thesefonts the value of the "ascent" font characteristic is used. Forideographic fonts, the position of this baseline is normally 1 EM in the shift-directionfrom the "ideographic" baseline. However, some ideographic fonts havea reduced width in the inline-progression-direction to allow tighter setting.When such a font, designed only for vertical writing-modes, is used in ahorizontal writing-mode, the "text-before-edge" baseline may be lessthan 1 EM from the text-after-edge.

text-after-edge

这指定 EM 框的后-边。这一基线的位置可以通过基线表来指定或通过计算得到。Thisidentifies the after-edge of the EM box. The position of this baseline may bespecified in the baseline-table or it may be calculated.

注意:NOTE:

对于作为下标的字体,这一基线通常在字母下部的底部或其附近。对于这些字体"descent"字体特征的值被使用。对于表意字体,这一基线的位置通常在"ideographic"基线上.  For fonts with descenders, the position of this baseline isnormally around or at the bottom of the descenders. For these fonts the valueof the "descent" font characteristic is used. For ideographic fonts,the position of this baseline is normally at the "ideographic"baseline.

另外,存在只对线区域定义的两种计算基线。由于精图不支持基于线区域的计算概念,故这两种计算基线映照如下:There are, in addition, two computed baselines that are only definedfor line areas. Since SVG does not support the notion of computations based online areas, the two computed baselines are mapped as follows:

before-edge

对于精图而言,这等价于text-before-edge. For SVG, this isequivalent to text-before-edge.

after-edge

对于精图而言,这等价于text-after-edge.  For SVG, this isequivalent to text-after-edge.

同样存在只对水平书写模式进行定义的四种基线。There are also four baselines that are defined only for horizontalwriting-modes.

top

在水平书写模式下这一基线与"before-edge"基线相同并且在垂直书写模式下无定义。This baseline is the same as the "before-edge" baseline ina horizontal writing-mode and is undefined in a vertical writing mode.

text-top

在水平书写模式下这一基线与"text-before-edge"基线相同并且在垂直书写模式下无定义。This baseline is the same as the "text-before-edge" baselinein a horizontal writing-mode and is undefined in a vertical writing mode.

bottom

在水平书写模式下这一基线与"after-edge"基线相同并且在垂直书写模式下无定义。This baseline is the same as the "after-edge" baseline ina horizontal writing-mode and is undefined in a vertical writing mode.

text-bottom

在水平书写模式下这一基线与"text-after-edge" 基线相同并且在垂直书写模式下无定义。This baseline is the same as the "text-after-edge"baseline in a horizontal writing-mode and is undefined in a vertical writingmode.

基线对齐特性如下。Thebaseline-alignment properties follow.

 

'dominant-baseline'

Value:  

auto | use-script | no-change | reset-size | alphabetic | hanging | ideographic | mathematical | central | middle | text-after-edge | text-before-edge | text-top | text-bottom |inherit

Initial:  

auto

Applies to:  

text content elements

Inherited:  

no

Percentages:  

N/A

Media:  

visual

Animatable:  

yes

特性用于确定或重确定一个比例基线表。一个比例基线表为三种分量的合成值:针对支配基线的一个基线标识符,一个基线表和一个基线表字体尺寸。此特性的某些值重新确定所有这三个值;而其它的只重确定基线表字体尺寸。当初始值, "auto", 给出一种不期望的结果时,这一特性用于明确地设置所期望的比例基线表。  The "dominant-baseline" property is used todetermine or re-determine a scaled-baseline-table. A scaled-baseline-table is acompound value with three components: a baseline-identifier for thedominant-baseline, a baseline-table and a baseline-table font-size. Some valuesof the property re-determine all three values; other only re-establish thebaseline-table font-size. When the initial value, "auto", would givean undesired result, this property can be used to explicitly set the desirescaled-baseline-table.

此特性的值具有下列意义:Values forthe property have the following meaning:

auto

如果这一特性在一个文本'text' 元素上出现,那么此计算值依赖于特性'writing-mode' 的值。如果'writing-mode'为水平,那么dominant-baseline分量的值为 'alphabetic', 否则如果 'writing-mode'为垂直,那么dominant-baseline分量的值为 'central'.      If this property occurs ona'text' element, then the computed value dependson the value of the 'writing-mode' property. If the 'writing-mode' ishorizontal, then the value of the dominant-baseline component is 'alphabetic',else if the 'writing-mode' is vertical, then the value of the dominant-baselinecomponent is 'central'.

如果这一特性在一个'tspan','tref', 'altGlyph' 或'textPath' 元素上出现,那么dominant-baseline 和 baseline-table分量保持与上级文本内容元素相同。如果的'baseline-shift' 计算值实际上平移了基线,那么基线表字体尺寸分量被设置为出现特性 'dominant-baseline' 的元素上的特性 'font-size' 的值,否则基线表字体尺寸保持与元素的相同。如果无上级文本内容元素, 比例基线表值同上述文本'text' 元素一样构造。If this property occurs on a 'tspan', 'tref', 'altGlyph' or 'textPath' element, then the dominant-baselineand the baseline-table components remain the same as those of the parenttextcontent element. If the computed 'baseline-shift' value actually shifts thebaseline, then the baseline-table font-size component is set to the value ofthe'font-size' property on the element on which the'dominant-baseline' property occurs, otherwise thebaseline-table font-size remains the same as that of the element. If there isno parenttextcontent element, the scaled-baseline-table value is constructed as abovefor'text' elements.

use-script

dominant-baseline和 baseline-table分量由字符数据内容中所确定的主要脚本来设置。'writing-mode'无论为水平还是垂直都被用来选择适当的一组baseline-table和用来选择对应于基线的基线表的支配基线。baseline-tablefont-size分量被设置成出现特性'dominant-baseline' 的元素的特性 'font-size'的值。The dominant-baseline and the baseline-table components are set bydetermining the predominant script of the character data content. The'writing-mode', whether horizontal or vertical, is used to select theappropriate set of baseline-tables and the dominant baseline is used to selectthe baseline-table that corresponds to that baseline. The baseline-tablefont-size component is set to the value of the'font-size' property on the element on which the'dominant-baseline' property occurs.

no-change

dominant-baseline, baseline-table和baseline-table font-size分量保持与上级文本内容元素相同。The dominant-baseline, thebaseline-table, and the baseline-table font-size remain the same as that of theparent textcontent element.

reset-size

dominant-baseline和 baseline-table 保持相同, 而baseline-table font-size 改变成这一元素上特性 'font-size'的值. 这根据当前 'font-size'重新计算比例 baseline-table.     The dominant-baseline andthe baseline-table remain the same, but the baseline-table font-size is changedto the value of the'font-size' property on this element. This re-scalesthe baseline-table for the current'font-size'.

alphabetic

dominant-baseline的基线标识符被设置为 'alphabetic',通过使用在挂名字体中的'alphabetic'基线表来构造导出的基线表,而基线表字体尺寸改变成此元素上特性'font-size' 的值。The baseline-identifier for the dominant-baseline is set to be'alphabetic', the derived baseline-table is constructed using the 'alphabetic'baseline-table in the nominal font, and the baseline-table font-size is changedto the value of the 'font-size' property on this element.

hanging

dominant-baseline的基线标识符被设置为 'hanging',通过使用在挂名字体中的'hanging'基线表来构造导出的基线表,而基线表字体尺寸改变成此元素上特性'font-size' 的值。The baseline-identifier for the dominant-baseline is set to be'hanging', the derived baseline-table is constructed using the 'hanging'baseline-table in the nominal font, and the baseline-table font-size is changedto the value of the 'font-size' property on this element.

ideographic

dominant-baseline的基线标识符被设置为 'ideographic',通过使用在挂名字体中的'ideographic'基线表来构造导出的基线表,而基线表字体尺寸改变成此元素上特性'font-size' 的值。The baseline-identifier for the dominant-baseline is set to be'ideographic', the derived baseline-table is constructed using the'ideographic' baseline-table in the nominal font, and the baseline-tablefont-size is changed to the value of the 'font-size' property on this element.

mathematical

dominant-baseline的基线标识符被设置为 'mathematical',通过使用在挂名字体中的'mathematical'基线表来构造导出的基线表,而基线表字体尺寸改变成此元素上特性'font-size' 的值。The baseline-identifier for the dominant-baseline is set to be'mathematical', the derived baseline-table is constructed using the'mathematical' baseline-table in the nominal font, and the baseline-tablefont-size is changed to the value of the 'font-size' property on this element.

central

dominant-baseline的基线标识符被设置为 'central',通过使用在挂名字体中的一种基线表来构造导出的基线表,这一字体基线表根据下列基线表名字的优先权顺序进行选择: 'ideographic', 'alphabetic', 'hanging', 'mathematical'. 而基线表字体尺寸改变成此元素上特性'font-size' 的值。The baseline-identifier for the dominant-baseline is set to be'central'. The derived baseline-table is constructed from the defined baselinesin a baseline-table in the nominal font. That font baseline-table is chosenusing the following priority order of baseline-table names: 'ideographic','alphabetic', 'hanging', 'mathematical'. The baseline-table font-size ischanged to the value of the'font-size' property on this element.

middle

dominant-baseline的基线标识符被设置为 'middle',通过使用在挂名字体中的一种基线表来构造导出的基线表,这一字体基线表根据下列基线表名字的 优先权顺序进行选择: 'alphabetic','ideographic', 'hanging', 'mathematical'. 而基线表字体尺寸改变成此元素上特性'font-size' 的值。The baseline-identifier for the dominant-baseline is set to be'middle'. The derived baseline-table is constructed from the defined baselinesin a baseline-table in the nominal font. That font baseline -table is chosenusing the following priority order of baseline-table names: 'alphabetic','ideographic', 'hanging', 'mathematical'. The baseline-table font-size ischanged to the value of the'font-size' property on this element.

text-after-edge

dominant-baseline的基线标识符被设置为'text-after-edge',通过使用在挂名字体中的一种基线表来构造导出的基线表,从挂名字体中的基线表中所用的字体基线表的选择由实现来定义. 而基线表字体尺寸改变成此元素上特性'font-size' 的值。The baseline-identifier for the dominant-baseline is set to be'text-after-edge'. The derived baseline-table is constructed from the definedbaselines in a baseline-table in the nominal font. The choice of which fontbaseline-table to use from the baseline-tables in the nominal font isimplementation defined. The baseline-table font-size is changed to the value ofthe'font-size' property on this element.

注记:使用下列基线表名字的 优先权顺序进行选择:'alphabetic','ideographic', 'hanging', 'mathematical'也许对于确定使用哪个字体基线表是一种较为合理的策略。NOTE: using the following priority order of baseline-table names:'alphabetic', 'ideographic', 'hanging', 'mathematical' is probably a reasonablestrategy for determining which font baseline-table to use.

text-before-edge

dominant-baseline的基线标识符被设置为 'text-before-edge',通过使用在挂名字体中的一种基线表来构造导出的基线表,从挂名字体中的基线表中所用的字体基线表的选择由实现来定义. 而基线表字体尺寸改变成此元素上特性'font-size' 的值。The baseline-identifier for the dominant-baseline is set to be'text-before-edge'. The derived baseline-table is constructed from the definedbaselines in a baseline-table in the nominal font. The choice of whichbaseline-table to use from the baseline-tables in the nominal font isimplementation defined. The baseline-table font-size is changed to the value ofthe'font-size' property on this element.

注记:使用下列基线表名字的 优先权顺序进行选择:'alphabetic','ideographic', 'hanging', 'mathematical'也许对于确定使用哪个字体基线表是一种较为合理的策略。NOTE: Using the following priority order of baseline-table names:'alphabetic', 'ideographic', 'hanging', 'mathematical' is probably a reasonablestrategy for determining which font baseline-table to use.

text-top

参见'text-top'基线的定义。Seedefinitionof 'text-top' baseline.

text-bottom

参见'text-bottom'基线的定义。Seedefinitionof 'text-bottom' baseline.

如果在挂名字体内无基线表或者基线表中缺乏所期望的基线,那么用户代理可以通过使用启发式来确定所期望的基线的位置。If there is no baseline table in the nominal font or if the baselinetable lacks an entry for the desired baseline, then the user agent may useheuristics to determine the position of the desired baseline.

 

'alignment-baseline'

Value:  

auto | baseline | before-edge | text-before-edge | middle | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical |inherit

Initial:  

auto

Applies to:  

'tspan','tref', 'altGlyph', 'textPath' elements

Inherited:  

no

Percentages:  

N/A

Media:  

visual

Animatable:  

yes

这一特性指定一个对象如何与它的祖先进行对齐。这一特性指定这一元素的哪个基线将与其祖先的相应基线进行对齐。例如,这允许在罗马文本的alphabetic基线在字体尺寸改变时仍然保持对齐。缺省情况下基线与alignment-baseline特性的计算值具有相同的名字。就是说,在block-progression-direction内的"ideographic"对齐点的位置是在被对齐对象的基线表中的"ideographic" 基线的位置。  This property specifies how an object is aligned with respectto its parent. This property specifies which baseline of this element is to bealigned with the corresponding baseline of the parent. For example, this allowsalphabetic baselines in Roman text to stay aligned across font size changes. Itdefaults to the baseline with the same name as the computed value of thealignment-baseline property. That is, the position of "ideographic"alignment-point in theblock-progression-direction is the position ofthe "ideographic" baseline in the baseline-table of the object beingaligned.

此特性的值具有下列意义:Values havethe following meanings:

auto

此值为字符所属文本的支配基线-即使用祖先的支配基线。 The value is the dominant-baseline of the script to which thecharacter belongs - i.e., use the dominant-baseline of the parent.

baseline

将被对齐的对象的对齐点与祖先文本内容元素的支配基线对齐.    Thealignment-point of the object being aligned is aligned with thedominant-baseline of the parenttextcontent element.

before-edge

将被对齐的对象的对齐点与祖先文本内容元素的"before-edge"基线对齐.    Thealignment-point of the object being aligned is aligned with the"before-edge" baseline of the parent textcontent element.

text-before-edge

将被对齐的对象的对齐点与祖先文本内容元素的"text-before-edge"基线对齐.    Thealignment-point of the object being aligned is aligned with the"text-before-edge" baseline of the parent text contentelement.

central

将被对齐的对象的对齐点与祖先文本内容元素的"central"基线对齐.    Thealignment-point of the object being aligned is aligned with the"central" baseline of the parent textcontent element.

middle

将被对齐的对象的对齐点与祖先文本内容元素的"middle"基线对齐.    Thealignment-point of the object being aligned is aligned with the"middle" baseline of the parent textcontent element.

after-edge

将被对齐的对象的对齐点与祖先文本内容元素的"after-edge"基线对齐.    Thealignment-point of the object being aligned is aligned with the"after-edge" baseline of the parent textcontent element.

text-after-edge

将被对齐的对象的对齐点与祖先文本内容元素的"text-after-edge"基线对齐.    Thealignment-point of the object being aligned is aligned with the"text-after-edge" baseline of the parent textcontent element.

ideographic

将被对齐的对象的对齐点与祖先文本内容元素的"ideographic"基线对齐.    Thealignment-point of the object being aligned is aligned with the"ideographic" baseline of the parent textcontent element.

alphabetic

将被对齐的对象的对齐点与祖先文本内容元素的"alphabetic"基线对齐.    Thealignment-point of the object being aligned is aligned with the"alphabetic" baseline of the parent textcontent element.

hanging

将被对齐的对象的对齐点与祖先文本内容元素的"hanging"基线对齐.    Thealignment-point of the object being aligned is aligned with the"hanging" baseline of the parent textcontent element.

mathematical

将被对齐的对象的对齐点与祖先文本内容元素的"mathematical"基线对齐.    Thealignment-point of the object being aligned is aligned with the"mathematical" baseline of the parent textcontent element.

top

如果书写模式为水平那么将被对齐的对象的对齐点与祖先文本内容元素的"top"基线对齐.  否则使用支配基线。  Thealignment-point of the object being aligned is aligned with the "top"baseline of the parent textcontent element if the writing-mode is horizontal. Otherwise, thedominant-baseline is used.

bottom

如果书写模式为水平那么将被对齐的对象的对齐点与祖先文本内容元素的"bottom"基线对齐.  否则使用支配基线。 The alignment-point ofthe object being aligned is aligned with the "bottom" baseline of theparent textcontent element if the writing-mode is horizontal. Otherwise, thedominant-baseline is used.

text-top

如果书写模式为水平那么将被对齐的对象的对齐点与祖先文本内容元素的"text-top"基线对齐.  否则使用支配基线。 The alignment-point ofthe object being aligned is aligned with the "text-top" baseline ofthe parent textcontent element if the writing-mode is horizontal. Otherwise, thedominant-baseline is used.

text-bottom

如果书写模式为水平那么将被对齐的对象的对齐点与祖先文本内容元素的"text-bottom"基线对齐.  否则使用支配基线。 The alignment-point ofthe object being aligned is aligned with the "text-bottom" baselineof the parent textcontent element if the writing-mode is horizontal. Otherwise, thedominant-baseline is used.

 

'baseline-shift'

Value:  

baseline | sub | super | <percentage> | <length> | inherit

Initial:  

baseline

Applies to:  

'tspan','tref', 'altGlyph', 'textPath' elements

Inherited:  

no

Percentages:  

refers to the "line-height" of the 'text' element, which in the case of SVG is defined to be equal to the 'font-size'

Media:  

visual

Animatable:  

yes

特性'baseline-shift' 允许相对于祖先 文本内容元素的支配基线的支配基线的重定位。平移的对象也许为下标或上标。在平移的对象内,整个基线表是偏移;不刚好为单一的基线。平移的数量由祖先文本内容元素的信息,相对于祖先文本内容元素的挂名字体的下标或上标偏移量,祖先 文本内容元素的"行高"的百分比或一个绝对值来决定。   The 'baseline-shift' property allows repositioning of thedominant-baseline relative to the dominant-baseline of the parenttextcontent element. The shifted object might be a sub- or superscript. Withinthe shifted object, the whole baseline-table is offset; not just a singlebaseline. The amount of the shift is determined from information from the parenttextcontent element, the sub- or superscript offset from the nominal font ofthe parent textcontent element, percent of the "line-height" of the parent textcontent element or an absolute value.

在精图中,'baseline-shift' 特性表示对基线表附加的调整.  'baseline-shift' 特性对每个图元平移基线表到一个新的临时位置 , 例如升高或降低图元到上标或下标的位置, 可是它不影响当前文本位置. 当在渲染一个图元之后当前文本位置考虑图元的增量值时,所发生的调整好像不存在基线平移一样。      In SVG, the 'baseline-shift'property represents a supplemental adjustment to the baseline tables. The 'baseline-shift' property shifts the baseline tables foreach glyph to temporary new positions, for example to lift the glyph into superscriptor subscript position, but it does not effect the current text position. Whenthe current text position is adjusted after rendering a glyph to take intoaccount glyph advance values, the adjustment happens as if there were nobaseline shift.

'baseline-shift' 特性能够嵌套.每个嵌套的 'baseline-shift' 被加到上一个基线平移值.    'baseline-shift' properties can nest. Each nested 'baseline-shift' is added to previous baseline shiftvalues.

 此特性的值具有下列意义:  Values for the property have the following meaning:

baseline

不存在基线平移,占优势的基线保留在它的原来的位置。 There is no baseline shift; the dominant-baseline remains in itsoriginal position.

sub

平移dominant-baseline到下标的缺省位置。到此位置的偏移量由挂名字体的字体数据所确定。因为大多数字体的下标位置通常是相对"alphabetic"基线来给定的,当某一其它基线为支配基线时用户代理也许需要计算下标的有效位置。推荐的计算方法为从下标位置减去支配基线的位置和"alphabetic"基线的位置之差。作为结果的偏移量由有效的下标位置乘以支配基线字体尺寸来确定。如果无可用的字体数据用户代理可以使用启发式确定这一偏移量。The dominant-baseline is shifted to the default position forsubscripts. The offset to this position is determined using the font data forthe nominal font. Because in most fonts the subscript position is normallygiven relative to the "alphabetic" baseline, the user agent maycompute the effective position for subscripts for superscripts when some otherbaseline is dominant. The suggested computation is to subtract the differencebetween the position of the dominant baseline and the position of the"alphabetic" baseline from the position of the subscript. Theresulting offset is determined by multiplying the effective subscript positionby the dominant baseline-table font-size. If there is no applicable font datathe user agent may use heuristics to determine the offset.

super

平移dominant-baseline到上标的缺省位置。到此位置的偏移量由挂名字体的字体数据所确定。因为大多数字体的上标位置通常是相对"alphabetic"基线来给定的,当某一其它基线为支配基线时用户代理也许需要计算上标的有效位置。推荐的计算方法为从上标位置减去支配基线的位置和"alphabetic"基线的位置之差。作为结果的偏移量由有效的上标位置乘以支配基线字体尺寸来确定。如果无可用的字体数据用户代理可以使用启发式确定这一偏移量。The dominant-baseline is shifted to the default position forsuperscripts. The offset to this position is determined using the font data forthe nominal font. Because in most fonts the superscript position is normallygiven relative to the "alphabetic" baseline, the user agent maycompute the effective position for superscripts when some other baseline isdominant. The suggested computation is to subtract the difference between theposition of the dominant baseline and the position of the"alphabetic" baseline from the position of the superscript. Theresulting offset is determined by multiplying the effective superscriptposition by the dominant baseline-table font-size. If there is no applicablefont data the user agent may use heuristics to determine the offset.

<percentage>

特性的这一计算值为这一百分数乘以文本'text'元素的所计算的"行高"。支配基线在祖先文本内容元素的 平移方向 (正值) 或与平移方向 相反的方向(负值) 平移所计算的值。值"0%" 等价于"baseline".  The computed value of the property is thispercentage multiplied by the computed "line-height" of the 'text' element. The dominant-baseline is shiftedin the shiftdirection (positive value) or opposite to the shift direction(negative value) of the parent textcontent element by the computed value. A value of "0%" isequivalent to "baseline".

<length>

将 dominant-baseline  在祖先文本内容元素的平移方向 (正值) 或与平移方向 相反的方向(负值) 平移 <length> 值. 值"0cm" 等价于"baseline".       The dominant-baselineis shifted in theshiftdirection (positive value) or opposite to the shift direction(negative value) of the parent textcontent element by the <length> value. A value of "0cm" isequivalent to "baseline".

 

10.10 字体挑选属性 Font selection properties

精图使用下列字体规范特性。除了本规范提供的任何附加的信息外,这些特性的正式定义在 [CSS2-fonts]中给出。关于这些特性的任何精图特定的注记包含在下列描述中。SVGuses the following font specification properties. Except for any additionalinformation provided in this specification, the normative definition of theproperty is in [CSS2-fonts].Any SVG-specific notes about these properties are contained in the descriptionsbelow.

'font-family'

Value:  

[[ <family-name> |
<generic-family> ],]* [<family-name> |
<generic-family>] | inherit

Initial:  

depends on user agent

Applies to:  

text content elements

Inherited:  

yes

Percentages:  

N/A

Media:  

visual

Animatable:  

yes

这一特性表示使用哪种字体渲染文本,它通过一个一定次序的字体名字或类属名字列表来指定。除了本规范提供的任何附加的信息外,这一特性的正式定义在 [CSS2-font-family]中给出。表示CSS特性值的语法的规则在[CSS2-propdef]中可以找到。This property indicateswhich font family is to be used to render the text, specified as a prioritizedlist of font family names and/or generic family names. Except for anyadditional information provided in this specification, the normative definitionof the property is in [CSS2-font-family].The rules for expressing the syntax of CSS property values can be found at [CSS2-propdef].

'font-style'

Value:  

normal | italic | oblique | inherit

Initial:  

normal

Applies to:  

text content elements

Inherited:  

yes

Percentages:  

N/A

Media:  

visual

Animatable:  

yes

这一特性指定是否使用正常、倾斜或歪斜外观来渲染文本。除了本规范提供的任何附加的信息外,这一特性的正式定义在 [CSS2-font-style]中给出。This property specifieswhether the text is to be rendered using a normal, italic or oblique face.Except for any additional information provided in this specification, thenormative definition of the property is in [CSS2-font-style].

'font-variant'

Value:  

normal | small-caps | inherit

Initial:  

normal

Applies to:  

text content elements

Inherited:  

yes

Percentages:  

N/A

Media:  

visual

Animatable:  

yes

这一特性表示是否对小写字符使用正规图元或对小写字符使用small-caps图元来渲染文本。除了本规范提供的任何附加的信息外,这一特性的正式定义在 [CSS2-font-variant]中给出。This property indicateswhether the text is to be rendered using the normal glyphs for lowercasecharacters or using small-caps glyphs for lowercase characters. Except for anyadditional information provided in this specification, the normative definitionof the property is in [CSS2-font-variant].

'font-weight'

Value:  

normal | bold | bolder | lighter | 100 | 200 | 300
| 400 | 500 | 600 | 700 | 800 | 900 | inherit

Initial:  

normal

Applies to:  

text content elements

Inherited:  

yes

Percentages:  

N/A

Media:  

visual

Animatable:  

yes

此特性指定引用图元的黑体或淡体来渲染文本,相对于同一字体族中的其它字体。除了本规范提供的任何附加的信息外,这一特性的正式定义在 [CSS2-font-weight]中给出。This property refers to theboldness or lightness of the glyphs used to render the text, relative to otherfonts in the same font family. Except for any additional information providedin this specification, the normative definition of the property is in [CSS2-font-weight].

'font-stretch'

Value:  

normal | wider | narrower |
ultra-condensed | extra-condensed |
condensed | semi-condensed |
semi-expanded | expanded |
extra-expanded | ultra-expanded | inherit

Initial:  

normal

Applies to:  

text content elements

Inherited:  

yes

Percentages:  

N/A

Media:  

visual

Animatable:  

yes

这一特性表示使用所期望的在图元上进行特定量的收缩或膨胀来渲染文本。除了本规范提供的任何附加的信息外,这一特性的正式定义在 [CSS2-font-stretch]中给出。This property indicates thedesired amount of condensing or expansion in the glyphs used to render thetext. Except for any additional information provided in this specification, thenormative definition of the property is in [CSS2-font-stretch].

'font-size'

Value:  

<absolute-size> | <relative-size> |
<length> | <percentage> | inherit

Initial:  

medium

Applies to:  

text content elements

Inherited:  

yes, the computed value is inherited

Percentages:  

refer to parent element's font size

Media:  

visual

Animatable:  

yes

这一特性引用当多行文本在一个多行布局环境中被设置为固定的从基线到基线的字体的尺寸。对于精图而言,如果<length>不带单位标识符 (例如, 一个没限制的数 128), 那么精图用户代理处理此<length>为当前用户坐标系中的一种高度值。This propertyrefers to the size of the font from baseline to baseline when multiple lines oftext are set solid in a multiline layout environment. For SVG, if a <length> is provided without a unit identifier(e.g., an unqualified number such as 128), theSVG user agent processes the <length> as aheight value in the current user coordinate system.

如果所提供的带有单位标识符 (比如, 12pt或 10%),那么精图用户代理根据在单位中所描述的规则将<length>转换成当前用户坐标系中对应的值。If a <length> is provided with one of the unitidentifiers (e.g., 12pt or 10%), then the SVG user agent converts the <length> into a corresponding value in thecurrent user coordinate system by applying the rules described inUnits.

除了本规范提供的任何附加的信息外,这一特性的正式定义在 [CSS2-font-size]中给出。Except for any additionalinformation provided in this specification, the normative definition of theproperty is in [CSS2-font-size].

'font-size-adjust'

Value:  

<number> | none | inherit

Initial:  

none

Applies to:  

text content elements

Inherited:  

yes

Percentages:  

N/A

Media:  

visual

Animatable:  

yes (non-additive, 'set' and 'animate' elements only)

这一特性允许作者为一个保存在一个备选字体中的第一个选择的字体的x-height的元素指定样式值。除了本规范提供的任何附加的信息外,这一特性的正式定义在 [CSS2-font-size-adjust]中给出。This property allows authorsto specify an aspect value for an element that will preserve the x-height ofthe first choice font in a substitute font. Except for any additionalinformation provided in this specification, the normative definition of theproperty is in [CSS2-font-size-adjust].

'font'

Value:  

[ [ <'font-style'> || <'font-variant'> || <'font-weight'> ]?
<'font-size'> [ / <'line-height'> ]? <'font-family'> ] |
caption | icon | menu | message-box|
small-caption | status-bar | inherit

Initial:  

see individual properties

Applies to:  

text content elements

Inherited:  

yes

Percentages:  

allowed on 'font-size' and 'line-height' (Note: for the purposes of processing the 'font' property in SVG, 'line-height' is assumed to be equal the value for property 'font-size')

Media:  

visual

Animatable:  

yes (non-additive, 'set' and 'animate' elements only)

这是用于设置 'font-style','font-variant', 'font-weight', 'font-size', 'line-height' 和 'font-family'的速记特性。在精图的文本布局上特性 'line-height' 无效。对于特性 'font' 来说,'line-height'被假定等于特性'font-size' 的值。不要求精图兼容浏览器支持各种字体选项(标题, 图标, 菜单, 消息框, 小标题 和 状态条)并且可以用一个系统字体或通用字体来代替。Shorthandproperty for setting 'font-style', 'font-variant', 'font-weight', 'font-size','line-height' and 'font-family'. The 'line-height' property has no effect ontext layout in SVG. For the purposes of the 'font'property, 'line-height' is assumed to be equal to the value of the'font-size' property. ConformingSVG Viewers are not required to support the various system font options(caption, icon, menu, message-box, small-caption and status-bar) and can use asystem font or one of the generic fonts instead.

除了本规范提供的任何附加的信息外,这一特性的正式定义在  [CSS2-font]中给出。表示CSS特性值的语法的规则在 [CSS2-propdef]中可以找到。Except for any additionalinformation provided in this specification, the normative definition of theproperty is in [CSS2-font].The rules for expressing the syntax of CSS property values can be found at [CSS2-propdef].

10.11 空白属性 Spacing properties

三个特性影响字词之间的空白。Threeproperties affect the space between characters and words:

  • 'kerning' 表示用户代理是基于包含在相关字体中的字距调整表来调整图元间的空白(即, 应用 auto-kerning) 还是不应用 auto-kerning 而代之以设置字符间空白为指定的长度(典型地, 为零).     'kerning' indicates whether the user agent should adjust inter-glyph spacing based on kerning tables that are included in the relevant font (i.e., enable auto-kerning) or instead disable auto-kerning and instead set inter-character spacing to a specific length (typically, zero).
  • 'letter-spacing'表示将加到文本字符之间的一定量的空白,它将由特性'kerning'所指定的空白进行补充。'letter-spacing' indicates an amount of space that is to be added between text characters supplemental to any spacing due to the'kerning' property.
  • 'word-spacing'表示单词间的补白行为。'word-spacing' indicates the spacing behavior between words.

'kerning'

Value:  

auto | <length> | inherit

Initial:  

auto

Applies to:  

text content elements

Inherited:  

yes

Percentages:  

N/A

Media:  

visual

Animatable:  

yes

值auto表示用户代理基于包含在将被使用的字体中的字距调整表来调整图元间的空白(即, 应用 auto-kerning)。The value of auto indicates that the user agent should adjustinter-glyph spacing based on kerning tables that are included in the font thatwill be used (i.e., enable auto-kerning).

当提供一个 <length>, 那么不用 auto-kerning. 代之以, 字符间空白被设置为此给定的<length>. 最通常的情形, 除了 auto, 是设置'kerning' 为 0 这样便能不用auto-kerning.     If a <length>is provided, then auto-kerning is disabled. Instead, inter-character spacing isset to the given <length>. The most commonscenario, other than auto, is to set 'kerning' to a value of 0so that auto-kerning is disabled.

如果<length>不带单位标识符 (例如, 一个没限制的数 128), 那么精图用户代理处理此<length>为当前用户坐标系中的一种高度值。If a <length> is provided without a unit identifier(e.g., an unqualified number such as 128), theSVG user agent processes the <length> as awidth value in the current user coordinate system.

如果所提供的带有单位标识符 (比如, .25em或 1%),那么精图用户代理根据在单位中所描述的规则将<length>转换成当前用户坐标系中对应的值。If a <length> is provided with one of the unitidentifiers (e.g., .25em or 1%), then the SVG user agent converts the <length> into a corresponding value in thecurrent user coordinate system by applying the rules described inUnits.

当提供一个 <length>,其值被加到由特性'letter-spacing' 所指定的字符间的空白值中。When a <length>is provided, its value is added to the inter-character spacing value specifiedby the 'letter-spacing' property.

'letter-spacing'

Value:  

normal | <length> | inherit

Initial:  

normal

Applies to:  

text content elements

Inherited:  

yes

Percentages:  

N/A

Media:  

visual

Animatable:  

yes

这一特性指定文本字符之间的空白行为,它是对由特性 'kerning' 指定的任何空白的补充。This property specifies spacing behavior between text characterssupplemental to any spacing due to the'kerning' property.

对于精图而言,如果<length>不带单位标识符 (例如, 一个没限制的数 128), 那么精图用户代理处理此<length>为当前用户坐标系中的一种高度值。For SVG, if a <length> is provided without a unit identifier(e.g., an unqualified number such as 128), theSVG user agent processes the <length> as awidth value in the current user coordinate system.

如果所提供的带有单位标识符 (比如, .25em或 1%),那么精图用户代理根据在单位中所描述的规则将<length>转换成当前用户坐标系中对应的值。If a <length> is provided with one of the unitidentifiers (e.g., .25em or 1%), then the SVG user agent converts the <length> into a corresponding value in thecurrent user coordinate system by applying the rules described inUnits.

除了本规范提供的任何附加的信息外,这一特性的正式定义在  [CSS2-letter-spacing]中给出。Except for any additionalinformation provided in this specification, the normative definition of theproperty is in [CSS2-letter-spacing].

'word-spacing'

Value:  

normal | <length> | inherit

Initial:  

normal

Applies to:  

text content elements

Inherited:  

yes

Percentages:  

N/A

Media:  

visual

Animatable:  

yes

这一特性指定单词之间的空白行为。对于精图而言,如果<length>不带单位标识符 (例如, 一个没限制的数 128), 那么精图用户代理处理此<length>为当前用户坐标系中的一种高度值。This propertyspecifies spacing behavior between words. For SVG, if a <length>is provided without a unit identifier (e.g., an unqualified number such as 128), the SVG user agent processes the <length> as a width value in the current usercoordinate system.

如果所提供的带有单位标识符 (比如, .25em或 1%),那么精图用户代理根据在单位中所描述的规则将<length>转换成当前用户坐标系中对应的值。If a <length> is provided with one of the unitidentifiers (e.g., .25em or 1%), then the SVG user agent converts the <length> into a corresponding value in thecurrent user coordinate system by applying the rules described inUnits.

除了本规范提供的任何附加的信息外,这一特性的正式定义在  [CSS2-word-spacing]中给出。Except for any additionalinformation provided in this specification, the normative definition of theproperty is in [CSS2-word-spacing].

10.12 文本修饰 Text decoration

'text-decoration'

Value:  

none | [ underline || overline || line-through || blink ] | inherit

Initial:  

none

Applies to:  

text content elements

Inherited:  

no (see prose)

Percentages:  

N/A

Media:  

visual

Animatable:  

yes

这一特性描述附加到一个元素的文本上的修饰。不要求精图兼容浏览器支持blink 值。Thisproperty describes decorations that are added to the text of an element.ConformingSVG Viewers are not required to support the blink value.

除了本规范提供的任何附加的信息外,这一特性的正式定义在  [CSS2-text-decoration]中给出。表示CSS特性值的语法的规则在 [CSS2-propdef]中可以找到。Except for any additionalinformation provided in this specification, the normative definition of theproperty is in [CSS2-text-decoration].The rules for expressing the syntax of CSS property values can be found at [CSS2-propdef].

CSS2 规范 [CSS2] 通过使用术语 "block-level elements"和 "inlineelements"定义了特性 'text-decoration' 的行为. 对于特性 'text-decoration' 的目的和精图而言, 一个文本'text' 元素代表一个块级的元素而一个文本'text' 元素的任何潜在的孩子(例如, 一个'tspan') 表示内联元素.    The CSS2 specification [CSS2] defines the behavior of the 'text-decoration' property using the terminology"block-level elements" and "inline elements". For thepurposes of the 'text-decoration' property andSVG, a 'text' element represents a block-level elementand any of the potential children of a'text' element (e.g., a 'tspan') represent inline elements.

同时, 'text-decoration' 的 CSS2 定义规定"装饰的颜色"与它的后代元素保持一致. 因为精图提供一个由使用既在文本内部(即, "填充")又在文本外部(即, "描边")各种类型绘制方式(参见绘画: 填充, 描边和标记符号)的能力组成绘制模型, 对于精图而言定义特性 'text-decoration' 使得, 对于一个指定了特性'text-decoration'的值的元素, 在它的内容和其后代的内容将使用此给定元素上呈现的相同的填充和描边特性来进行渲染. 如果在一个后代元素上指定了特性 'text-decoration' , 那么它将覆盖祖先的特性.       Also, the CSS2 definition of 'text-decoration' specifies that the "color of thedecorations" remain the same on descendant elements. Since SVG offers apainting model consisting of the ability to apply various types of paint (seePainting: Filling, Strokingand Marker Symbols) to both the interior (i.e., the "fill") andthe outline (i.e., the "stroke") of text, for SVG the 'text-decoration' property is defined such that, for anelement which has a specified value for the 'text-decoration'property, all decorations on its content and that of its descendants arerendered using the same fill and stroke properties as are present on the givenelement. If the 'text-decoration' property isspecified on a descendant, then that overrides the ancestor.

因为精图允许对文本进行填充和描边,在某些具有文本装饰的情形下绘制的次序比较重要。文本装饰的绘制次序应当如下:  Because SVG allows text to be both filled and stroked, drawingorder matters in some circumstances with text decorations. Text decorationdrawing order should be as follows:

  • 除了line-through所有文本装饰应该在文本被填充和描边之前进行绘制;于是,文本在这些装饰上面进行渲染。All text decorations except line-through should be drawn before the text is filled and stroked; thus, the text is rendered on top of these decorations.
  • Line-through应该在文本被填充和描边之后进行绘制;于是,Line-through在文本的上面进行渲染。Line-through should be drawn after the text is filled and stroked; thus, the line-through is rendered on top of the text.

例子 textdecoration01 提供关于'text-decoration'的例子. 第一行文本没有为 'text-decoration'赋值, 故使用初始值'text-decoration:none' . 第二行说明 'text-decoration:line-through'. 第三行说明 'text-decoration:underline'. 第四行解释如何对装饰进行渲染的规则,即使用与其指定了特性'text-decoration' 的元素所呈现的填充和描边特性相同的特性对装饰进行渲染. 因为在此文本'text' 元素上指定了特性'text-decoration', 在此文本'text' 元素内的所有文本具有用与此文本'text'元素上相同的填充和描边特性(即, 蓝色填充, 红色描边)渲染的下划线, 哪怕各个单词有不同的填充和描边特性值. 但是, 单词 "different" 为'text-decoration'显式指定一种值 ; 于是, 它的下划线使用包围在单词"different"周围的'tspan' 元素的填充和描边特性(即, 黄色填充, 深绿描边)来进行渲染:      Example textdecoration01 provides examples for 'text-decoration'. The first line of text has no valuefor 'text-decoration', so the initial value of 'text-decoration:none' is used. The second line shows 'text-decoration:line-through'. The third line shows 'text-decoration:underline'. The fourth lineillustrates the rule whereby decorations are rendered using the same fill andstroke properties as are present on the element for which the 'text-decoration' is specified. Since 'text-decoration' is specified on the 'text' element, all text within the 'text' element has its underline rendered withthe same fill and stroke properties as exist on the'text' element (i.e., blue fill, red stroke),even though the various words have different fill and stroke property values.However, the word "different" explicitly specifies a value for 'text-decoration'; thus, its underline is rendered usingthe fill and stroke properties as the 'tspan' element that surrounds the word"different" (i.e., yellow fill, darkgreen stroke):

 
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="12cm" height="4cm" viewBox="0 0 1200 400"
     xmlns="http://www.w3.org/2000/svg">
  <desc>Example textdecoration01 - behavior of 'text-decoration' property</desc>
  <rect x="1" y="1" width="1198" height="398" fill="none" stroke="blue" stroke-width="2" />
  <g font-size="60" fill="blue" stroke="red" stroke-width="1" >
    <text x="100" y="75">Normal text</text>
    <text x="100" y="165" text-decoration="line-through" >Text with line-through</text>
    <text x="100" y="255" text-decoration="underline" >Underlined text</text>
    <text x="100" y="345" text-decoration="underline" >
      <tspan>One </tspan>
      <tspan fill="yellow" stroke="purple" >word </tspan>
      <tspan fill="yellow" stroke="black" >has </tspan>
      <tspan fill="yellow" stroke="darkgreen" text-decoration="underline" >different </tspan>
      <tspan fill="yellow" stroke="blue" >underlining</tspan>
    </text>
  </g>
</svg>

Example textdecoration01

View thisexample as SVG (SVG-enabled and CSS-enabled browsers only)
 


 

10.13 路径文本 Text on a path

10.13.1 路径文本概述 Introduction to text on apath

除了将文本绘制在直线上外,精图也包括沿着一个路径 'path' 元素安置文本的能力。为了指定一段文本沿着一'path'的形状进行渲染,需要使用一个包括属性xlink:href具有URI引用指向一个路径'path'元素的文本路径'textPath' 元素包括这一给定的文本。In addition to text drawn in a straight line, SVG also includes theability to place text along the shape of a'path' element. To specify that a block of textis to be rendered along the shape of a'path', include the given text within a 'textPath' element which includes an xlink:href attribute with a URI referenceto a 'path' element.

10.13.2 文本路径元素 'textPath'  The 'textPath' element

 
<!ENTITY % textPathExt "" >
<!ELEMENT textPath (#PCDATA|desc|title|metadata|tspan|tref|altGlyph|a|animate|set|animateColor
                %textPathExt;)* >
<!ATTLIST textPath
  %stdAttrs;
  %xlinkRefAttrs;
  xlink:href %URI; #REQUIRED
  %langSpaceAttrs;
  %testAttrs;
  externalResourcesRequired %Boolean; #IMPLIED
  class %ClassList; #IMPLIED
  style %StyleSheet; #IMPLIED
  %PresentationAttributes-Color;
  %PresentationAttributes-FillStroke;
  %PresentationAttributes-FontSpecification;
  %PresentationAttributes-Graphics;
  %PresentationAttributes-TextContentElements;
  %graphicsElementEvents;
  startOffset %Length; #IMPLIED
  textLength %Length; #IMPLIED
  lengthAdjust (spacing|spacingAndGlyphs) #IMPLIED
  method (align|stretch) #IMPLIED
  spacing (auto|exact) #IMPLIED >

属性定义: Attribute definitions:

startOffset = "<length>"

初始的当前文本位置与'path' 的开始的偏移量,此偏移量通过使用用户代理的沿着路径的距离算法来计算。An offset from the startof the 'path' for the initial current text position,calculated using the user agent'sdistancealong the path algorithm.
如果给出的<length>不是百分数,那么此startOffset 表示按照当前用户坐标系进行测量的沿着此路径上的距离。If a<length>other than a percentage is given, then the startOffsetrepresents a distance along the path measured in the current user coordinatesystem.
如果给出的是百分数,那么此startOffset 表示的沿着整个路径上的距离的百分比。于是,startOffset="0%"代表'path'的起始点而startOffset="100%"代表'path'的终止点。If a percentage is given, then the startOffsetrepresents a percentage distance along the entire path. Thus, startOffset="0%" indicates the start point ofthe'path' and startOffset="100%"indicates the end point of the 'path'.
一个负值为一种错误(参见 错误处理). Anegative value is an error (see Errorprocessing).
如果不指定此属性,其效果相当于指定其值为 "0" 。If the attribute is not specified, the effect is as if a value of"0" were specified.
Animatable:yes.

method = "align | stretch"

表示将使用哪种方法沿着路径对文本进行渲染。Indicates the method by which text should be rendered along thepath.
值align表示将使用不存在图元的拉伸或扭曲的简单2x3变换对图元进行渲染。典型情况下,对于每个渲染的图元进行附加的旋转、缩放和平移变换。作为align的一种结果,对于那些其图元被设计成可以连接的字体(例如, 草体),当文本沿着路径进行渲染时,图元之间的连接也许不被适当对准。Avalue of align indicates that the glyphs shouldbe rendered using simple 2x3 transformations such that there is nostretching/warping of the glyphs. Typically, supplemental rotation, scaling andtranslation transformations are done for each glyph to be rendered. As aresult, with align, fonts where the glyphs aredesigned to be connected (e.g., cursive fonts), the connections may not alignproperly when text is rendered along a path.
值stretch表示图元轮廓将转换成路径,然后所有终点和控制点将沿着路径上的正交矢量进行调整,因此图元可能被拉伸或扭曲。使用这种方法,连接的图元,比如草书文本,将维持它们的连接。A value of stretch indicates that theglyph outlines will be converted into paths, and then all end points andcontrol points will be adjusted to be along the perpendicular vectors from thepath, thereby stretching and possibly warping the glyphs. With this approach,connected glyphs, such as in cursive scripts, will maintain their connections.
如果不指定此属性,其效果相当于指定其值为 align 。If the attribute is notspecified, the effect is as if a value of alignwere specified.
Animatable:yes.

spacing = "auto | exact"

表示用户代理将如何确定在沿着路径渲染的图元之间的空白。Indicates how the user agent should determine the spacing betweenglyphs that are to be rendered along a path.
值exact表示图元将按照在路径上的文本的布局规则中指定的空白规则进行渲染。A value of exact indicates that the glyphs should be renderedexactly according to the spacing rules as specified in Text on apath layout rules.
值auto表示用户代理将使用路径上文本布局算法调整图元之间的空白以便达到吸引人的视觉效果。A value of auto indicates that theuser agent should use text-on-a-path layout algorithms to adjust the spacingbetween glyphs in order to achieve visually appealing results.
如果不指定此属性,其效果相当于指定其值为 exact 。If the attribute is notspecified, the effect is as if a value of exactwere specified.
Animatable:yes.

xlink:href = "<uri>"

对图元将在其上进行渲染的路径'path'元素一种URI引用。如果<uri>为一种无效引用(例如, 这一元素不存在, 或者被引用的元素不是一个路径'path'元素 ),那么此文本路径'textPath'元素是一种错误并且它的整个内容将不被用户代理所渲染。AURIreference to the 'path' element onto which the glyphs will berendered. If <uri> is an invalid reference (e.g., no such element exists,or the referenced element is not a'path'), then the 'textPath'element is in error and its entire contents shall not be rendered by the useragent.
Animatable:yes.

在别处定义的属性:  Attributes defined elsewhere:

%stdAttrs;,%xlinkRefAttrs;,%langSpaceAttrs;,%testAttrs;,externalResourcesRequired,class,style, %PresentationAttributes-Color;,%PresentationAttributes-FillStroke;,%PresentationAttributes-FontSpecification;,%PresentationAttributes-Graphics;,%PresentationAttributes-TextContentElements;,%graphicsElementEvents;,textLength,lengthAdjust.

在所引用的路径'path'元素中的路径数据坐标被假定与当前文本'text' 元素具有相同的坐标系,而不是使用路径'path'元素所定义的地方的坐标系。在所引用的'path'元素上的transform属性表示相对于当前文本'text'元素的当前用户坐标系的附加变换,包括由于在当前文本'text'元素上的可能的transform属性所导致的对当前用户坐标系的任何调整。例如,下列精图内容的片段:  The path data coordinates within the referenced'path' element are assumed to be in the samecoordinate system as the current 'text'element, not in the coordinate system where the'path' element is defined. The transform attribute on the referenced 'path' element represents a supplementaltransformation relative to the current user coordinate system for the current'text' element, including any adjustments to thecurrent user coordinate system due to a possibletransform attribute on the current 'text' element. For example, the followingfragment of SVG content:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <g transform="translate(25,25)">
    <defs>
      <path id="path1" transform="scale(2)" d="..." fill="none" stroke="red"/>
    </defs>
  </g>
  <text transform="rotate(45)">
    <textPath xlink:href="#path1">Text along path1</textPath>
  </text>
</svg>

应该与下列片段具有相同的效果:shouldhave the same effect as the following:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <g transform="rotate(45)">
    <defs>
      <path id="path1" transform="scale(2)" d="..." fill="none" stroke="red"/>
    </defs>
    <text>
      <textPath xlink:href="#path1">Text along path1</textPath>
    </text>
  </g>
</svg>

注意 transform="translate(25,25)" 在 'textPath' 元素上无任何效果, 而transform="rotate(45)" 既用于 'text' 也用于作为路径上文本所引用的形状的路径'path' 元素.     Note that thetransform="translate(25,25)" has no effect on the 'textPath'element, whereas thetransform="rotate(45)"applies to both the 'text' and the use of the 'path' element as the referenced shape for text on apath.

例子 toap01 提供一个路径上的文本的简单的例子:   Example toap01 provides a simple example of text on apath:

 
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="12cm" height="3.6cm" viewBox="0 0 1000 300"
     xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <defs>
    <path id="MyPath"
          d="M 100 200 
             C 200 100 300   0 400 100
             C 500 200 600 300 700 200
             C 800 100 900 100 900 100" />
  </defs>
  <desc>Example toap01 - simple text on a path</desc>
 
  <use xlink:href="#MyPath" fill="none" stroke="red"  />
  <text font-family="Verdana" font-size="42.5" fill="blue" >
    <textPath xlink:href="#MyPath">
      We go up, then we go down, then up again
    </textPath>
  </text>
 
  <!-- Show outline of canvas using 'rect' element -->
  <rect x="1" y="1" width="998" height="298"
        fill="none" stroke="blue" stroke-width="2" />
</svg>

Example toap01

View this exampleas SVG (SVG-enabled browsers only)
 

例子 toap02 说明能够包含在文本'textPath'路径元素中的'tspan' 元素是如何在渲染一个特殊图元之前调整样式属性和当前文本位置的. 单词"up"的第一次出现用红色填充. 属性dy 用来从基线上抬升单词"up".      Example toap02 shows how 'tspan' elements can be included within 'textPath' elements to adjust styling attributes andadjust the current text position before rendering a particular glyph. The firstoccurrence of the word "up" is filled with the color red. Attributedy is used to lift the word "up" from thebaseline.

 
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="12cm" height="3.6cm" viewBox="0 0 1000 300"
     xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <defs>
    <path id="MyPath"
          d="M 100 200 
             C 200 100 300   0 400 100
             C 500 200 600 300 700 200
             C 800 100 900 100 900 100" />
  </defs>
  <desc>Example toap02 - tspan within textPath</desc>
 
  <use xlink:href="#MyPath" fill="none" stroke="red"  />
  <text font-family="Verdana" font-size="42.5" fill="blue" >
    <textPath xlink:href="#MyPath">
      We go 
      <tspan dy="-30" fill="red" >
        up
      </tspan>
      <tspan dy="30">
        ,
      </tspan>
      then we go down, then up again
    </textPath>
  </text>
 
  <!-- Show outline of canvas using 'rect' element -->
  <rect x="1" y="1" width="998" height="298"
        fill="none" stroke="blue" stroke-width="2" />
</svg>

Example toap02

View this exampleas SVG (SVG-enabled browsers only)
 

例子 toap03 示范使用在文本路径 'textPath' 元素上属性startOffset指定文本字符串的开始位置为沿着路径的一个特定的位置。 注意不对越过路径末端的图元进行渲染 (参见路径上的文本的布局规则).     Example toap03 demonstrates the use of the startOffset attribute on the 'textPath'element to specify the start position of the text string as a particularposition along the path. Notice that glyphs that fall off the end of the pathare not rendered (seetext on apath layout rules).

 
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="12cm" height="3.6cm" viewBox="0 0 1000 300"
     xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <defs>
    <path id="MyPath"
          d="M 100 200 
             C 200 100 300   0 400 100
             C 500 200 600 300 700 200
             C 800 100 900 100 900 100" />
  </defs>
  <desc>Example toap03 - text on a path with startOffset attribute</desc>
 
  <use xlink:href="#MyPath" fill="none" stroke="red"  />
  <text font-family="Verdana" font-size="42.5" fill="blue" >
    <textPath xlink:href="#MyPath" startOffset="80%">
      We go up, then we go down, then up again
    </textPath>
  </text>
 
  <!-- Show outline of canvas using 'rect' element -->
  <rect x="1" y="1" width="998" height="298"
        fill="none" stroke="blue" stroke-width="2" />
</svg>

Example toap03

View this exampleas SVG (SVG-enabled browsers only)
 

10.13.3 路径文本的布局规则 Text on a path layoutrules

概念上说来,对于路径上的文本,目标路径要么被拉伸为一水平直线段要么被拉伸为垂直直线段。对于水平文本布局流而言,此路径被拉伸成为一假想的水平线段使得路径的起点被映射到直线段的左端。对于垂直文本布局流而言,此路径被拉伸成为一假想的垂直线段使得路径的起点被映射到直线段的顶端。标准的文本布局规则被用于这一假想的直线段上并且其结果被映照回目标路径上。垂直的和双向文本布局规则也用于路径上的文本。Conceptually, fortext on a path the target path is stretched out into either a horizontal orvertical straight line segment. For horizontal text layout flows, the path isstretched out into a hypothetical horizontal line segment such that the startof the path is mapped to the left of the line segment. For vertical text layoutflows, the path is stretched out into a hypothetical vertical line segment suchthat the start of the path is mapped to the top of the line segment. Thestandardtextlayout rules are applied to the hypothetical straight line segment and theresult is mapped back onto the target path. Vertical and bidirectionaltext layout rulesalso apply to text on a path.

对于沿着路径渲染的每个图元而言它们各自确定自己的参考方向。对于水平文本布局流而言,给定图元的参考方向为矢量此矢量开始于缚上图元的路径上的交叉点并指向此曲线在交叉点的角度逆时针旋转90度的方向。对于垂直文本布局流而言,给定图元的参考方向为矢量此矢量开始于缚上图元的路径上的交叉点并指向此曲线在交叉点的角度旋转180度的方向。Thereferenceorientation is determined individually for each glyph that is renderedalong the path. For horizontal text layout flows, the reference orientation fora given glyph is the vector that starts at the intersection point on the pathto which the glyph is attached and which points in the direction 90 degreescounter-clockwise from the angle of the curve at the intersection point. Forvertical text layout flows, the reference orientation for a given glyph is thevector that starts at the intersection point on the path to which the glyph isattached and which points in the direction 180 degrees from the angle of thecurve at the intersection point.

例子 toap04 将用于解释对于直线水平或垂直文本的基本 文本布局规则进行补充的特殊布局规则。   Example toap04 will be used to illustrate theparticular layout rules for text on a path that supplement the basictext layout rulesfor straight line horizontal or vertical text.

 
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="12cm" height="3.6cm" viewBox="0 0 1000 300"
     xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <defs>
    <path id="MyPath"
          d="M 100 125 
             C 150 125 250 175 300 175
             C 350 175 450 125 500 125
             C 550 125 650 175 700 175
             C 750 175 850 125 900 125" />
  </defs>
  <desc>Example toap04 - text on a path layout rules</desc>
 
  <use xlink:href="#MyPath" fill="none" stroke="red"  />
  <text font-family="Verdana" font-size="60" fill="blue" letter-spacing="2" >
    <textPath xlink:href="#MyPath">
      Choose shame or get war 
    </textPath>
  </text>
 
  <!-- Show outline of canvas using 'rect' element -->
  <rect x="1" y="1" width="998" height="298"
        fill="none" stroke="blue" stroke-width="2" />
</svg>

Example toap04

View this exampleas SVG (SVG-enabled browsers only)
 

下图显示对此文本'text'元素的第一个图元的一种初步的放大。The following picture does an initial zoom in on the first glyph inthe'text' element.

上图中的小圆点说明图元缚上路径的那个点。图元周围的方框说明对图元进行旋转使得它的水平轴与曲线在图元缚上路径的这个点上的切线平行。此方框也显示了图元的字符宽度 (即, 当图元使用水平文本布局进行绘制之后当前文本位置的增量).     The small dot above shows the point at which the glyph is attached to the path.The box around the glyph shows the glyph is rotated such that its horizontalaxis is parallel to the tangent of the curve at the point at which the glyph isattached to the path. The box also shows the glyph's charwidth(i.e., the amount which the current text position advances horizontally whenthe glyph is drawn using horizontal text layout).

进行进一步放大的下一个图片示范了更详细的布局规则。The next picture zooms in further to demonstrate the detailed layoutrules.

对于沿着一个路径从左到右水平文本布局而言(即, 当图元的方向正交于 内联-书写-方向时),布局规则如下:For left-to-right horizontal text layout alonga path (i.e., when the glyph orientation is perpendicular to theinline-progression-direction),the layout rules are as follows:

  • 确定使用属性 startOffset 和特性  'text-anchor'的第一个图元的路径上的起点 startpoint-on-the-path .对于 'text-anchor:start'而言, 路径上的起点startpoint-on-the-path 为路径上的点 ,此点位于从路径的开始处沿着路径移动距离startOffset所在的点, 距离的计算使用用户代理的沿着路径的距离 算法. 对于 'text-anchor:middle'而言, 路径上的起点startpoint-on-the-path 为路径上的点 ,此点位于从路径的开始处沿着路径移动距离 [startOffset 减去在文本路径'textPath' 元素中的所有图元的整个增量值的一半 ] 所在的点, 距离的计算使用用户代理的 沿着路径的距离 算法. 对于 'text-anchor:end'而言, 路径上的起点startpoint-on-the-path 为路径上的点,此点表示路径上的位于 [  startOffset 减去在文本路径'textPath' 元素中的所有图元的整个增量值 ]的点. 在渲染第一个图元之前, 路径上的起点startpoint-on-the-path的水平分量被调整,这种调整考虑各种各样的水平对齐文本特性和属性,比如在'tspan'元素上的一个dx属性值. (在上图中, 路径上的起点startpoint-on-the-path为此路径上最左边的那个圆点.)       Determine the startpoint-on-the-path for the first glyph using attribute startOffset and property 'text-anchor'. For 'text-anchor:start', startpoint-on-the-path is the point on the path which represents the point on the path which isstartOffset distance along the path from the start of the path, calculated using the user agent'sdistance along the path algorithm. For 'text-anchor:middle', startpoint-on-the-path is the point on the path which represents the point on the path which is [startOffset minus half of the total advance values for all of the glyphs in the 'textPath' element ] distance along the path from the start of the path, calculated using the user agent'sdistance along the path algorithm. For 'text-anchor:end', startpoint-on-the-path is the point on the path which represents the point on the path which is [startOffset minus the total advance values for all of the glyphs in the 'textPath' element ]. Before rendering the first glyph, the horizontal component of the startpoint-on-the-path is adjusted to take into account various horizontal alignment text properties and attributes, such as a dx attribute value on a 'tspan' element. (In the picture above, the startpoint-on-the-path is the leftmost dot on the path.)
  • 确定图元的字符宽度(即, 当图元使用水平文本布局进行绘制之后当前文本位置的在水平方向上的增量). (在上图中, 字符宽度为方框的两边的两个点之间的距离.)    Determine the glyph's charwidth (i.e., the amount which the current text position advances horizontally when the glyph is drawn using horizontal text layout). (In the picture above, the charwidth is the distance between the two dots at the side of the box.)
  • 确定从此图元路径上起始点沿着路径移动字符宽度的距离后曲线上的点,  计算使用用户代理的 沿路径的距离 算法. 这一点被称为图元的路径上的终止点 endpoint-on-the-path . (在上图中, 图元的在路径上的终止点(endpoint-on-the-path)为路径上最右边的圆点.)     Determine the point on the curve which is charwidth distance along the path from the startpoint-on-the-path for this glyph, calculated using the user agent's distance along the path algorithm. This point is the endpoint-on-the-path for the glyph. (In the picture above, the endpoint-on-the-path for the glyph is the rightmost dot on the path.)
  • 确定路径上的中点midpoint-on-the-path,它是路径上的一点此点在路径上的起点startpoint-on-the-path和路径上的终点endpoint-on-the-path之间的"半路"上 (用户代理可以选择距离计算法或参量计算法) . (在上图中, 路径上的中点 midpoint-on-the-path 用白色的圆点表示.)      Determine the midpoint-on-the-path, which is the point on the path which is "halfway" (user agents can choose either a distance calculation or a parametric calculation) between the startpoint-on-the-path and the endpoint-on-the-path. (In the picture above, the midpoint-on-the-path is shown as a white dot.)
  • 确定图元中线 glyph-midline, 它是在图元坐标系中的贯穿图元x-轴中点的一根垂直线. (在上图中, 图元中线显示为一根破折线.)     Determine the glyph-midline, which is the vertical line in the glyph's coordinate system that goes through the glyph's x-axis midpoint. (In the picture above, the glyph-midline is shown as a dashed line.)
  • 安置此图元使得图元中线通过路径上的中点midpoint-on-the-path并且与通过路径上的起点startpoint-on-the-path和路径上的终点endpoint-on-the-path的直线正交。  Position the glyph such that the glyph-midline passes through the midpoint-on-the-path and is perpendicular to the line through the startpoint-on-the-path and the endpoint-on-the-path.
  • 相对于基于特性 'alignment-baseline' 和在一个'tspan' 元素上属性dy指定的任何值的路径上的中点midpoint-on-the-path垂直地对齐此图元. 在上面地例子中, 特性 'alignment-baseline' 没有指定, 故使用初始值 'alignment-baseline:baseline' . 无 'tspan' 元素; 于是, 图元的基线与路径上的中点midpoint-on-the-path对齐.        Align the glyph vertically relative to the midpoint-on-the-path based on property'alignment-baseline' and any specified values for attribute dy on a 'tspan' element. In the example above, the 'alignment-baseline' property is unspecified, so the initial value of 'alignment-baseline:baseline' will be used. There are no 'tspan' elements; thus, the baseline of the glyph is aligned to the midpoint-on-the-path.
  • 对于每个随后的图元, 设置前一个路径上的终止点endpoint-on-the-path为一个新的路径上起始点startpoint-on-the-path, 但是要作适当的调整,这种调整要考虑字体内的水平字距调整表以及各种属性和特性(包括空白特性 和为属性 dx 和 dy提供了值的 'tspan' 元素)的当前值. 所有调整按照沿着路径的距离调整来计算, 计算使用用户代理的 沿着路径的距离 算法.        For each subsequent glyph, set a new startpoint-on-the-path as the previous endpoint-on-the-path, but with appropriate adjustments taking into account horizontal kerning tables in the font and current values of various attributes and properties, including spacing properties and 'tspan' elements with values provided for attributes dx and dy. All adjustments are calculated as distance adjustments along the path, calculated using the user agent'sdistance along the path algorithm.
  • 那些路径上的中点(midpoint-on-the-path)位于路径的端点之外的图元不被渲染。Glyphs whose midpoint-on-the-path are off either end of the path are not rendered.
  • 连续渲染图元直到不存在更多的图元为止。Continue rendering glyphs until there are no more glyphs.

相比较的规则用于沿着一个路径从上到下垂直文本布局(即, 当图元的方向平行于 内联-书写-方向时),布局规则如下:Comparable rules are used for top-to-bottomvertical text layout along a path (i.e., when the glyph orientation is parallelwith theinline-progression-direction),the layout rules are as follows:

  • 使用与沿着路径的水平文本布局相同的方法确定路径上的起点startpoint-on-the-path,除了在渲染第一个图元之前,路径上的起点startpoint-on-the-path的水平分量被调整为考虑各种垂直对齐文本特性和属性,比如在一个'tspan' 元素上的属性dy。  Determine the startpoint-on-the-path using the same method as for horizontal text layout along a path, except that before rendering the first glyph, the horizontal component of the startpoint-on-the-path is adjusted to take into account various vertical alignment text properties and attributes, such as ady attribute value on a 'tspan' element.
  • 确定图元的字符高度(即, 当图元使用垂直文本布局进行绘制之后当前文本位置在垂直方向的增量).     Determine the glyph's charheight (i.e., the amount which the current text position advances vertically when the glyph is drawn using vertical text layout).
  • 确定从此图元路径上起始点沿着路径移动字符高度的距离后曲线上的点,  计算使用用户代理的 沿路径的距离 算法. 这一点被称为图元的路径上的终止点 .   Determine the point on the curve which is charheight distance along the path from the startpoint-on-the-path for this glyph, calculated using the user agent'sdistance along the path algorithm. This point is the endpoint-on-the-path for the glyph.
  • 确定路径上的中点midpoint-on-the-path,它是路径上的一点此点在路径上的起点startpoint-on-the-path和路径上的终点endpoint-on-the-path之间的"半路"上 (用户代理可以选择距离计算法或参量计算法) .     Determine the midpoint-on-the-path, which is the point on the path which is "halfway" (user agents can choose either a distance calculation or a parametric calculation) between the startpoint-on-the-path and the endpoint-on-the-path.
  • 确定图元中线glyph-midline, 它是在图元坐标系中的贯穿图元y-轴中点的一根水平线. Determine the glyph-midline, which is the horizontal line in the glyph's coordinate system that goes through the glyph's y-axis midpoint.
  • 安置此图元使得图元中线通过路径上的中点midpoint-on-the-path并且与通过路径上的起点startpoint-on-the-path和路径上的终点endpoint-on-the-path的直线正交。  Position the glyph such that the glyph-midline passes through the midpoint-on-the-path and is perpendicular to the line through the startpoint-on-the-path and the endpoint-on-the-path.
  • 相对于基于特性 'alignment-baseline' 和在一个'tspan' 元素上属性dx指定的任何值的路径上的中点midpoint-on-the-path水平地 (这里水平是相对于图元的坐标系)对齐此图元.   Align the glyph horizontally (where horizontal is relative to the glyph's coordinate system) relative to the midpoint-on-the-path based on property'alignment-baseline' and any specified values for attribute dx on a 'tspan' element.
  • 对于每个随后的图元, 设置前一个路径上的终止点endpoint-on-the-path为一个新的路径上起始点startpoint-on-the-path, 但是要作适当的调整,这种调整要考虑字体内的垂直字距调整表以及各种属性和特性(包括空白特性 和为属性 dx 和 dy提供了值的 'tspan' 元素)的当前值. 所有调整按照沿着路径的距离调整来计算, 计算使用用户代理的 沿着路径的距离 算法.       For each subsequent glyph, set a new startpoint-on-the-path as the previous endpoint-on-the-path, but with appropriate adjustments taking into account vertical kerning tables in the font and current values of various attributes and properties, including spacing properties and 'tspan' elements with values provided for attributes dx and dy. All adjustments are calculated as distance adjustments along the path, calculated using the user agent'sdistance along the path algorithm.
  • 那些路径上的中点(midpoint-on-the-path)位于路径的端点之外的图元不被渲染。Glyphs whose midpoint-on-the-path are off either end of the path are not rendered.
  • 连续渲染图元直到不存在更多的图元为止。Continue rendering glyphs until there are no more glyphs.

在上述计算中,如果在路径上的起始点(startpoint-on-the-path)或在路径上的终止点(endpoint-on-the-path)越过路径的端点,那么用一平行于路径的端点的切线的直线在端点之外扩展此路径使得仍然能够计算路径上的中点( midpoint-on-the-path)。In the calculations above, if either the startpoint-on-the-path orthe endpoint-on-the-path is off the end of the path, then extend the pathbeyond its end points with a straight line that is parallel to the tangent atthe path at its end point so that the midpoint-on-the-path can still becalculated.

当内联-书写-方向为水平方向时, 那么在'text', 'tspan', 'tref' 或者'altGlyph' 元素上任何x 属性表示新的沿着此路径的绝对偏移量 , 于是为路径上的起始点(startpoint-on-the-path)提供新的明确的值. 在 'text', 'tspan', 'tref' 或者'altGlyph' 元素上任何 y  属性将被忽略. 当内联-书写-方向为垂直方向时, 那么在'text', 'tspan', 'tref' 或者'altGlyph' 元素上任何y 属性表示新的沿着此路径的绝对偏移量 , 于是为路径上的起始点(startpoint-on-the-path)提供新的明确的值. 在 'text', 'tspan', 'tref' 或者'altGlyph' 元素上任何 x  属性将被忽略.      When the inline-progression-directionis horizontal, then any x attributes on 'text', 'tspan', 'tref' or 'altGlyph' elements represent new absoluteoffsets along the path, thus providing explicit new values forstartpoint-on-the-path. Anyy attributes on 'text', 'tspan', 'tref' or 'altGlyph' elements are ignored. When the inline-progression-directionis horizontal, then any y attributes on 'text', 'tspan', 'tref' or 'altGlyph' elements represent new absoluteoffsets along the path, thus providing explicit new values forstartpoint-on-the-path. Anyx attributes on 'text', 'tspan', 'tref' or 'altGlyph' elements are ignored.

 

10.14 备用图元 Alternate glyphs

在某些情况下比如组合字符,特定用途的字体(例如, 表示音乐符号的字体)或者关于亚洲文本串的替换图元此时除正常情况下对应于给定字符数据的图元外需要使用另一套不同的图元。 There are situations such as ligatures, special-purpose fonts (e.g.,a font for music symbols) or alternate glyphs for Asian text strings where itis required that a different set of glyphs is used than the glyph(s) whichnormally corresponds to the given character data.

元素 'altGlyph' 提供对用于渲染特殊字符数据的图元的控制。The 'altGlyph' element provides control over the glyphsused to render particular character data.

 
<!ENTITY % altGlyphExt "" >
<!ELEMENT altGlyph (#PCDATA %altGlyphExt;)* >
<!ATTLIST altGlyph
  %stdAttrs;
  %xlinkRefAttrs;
  xlink:href %URI; #IMPLIED 
  glyphRef CDATA #IMPLIED
  format CDATA #IMPLIED
  %testAttrs;
  %langSpaceAttrs;
  externalResourcesRequired %Boolean; #IMPLIED
  class %ClassList; #IMPLIED
  style %StyleSheet; #IMPLIED
  %PresentationAttributes-Color;
  %PresentationAttributes-FillStroke;
  %PresentationAttributes-FontSpecification;
  %PresentationAttributes-Graphics;
  %PresentationAttributes-TextContentElements;
  %graphicsElementEvents;
  x %Coordinates; #IMPLIED
  y %Coordinates; #IMPLIED
  dx %Lengths; #IMPLIED
  dy %Lengths; #IMPLIED
  rotate %Numbers; #IMPLIED >

属性定义: Attribute definitions:

xlink:href = "<uri>"

一个 URI 引用 它要么指向精图文档片段中的一个'glyph' 元素要么指向一个'altGlyphDef' 元素.   A URIreference either to a 'glyph' element in an SVG documentfragment or to an'altGlyphDef' element.

如果此引用指向一个 'glyph' 元素并且此图元可用, 那么将替换'altGlyph'元素内部的字符而对此图元进行渲染.   Ifthe reference is to a 'glyph' element and thatglyph is available, then that glyph is rendered instead of the character(s)that are inside of the 'altGlyph' element.

如果此引用指向一个 'altGlyphDef' 元素, 那么如果从处理'altGlyphDef' 元素能够定位一套适当的图元, 那么那些替补图元将代替'altGlyph'元素内部的字符而被渲染.   If thereference is to an'altGlyphDef' element, then if anappropriate set of alternate glyphs is located from processing the 'altGlyphDef' element, then those alternate glyphsare rendered instead of the character(s) that are inside of the 'altGlyph' element.

Animatable:no.

glyphRef = "<string>"

图元标识符, 其格式依赖于给定字体的格式 format . (与元素'glyphRef'上的属性glyphRef具有相同的意思.)    The glyph identifier, the format of which isdependent on the format of the given font. (Same meaning as the glyphRef attribute on the 'glyphRef' element.)
Animatable:no.

format = "<string>"

给定字体的格式. 如果此字体为规范[CSS2-src]所列出的格式之一(例如,TrueDoc™ Portable FontResource 或者 Embedded OpenType), 那么 <string> 必须包含定义在[CSS2-src]中的相应的字体格式串(例如,truedoc-pfr 或者 embedded-opentype). (与元素'glyphRef'上的属性format具有相同的意思.)    The format of the given font. If the font is inone of the formats listed in the [CSS2-src]specification (e.g.,TrueDoc™ Portable Font Resource or EmbeddedOpenType), then the <string> must contain the corresponding fontformat string defined in [CSS2-src](e.g.,truedoc-pfr or embedded-opentype). (Same meaning asthe format attribute on the 'glyphRef' element.)
Animatable:no.

x = "<coordinate>+"

值<coordinate> 一般按照元素'tspan' 中的属性 x 相同的方式进行处理, 除了下列例外情况: 如果所引用的替换图元而不是在 'altGlyph' 元素里面的Unicode字符被渲染, 那么在这一元素上或者任何祖先的'text''tspan' 元素对于在 'altGlyph' 元素内的从第2个到第 <n> 个  Unicode 字符上 经由一个 x 属性所指定的任何绝对 X 坐标  将被忽略. 在渲染第一个替换图元之前将在这一元素上或者任何祖先的'text''tspan' 元素对于在 'altGlyph' 元素内的第1个Unicode 字符上经由一个 x 属性所指定的任何绝对 X 坐标 设置为当前文本位置 的新的绝对 X 坐标.      The<coordinate>values are processed in the same manner as the x attribute on the 'tspan' element, with the followingexception: If the referenced alternate glyphs are rendered instead of theUnicode characters inside the 'altGlyph'element, then any absolute X coordinates specified via an x attribute on this element or any ancestor 'text' or 'tspan' elements for Unicode characters2 through <n> within the 'altGlyph'element are ignored. Any absolute X coordinate specified via an x attribute on this element or any ancestor'text' or 'tspan' elements for the first Unicodecharacter within the 'altGlyph' element sets anew absolute X coordinate for thecurrent textposition before rendering the first alternate glyph.
Animatable:yes.

y = "<coordinate>+"

用于渲染'altGlyph' 元素所对应的绝对Y坐标。The corresponding absolute Ycoordinates for rendering the 'altGlyph'element.
Animatable:yes.

dx = "<length>+"

值<length> 一般按照元素'tspan' 中的属性  dx  相同的方式进行处理, 除了下列例外情况: 如果所引用的替换图元而不是在 'altGlyph' 元素里面的 Unicode字符被渲染, 那么在这一元素上或者任何祖先的'text''tspan' 元素对于在 'altGlyph' 元素内的从第2个到第 <n> 个 Unicode字符上 经由一个 dx 属性所指定的任何相对 X 坐标  将被忽略. 在渲染第一个替换图元之前将在这一元素上或者任何祖先的'text''tspan' 元素对于在 'altGlyph' 元素内的第1个 Unicode 字符上经由一个dx 属性所指定的任何相对 X 坐标 设置为当前文本位置 的新的相对X 坐标.      The<length>values are processed in the same manner as the dx attribute on the 'tspan' element, with the followingexception: If the referenced alternate glyphs are rendered instead of theUnicode characters inside the 'altGlyph'element, then any relative X coordinates specified via an dx attribute on this element or any ancestor 'text' or 'tspan' elements for Unicode characters2 through <n> within the 'altGlyph'element are ignored. Any relative X coordinate specified via an dx attribute on this element or any ancestor'text' or 'tspan' elements for the first Unicodecharacter within the 'altGlyph' element sets anew relative X coordinate for thecurrent textposition before rendering the first alternate glyph.
Animatable:yes.

dy = "<length>+"

用于渲染'altGlyph' 元素所对应的相对Y坐标。The corresponding relative Ycoordinates for rendering the 'altGlyph'element.
Animatable:yes.

rotate = "<number>+"

值<number> 一般按照元素'tspan' 中的属性rotate相同的方式进行处理, 除了下列例外情况: 如果所引用的替换图元而不是在 'altGlyph' 元素里面的 Unicode字符被渲染, 那么在这一元素上或者任何祖先的'text''tspan' 元素对于在 'altGlyph' 元素内的从第2个到第 <n> 个 Unicode字符上 经由一个 rotate 属性所指定的任何附加的旋转值将被忽略. 在渲染第一个替换图元之前将在这一元素上或者任何祖先的'text''tspan' 元素对于在 'altGlyph' 元素内的第1个 Unicode 字符上经由一个rotate 属性所指定的任何附加的旋转角度 设置为一种新的附加的旋转角度.      The<number>values are processed in the same manner as the rotate attribute on the 'tspan' element, with the followingexception: If the referenced alternate glyphs are rendered instead of theUnicode characters inside the 'altGlyph' element,then any supplemental rotation values specified via an rotateattribute on this element or any ancestor 'text' or 'tspan' elements for Unicode characters2 through <n> within the 'altGlyph'element are ignored. Supplemental rotation values specified via an rotate attribute on this element or any ancestor'text' or 'tspan' elements for the first Unicodecharacter within the 'altGlyph' element sets anew supplemental rotation angle before rendering the alternate glyphs.
Animatable:yes (无附加, 只对'set' 和'animate' 元素).

在别处定义的属性: Attributes defined elsewhere:

%stdAttrs;,%xlinkRefAttrs;,%testAttrs;,%langSpaceAttrs;,externalResourcesRequired,class,,style,%PresentationAttributes-Color;,%PresentationAttributes-FillStroke;,%PresentationAttributes-FontSpecification;,%PresentationAttributes-Graphics;,%PresentationAttributes-TextContentElements;%graphicsElementEvents;.

如果对替换的图元的引用不能产生替换的图元成功的标识来用, 那么在 'altGlyph' 元素里面的字符将被渲染就像此 'altGlyph' 元素被 'tspan'元素替换了一样.      If thereferences to alternate glyphs do not result in successful identification ofalternate glyphs to use, then the character(s) that are inside of the 'altGlyph' element are rendered as if the 'altGlyph' element were a 'tspan' element instead.

一个 'altGlyph' 元素要么引用一个 'glyph' 元素要么经由它的 xlink:href 属性引用一个'altGlyphDef' 元素 要么依靠依靠字体选择特性、一个图元标识符和一种字体格式来标识一个图元 . 如果指定属性 xlink:href , 则优先考虑此属性, 并且其它图元标识属性和特性将被忽略.          An 'altGlyph' element either references a'glyph' element or an 'altGlyphDef' element via its xlink:href attribute or identifies a glyph by meansof fontselection properties, a glyph identifier and a font format. If the xlink:href attribute is specified, it takesprecedence, and the other glyph identification attributes and properties areignored.

元素 'altGlyphDef' 定义一套可能的图元替补.  The 'altGlyphDef' elementdefines a set of possible glyph substitutions.

 
<!ENTITY % altGlyphDefExt "" >
<!ELEMENT altGlyphDef ((glyphRef+|altGlyphItem+) %altGlyphDefExt;) >
<!ATTLIST altGlyphDef
  %stdAttrs; >

在别处定义的属性: Attributes defined elsewhere:

%stdAttrs;.

一个 'altGlyphDef' 可以包含下列之一:  An 'altGlyphDef' can contain either of the following:

  • 在最简单的情况下, 一个 'altGlyphDef' 包含一个或更多的 'glyphRef' 元素. 每个 'glyphRef' 元素引用一个在特殊字体里的单一的图元 . 如果所有引用的图元是可用的, 那么这些图元将被渲染来代替所引用的 'altGlyph' 元素内的字符. 如果被引用的图元中任何一个不可用, 那么'altGlyph' 元素内的字符将被渲染好像在这些字符周围不存在'altGlyph' 元素一样.              In the simplest case, an 'altGlyphDef' contains one or more 'glyphRef' elements. Each 'glyphRef' element references a single glyph within a particular font. If all of the referenced glyphs are available, then these glyphs are rendered instead of the character(s) inside of the referencing 'altGlyph' element. If any of the referenced glyphs are unavailable, then the character(s) that are inside of the 'altGlyph' element are rendered as if there were not an 'altGlyph' element surrounding those characters.
  • 在更复杂的情况下, 一个 'altGlyphDef' 包含一个或更多的 'altGlyphItem' 元素. 每个 'altGlyphItem' 表示一套候选的用于置换图元. 每个 'altGlyphItem' 包含一个或更多的 'glyphRef' 元素. 每个 'glyphRef' 元素引用在特定字体下的一个单独的图元 . 将选择其引用的图元都可用的第一个'altGlyphItem' . 从这一'altGlyphItem' 所引用的图元将被渲染而代替引用的'altGlyph'元素内部的字符. 如果这些 'altGlyphItem' 元素不能产生成功的匹配 (即, 没有一个 'altGlyphItem' 元素它的所有引用的图元都是可用的), 那么'altGlyph' 元素内的字符将被渲染好像在这些字符周围不存在'altGlyph' 元素一样.                        In the more complex case, an 'altGlyphDef' contains one or more'altGlyphItem' elements. Each 'altGlyphItem' represents a candidate set of substitute glyphs. Each'altGlyphItem' contains one or more 'glyphRef' elements. Each 'glyphRef' element references a single glyph within a particular font. The first'altGlyphItem' in which all referenced glyphs are available is chosen. The glyphs referenced from this'altGlyphItem' are rendered instead of the character(s) that are inside of the referencing 'altGlyph' element. If none of the'altGlyphItem' elements result in a successful match (i.e., none of the'altGlyphItem' elements has all of its referenced glyphs available), then the character(s) that are inside of the 'altGlyph' element are rendered as if there were not an 'altGlyph' element surrounding those characters.

元素 'altGlyphItem' 定义一套候选的可能的图元置换. 引用的图元的第一个 'altGlyphItem' 元素都可以用于选择. 它的图元被渲染以代替在引用'altGlyph'元素里面的字符    The 'altGlyphItem' element defines a candidateset of possible glyph substitutions. The first 'altGlyphItem'element whose referenced glyphs are all available is chosen. Its glyphs arerendered instead of the character(s) that are inside of the referencing 'altGlyph' element

 
<!ENTITY % altGlyphItemExt "" >
<!ELEMENT altGlyphItem (glyphRef+ %altGlyphItemExt;) >
<!ATTLIST altGlyphItem
  %stdAttrs; >

在别处定义的属性: Attributes defined elsewhere:

%stdAttrs;.

元素 'glyphRef' 定义一个可能将被使用的图元.   The 'glyphRef' element defines a possible glyph to use.

 
<!ELEMENT glyphRef EMPTY >
<!ATTLIST glyphRef
  %stdAttrs;
  %xlinkRefAttrs;
  xlink:href %URI; #IMPLIED
  class %ClassList; #IMPLIED
  style %StyleSheet; #IMPLIED
  %PresentationAttributes-FontSpecification;
  glyphRef CDATA #IMPLIED
  format CDATA #IMPLIED
  x %Number; #IMPLIED
  y %Number; #IMPLIED
  dx %Number; #IMPLIED
  dy %Number; #IMPLIED >

属性定义: Attributedefinitions:

xlink:href = "<uri>"

 一个指向在某个精图文档片段内的一个图元'glyph'元素的URI 引用 . 所引用的图元 'glyph' 将作为一个备选图元来渲染.    A URIreference to a 'glyph' element in an SVG documentfragment. The referenced 'glyph' is rendered asan alternate glyph.
Animatable:no.

glyphRef = "<string>"

图元标识符, 其格式format依赖于所给定字体的格式 format .    The glyph identifier, theformat of which is dependent on the format of the given font.
Animatable:no.

format = "<string>"

给定字体的格式. 如果此字体为规范[CSS2-src]所列出的格式之一(例如,TrueDoc™ Portable FontResource 或者 Embedded OpenType), 那么 <string> 必须包含定义在[CSS2-src]中的相应的字体格式串(例如,truedoc-pfr 或者 embedded-opentype).    The format of the given font. If the font is inone of the formats listed in [CSS2-src](e.g.,TrueDoc™ Portable Font Resource or Embedded OpenType),then the <string> must contain the corresponding font format stringdefined in [CSS2-src](e.g.,truedoc-pfr or embedded-opentype).
Animatable:no.

x = "<number>"

这个值表示针对这一图元的字体的坐标系内的新的绝对 X 坐标.   This value represents the new absolute X coordinate within the font'scoordinate system for this glyph.
字体坐标系基于在"层叠样式表 (CSS) 级别 2"规范[CSS2]的章节"字体" 中所描述的em square 模型.   The font coordinate system is based on the em square model describedin the"Fonts"chapter of the "Cascading Style Sheets (CSS) level 2" specification [CSS2].
如果未指定此属性, 对于第一个'glyphRef' 子元素而言, 其效果相当于设置此属性为"0", 而随后的 'glyphRef' 子元素, 其效果相当于设置此属性为以前的'glyphRef' 元素的末端的 X坐标.     If the attribute is not specified, for the first 'glyphRef'child element, the effect is as if the attribute were set to "0",whereas for subsequent 'glyphRef' childelements, the effect is as if the attribute were set to the end X coordinatefrom the previous 'glyphRef' element.
Animatable:no.

y = "<number>"

针对这一图元的字体的坐标系内所对应的新的绝对 Y 坐标.  The corresponding new absolute Y coordinate within the font's coordinate systemfor this glyph.
Animatable:no.

dx = "<number>"

这个值表示针对这一图元的字体的坐标系内的相对 X 坐标.于是图元沿着在字体坐标系内正的 X 轴平移<number>单位以补充由 x 属性 (要么由一个显式的 x 属性 要么由 x 属性的缺省值处理)所建立的绝对X 坐标.    This value represents the relative X coordinate within the font's coordinatesystem for this glyph. The glyph is thus shifted by <number>units along the positive X axis within the font's coordinate systemsupplemental to the absolute X coordinate established by the x attribute (either due to an explicit x attribute or due to default value processing forthe x attribute).
字体坐标系基于在"层叠样式表 (CSS) 级别 2"规范 [CSS2]的章节"字体" 中所描述的em square 模型.   The font coordinate system is based on the em square model describedin the"Fonts"chapter of the "Cascading Style Sheets (CSS) level 2" specification [CSS2].
如果未指定此属性, 其效果相当于设置此属性为"0"。If the attribute is notspecified, the effect is as if the attribute were set to "0".
Animatable:no.

dy = "<number>"

以在字体坐标系内的单位为单位沿着相对于由y 属性所建立的绝对Y坐标的正的 Y轴平移此图元所对应的数值。Thecorresponding number of units within the font's coordinate system to shift theglyph along the positive Y axis relative to the absolute Y coordinateestablished by they attribute.
Animatable:no.

在别处定义的属性: Attributes defined elsewhere:

%stdAttrs;,%xlinkRefAttrs;,class,style, %PresentationAttributes-FontSpecification;.

一个 'glyphRef' 要么通过它的属性xlink:href引用精图文档片段中的一个'glyph' 元素或者依靠字体选择特性、 一个图元标识符和一种字体格式来确定一个图元 . 如果给定不足够的属性和特性来标识一个图元, 那么 'glyphRef' 按照当一个图元引用被充分给定时的相同方式进行处理, 可是给定的图元是不可用的. 如果指定属性xlink:href , 则优先考虑此属性,而其它的图元标识属性和特性将被忽略 .      A 'glyphRef'either references a'glyph' element in an SVG documentfragment via itsxlink:href attribute or identifies a glyph by meansof fontselection properties, a glyph identifier and a font format. If insufficientattributes and properties have been specified to identify a glyph, then the 'glyphRef' is processed in the same manner as when aglyph reference is fully specified, but the given glyph is not available. Ifthe xlink:href attribute is specified, it takesprecedence, and the other glyph identification attributes and properties areignored.

10.15 空白字符处理 White space handling

精图支持标准的 XML 属性 xml:space 来指定对在一给定的文本'text'元素的字符数据中的空白字符的处理方式. 精图用户代理具有如下所述的与此属性相关的特殊的处理规则. 这些是出现在随后的 XML 分析 [XML10] 和文档对象模型[DOM2]的任何构造中的行为 .   SVG supports the standard XML attributexml:space to specifythe handling of white space characters within a given'text' element'scharacter data. The SVG user agent has special processing rules associated withthis attribute as described below. These are behaviors that occur subsequent toXML parsing [XML10] and anyconstruction of a Document Object Model [DOM2].

xml:space 为一种可继承的属性它可以取下列两个值之一:  xml:spaceis an inheritable attribute which can have one of two values:

  • default (xml:space  的初始/缺省值) - 当 xml:space="default"时, 精图用户代理将利用原来的字符数据内容的复制做下列事情. 首先, 去掉所有换行字符. 然后将所有制表符替换成空白字符. 接着, 除去所有开头和尾部的空白字符. 最后, 将所有连续的空白字符合并成一个空白字符.     default (the initial/default value for xml:space) - When xml:space="default", the SVG user agent will do the following using a copy of the original character data content. First, it will remove all newline characters. Then it will convert all tab characters into space characters. Then, it will strip off all leading and trailing space characters. Then, all contiguous space characters will be consolidated.
  • preserve - 当 xml:space="preserve"时, 精图用户代理将利用原来的字符数据内容的复制做下列事情. 将所有换行和制表符替换成空白字符. 然后, 将绘制所有空白字符, 包括开头的, 尾部的和多个连续的空白字符. 于是, 当按照xml:space="preserve"进行绘制时, 字符串 "a   b" (在"a"和"b"之间有三个空白字符 ) 将在"a"和"b"之间比"a b"(在 "a"和"b"之间有一个空白字符)产生一个较大的分隔 .   preserve - When xml:space="preserve", the SVG user agent will do the following using a copy of the original character data content. It will convert all newline and tab characters into space characters. Then, it will draw all space characters, including leading, trailing and multiple contiguous space characters. Thus, when drawn withxml:space="preserve", the string "a   b" (three spaces between "a" and "b") will produce a larger separation between "a" and "b" than"a b" (one space between "a" and "b").

下列例子解释当使用xml:space="default"时行的缩排是重要的. 下面的片段显示了两对类似文本'text' 元素, 这两个文本'text'元素都具有属性 xml:space='default'. 对于这些例子而言, 在每行的尾部不存在额外的空白字符 (即, 在最后一个可见字符之后马上出现一个换行符).     The following example illustrates that line indentation can be important whenusingxml:space="default". The fragment below show two pairs of similar 'text' elements, with both 'text'elements using xml:space='default'. For theseexamples, there is no extra white space at the end of any of the lines (i.e.,the line break occurs immediately after the last visible character).

 
[01]  <text xml:space='default'>
[02]    WS example
[03]    indented lines
[04]  </text>
[05]  <text xml:space='preserve'>WS example indented lines</text>
[06]
[07]  <text xml:space='default'>
[08]WS example
[09]non-indented lines
[10]  </text>
[11]  <text xml:space='preserve'>WS examplenon-indented lines</text>

上面第一对文本'text' 元素说明缩进字符数据的效果. 在第一个文本'text' 元素的属性 xml:space='default' 指示用户代理进行下列处理:     The first pair of 'text' elements above show the effect of indentedcharacter data. The attribute xml:space='default'in the first 'text' element instructs the useragent to:

  • 将所有制表符(如果有的话)替换成空白字符,convert all tabs (if any) to space characters,
  • 去掉所有换行字符(即, 去掉在行 [01], [02] 和 [03] 尾部的换行符),  strip out all line breaks (i.e., strip out the line breaks at the end of lines [01], [02] and [03]),
  • 除去所有开头的空白字符(即, 除去行 [02]上在"WS example"之前的空白字符),   strip out all leading space characters (i.e., strip out space characters before "WS example" on line [02]),
  • 除去所有尾部的空白字符(即, 除去行 [04]上在"</text>"之前的空白字符),   strip out all trailing space characters (i.e., strip out space characters before "</text>" on line [04]),
  • 合并所有中间的空白字符 (即, 行 [03]上在"indented lines" 之前的空白字符) 到一个单一的空白字符.    consolidate all intermediate space characters (i.e., the space characters before "indented lines" on line [03]) into a single space character.

上面第二对文本'text' 元素说明非缩进字符数据的效果. 在第三个文本'text' 元素的属性 xml:space='default' 指示用户代理进行下列处理:     The second pair of 'text' elements above show the effect of non-indentedcharacter data. The attribute xml:space='default'in the third 'text' element instructs the useragent to:

  • 将所有制表符(如果有的话)替换成空白字符,convert all tabs (if any) to space characters,
  • 去掉所有换行字符(即, 去掉在行[07], [08]  和 [09] 尾部的换行符),  strip out all line breaks (i.e., strip out the line breaks at the end of lines [07], [08] and [09]),
  • 除去所有开头的空白字符(在这个例子中没有开头的空白字符),   strip out all leading space characters (there are no leading space characters in this example),
  • 除去所有尾部的空白字符(即, 除去行 [10]上在"</text>"之前的空白字符),   strip out all trailing space characters (i.e., strip out space characters before "</text>" on line [10]),
  • 合并所有中间的空白字符 (在这个例子中没有中间的空白字符) 到一个单一的空白字符.   consolidate all intermediate space characters into a single space character (in this example, there are no intermediate space characters).

注意在将字符数据传给应用之前我们要求XML分析程序将换行标识(例如, 两个字符的文字序列 "#xD#xA" 或单个文字 #xD 或 #xA)转换成标准的表示即单个字符  #xA . 于是,在精图内的每个换行将由单个字符#xA表示 , 无论在原先的资源内用什么表示换行. (参见XML end-of-line handling.)      Note that XML parsers are required to convert the standard representations fora newline indicator (e.g., the literal two-character sequence"#xD#xA" or the stand-alone literals #xD or #xA) into the singlecharacter #xA before passing character data to the application. Thus, each newlinein SVG will be represented by the single character #xA, no matter whatrepresentation for newlines might have been used in the original resource. (SeeXML end-of-line handling.)

在精图语言或精图文档对象模型中的任何基于字符位置数的特征, 比如在 'text', 'tspan', 'tref' 'altGlyph' 元素上的属性 x, y, dx, dy 和 rotate  ,  是基于在使用这里所描述的空白字符处理规则后的字符位置. 特别, 如果 xml:space="default", 作为处理的一部分常常是空白字符被去掉. 字符位置数将被索引到在被这一节中的规则所移去的空白字符之后的文本字符串.        Any features in the SVGlanguage or the SVG DOM that are based on character position number, such asthex, y, dx, dy and rotate attributes on the 'text', 'tspan', 'tref' 'altGlyph' elements, are based oncharacter position after applying the white space handling rules describedhere. In particular, ifxml:space="default", it is often the case that white space characters are removed aspart of processing. Character position numbers index into the text string afterthe white space characters have been removed per the rules in this section.

属性 xml:space 具有性质:   The xml:space attribute is:

    Animatable:no.

10.16 文本的选择和剪贴板操作 Text selection andclipboard operations

在具有文本选择能力(例如, 装备了指点设备比如鼠标)并且其具有复制/ 粘贴操作的系统剪贴板的系统上的兼容精图浏览器 要求支持:  ConformingSVG viewers on systems which have the capacity for text selection (e.g.,systems which are equipped with a pointer device such as a mouse) and whichhave system clipboards for copy/paste operations are required to support:

  • 在精图内容中的文本串的用户选择  user selection of text strings in SVG content
  • 复制所选文本串到系统剪切板的能力 the ability to copy selected text strings to the system clipboard

当下列情况出现时一个文本选择操作开始:Atext selection operation starts when all of the following occur:

  • 用户定位指点设备在作为文本'text'元素的一部分进行渲染的一个图元上, 这时开始一个选择 操作 (例如, 按下标准的系统鼠标按钮进行选择操作) 然后在连续进行选择 操作的同时移动指点设备 (例如,继续按着标准的系统鼠标按钮进行选择操作)    the user positions the pointing device over a glyph that has been rendered as part of a'text' element, initiates a select operation (e.g., pressing the standard system mouse button for select operations) and then moves the pointing device while continuing theselect operation (e.g., continuing to press the standard system mouse button for select operations)
  • 在指点设备点击的点上的图元的上面无其它可视的图形元素  no other visible graphics element has been painted above the glyph at the point at which the pointing device was clicked
  • 无任何已经指派给此 'text' , 'tspan''textPath' , 元素(s) (或它们的祖先)的 链接 或 事件 与此给定的图元相联系.    no links or events have been assigned to the 'text' , 'tspan' or 'textPath' , element(s) (or their ancestors) associated with the given glyph.

当进行文本选择操作的时候 (例如, 用户连续按着给定的鼠标按钮时), 所有与其它图形元素相关的事件被忽略 (即, 文本选择操作是模式的) 并且精图用户代理将动态地用适当的突出显示技术表示哪些字符已被选择,例如用相反的颜色重画所选的图元. 在文本选择处理期间当移动指针时, 文本选择操作的最后的图元为在相同的'text' 元素中其图元小室最接近此指针的图元. 如果某一文本'text'元素位于介于选择的开始和选择的结束之间的一个文本'text' 元素之内那么所有在此文本元素内的字符将被突出显示, 既不考虑画布上的位置也不考虑在选择点的尾部的上方的如何图形元素.     As the text selection operation proceeds (e.g., the user continues to press thegiven mouse button), all associated events with other graphics elements areignored (i.e., the text selection operation is modal) and the SVG user agentshall dynamically indicate which characters are selected by an appropriatehighlighting technique, such as redrawing the selected glyphs with inversecolors. As the pointer is moved during the text selection process, the endglyph for the text selection operation is the glyph within the same'text' element whose glyph cell isclosest to the pointer. All characters within the'text' element whose position within the'text' element is between the start ofselection and end of selection shall be highlighted, regardless of position onthe canvas and regardless of any graphics elements that might be above the endof selection point.

一旦文本选择操作结束(例如, 用户释放给定的鼠标按钮), 所选择的文本仍然停留在突出显示的状态直到出现取消文本选择的事件,比如一个指点设备的活动事件 (例如, 按下一个鼠标按钮).   Once thetext selection operation ends (e.g., the user releases the given mouse button),the selected text will stay highlighted until an event occurs which cancelstext selection, such as a pointer device activation event (e.g., pressing amouse button).

在文本选择操作期间如何确定对那些字符进行突出显示的详细规则在文本选择实现注记中提供。Detailed rules fordetermining which characters to highlight during a text selection operation areprovided in Textselection implementation notes.

对于那些提供系统剪切板功能的系统而言, 要求精图用户代理提供一个用户接口用于当前选择文本的开始复制到系统剪切板. 只要精图用户代理按照针对纯文本的系统的适当的剪切板格式传送所选的文本串就足够了, 不过精图用户代理如果也能够传送捕获了与给定文本串相关的各种字体特性的一种可以代替的富文本那就更好.     For systems which have system clipboards, the SVG user agent is required toprovide a user interface for initiating a copy of the currently selected textto the system clipboard. It is sufficient for the SVG user agent to post theselected text string in the system's appropriate clipboard format for plaintext, but it is preferable if the SVG user agent also posts a rich textalternative which captures the variousfontproperties associated with the given text string.

对于双向文本而言, 用户代理必须支持按逻辑顺序进行文本选择, 这样会导致不连续的图元的突出显示因为字符的双向重定序. 用户代理可以提供一种替换的能力按照可视的渲染次序来选择双向文本(即, 在bidirectional文本布局算法被使用之后), 从而所选的字符数据也许在逻辑上是不连续的. 在这中情况下, 如果用户要求将此双向文本复制到剪切板, 那么要求用户代理做适当的调整只复制那些可见的被选择的字符到剪切板上.     For bidirectional text, the user agentmust support text selection in logical order, which will result indiscontinuous highlighting of glyphs due to the bidirectional reordering ofcharacters. User agents can provide an alternative ability to selectbidirectional text in visual rendering order (i.e., afterbidirectionaltext layout algorithms have been applied), with the result that selectedcharacter data might be discontinuous logically. In this case, if the userrequests that bidirectional text be copied to the clipboard, then the useragent is required to make appropriate adjustments to copy only the visuallyselected characters to the clipboard.

当切实可行时,建议精图生成器应尝试对它们产生的文本串进行定序使得精图浏览应用比如网页浏览器可以较容易适当地确定文本选择的顺序。When feasible, it is recommended that generators of SVG attempt toorder their text strings to facilitate properly ordered text selection withinSVG viewing applications such as Web browsers.

 

10.17 文档对象模型接口 DOM interfaces

The following interfaces are defined below: SVGTextContentElement, SVGTextPositioningElement, SVGTextElement, SVGTSpanElement, SVGTRefElement, SVGTextPathElement, SVGAltGlyphElement, SVGAltGlyphDefElement, SVGAltGlyphItemElement, SVGGlyphRefElement.

 

Interface SVGTextContentElement

The SVGTextContentElementinterface is inherited by various text-related interfaces, such asSVGTextElement, SVGTSpanElement, SVGTRefElement, SVGAltGlyphElement and SVGTextPathElement.


IDL Definition

 
interface SVGTextContentElement : 
                SVGElement,
                SVGTests,
                SVGLangSpace,
                SVGExternalResourcesRequired,
                SVGStylable,
                events::EventTarget { 
 
  // lengthAdjust Types
  const unsigned short LENGTHADJUST_UNKNOWN   = 0;
  const unsigned short LENGTHADJUST_SPACING     = 1;
  const unsigned short LENGTHADJUST_SPACINGANDGLYPHS     = 2;
 
  readonly attribute SVGAnimatedLength      textLength;
  readonly attribute SVGAnimatedEnumeration lengthAdjust;
 
  long     getNumberOfChars (  );
  float    getComputedTextLength (  );
  float    getSubStringLength ( in unsigned long charnum, in unsigned long nchars )
                  raises( DOMException );
  SVGPoint getStartPositionOfChar ( in unsigned long charnum )
                  raises( DOMException );
  SVGPoint getEndPositionOfChar ( in unsigned long charnum )
                  raises( DOMException );
  SVGRect  getExtentOfChar ( in unsigned long charnum )
                  raises( DOMException );
  float    getRotationOfChar ( in unsigned long charnum )
                  raises( DOMException );
  long     getCharNumAtPosition ( in SVGPoint point );
  void     selectSubString ( in unsigned long charnum, in unsigned long nchars )
                  raises( DOMException );
};

 

Definition group lengthAdjust Types

Definedconstants

LENGTHADJUST_UNKNOWN

 

The enumeration was set to a value that is not one of predefined types. It is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type.

LENGTHADJUST_SPACING

 

Corresponds to value spacing.

LENGTHADJUST_SPACINGANDGLYPHS

 

Corresponds to value spacingAndGlyphs.

Attributes

readonly SVGAnimatedLength textLength

Corresponds toattribute textLength on the given element.

readonly SVGAnimatedEnumeration lengthAdjust

Corresponds toattribute lengthAdjust on the given element. Thevalue must be one of the length adjust constants specified above.

Methods

getNumberOfChars

Returns thetotal number of characters to be rendered within the current element. Includescharacters which are included via a 'tref' reference.

No Parameters

Return value

long

 

Total number of characters.

No Exceptions

getComputedTextLength

The total sum ofall of the advance values from rendering all of the characters within this element,including the advance value on the glyphs (horizontal or vertical), the effectof properties'kerning', 'letter-spacing' and 'word-spacing' and adjustments due to attributes dx and dy on 'tspan' elements. For non-rendering environments,the user agent shall make reasonable assumptions about glyph metrics.

No Parameters

Return value

float

 

The text advance distance.

No Exceptions

getSubStringLength

The total sum ofall of the advance values from rendering the specified substring of thecharacters, including the advance value on the glyphs (horizontal or vertical),the effect of properties'kerning', 'letter-spacing' and 'word-spacing' and adjustments due to attributes dx and dy on 'tspan' elements. For non-rendering environments,the user agent shall make reasonable assumptions about glyph metrics.

Parameters

in unsigned long charnum

 

The index of the first character in the substring, where the first character has an index of 0.

in unsigned long nchars

 

The number of characters in the substring.

Return value

float

 

The text advance distance.

Exceptions

DOMException

 

INDEX_SIZE_ERR: Raised if the charnum is negative or if charnum+nchars is greater than or equal to the number of characters at this node.

getStartPositionOfChar

Returns the currenttext position before rendering the character in the user coordinate system forrendering the glyph(s) that correspond to the specified character. The currenttext position has already taken into account the effects of any inter-characteradjustments due to properties 'kerning', 'letter-spacing' and 'word-spacing' and adjustments due to attributes x, y, dx and dy. If multiple consecutive characters are renderedinseparably (e.g., as a single glyph or a sequence of glyphs), then each of theinseparable characters will return the start position for the first glyph.

Parameters

in unsigned long charnum

 

The index of the character, where the first character has an index of 0.

Return value

SVGPoint

 

The character's start position.

Exceptions

DOMException

 

INDEX_SIZE_ERR: Raised if the charnum is negative or if charnum is greater than or equal to the number of characters at this node.

getEndPositionOfChar

Returns thecurrent text position after rendering the character in the user coordinatesystem for rendering the glyph(s) that correspond to the specified character.This current text position doesnot take into account the effects ofany inter-character adjustments to prepare for the next character, such asproperties'kerning', 'letter-spacing' and 'word-spacing' and adjustments due to attributes x, y, dx and dy. If multiple consecutive characters are renderedinseparably (e.g., as a single glyph or a sequence of glyphs), then each of theinseparable characters will return the end position for the last glyph.

Parameters

in unsigned long charnum

 

The index of the character, where the first character has an index of 0.

Return value

SVGPoint

 

The character's end position.

Exceptions

DOMException

 

INDEX_SIZE_ERR: Raised if the charnum is negative or if charnum is greater than or equal to the number of characters at this node.

getExtentOfChar

Returns a tightestrectangle which defines the minimum and maximum X and Y values in the usercoordinate system for rendering the glyph(s) that correspond to the specifiedcharacter. The calculations assume that all glyphs occupy the full standardglyph cell for the font. If multiple consecutive characters are renderedinseparably (e.g., as a single glyph or a sequence of glyphs), then each of theinseparable characters will return the same extent.

Parameters

in unsigned long charnum

 

The index of the character, where the first character has an index of 0.

Return value

SVGRect

 

The rectangle which encloses all of the rendered glyph(s).

Exceptions

DOMException

 

INDEX_SIZE_ERR: Raised if the charnum is negative or if charnum is greater than or equal to the number of characters at this node.

getRotationOfChar

Returns therotation value relative to the current user coordinate system used to renderthe glyph(s) corresponding to the specified character. If multiple glyph(s) areused to render the given character and the glyphs each have different rotations(e.g., due to text-on-a-path), the user agent shall return an average value(e.g., the rotation angle at the midpoint along the path for all glyphs used torender this character). The rotation value represents the rotation that issupplemental to any rotation due to properties'glyph-orientation-horizontal' and 'glyph-orientation-vertical'; thus, any glyphrotations due to these properties arenot included into the returnedrotation value. If multiple consecutive characters are rendered inseparably(e.g., as a single glyph or a sequence of glyphs), then each of the inseparablecharacters will return the same rotation value.

Parameters

in unsigned long charnum

 

The index of the character, where the first character has an index of 0.

Return value

float

 

The rotation angle.

Exceptions

DOMException

 

INDEX_SIZE_ERR: Raised if the charnum is negative or if charnum is greater than or equal to the number of characters at this node.

getCharNumAtPosition

Returns the indexof the character whose corresponding glyph cell bounding box contains thespecified point. The calculations assume that all glyphs occupy the fullstandard glyph cell for the font. If no such character exists, a value of -1 isreturned. If multiple such characters exist, the character within the elementwhose glyphs were rendered last (i.e., take into account any reordering such asfor bidirectional text) is used. If multiple consecutive characters arerendered inseparably (e.g., as a single glyph or a sequence of glyphs), thenthe user agent shall allocate an equal percentage of the text advance amount toeach of the contributing characters in determining which of the characters ischosen.

Parameters

in SVGPoint point

 

A point in user space.

Return value

long

 

The index of the character which is at the given point, where the first character has an index of 0.

No Exceptions

selectSubString

Causes thespecified substring to be selected just as if the user selected the substring interactively.

Parameters

in unsigned long charnum

 

The index of the start character which is at the given point, where the first character has an index of 0.

in unsigned long nchars

 

The number of characters in the substring. If nchars specifies more characters than are available, then the substring will consist of all characters starting with charnum until the end of the list of characters.

No Return Value

Exceptions

DOMException

 

INDEX_SIZE_ERR: Raised if the charnum is negative or if charnum is greater than or equal to the number of characters at this node.

 

Interface SVGTextPositioningElement

The SVGTextPositioningElementinterface is inherited by text-related interfaces:SVGTextElement, SVGTSpanElement, SVGTRefElement and SVGAltGlyphElement.


IDL Definition

 
interface SVGTextPositioningElement : SVGTextContentElement { 
  readonly attribute SVGAnimatedLengthList x;
  readonly attribute SVGAnimatedLengthList y;
  readonly attribute SVGAnimatedLengthList dx;
  readonly attribute SVGAnimatedLengthList dy;
  readonly attribute SVGAnimatedNumberList rotate;
};

 

Attributes

readonly SVGAnimatedLengthList x

Corresponds toattribute x on the given element.

readonly SVGAnimatedLengthList y

Corresponds toattribute y on the given element.

readonly SVGAnimatedLengthList dx

Corresponds toattribute dx on the given element.

readonly SVGAnimatedLengthList dy

Corresponds toattribute dy on the given element.

readonly SVGAnimatedNumberList rotate

Corresponds toattribute rotate on the given element.

 

Interface SVGTextElement

The SVGTextElementinterface corresponds to the 'text' element.


IDL Definition

 
interface SVGTextElement : 
                SVGTextPositioningElement,
                SVGTransformable {};

 

 

Interface SVGTSpanElement

The SVGTSpanElementinterface corresponds to the 'tspan' element.


IDL Definition

 
interface SVGTSpanElement : SVGTextPositioningElement {};

 

 

Interface SVGTRefElement

The SVGTRefElementinterface corresponds to the 'tref' element.


IDL Definition

 
interface SVGTRefElement : 
                SVGTextPositioningElement,
                SVGURIReference {};

 

 

Interface SVGTextPathElement

The SVGTextPathElementinterface corresponds to the 'textPath'element.


IDL Definition

 
interface SVGTextPathElement : 
                SVGTextContentElement,
                SVGURIReference { 
 
  // textPath Method Types
  const unsigned short TEXTPATH_METHODTYPE_UNKNOWN   = 0;
  const unsigned short TEXTPATH_METHODTYPE_ALIGN     = 1;
  const unsigned short TEXTPATH_METHODTYPE_STRETCH     = 2;
  // textPath Spacing Types
  const unsigned short TEXTPATH_SPACINGTYPE_UNKNOWN   = 0;
  const unsigned short TEXTPATH_SPACINGTYPE_AUTO     = 1;
  const unsigned short TEXTPATH_SPACINGTYPE_EXACT     = 2;
 
  readonly attribute SVGAnimatedLength              startOffset;
  readonly attribute SVGAnimatedEnumeration method;
  readonly attribute SVGAnimatedEnumeration spacing;
};

 

Definition group textPath Method Types

Definedconstants

TEXTPATH_METHODTYPE_UNKNOWN

 

The enumeration was set to a value that is not one of predefined types. It is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type.

TEXTPATH_METHODTYPE_ALIGN

 

Corresponds to value align.

TEXTPATH_METHODTYPE_STRETCH

 

Corresponds to value stretch.

Definition group textPath Spacing Types

Definedconstants

TEXTPATH_SPACINGTYPE_UNKNOWN

 

The enumeration was set to a value that is not one of predefined types. It is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type.

TEXTPATH_SPACINGTYPE_AUTO

 

Corresponds to value auto.

TEXTPATH_SPACINGTYPE_EXACT

 

Corresponds to value exact.

Attributes

readonly SVGAnimatedLength startOffset

Corresponds toattribute startOffset on the given 'textPath' element.

readonly SVGAnimatedEnumeration method

Corresponds toattribute method on the given 'textPath' element. The value must be one of themethod type constants specified above.

readonly SVGAnimatedEnumeration spacing

Corresponds toattribute spacing on the given 'textPath' element. The value must be one of thespacing type constants specified above.

 

Interface SVGAltGlyphElement

The SVGAltGlyphElementinterface corresponds to the 'altGlyph'element.


IDL Definition

 
interface SVGAltGlyphElement : 
                SVGTextPositioningElement,
                SVGURIReference { 
 
           attribute DOMString glyphRef;
                       // raises DOMException on setting
           attribute DOMString format;
                       // raises DOMException on setting
};

 

Attributes

DOMString glyphRef

Corresponds toattribute glyphRef on the given element.

Exceptions on setting

DOMException

 

NO_MODIFICATION_ALLOWED_ERR: Raised on an attempt to change the value of a readonly attribute.

DOMString format

Corresponds toattribute format on the given element.

Exceptions on setting

DOMException

 

NO_MODIFICATION_ALLOWED_ERR: Raised on an attempt to change the value of a readonly attribute.

 

Interface SVGAltGlyphDefElement

The SVGAltGlyphDefElementinterface corresponds to the 'altGlyphDef'element.


IDL Definition

 
interface SVGAltGlyphDefElement : SVGElement {};

 

 

Interface SVGAltGlyphItemElement

The SVGAltGlyphItemElementinterface corresponds to the 'altGlyphItem'element.


IDL Definition

 
interface SVGAltGlyphItemElement : SVGElement {};

 

 

Interface SVGGlyphRefElement

The SVGGlyphRefElementinterface corresponds to the 'glyphRef'element.


IDL Definition

 
interface SVGGlyphRefElement : 
                SVGElement,
                SVGURIReference,
                SVGStylable { 
 
           attribute DOMString glyphRef;
                       // raises DOMException on setting
           attribute DOMString format;
                       // raises DOMException on setting
           attribute float    x;
                       // raises DOMException on setting
           attribute float    y;
                       // raises DOMException on setting
           attribute float    dx;
                       // raises DOMException on setting
           attribute float    dy;
                       // raises DOMException on setting
};

 

Attributes

DOMString glyphRef

Corresponds toattribute glyphRef on the given element.

Exceptions on setting

DOMException

 

NO_MODIFICATION_ALLOWED_ERR: Raised on an attempt to change the value of a readonly attribute.

DOMString format

Corresponds toattribute format on the given element.

Exceptions on setting

DOMException

 

NO_MODIFICATION_ALLOWED_ERR: Raised on an attempt to change the value of a readonly attribute.

float x

Corresponds toattribute x on the given element.

Exceptions on setting

DOMException

 

NO_MODIFICATION_ALLOWED_ERR: Raised on an attempt to change the value of a readonly attribute.

float y

Corresponds toattribute y on the given element.

Exceptions on setting

DOMException

 

NO_MODIFICATION_ALLOWED_ERR: Raised on an attempt to change the value of a readonly attribute.

float dx

Corresponds toattribute dx on the given element.

Exceptions on setting

DOMException

 

NO_MODIFICATION_ALLOWED_ERR: Raised on an attempt to change the value of a readonly attribute.

float dy

Corresponds toattribute dy on the given element.

Exceptions on setting

DOMException

 

NO_MODIFICATION_ALLOWED_ERR: Raised on an attempt to change the value of a readonly attribute.


previous next   contents   elements   attributes   properties   index  

最后

以上就是单薄钻石为你收集整理的精图规范1.0----10 文本 Text10 文本 Text的全部内容,希望文章能够帮你解决精图规范1.0----10 文本 Text10 文本 Text所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(48)

评论列表共有 0 条评论

立即
投稿
返回
顶部