您的位置:首页 > 其它

精图规范1.0----10 文本 Text

2014-06-08 17:50 295 查看
previousnext

contents
elements
attributes
properties
index

04September2001

10文本Text

内容Contents

10.1引言Introduction
10.2字符及其相应的图元Charactersandtheircorrespondingglyphs
10.3字体、字体属性表和基线Fonts,fonttablesandbaselines
10.4文本元素'text'The'text'element
10.5文本片段修饰元素'tspan'The'tspan'element
10.6文本引用元素'tref'The'tref'element
10.7文本布局Textlayout

10.7.1文本布局概述Textlayoutintroduction
10.7.2设置内部书写方向Settingtheinline-progression-direction
10.7.3文本实现中图元的方向Glyphorientationwithinatextrun
10.7.4双向文本Relationshipwithbidirectionality

10.8文本渲染次序Textrenderingorder
10.9对齐属性Alignmentproperties

10.9.1文本对齐属性Textalignmentproperties
10.9.2基线对齐属性Baselinealignmentproperties

10.10字体挑选属性Fontselectionproperties
10.11空白属性Spacingproperties
10.12文本修饰Textdecoration
10.13路径文本Textonapath

10.13.1路径文本概述Introductiontotextonapath
10.13.2文本路径元素'textPath'The'textPath'element
10.13.3路径文本的布局规则Textonapathlayoutrules

10.14备用图元Alternateglyphs
10.15空白字符处理Whitespacehandling
10.16文本的选择和剪贴板操作Textselectionandclipboardoperations
10.17文档对象模型接口DOMinterfaces

10.1引言Introduction

作为精图文档片段的一部分进行渲染的文本通过使用文本元素
'text'来进行说明。在文本元素
'text'中的将被绘制的字符按照XML字符数据[XML10]的表示方法表示。TextthatistoberenderedaspartofanSVGdocumentfragmentisspecifiedusingthe'text'
element.ThecharacterstobedrawnareexpressedasXMLcharacterdata[XML10]insidethe'text'element.

精图的文本元素
'text'按照其它图形元素的渲染方法进行渲染。因此,
坐标系变换,
绘制,
剪裁和
蒙版等特征可依照与应用于各种形状如路径

长方形相同的方式应用到文本元素
'text'中。SVG's
'text'elementsarerenderedlikeothergraphicselements.Thus,
coordinatesystemtransformations,painting,clipping
and
maskingfeaturesapplyto'text'elementsinthesamewayastheyapplytoshapes
suchas
pathsand
rectangles.

每个文本元素
'text'产生一个将被渲染的单一的文本字符串。精图并不自动进行折行和断词处理.为了达到多行文本的效果,可以使用下列方法之一:Each
'text'elementcausesasinglestringoftexttoberendered.SVGperformsnoautomaticlinebreakingorwordwrapping.Toachievetheeffectofmultiplelinesoftext,useoneofthefollowingmethods:

创作者或者创作软件包需要事先计算折行的位置并使用多个文本元素
'text'(每一行一个文本元素).Theauthororauthoringpackageneedstopre-computethelinebreaksandusemultiple'text'elements(one
foreachlineoftext).
创作者或者创作软件包需要事先计算折行的位置并使用单个文本元素
'text',而此文本元素具有一个或多个文本块子元素
'tspan',这些文本块子元素具有属性
x,
y,
dx和
dy的适当值,它们用来设置新行中的字符的新的起始位置.(这种方法允许用户进行多行的文本选择--参见
文本选择和剪贴板操作.)Theauthororauthoringpackageneedstopre-computethelinebreaksanduseasingle'text'elementwithoneor
more
'tspan'childelementswithappropriatevaluesforattributes
x,
y,
dxand
dytosetnewstartpositionsforthosecharacterswhichstartnewlines.(Thisapproachallowsusertextselectionacrossmultiplelinesoftext--seeText
selectionandclipboardoperations.)
将要渲染的文本用另一个XML命名空间如XHTML[XHTML]通过使用外部对象元素'foreignObject'
进行内联嵌入.(注意:此方法的精确语义此时不被完全定义.)ExpressthetexttoberenderedinanotherXMLnamespacesuchasXHTML[XHTML]embeddedinlinewithina'foreignObject'
element.(Note:theexactsemanticsofthisapproacharenotcompletelydefinedatthistime.)

在文本元素'text'中的文本串既可以按照直线也可以沿着路径元素'path'
的轮廓线进行渲染.对于直线上的文本或者路径上的文本精图支持下列国际文本处理特性:SVGsupportsthefollowinginternationaltextprocessingfeaturesforbothstraightlinetextandtextonapath:Thetextstringswithin'text'elements
canberenderedinastraightlineorrenderedalongtheoutlineofa'path'element.SVGsupportsthefollowinginternational
textprocessingfeaturesforbothstraightlinetextandtextonapath:

文本的水平和垂直方向horizontalandverticalorientationoftext
从左到右或者双向文本(即,混合右到左以及左到右的文本的语言,如阿拉伯语和希伯来语)left-to-rightorbidirectionaltext(i.e.,languageswhichintermixright-to-leftandleft-to-righttext,suchasArabicandHebrew)
当使用
精图字体时,相应于
阿拉伯语和
汉语文本的当前形状的正确的图元将被自动选择。when
SVGfontsareused,automaticselectionofthecorrectglyphcorrespondingtothecurrentformforArabic
and
Hantext

(关于直线文本的布局规则在文本布局中描述.而路径上的文本的布局规则在路径上的文本的布局规则描述.)
(Thelayoutrulesforstraightlinetextaredescribedin
Textlayout.Thelayoutrulesfortextonapatharedescribedin
Textonapathlayoutrules.)

因为精图文本是以XML字符数据[XML10]打包的:BecauseSVGtextispackagedasXMLcharacterdata[XML10]:

在精图内容中的文本对于弱视群体是易于阅读的(参见
易访问性支持)TextdatainSVGcontentisreadilyaccessibletothevisuallyimpaired(seeAccessibilitySupport)

在很多浏览的场合,用户可以查找和选择文本串并且复制所选定的文本串到系统剪贴板(参见
文本选择和剪贴板操作)Inmanyviewingscenarios,theuserwillbeabletosearchforandselecttextstringsandcopyselectedtextstringstothesystemclipboard(seeText
selectionandclipboardoperations)
与XML兼容的环球网搜索引擎查找精图内容中的文本串,只需按照其它XML文档中进行搜索的方式进行搜索,而无须进行额外的工作。XML-compatibleWebsearchengineswillfindtextstringsinSVGcontentwithnoadditionaleffortoverwhattheyneedtodotofindtextstringsinotherXMLdocuments

通过
基于用户所选的语言替换不同的文本串,可以实现多种语言的精图内容.Multi-languageSVGcontentispossibleby
substitutingdifferenttextstringsbasedontheuser'spreferredlanguage.

基于易访问的原因,建议包含在文档中的文本有适当的语义标记表明其作用。更多的内容请参见
精图易访问性指南.Foraccessibilityreasons,itisrecommendedthattextwhichisincludedinadocumenthaveappropriatesemanticmarkuptoindicateitsfunction.SeeSVGaccessibility
guidelinesformoreinformation.

 

10.2字符及其相应的图元Charactersandtheircorrespondingglyphs

在XML[XML10]中,文本内容是通过XML字符序列来定义的,而每个字符通过一个特定的统一的字符编码标准[UNICODE]中的编码来确定的.
另一方面,字体由一套图元以及与之相关的信息例如字体属性表组成.一个图元是一个或多个字符(或者同理一个字符的部分)的表现形式.每一图元由某类标识符(某些情况下为字符串,
其它情况下为数值)以及此图元的用于渲染的绘制指令构成.InXML[XML10],textualcontentisdefinedintermsofasequenceofXMLcharacters,whereeachcharacterisdefinedbyaparticularUnicodecodepoint[UNICODE].
Fonts,ontheotherhand,consistsofacollectionofglyphsandotherassociatedinformation,suchasfonttables.Aglyph
isapresentableformofoneormorecharacters(orapartofacharacterinsomecases).Eachglyphconsistsofsomesortofidentifier(insomecasesastring,inothercasesanumber)alongwithdrawinginstructionsforrenderingthatparticularglyph.

在很多情况下,存在统一字符编码(即,统一字符编码点)到字体中的图元的一一映射关系.例如,通常针对拉丁语言(这里术语拉丁用于表示有字母表的欧洲语言如英语类似于并且或者从拉丁语派生的语言)字体的设计包含标准ASCII字符(即,A-到-Z,a-到-z,0-到-9,外加ASCII中各种标点符号字符)所对应的图元.于是,在大部分情况下,字符串"XML",它由三个统一字符编码字符构成,将通过三个分别对应于"X","M"和"L"的图元来渲染.Inmanycases,
thereisaone-to-onemappingofUnicodecharacters(i.e.,Unicodecodepoints)toglyphsinafont.Forexample,itiscommonforafontdesignedforLatinlanguages(wherethetermLatinisusedforEuropeanlanguagessuchasEnglishwithalphabetssimilar
toand/orderivativetotheLatinlanguage)tocontainasingleglyphforeachofthestandardASCIIcharacters(i.e.,A-to-Z,a-to-z,0-to-9,plusthevariouspunctuationcharactersfoundinASCII).Thus,inmostsituations,thestring"XML",whichconsists
ofthreeUnicodecharacters,wouldberenderedbythethreeglyphscorrespondingto"X","M"and"L",respectively.

但是在某些特殊情况下,统一字符编码字符与图元并不存在一一映射关系.下面为一些不为一一映射关系的情形:Invariousothercases,however,thereisnotastrictone-to-onemappingofUnicodecharacterstoglyphs.Someofthecircumstanceswhenthemappingisnotone-to-one:

连字-为了排字有最好的视觉效果,常常希望将某些特定字符序列作为单一的图元进行渲染.例如单词"office".很多字体会定义一个连字"ffi".当对单词"office"进行渲染时,有时用户代理会对连字"ffi"所对应的图元进行渲染而不对三个字符所对应的各自的图元(即,"f","f"和"i")进行渲染.于是,对于连字,多个统一字符编码字符映射到单个图元.(注意某些语言特定的渲染方式,对于某些字符的组合必须使用连字.)Ligatures-Forbestlooking
typesetting,itisoftendesirablethatparticularsequencesofcharactersarerenderedasasingleglyph.Anexampleistheword"office".Manyfontswilldefinean"ffi"ligature.Whentheword"office"isrendered,sometimestheuseragentwillrenderthe
glyphforthe"ffi"ligatureinsteadofrenderingdistinctglyphs(i.e.,"f","f"and"i")foreachofthethreecharacters.Thus,forligatures,multipleUnicodecharactersmaptoasingleglyph.(Notethatforproperrenderingofsomelanguages,ligatures
arerequiredforcertaincharactercombinations.)
合字-在很多情况下,常用的装饰符例如变音符号会作为一个特殊的图元在一种字体中只存储一次,然后通过与一个或多个其它图元进行组合生成所期望的字符.例如,可以这样,某个字体引擎可以通过先渲染字符e的图元然后渲染´(重音符号)图元使得重音符号出现在e的上方来实现对字符é的渲染.此时,单个统一字符编码字符被映射为多个图元.Compositecharacters-Invarioussituations,commonlyusedadornmentssuchas
diacriticalmarkswillbestoredonceinafontasaparticularglyphandthencomposedwithoneormoreotherglyphstoresultinthedesiredcharacter.Forexample,itispossiblethatafontenginemightrendertheécharacterbyfirstrenderingtheglyph
foreandthenrenderingtheglyphfor´(theaccentmark)suchthattheaccentmarkwillappearoverthee.Inthissituation,asingleUnicodecharactermapstomultipleglyphs.
图元置换-某些排印系统检查文本内容的性质,在不同的情况下选用不同的图元.例如,在阿拉伯语中,同一统一字符编码字符可以渲染成四种不同的图元,依赖于这种因素如此字符是否出现在草写连结字符序列的开头、末尾或中间等.标点符号字符根据内部书写方向(例如,水平或者垂直)将使用不同的图元.此时,单个统一字符编码字符被映射为多个图元中的一个图元.Glyphsubstitution-Sometypographysystemsexaminethenatureofthetextual
contentandutilizedifferentglyphsindifferentcircumstances.Forexample,inArabic,thesameUnicodecharactermightrenderasanyoffourdifferentglyphs,dependingonsuchfactorsaswhetherthecharacterappearsatthestart,theendorthemiddle
ofasequenceofcursivelyjoinedcharacters.Differentglyphsmightbeusedforapunctuationcharacterdependingoninline-progression-direction(e.g.,horizontalvs.vertical).Inthesesituations,asingleUnicodecharactermightmaptooneofseveral
alternativeglyphs.
在某些语言中,字符的特定序列将被转换成多个图元使得特定字符的某些部分在一个图元中而此字符的剩余部分在另一个图元中.Insomelanguages,particularsequencesofcharacterswillbeconvertedintomultipleglyphssuchthatpartsofaparticularcharacterareinoneglyphandtheremainderofthatcharacterisin
anotherglyph.
二选一图元规范-精图包含一种机制使得作者可以明确指定统一字符编码的特定字符序列按照某一特定的图元进行渲染.(参见
二选一图元.)当使用这种机制时多个统一字符编码字符序列被映射为单一的图元.Alternativeglyphspecification-SVGcontainsafacilityfortheauthortoexplicitlyspecifythataparticularsequenceofUnicodecharactersistoberenderedusingaparticularglyph.(SeeAlternate
glyphs.)Whenthisfacilityisused,multipleUnicodecharactersmaptoasingleglyph.

在很多情况下,将字符映射为图元的算法依赖于特定的系统,这导致在不同的用户环境中文本的渲染效果可能是不同的(通常为少许的不同).如果精图的作者要求对字体和图元作出精确的选择,那么建议所需的字体(仅此给定文档所需要包含的潜在的图元子集)要么作为精图字体
嵌入精图文档中或者作为
环球网字体按照精图相同的环球网位置进行传送.Inmanysituations,thealgorithmsformappingfromcharacterstoglyphsaresystem-dependent,resultinginthepossibilitythattherenderingoftextmightbe(usuallyslightly)differentwhenviewedindifferentuserenvironments.
IftheauthorofSVGcontentrequirespreciseselectionoffontsandglyphs,thentherecommendationisthatthenecessaryfonts(potentiallysubsettedtoincludeonlytheglyphsneededforthegivendocument)beavailableeitherasSVG
fontsembeddedwithintheSVGcontentoras
WebFontspostedatthesameWeblocationastheSVGcontent.

贯穿本章,术语字符等价于XML[XML10]中字符的定义.Throughoutthischapter,thetermcharactershallbeequivalenttothedefinitionofacharacterinXML[XML10].

10.3字体、字体属性表和基线Fonts,
fonttablesandbaselines

一种字体是由一套图元以及在某些媒体中如何运用这些图元来表示字符所需的必要信息(字体属性表)组成.一套图元以及其相应的字体属性表的组合称之为字体数据.字体属性表包含将字符映射为图元所必需的信息,以及确定图元区域的尺寸及位置的信息.每一个字体属性表由一个或多个字体特性如粗体和字型组成.Afontconsistsofacollectionofglyphstogetherwiththeinformation(thefonttables)necessary
tousethoseglyphstopresentcharactersonsomemedium.Thecombinationofthecollectionofglyphsandthefonttablesiscalledthefontdata.Thefonttablesincludetheinformationnecessarytomapcharacterstoglyphs,todeterminethesizeofglyph
areasandtopositiontheglypharea.Eachfonttableconsistsofoneormorefontcharacteristics,suchasthefont-weightandfont-style.

几何字体特征按照基于EM方框的坐标系统来表示的.(EM是对字体中的图元的一种相对测量;参见
CSS2em平方.)方框1EM高和1EM宽被称为设计空间.这种空间通过细分EM到一定数目的
units-per-em给出一种几何坐标.ThegeometricfontcharacteristicsareexpressedinacoordinatesystembasedontheEMbox.(TheEMisarelativemeasureoftheheightoftheglyphsinthefont;seeCSS2
emsquare.)Thebox1EMhighand1EMwideiscalledthedesignspace.Thisspaceisgivenageometriccoordinatesbysub-dividingtheEMintoanumberofunits-per-em.

注记:Units-per-em是一种字体特性。其典型的值为1000或2048。Note:Units-per-emisafontcharacteristic.Atypicalvalueforunits-per-EMis1000or2048.

EM方框的坐标空间被称之为设计空间坐标系.对于可缩放字体而言,用于绘制图元的曲线和直线使用这种坐标系来表示.ThecoordinatespaceoftheEMboxiscalledthedesignspacecoordinatesystem.Forscalablefonts,thecurvesandlinesthatareusedtodrawaglypharerepresentedusingthiscoordinate
system.

注记:在最多的时候,在这种坐标系中点(0,0)位于EM方框的左边,但不在左下角.大写罗马字母的底部的Y坐标为零.并且小写罗马字母的下部具有负的坐标值.Note:Mostoften,the(0,0)pointinthiscoordinatesystemispositionedontheleftedgeoftheEMbox,butnotatthebottomleftcorner.TheYcoordinateofthebottom
ofaromancapitalletterisusuallyzero.Andthedescendersonlowercaseromanlettershavenegativecoordinatevalues.

精图假定字体属性表至少要提供三种字体特性:一个上距,一个下距和一套基线表.上距为字体的(0,0)点到EM方框的顶部的距离;而下距为字体的(0,0)点到EM方框的底部的距离.基线表将在下面解释.SVGassumesthatthefonttableswillprovideatleastthreefontcharacteristics:anascent,adescentandasetofbaseline-tables.Theascentis
thedistancetothetopoftheEMboxfromthe(0,0)pointofthefont;thedescentisthedistancetothebottomoftheEMboxfromthe(0.0)pointofthefont.Thebaseline-tableisexplainedbelow.

注记:在一个开式的字体内,对于水平书写模式而言,上距和下距由OS/2表中的sTypoAscender项和sTypoDescender项给定.对于垂直书写模式而言,下距(此时为(0,0)点到图元的左边的距离)通常为零因为(0,0)点在左边.上距要么为1em要么由开式基表中表意字顶部基线值来确定.Note:WithinanOpenTypefont,forhorizontalwriting-modes,theascentanddescentaregiven
bythesTypoAscenderandsTypoDescenderentriesintheOS/2table.Forverticalwriting-modes,thedescent(thedistance,inthiscasefromthe(0,0)pointtotheleftedgeoftheglyph)isnormallyzerobecausethe(0,0)pointisontheleftedge.Theascent
forverticalwriting-modesiseither1emorisspecifiedbytheideographictopbaselinevalueintheOpenTypeBasetableforverticalwriting-modes.

在水平书写模式中,给定文本的图元按照每个图元的一个特定的点来进行安置,这个点称为对齐点,它与此文本中的其它图元的对齐点进行对齐.不同类型文字的图元,例如,西文、北印和中文文本,以具有各自代表性的图元的不同点来进行对齐.
例如,西文图元按大写字母的底部对齐,北印图元按照接近图元的顶部的一个水平笔划进行对齐而中文图元要么按照图元的底部或中心进行对齐.在一种文字和具有相同字体尺寸的一行文本中,按照内部的书写方向一系列对齐点所定义的几何线称为基线.西文和大多数别的字母和音节图元按照一种"字母"基线对齐,而北印图元按照"悬挂"基线进行对齐而中文图元按照一种"表意"基线进行对齐.Inhorizontalwriting-modes,theglyphsofagivenscriptare
positionedsothataparticularpointoneachglyph,thealignment-point,isalignedwiththealignment-pointsofthe
otherglyphsinthatscript.Theglyphsofdifferentscripts,forexample,Western,NorthernIndicandFar-Easternscripts,aretypicallyalignedatdifferentpointsontheglyph.Forexample,Westernglyphsarealignedonthebottomsofthecapitalletters,northern
indicglyphsarealignedatthetopofahorizontalstrokenearthetopoftheglyphsandfar-easternglyphsarealignedeitheratthebottomorcenteroftheglyph.Withinascriptandwithinalineoftexthavingasinglefont-size,thesequenceofalignment-points
defines,intheinline-progression-direction,ageometriclinecalledabaseline.Westernandmostotheralphabeticandsyllabicglyphsarealignedtoan"alphabetic"baseline,thenorthernindicglyphsarealignedtoa"hanging"baselineandthefar-eastern
glyphsarealignedtoan"ideographic"baseline.

一个基线表指定一个或多个基线在设计空间坐标系中的位置.基线表的作用在于当不同的文字被混合安置在同一文本行上时易于对齐.因为期望的相对对齐方式依赖于在一行(或一块)中的哪种文字具有主导地位,所以对于每一种文字可以有不同的基线表.另外,对于水平书写方向和垂直书写方向需要不同的对齐位置.因此,字体有一套基线表t:通常,一个或更多用于水平书写模式,零个或多个用于垂直模式.Abaseline-tablespecifiesthepositionofone
ormorebaselinesinthedesignspacecoordinatesystem.Thefunctionofthebaselinetableistofacilitatethealignmentofdifferentscriptswithrespecttoeachotherwhentheyaremixedonthesametextline.Becausethedesiredrelativealignmentsmaydepend
onwhichscriptisdominantinaline(orblock),theremaybeadifferentbaselinetableforeachscript.Inaddition,differentalignmentpositionsareneededforhorizontalandverticalwritingmodes.Therefore,thefontmayhaveasetofbaselinetables:typically,
oneormoreforhorizontalwriting-modesandzeroormoreforverticalwriting-modes.

注记:某些字体也许其基线表上没有取值.当一个字体不提供基线表时,建议试探地给其赋予一个近似地基线表.Note:Somefontsmaynothavevaluesforthebaselinetables.Heuristicsaresuggestedforapproximatingthebaselinetableswhenagivenfontdoesnotsupplybaselinetables.

精图进一步假定一种字体的字体数据中的每一个图元具有两种宽度值,两种对齐基线和两个对齐点,一个用于水平书写模式而另一个用于垂直书写模式.(即使只指定一种宽度,对于垂直书写模式而言这一宽度将用在垂直方向上.)图元所属的文本确定了用来对齐图元的对齐基线.对齐点的内建书写方向
位于图元的起始边.SVGfurtherassumesthatforeachglyphinthefontdataforafont,therearetwowidthvalues,twoalignment-baselinesandtwoalignment-points,oneeachforhorizontalwriting-modesandtheotherforverticalwriting-modes.(Eventhoughitisspecified
asawidth,forverticalwriting-modesthewidthisusedintheverticaldirection.)Thescripttowhichaglyphbelongsdeterminesanalignment-baselinetowhichtheglyphistobealigned.Theinline-progression-directionposition
ofthealignment-pointisonthestart-edgeoftheglyph.

与基线相关的属性在下面的
基线对齐属性中描述.Propertiesrelatedtobaselinesaredescribedbelowunder
Baselinealignmentproperties.

除了上面所要求地一些字体特性外,某种字体也许提供替换和定位表用来格式化重新排列组合和定位一系列图元生成一个或多个合成图元.合成也许同连字一样简单,也许和北印文的音节一样复杂,这种北印文的音节由多个辅音和元音图元组成,通常会进行某些重新排列.Inadditiontothefontcharacteristicsrequiredabove,afontmayalsosupplysubstitutionandpositioningtablesthatcanbeused
byaformattertore-order,combineandpositionasequenceofglyphstomakeoneormorecompositeglyphs.Thecombinationmaybeassimpleasaligature,orascomplexasanindicsyllablewhichcombines,usuallywithsomere-ordering,multipleconsonantsand
vowelglyphs.

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

文本元素'text'定义一种由文本组成的图形元素.在文本元素'text'中的XML[XML10]字符数据,依照相关的属性和性质以及字体本身内的字符到图元的映射关系,规定被渲染的图元.(参见字符及其相应的图元.)文本元素'text'上的属性和性质表示这种事情如书写方向、字体规格以及规定如何正确对字符进行渲染的绘制属性.本章以后的章节描述文本特有的属性和性质,特别是文本布局

双向性.The'text'elementdefinesagraphicselementconsistingoftext.TheXML[XML10]characterdatawithinthe'text'element,alongwithrelevantattributesandpropertiesandcharacter-to-glyph
mappingtableswithinthefontitself,definetheglyphstoberendered.(See
Charactersandtheircorrespondingglyphs.)Theattributesandpropertiesonthe'text'elementindicatesuchthingsasthewritingdirection,fontspecificationandpaintingattributeswhichdescribehowexactlytorenderthecharacters.Subsequentsections
ofthischapterdescribetherelevanttext-specificattributesandproperties,particulartextlayoutand

bidirectionality.

由于对文本元素'text'的渲染采用与其它图形元素相同的渲染方法,所有应用到
形状如
路径和
长方形的同一
坐标系变换、绘制、剪裁
蒙版特性同样也应用到文本元素'text'.Since'text'elementsarerenderedusingthesamerenderingmethodsasothergraphicselements,allofthesamecoordinate
systemtransformations,
painting,clippingandmasking
featuresthatapplyto
shapessuchas
pathsand
rectanglesalsoapplyto'text'elements.

可以对文本使用色彩渐变、模式填充、路径剪裁、蒙版或滤镜.当这些工具的某一种被用于文本时,关键字objectBoundingBox(参见对象边界方框单元)被用来说明相对于"对象边界方框"的一种图形效果,
则对象边界方框单元在所有情况下按照整个文本元素'text'进行计算,即使不同的效果用于此文本元素'text'中的不同的文本块元素'tspan'同样如此.Itispossibletoapplyagradient,pattern,
clippingpath,maskorfiltertotext.WhenoneofthesefacilitiesisappliedtotextandkeywordobjectBoundingBoxisused(seeObject
boundingboxunits)tospecifyagraphicaleffectrelativetothe"objectboundingbox",thentheobjectboundingboxunitsarecomputedrelativetotheentire'text'elementinallcases,evenwhendifferenteffectsareappliedtodifferent'tspan'
elementswithinthesame'text'element.

文本元素'text'在初始当前文本位置上渲染它的第一个图元(在双向性
重新排列之后),而初始当前文本位置由此文本元素'text'的
x和
y属性所确定(也许由于性质
'text-anchor'的取值,出现一个文本路径元素
'textPath'包含第一个字符,并且/或者在一个
'tspan',
'tref'或'altGlyph'元素的x,

y,
dx或
dy属性中包含第一个字符等原因会导致相应的调整).在相应于给定的字符的图元被渲染之后,当前文本位置被更新以对应于下一个字符.在最简单的情况下,新的当前文本位置为前一个当前文本位置加上图元的增量值(水平或垂直).请参见文本布局关于图元安置和图元增量的情况.
The'text'elementrendersitsfirstglyph(after
bidirectionalityreordering)attheinitial
currenttextposition,whichisestablishedbythe
xand
yattributesonthe'text'element(withpossibleadjustmentsduetothevalueofthe'text-anchor'property,thepresence
ofa
'textPath'elementcontainingthefirstcharacter,and/oran
x,
y,
dxor
dyattributesona
'tspan',
'tref'or
'altGlyph'elementwhichcontainsthefirstcharacter).Aftertheglyph(s)correspondingtothegivencharacteris(are)rendered,thecurrenttextpositionisupdatedforthenextcharacter.Inthesimplestcase,thenewcurrenttextpositionistheprevious
currenttextpositionplustheglyphs'advancevalue(horizontalorvertical).Seetextlayoutforadescriptionofglyphplacement
andglyphadvance.


<!ENTITY%textExt"">

<!ELEMENTtext(#PCDATA|desc|title|metadata|

tspan|tref|textPath|altGlyph|a|animate|set|

animateMotion|animateColor|animateTransform

%geExt;%textExt;)*>

<!ATTLISTtext

%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坐标指定用于渲染此元素或任何子元素的第一个字符所对应的图元的当前文本位置
.Ifasingle
<coordinate>isprovided,thenthevaluerepresentsthenewabsoluteXcoordinateforthecurrenttextpositionforrendering
theglyphsthatcorrespondtothefirstcharacterwithinthiselementoranyofitsdescendants.

如果提供了由逗号或空格分隔的<n>个
<坐标>列表,那么这些值所表示新的绝对X坐标指定用于渲染此元素或任何子元素的第<n>个字符所对应的每个图元的当前文本位置.Ifacomma-orspace-separatedlistof<n><coordinate>sis
provided,thenthevaluesrepresentnewabsoluteXcoordinatesforthecurrenttextpositionforrenderingtheglyphscorresponding
toeachofthefirst<n>characterswithinthiselementoranyofitsdescendants.

至于额外的处理规则,参见文本块元素
'tspan'的属性x的描述.Foradditionalprocessingrules,refertothedescriptionofthex
attributeonthe
'tspan'element.

如果不设置此属性,则其效果等同于设置此属性的值为"0"效果.Iftheattributeisnotspecified,theeffectisasifavalueof"0"werespecified.

Animatable:yes.

y="<坐标值>+"

在此元素内的字符所对应图元的绝对Y坐标的相应列表.针对属性'y'的处理规则与针对属性
'x'的一致.ThecorrespondinglistofabsoluteYcoordinatesfortheglyphscorrespondingtothecharacterswithinthiselement.Theprocessingrulesforthe'y'attributeparalleltheprocessingrulesforthe'x'
attribute.

如果不设置此属性,则其效果等同于设置此属性的值为"0"效果.Iftheattributeisnotspecified,theeffectisasifavalueof"0"werespecified.

Animatable:yes.

dx="<长度值>+"

此元素或其子孙中的字符相对当前文本位置沿着x-轴的偏移量.Shiftsinthecurrent
textpositionalongthex-axisforthecharacterswithinthiselementoranyofitsdescendants.

参见对文本块元素
'tspan'的属性dx的描述.Refertothedescriptionofthedx
attributeonthe
'tspan'element.

如果不设置此元素或其子元素的此属性,则不会出现沿着x-轴的偏移量.Iftheattributeisnotspecifiedonthiselementoranyofitsdescendants,nosupplementalshiftsalongthex-axiswilloccur.

Animatable:yes.

dy="<长度值>+"

此元素或其子孙中的字符相对当前文本位置沿着y-轴的偏移量.Shiftsinthecurrent
textpositionalongthey-axisforthecharacterswithinthiselementoranyofitsdescendants.

参见对文本块元素
'tspan'的属性dy的描述.Refertothedescriptionofthedy
attributeonthe
'tspan'element.

如果不设置此元素或其子元素的此属性,则不会出现沿着y-轴的偏移量.Iftheattributeisnotspecifiedonthiselementoranyofitsdescendants,nosupplementalshiftsalongthey-axiswilloccur.

Animatable:yes.

rotate="<number>+"

当前文本位置周围作用于对应于此元素中的每一字符的所有图元的附加旋转.Thesupplementalrotationaboutthecurrent
textpositionthatwillbeappliedtoalloftheglyphscorrespondingtoeachcharacterwithinthiselement.

参见对文本块元素
'tspan'的属性rotate的描述.Refertothedescriptionoftherotate
attributeonthe
'tspan'element.

如果不设置此元素或其子元素的此属性,则不会出现附加旋转.Iftheattributeisnotspecifiedonthiselementoranyofitsdescendants,nosupplementalrotationswilloccur.

Animatable:yes(non-additive,'set'and'animate'elementsonly).

textLength="<长度值>"

此文本元素中对应于所有字符数据的增量的总和的作者的计算值,包括图元(水平或垂直)的增量值,考虑性质
'kerning',
'letter-spacing'和
'word-spacing'的效果以及由于文本块元素'tspan'的属性dx

dy所作的调整.此值用于校准用户代理的计算与作者的计算.Theauthor'scomputationofthetotalsumofalloftheadvancevaluesthatcorrespondtocharacterdatawithinthiselement,includingtheadvancevalueontheglyph(horizontalorvertical),theeffectofproperties'kerning',

'letter-spacing'and
'word-spacing'andadjustmentsduetoattributes
dxand
dyon
'tspan'elements.Thisvalueisusedtocalibratetheuseragent'sowncalculationswiththatoftheauthor.

这个属性的目的在于允许作者使得在任何
双向重新排列之后的依照可见的渲染次序,将对应于此元素的第一和最后一个被渲染的图元进行精确的对齐;于是,对于最后渲染的字符而言(在任何
双向重新排列之后的依照可见的渲染次序),当用户代理确定适当的数量以便对文本串进行适当伸缩满足textLength的长度时,正常图元增量之外的附加内部字符之间的空白增量将被忽略(在大多数情况下).Thepurposeofthisattributeistoallowtheauthortoachieveexactalignment,invisualrenderingorderafteranybidirectionalreordering,
forthefirstandlastrenderedglyphsthatcorrespondtothiselement;thus,forthelastrenderedcharacter(invisualrenderingorderafteranybidirectionalreordering),
anysupplementalinter-characterspacingbeyondnormalglyphadvancesareignored(inmostcases)whentheuseragentdeterminestheappropriateamounttoexpand/compressthetextstringtofitwithinalengthoftextLength.

一种负值是一种错误(参见
错误处理).Anegativevalueisanerror(see
Errorprocessing).

如果不设置此属性,其效果相当于作者的计算与用户代理的计算完全相等时所出现的情况;于是,无须此时进行进一步的调整.Iftheattributeisnotspecified,theeffectisasiftheauthor'scomputationexactlymatchedthevaluecalculatedbytheuseragent;thus,noadvanceadjustmentsaremade.

Animatable:yes.

lengthAdjust="spacing|spacingAndGlyphs"

表示调整的类型,此类型使用户代理将按照属性textLength的值安排文本的渲染长度.IndicatesthetypeofadjustmentswhichtheuseragentshallmaketomaketherenderedlengthofthetextmatchthevaluespecifiedonthetextLengthattribute.

spacing表示只对增量值进行调整.图元本身不进行伸缩.spacingindicatesthatonlytheadvancevaluesareadjusted.Theglyphsthemselvesarenotstretchedorcompressed.

spacingAndGlyphs表示增量值将进行调整并且图元也要在一个轴上(即,与内部书写方向平行的方向)进行伸缩.spacingAndGlyphsindicatesthattheadvancevaluesareadjustedandtheglyphsthemselvesstretchedorcompressedinoneaxis(i.e.,adirectionparalleltotheinline-progression-direction).

用户代理要能确定文本串的正确起始和终止位置,但是中间图元的位置是不可预测的,因为用户代理为了平衡正确起始和终止位置和最佳的排印它会调用高级的算法伸缩文本串.Theuseragentisrequiredtoachievecorrectstartandendpositionsforthetextstrings,butthelocationsofintermediateglyphsarenotpredictablebecauseuseragentsmight
employadvancedalgorithmstostretchorcompresstextstringsinordertobalancecorrectstartandendpositioningwithoptimaltypography.

注意,对于包含<n>个字符的文本串来说,对于增量值的调整常常仅对<n-1>个字符进行(参见对属性
textLength的描述),而图元的伸缩则针对所有<n>个字符进行.Notethat,foratextstringthatcontains<n>characters,theadjustmentstotheadvancevaluesoftenoccuronlyfor<n-1>characters(seedescriptionofattributetextLength),
whereasstretchingorcompressingoftheglyphswillbeappliedtoall<n>characters.

如果不设置此属性,其效果相当于设置了空白值.Iftheattributeisnotspecified,theeffectisasavalueofspacingwerespecified.

Animatable:yes.

其它地方已经定义的属性Attributesdefinedelsewhere:

%stdAttrs;,%testAttrs;,%langSpaceAttrs;,externalResourcesRequired,class,style,

%PresentationAttributes-Color;,%PresentationAttributes-FillStroke;,%PresentationAttributes-FontSpecification;,%PresentationAttributes-Graphics;,%PresentationAttributes-TextContentElements;,%PresentationAttributes-TextElements;,transform,%graphicsElementEvents;.

在下面的例子text01包含文本串"Hello,outthere"它将使用以蓝色填充的Verdana字体渲染到绘制区域.Exampletext01belowcontainsthetextstring"Hello,outthere"whichwillberenderedontothecanvasusingtheVerdanafontfamily
withtheglyphsfilledwiththecolorblue.


<?xmlversion="1.0"standalone="no"?>

<!DOCTYPEsvgPUBLIC"-//W3C//DTDSVG20010904//EN"

"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">

<svgwidth="10cm"height="3cm"viewBox="001000300"

xmlns="http://www.w3.org/2000/svg">

<desc>Exampletext01-'Hello,outthere'inblue</desc>


<textx="250"y="150"

font-family="Verdana"font-size="55"fill="blue">

Hello,outthere

</text>


<!--Showoutlineofcanvasusing'rect'element-->

<rectx="1"y="1"width="998"height="298"

fill="none"stroke="blue"stroke-width="2"/>

</svg>

Exampletext01
ViewthisexampleasSVG(SVG-enabledbrowsersonly)

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

在一个文本元素
'text'内,包含在文本块元素'tspan'中的文本和字体的性质以及当前文本位置能够根据绝对或相对坐标进行调整.Withina'text'
element,textandfontpropertiesandthe
currenttextpositioncanbeadjustedwithabsoluteorrelativecoordinatevaluesbyincludinga'tspan'element.


<!ENTITY%tspanExt"">

<!ELEMENTtspan(#PCDATA|desc|title|metadata|tspan|tref|altGlyph|a|animate|set|animateColor

%tspanExt;)*>

<!ATTLISTtspan

%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坐标指定用于渲染此元素或任何子元素的第一个字符所对应的图元的当前文本位置
.Ifasingle
<coordinate>isprovided,thenthevaluerepresentsthenewabsoluteXcoordinateforthecurrenttextpositionforrendering
theglyphsthatcorrespondtothefirstcharacterwithinthiselementoranyofitsdescendants.

如果提供了由逗号或空格分隔的<n>个
<坐标>列表,那么这些值所表示新的绝对X坐标指定用于渲染此元素或任何子元素的第<n>个字符所对应的每个图元的当前文本位置.Ifacomma-orspace-separated
listof<n><coordinate>sisprovided,thenthevaluesrepresentnewabsoluteXcoordinatesforthecurrent
textpositionforrenderingtheglyphscorrespondingtoeachofthefirst<n>characterswithinthiselementoranyofitsdescendants.

如果提供比字符还多的<坐标值>,则多余的<坐标值>
将不会影响图元的位置.Ifmore
<coordinate>sareprovidedthancharacters,thentheextra
<coordinate>swillhavenoeffectonglyphpositioning.

如果字符数大于
<坐标值>的个数,那么对于每个多余的字符而言:(a)如果上级文本元素
'text'或者文本块元素'tspan'通过属性x对于给定的字符设置了一个绝对X坐标,则此绝对X坐标作为此字符的起始X坐标(最近的上级优先考虑),否则(b)给定的字符所对应的图元渲染的起始X坐标为当前文本元素'text'
的最近进行渲染的图元所导出的
当前文本位置的X坐标.Ifmorecharactersexistthan
<coordinate>s,thenforeachoftheseextracharacters:(a)ifanancestor
'text'or
'tspan'elementspecifiesanabsoluteXcoordinateforthegivencharacterviaanxattribute,thenthatabsoluteXcoordinateisusedasthestartingXcoordinateforthatcharacter(nearestancestorhasprecedence),else(b)thestartingXcoordinatefor
renderingtheglyphscorrespondingtothegivencharacteristheXcoordinateoftheresultingcurrenttextpositionfrom
themostrecentlyrenderedglyphforthecurrent
'text'element.

如果不设置此属性:(a)如果一个上级文本元素
'text'或者文本块元素'tspan'通过属性x为给定的字符设置了绝对X坐标,则此绝对X坐标作为此字符的起始X坐标(最近的上级优先考虑),否则(b)给定的字符所对应的图元渲染的起始X坐标为当前文本元素'text'
的最近进行渲染的图元所导出的当前文本位置的X坐标.Iftheattributeisnotspecified:(a)ifanancestor'text'
or
'tspan'elementspecifiesanabsoluteXcoordinateforagivencharacterviaanxattribute,thenthatabsoluteXcoordinateisused(nearestancestorhasprecedence),else(b)thestartingXcoordinateforrenderingtheglyphscorrespondingtoagivencharacter
istheXcoordinateoftheresulting
currenttextpositionfromthemostrecentlyrenderedglyphforthecurrent
'text'element.

Animatable:yes.

y="<坐标值>+"

在此元素内的字符所对应图元的绝对Y坐标的相应列表.针对属性'y'的处理规则与针对属性
'x'的一致.ThecorrespondinglistofabsoluteYcoordinatesfortheglyphscorrespondingtothecharacterswithinthiselement.Theprocessingrulesforthe'y'attributeparalleltheprocessingrulesforthe'x'
attribute.

Animatable:yes.

dx="<长度值>+"

如果提供单一的<长度值>,那么此值表示用于渲染此元素或任何子元素的第一个字符所对应的图元相对于当前文本位置新的相对
X坐标.而此当前文本位置指的是在渲染第一个字符所对应的图元之前沿着当前用户坐标系的x-轴平移的<长度值>.If
asingle
<length>isprovided,thisvaluerepresentsthenewrelativeXcoordinateforthecurrenttextpositionforrendering
theglyphscorrespondingtothefirstcharacterwithinthiselementoranyofitsdescendants.Thecurrenttextposition
isshiftedalongthex-axisofthecurrentusercoordinatesystemby<length>beforethefirstcharacter'sglyphsarerendered.

如果提供了由逗号或空格分隔的<n>个
<长度值>列表,那么这些值表示用于渲染此元素或任何子元素的第<n>个字符所对应的图元相对于当前文本位置新的相对X坐标.而此当前文本位置指的是在渲染第
<n>个字符所对应的图元之前沿着当前用户坐标系的x-轴平移的
<长度值>.Ifacomma-orspace-separatedlistof<n>
<length>sisprovided,thenthevaluesrepresentincrementalshiftsalongthex-axisforthecurrenttextpositionbefore
renderingtheglyphscorrespondingtothefirst<n>characterswithinthiselementoranyofitsdescendants.Thus,beforetheglyphsarerenderedcorrespondingtoeachcharacter,thecurrent
textpositionresultingfromdrawingtheglyphsforthepreviouscharacterwithinthecurrent'text'elementisshiftedalong
theXaxisofthecurrentusercoordinatesystemby<length>.

如果提供比字符还多的<长度值>,则多余的<长度值>将不会影响图元的位置.If
more
<length>sareprovidedthancharacters,thenanyextra
<length>swillhavenoeffectonglyphpositioning.

如果字符数大于
<长度值>的个数,那么对于每个多余的字符而言:(a)如果上级文本元素
'text'或者文本块元素'tspan'通过属性dx对于给定的字符设置了一个相对X坐标,则当前文本位置为沿着当前用户坐标系的x-轴平移此数值所得出的值
(最近的上级优先考虑),否则(b)沿着当前用户坐标系的x-轴的平移不会出现.Ifmorecharactersexistthan
<length>s,thenforeachoftheseextracharacters:(a)ifanancestor
'text'or
'tspan'elementspecifiesarelativeXcoordinateforthegivencharacterviaadxattribute,thenthecurrenttextposition
isshiftedalongthex-axisofthecurrentusercoordinatesystembythatamount(nearestancestorhasprecedence),else(b)noextrashiftalongthex-axisoccurs.

如果不设置此属性:(a)如果上级文本元素
'text'或者文本块元素'tspan'通过属性dx对于给定的字符设置了一个相对X坐标,则当前文本位置为沿着当前用户坐标系的x-轴平移此数值所得出的值
(最近的上级优先考虑),否则(b)沿着当前用户坐标系的x-轴的平移不会出现.Iftheattributeisnotspecified:(a)ifanancestor'text'or

'tspan'elementspecifiesarelativeXcoordinateforagivencharacterviaadxattribute,thenthecurrenttextposition
isshiftedalongthex-axisofthecurrentusercoordinatesystembythatamount(nearestancestorhasprecedence),else(b)noextrashiftalongthex-axisoccurs.

Animatable:yes.

dy="<length>+"

在此元素内的字符所对应图元的相对Y坐标的相应列表.针对属性'dy'的处理规则与针对属性
'dx'的一致.ThecorrespondinglistofrelativeYcoordinatesforthecharacterswithinthe'tspan'element.Theprocessingrulesforthe'dy'attributeparalleltheprocessingrulesforthe'dx'
attribute.

Animatable:yes.

rotate="<number>+"

当前文本位置周围作用于对应于此元素中的每一字符的所有图元的附加旋转.Thesupplementalrotationaboutthecurrent
textpositionthatwillbeappliedtoalloftheglyphscorrespondingtoeachcharacterwithinthiselement.

如果提供了由逗号或空格分隔的<n>个
<number>列表,那么第一个
<number>所表示用于渲染此元素或任何子元素的第一个字符所对应的每个图元的附加旋转,第二个
<number>所表示用于渲染此元素或任何子元素的第二个字符所对应的每个图元的附加旋转,等等.Ifacomma-orspace-separatedlistof<number>sisprovided,thenthefirst

<number>representsthesupplementalrotationfortheglyphscorrespondingtothefirstcharacterwithinthiselementoranyofitsdescendants,thesecond<number>represents
thesupplementalrotationfortheglyphsthatcorrespondtothesecondcharacter,andsoon.

如果提供比字符还多的
<number>,则多余的
<number>将被忽略.Ifmore
<number>sareprovidedthantherearecharacters,thentheextra
<number>swillbeignored.

如果字符数大于<number>的个数,那么对于每个多余的字符而言:(a)如果上级文本元素'text'
或者文本块元素'tspan'通过属性rotate对于给定的字符设置了附加旋转,则此附加旋转作用于给定的字符(最近的上级优先考虑),否则(b)附加旋转不会出现.Ifmorecharactersareprovidedthan<number>s,then
foreachoftheseextracharacters:(a)ifanancestor
'text'or
'tspan'elementspecifiesasupplementalrotationforthegivencharacterviaarotateattribute,thenthegivensupplementalrotationisappliedtothegivencharacter,else(b)nosupplementalrotationoccurs.

如果不设置此属性:(a)如果一个上级文本元素
'text'或者文本块元素'tspan'通过属性rotate为给定的字符设置了附加旋转,则此附加旋转将作用于此字符(最近的上级优先考虑),否则(b)附加旋转不会出现.Iftheattributeisnotspecified:
(a)ifanancestor'text'or

'tspan'elementspecifiesasupplementalrotationforagivencharacterviaarotateattribute,thenthegivensupplementalrotationisappliedtothegivencharacter(nearestancestorhasprecedence),else(b)nosupplementalrotationoccurs.

这种附加旋转并不与图元渲染改变当前文本位置的规则发生冲突并且是对路径上的文本和'水平方向的图元'
或者
'垂直方向的图元'所导致的旋转的补充.Thissupplementalrotationhasnoimpactontherulesbywhichcurrenttextpositionismodifiedas
glyphsgetrenderedandissupplementaltoanyrotationduetotextonapathandto

'glyph-orientation-horizontal'or
'glyph-orientation-vertical'.

Animatable:yes(non-additive,'set'and'animate'elementsonly).

textLength="<长度值>"

此文本元素中对应于所有字符数据的增量的总和的作者的计算值,包括图元(水平或垂直)的增量值,考虑性质
'kerning',
'letter-spacing'和
'word-spacing'的效果以及由于文本块元素'tspan'的属性dx

dy所作的调整.此值用于校准用户代理的计算与作者的计算.Theauthor'scomputationofthetotalsumofalloftheadvancevaluesthatcorrespondtocharacterdatawithinthiselement,includingtheadvancevalueontheglyph(horizontalorvertical),theeffectofproperties'kerning',

'letter-spacing'and
'word-spacing'andadjustmentsduetoattributes
dxand
dyonthis
'tspan'elementoranydescendants.Thisvalueisusedtocalibratetheuseragent'sowncalculationswiththatoftheauthor.

这个属性的目的在于允许作者使得在任何
双向重新排列之后的依照可见的渲染次序,将对应于此元素的第一和最后一个被渲染的图元进行精确的对齐;于是,对于最后渲染的字符而言(在任何
双向重新排列之后的依照可见的渲染次序),当用户代理确定适当的数量以便对文本串进行适当伸缩满足textLength的长度时,正常图元增量之外的附加内部字符之间的空白增量将被忽略(在大多数情况下).Thepurposeofthisattributeistoallowtheauthortoachieveexactalignment,invisualrenderingorderafteranybidirectionalreordering,
forthefirstandlastrenderedglyphsthatcorrespondtothiselement;thus,forthelastrenderedcharacter(invisualrenderingorderafteranybidirectionalreordering),
anysupplementalinter-characterspacingbeyondnormalglyphadvancesareignored(inmostcases)whentheuseragentdeterminestheappropriateamounttoexpand/compressthetextstringtofitwithinalengthoftextLength.

如果一给定的元素及其上级都设置了属性textLength,则此元素上的所有字符数据的调整只由此元素的textLength的值来控制,可能的副作用是此元素的内容的调整比率与共享相同上级的其它内容的调整比率不同.用户代理必须假定在同一上级下的其它内容的整个增量值为上级增量值与此元素的增量值之差.IfattributetextLengthisspecifiedonagivenelementandalsospecifiedonanancestor,theadjustments
onallcharacterdatawithinthiselementarecontrolledbythevalueoftextLengthonthiselementexclusively,withthepossibleside-effectthattheadjustmentratioforthecontentsofthiselementmightbedifferentthantheadjustmentratiousedforother
contentthatsharesthesameancestor.Theuseragentmustassumethatthetotaladvancevaluesfortheothercontentwithinthatancestoristhedifferencebetweentheadvancevalueonthatancestorandtheadvancevalueforthiselement.

一种负值是一种错误(参见
错误处理).Anegativevalueisanerror(see
Errorprocessing).

如果不设置此属性,其效果相当于作者的计算与用户代理的计算完全相等时所出现的情况;于是,无须此时进行进一步的调整.Iftheattributeisnotspecifiedanywherewithina'text'element,the
effectisasiftheauthor'scomputationexactlymatchedthevaluecalculatedbytheuseragent;thus,noadvanceadjustmentsaremade.

Animatable:yes.

其它地方已经定义的属性Attributesdefinedelsewhere:

%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,
dyand
rotateonthe'tspan'elementareusefulinhigh-endtypographyscenarioswhereindividualglyphsrequireexactplacement.Theseattributesareusefulforminorpositioningadjustmentsbetweencharactersorformajorpositioningadjustments,suchasmoving
the
currenttextpositiontoanewlocationtoachievethevisualeffectofanewlineoftext.Multi-line'text'elementsarepossible
bydefiningdifferent'tspan'elementsforeachlineoftext,withattributesx,

y,
dxand/or
dydefiningthepositionofeach'tspan'.(Anadvantageofsuchanapproachisthatuserswillbeabletoperformmulti-linetext
selection.)

在需要微量位置调整的高级排字控制这种情况下,精图内容设计者需要保证必要的字体对所有文档浏览器是可用的(例如,以精图字体的形式将必要的字体数据打包或者存放在精图内容相同的位置上的另一种选择WebFont格式)并且使得浏览软件将按照期望的方式处理这种字体(哪怕各种系统之间的功能、特性以及字体布局机制存在较大的差异).如果精图内容中包含必须通过一套特殊的浏览软件进行处理的特殊字体的属性值x,

y,
dx或者
dy,如果这些要求之一未得到满足,则文本的显示效果较差.Insituationswheremicro-levelpositioningadjustmentarenecessaryforadvancedtypographiccontrol,theSVGcontentdesignerneedstoensurethatthenecessaryfontwillbeavailableforallviewersofthedocument(e.g.,package
upthenecessaryfontdataintheformofanSVGfontoranalternative
WebFontformatwhichisstoredatthesameWebsiteastheSVGcontent)andthattheviewingsoftwarewillprocessthefontintheexpectedway(thecapabilities,characteristicsandfontlayoutmechanismsvarygreatlyfromsystemtosystem).If
theSVGcontentcontains
x,
y,
dxor
dyattributevalueswhicharemeanttocorrespondtoaparticularfontprocessedbyaparticularsetofviewingsoftwareandeitheroftheserequirementsisnotmet,thenthetextmightdisplaywithpoorquality.

下面为包含一个数值列表的属性
x,
y,
dx,
dy和
rotate的附加规则:Thefollowingadditionalrulesapplytoattributes
x,
y,
dx,
dyand
rotatewhentheycontainalistofnumbers:

当单一的XML字符映照到单一的图元时-此时,属性
x,
y,
dx,
dyand
rotate的第i个值用于对应于第i个字符的相应图元.WhenasingleXMLcharactermapstoasingleglyph-Inthiscase,thei-thvalueforthex,

y,
dx,
dyand
rotateattributesisappliedtotheglyphthatcorrespondstothei-thcharacter.
当单一的XML字符映照到多个的图元时(例如,当把重音图元加到一个底部图元的顶部时)-此时,属性
x,
y,
dx和
dy的第i个值在渲染第一个图元之前被使用(即,调整
当前文本位置).相应于第i个
rotate值的旋转变换应用于这些图元相应于这一字符在组基上的内部图元预先值(即,此旋转值创建一个新的旋转坐标系,而对应于字符的图元被渲染到此旋转坐标系).WhenasingleXMLcharactermapstomultipleglyphs(e.g.,whenanaccentglyphisplacedontopofabaseglyph)-Inthiscase,thei-thvalueforthex,

y,
dxand
dyvaluesareapplied(i.e.,the
currenttextpositionisadjusted)beforerenderingthefirstglyph.Therotationtransformationcorrespondingtothei-throtate
valueisappliedtotheglyphsandtotheinter-glyphadvancevaluescorrespondingtothischaracteronagroupbasis(i.e.,therotationvaluecreatesatemporarynewrotatedcoordinatesystem,andtheglyphscorresponding
tothecharacterarerenderedintothisrotatedcoordinatesystem).
当多个的XML字符映照到单一的图元时(例如,当使用连字时)-假定第i个和第i+1个XML字符映照到单个图元.此时,属性
x,
y,
dx,
dy和
rotate的第i个值都被用于渲染此图元.而属性
x,
y,
dx,
dy和
rotate的第i+1个值将被忽略(除非:列表中最后的
rotate值将仍然用于随后的字符),而
dx和
dy被用于随后的XML字符(即,第(i+2)个字符),如果存在,则在渲染与此字符相关的第一个图元之前根据给定的数量变换
当前文本位置.WhenmultipleXMLcharactersmaptoasingleglyph(e.g.,whenaligatureisused)-Supposethatthei-thand(i+1)-thXMLcharactersmaptoasingleglyph.Inthiscase,thei-thvalueforthex,

y,
dx,
dyand
rotateattributesallapplywhenrenderingtheglyph.The(i+1)-thvalues,however,forx,

yand
rotateareignored(exception:thefinal
rotatevalueinthelistwouldstillapplytosubsequentcharacters),whereasthedxand

dyareappliedtothesubsequentXMLcharacter(i.e.,the(i+2)-thcharacter),ifoneexists,bytranslatingthecurrent
textpositionbythegivenamountsbeforerenderingthefirstglyphassociatedwiththatcharacter.
当字符和图元之间为多对多的关系时(例如,当三个字符映照为二个图元时,比如当第一个图元表示第一个字符和第二个字符的一半,而第二个图元表示第二个字符的一半加上第三个字符)-假设第i,第(i+1)和第(i+2)个XML字符映照到两个图元.此时,x,

y,
dxand
dy值的第i个值在渲染第一个图元之前被使用(即,
当前文本位置被调整).对应于第i个
rotate值的旋转变换既用于这两个图元也用于此群组中第一个图元的进一步的值(即,此旋转值创建一个新的临时旋转坐标系,而此两个图元被渲染到这一临时旋转坐标系).而对于属性x,

y和
rotate的第(i+1)个和第(i+2)个值不被使用(例外:列表中最后的
rotate值将仍然用于随后的字符),而属性
dx和
dy的第(i+1)个和第(i+2)个值被用于随后的XML字符(即,第(i+3)个字符),如果存在,则在渲染与此字符相关的第一个图元之前根据给定的数量变换当前文本位置.Whenthereisa
many-to-manymappingofcharacterstoglyphs(e.g.,whenthreecharactersmaptotwoglyphs,suchaswhenthefirstglyphexpressesthefirstcharacterandhalfofthesecondcharacter,andthesecondglyphexpressestheotherhalfofthesecondcharacter
plusthethirdcharacter)-Supposethatthei-th,(i+1)-thand(i+2)-thXMLcharactersmaptotwoglyphs.Inthiscase,thei-thvalueforthex,

y,
dxand
dyvaluesareapplied(i.e.,the
currenttextpositionisadjusted)beforerenderingthefirstglyph.Therotationtransformationcorrespondingtothei-throtate
valueisappliedtoboththetwoglyphsandtheglyphadvancevaluesforthefirstglyphonagroupbasis(i.e.,therotationvaluecreatesatemporarynewrotatedcoordinatesystem,andthetwoglyphsarerenderedintothetemporaryrotatedcoordinatesystem).
The(i+1)-thand(i+2)-thvalues,however,forthe
x,
yand
rotateattributesarenotapplied(exception:thefinal
rotatevalueinthelistwouldstillapplytosubsequentcharacters),whereasthe(i+1)-thand(i+2)-thvaluesforthedx
and
dyattributesareappliedtothesubsequentXMLcharacter(i.e.,the(i+3)-thcharacter),ifoneexists,bytranslatingthecurrent
textpositionbythegivenamountsbeforerenderingthefirstglyphassociatedwiththatcharacter.

双向性的关系-正如下面对双向性的讨论,文本的布局是按两步进行处理的,这里任何双向文本先重新排列为从左到右的字符串,然后按照此重新排列文本字符串进行文本布局.无论何时在一个文本块元素'tspan'
中的字符数据被重新排列,而在
x,
y,
dx,
dy和
rotate中的相应元素也被重新排列以便维持其对应关系.例如,假定有下列文本块元素'tspan':Relationshipto
bidirectionality-Asdescribedbelowinthediscussionon
bidirectionality,textislaidoutinatwo-stepprocess,whereanybidirectionaltextisfirstre-orderedintoaleft-to-rightstring,andthentextlayoutoccurswiththere-orderedtextstring.Wheneverthecharacterdatawithina'tspan'elementis
re-ordered,thecorrespondingelementswithinthe
x,
y,
dx,
dyand
rotatearealsore-orderedtomaintainthecorrespondence.Forexample,supposethatyouhavethefollowing'tspan'element:

·

·<tspandx="111213141502122230313233343536">LatinandHebrew</span>

并且词"Hebrew"将按照从右到左的方式进行绘制.首先,字符数据和
dx中的相应列表值将被重新排列,即文本串将变成"LatinandwerbeH"并且属性dx的列表将变成"111213141502122230363534333231".在这一重新排列之后,
相应于字符的图元将使用标准的从左到右的布局规则来定位.andthattheword"Hebrew"willbedrawnright-to-left.First,thecharacterdataandthecorrespondingvaluesinthedx
listwillbereordered,suchthatthetextstringwillbe"LatinandwerbeH"andthelistofvaluesforthedx
attributewillbe"111213141502122230363534333231".Afterthisre-ordering,theglyphscorrespondingtothecharacterswillbepositionedusingstandardleft-to-rightlayoutrules.

下面的一些例子说明对文本块元素'tspan'的基本使用.
Thefollowingexamplesshowbasicuseofthe'tspan'element.

例子tspan01使用一个文本块元素'tspan'以便说明单词"not"使用粗体并且使用红色填充.Exampletspan01usesa'tspan'elementtoindicatethattheword"not"istouseaboldfontandhaveredfill.


<?xmlversion="1.0"standalone="no"?>

<!DOCTYPEsvgPUBLIC"-//W3C//DTDSVG20010904//EN"

"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">

<svgwidth="10cm"height="3cm"viewBox="001000300"

xmlns="http://www.w3.org/2000/svg">

<desc>Exampletspan01-usingtspantochangevisualattributes</desc>


<gfont-family="Verdana"font-size="45">

<textx="200"y="150"fill="blue">

Youare

<tspanfont-weight="bold"fill="red">not</tspan>

abanana.

</text>

</g>


<!--Showoutlineofcanvasusing'rect'element-->

<rectx="1"y="1"width="998"height="298"

fill="none"stroke="blue"stroke-width="2"/>

</svg>

Exampletspan01
ViewthisexampleasSVG(SVG-enabledbrowsersonly)

例子tspan02使用文本块元素'tspan'的属性

dx和
dy来对一个文本元素'text'中的特定文本字符串分别在水平方向和垂直方向上对当前文本位置
进行调整.Exampletspan02usesthe
dxand
dyattributesonthe'tspan'elementtoadjustthe
currenttextpositionhorizontallyandverticallyforparticulartextstringswithina'text'element.


<?xmlversion="1.0"standalone="no"?>

<!DOCTYPEsvgPUBLIC"-//W3C//DTDSVG20010904//EN"

"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">

<svgwidth="10cm"height="3cm"viewBox="001000300"

xmlns="http://www.w3.org/2000/svg">

<desc>Exampletspan02-usingtspan'sdxanddyattributes

forincrementalpositioningadjustments</desc>


<gfont-family="Verdana"font-size="45">

<textx="200"y="150"fill="blue">

Butyou

<tspandx="2em"dy="-50"font-weight="bold"fill="red">

are

</tspan>

<tspandy="100">

apeach!

</tspan>

</text>

</g>


<!--Showoutlineofcanvasusing'rect'element-->

<rectx="1"y="1"width="998"height="298"

fill="none"stroke="blue"stroke-width="2"/>

</svg>

Exampletspan02
ViewthisexampleasSVG(SVG-enabledbrowsersonly)

例子tspan03使用文本块元素'tspan'的属性

x和
y对每个将被渲染的图元设置一个新的绝对当前文本位置.例子说明在一个单一的文本元素'text'
的文本可以显示成两行.因为两行文本都在同一个文本元素
'text'中,故如果用户代理支持
文本选择和剪贴板操作的话,用户便能够选定两行文本并复制它们到系统剪贴板中.Exampletspan03usesthe
xand
yattributesonthe'tspan'elementtoestablishanewabsolute
currenttextpositionforeachglyphtoberendered.Theexampleshowstwolinesoftextwithinasingle'text'element.Because
bothlinesoftextarewithinthesame
'text'element,theuserwillbeabletoselectthroughbothlinesoftextandcopythetexttothesystemclipboardinuseragentsthatsupporttextselection
andclipboardoperations,


<?xmlversion="1.0"standalone="no"?>

<!DOCTYPEsvgPUBLIC"-//W3C//DTDSVG20010904//EN"

"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">

<svgwidth="10cm"height="3cm"viewBox="001000300"

xmlns="http://www.w3.org/2000/svg">

<desc>Exampletspan03-usingtspan'sxandyattributes

formultilinetextandpreciseglyphpositioning</desc>


<gfont-family="Verdana"font-size="45">

<textfill="rgb(255,164,0)">

<tspanx="300350400450500550600650"y="100">

Cuteand

</tspan>

<tspanx="375425475525575"y="200">

fuzzy

</tspan>

</text>

</g>


<!--Showoutlineofcanvasusing'rect'element-->

<rectx="1"y="1"width="998"height="298"

fill="none"stroke="blue"stroke-width="2"/>

</svg>

Exampletspan03
ViewthisexampleasSVG(SVG-enabledbrowsersonly)

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

一个
'text'的文本内容要么为字符数据直接嵌入文本元素'text'要么为一个引用元素的字符数据内容,这里引用由一个引用元素'tref'来设置.Thetextualcontentfora'text'
canbeeithercharacterdatadirectlyembeddedwithinthe
'text'elementorthecharacterdatacontentofareferencedelement,wherethereferencingisspecifiedwitha'tref'element.


<!ENTITY%trefExt"">

<!ELEMENTtref(desc|title|metadata|animate|set|animateColor

%trefExt;)*>

<!ATTLISTtref

%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
referencetoanelement/fragmentwithinanSVGdocumentfragmentwhosecharacterdatacontentshallbeusedascharacterdataforthis'tref'element.

Animatable:yes.

其它地方已经定义的属性Attributesdefinedelsewhere:

%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.

在一个引用元素内的所有字符数据,包括括在附加标记内的字符数据,将被渲染.Allcharacterdatawithinthereferencedelement,includingcharacterdataenclosedwithinadditionalmarkup,willberendered.

属性
x,
y,
dx,
dy和
rotate与文本块元素'tspan'的相应属性具有相同的意义.所使用的属性就像此引用元素'tref'被一个具有引用字符数据(剥离了所有附加标记)的假定文本块元素'tspan'代替一样.Thex,

y,
dx,
dyand
rotateattributeshavethesamemeaningsasforthe
'tspan'element.Theattributesareappliedasifthe'tref'elementwasreplacedbya'tspan'withthereferencedcharacterdata(strippedofallsupplementalmarkup)embeddedwithinthehypothetical'tspan'element.

例子tref01说明了如何从一个不同的元素中引用字符数据如一个给定文本块元素'tspan'的字符数据.第一个文本元素'text'
(其id="ReferencedText")将不被绘制因为它是一个引用元素
'defs'的一部分.第二个文本元素
'text'绘制字符串"Inlinecharacterdata".第三个文本元素
'text'绘制字符串"Referencecharacterdata"因为它包含一个指向元素"ReferencedText"的引用的引用元素'tref',而此元素的字符数据为"Referencedcharacterdata".Exampletref01showshowtousecharacterdatafromadifferentelementasthecharacterdataforagiven'tspan'element.Thefirst'text'
element(withid="ReferencedText")willnotdrawbecauseitispartofa'defs'element.Thesecond

'text'elementdrawsthestring"Inlinecharacterdata".Thethird
'text'elementdrawsthestring"Referencecharacterdata"becauseitincludesa'tref'elementwhichisareferencetoelement"ReferencedText",andthatelement'scharacterdatais"Referencedcharacterdata".


<?xmlversion="1.0"standalone="no"?>

<!DOCTYPEsvgPUBLIC"-//W3C//DTDSVG20010904//EN"

"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">

<svgwidth="10cm"height="3cm"viewBox="001000300"

xmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink">

<defs>

<textid="ReferencedText">

Referencedcharacterdata

</text>

</defs>

<desc>Exampletref01-inlinevsreferencetextcontent</desc>


<textx="100"y="100"font-size="45"fill="blue">

Inlinecharacterdata

</text>

<textx="100"y="200"font-size="45"fill="red">

<trefxlink:href="#ReferencedText"/>

</text>


<!--Showoutlineofcanvasusing'rect'element-->

<rectx="1"y="1"width="998"height="298"

fill="none"stroke="blue"stroke-width="2"/>

</svg>

Exampletref01
ViewthisexampleasSVG(SVG-enabledbrowsersonly)

10.7文本布局Textlayout

10.7.1文本布局概述Textlayoutintroduction

本节描述精图支持的文本布局特征,这其中包括支持各种各样国际书写方向,比如从左到右(例如,拉丁文本)和双向(例如,希伯来文或阿拉伯文)和垂直方向(例如,亚洲文本)。本节所描述的假定为直线文本(即,文本相对当前用户坐标系要么严格水平要么严格垂直).而随后的章节将描述关于路径上的文本的补充布局规则。This
sectiondescribesthetextlayoutfeaturessupportedbySVG,whichincludessupportforvariousinternationalwritingdirections,suchasleft-to-right(e.g.,Latinscripts)andbidirectional(e.g.,HebreworArabic)andvertical(e.g.,Asianscripts).Thedescriptions
inthissectionassumestraightlinetext(i.e.,textthatiseitherstrictlyhorizontalorverticalwithrespecttothecurrentusercoordinatesystem).Subsequentsectionsdescribethesupplementallayoutrulesfortext
onapath.

精图不提供自动的折行或断词,这使得精图中国际文本的布局相对于支持多行文本块的格式的语言而言是比较简单的。SVGdoesnotprovideforautomaticlinebreaksorwordwrapping,whichmakesinternationalizedtextlayoutforSVGrelativelysimplerthanitisforlanguageswhichsupportformattingofmulti-linetext
blocks.

对于每个文本'text'
元素,精图用户代理确定当前的参考方向.对于标准水平或垂直文本(即,非路径上的文本),参考方向是指向当前用户坐标系的Y轴负无穷的向量方向。(注意:在初始坐标系中,参考方向向上.)对于路径上的文本而言,在每个字符上都会重新设置参考方向。For
each
'text'element,theSVGuseragentdeterminesthecurrentreferenceorientation.Forstandardhorizontalorverticaltext(i.e.,notext-on-a-path),thereferenceorientationisthevectorpointingtowardsnegativeinfinityinYwithinthecurrentusercoordinate
system.(Note:inthe
initialcoordinatesystem,thereferenceorientationisup.)For
textonapath,thereferenceorientationisresetwitheachcharacter.

根据参考方向和特性'writing-mode'的值,精图用户代理确定当前内部-书写-方向.
对于从左到右的文本,内部书写方向指向与参考方向矢量按顺时针方向旋转90度的方向。对于从右到左的文本,内部书写方向指向与参考方向矢量按逆时针方向旋转90度的方向。对于从上到下的文本,内部书写方向指向与参考方向矢量旋转180度的方向。Basedonthereferenceorientationandthevalueforproperty'writing-mode',
theSVGuseragentdeterminesthecurrentinline-progression-direction.Forleft-to-righttext,theinline-progression-directionpoints90degreesclockwisefromthereferenceorientationvector.Forright-to-lefttext,theinlineprogressionpoints90degrees
counter-clockwisefromthereferenceorientationvector.Fortop-to-bottomtext,theinline-progression-directionpoints180degreesfromthereferenceorientationvector.

根据参考方向和特性'writing-mode'的值,精图用户代理确定当前块-书写-方向.对于从左到右和从右到左文本,块-书写-方向指向与参考方向向量180度的方向因为只有两种水平'writing-mode'
为lr-tb和rl-tb可用.对于从上到下文本,块-书写-方向总是指向与参考方向向量逆时针方向90度的方向因为只有一种从上到下'writing-mode'为tb-rl可用。Basedonthereferenceorientationand
thevalueforproperty'writing-mode',theSVGuseragentdeterminesthecurrentblock-progression-direction.Forleft-to-right
andright-to-lefttext,theblock-progression-directionpoints180degreesfromthereferenceorientationvectorbecausetheonlyavailablehorizontal'writing-mode's
arelr-tbandrl-tb.Fortop-to-bottomtext,theblock-progression-directionalwayspoints90degreescounter-clockwisefromthereferenceorientationvectorbecausetheonlyavailabletop-to-bottom'writing-mode'
istb-rl.

由于特性'baseline-shift'取值为正移动方向是朝向基线表
移动的方向.移动方向是这样朝着在父级基线表内最上面的项移动基线表的一种正值.Theshiftdirectionisthedirectiontowardswhichthebaselinetable
movesduetopositivevaluesforproperty
'baseline-shift'.Theshiftdirectionissuchthatapositivevalueshiftsthebaselinetabletowardsthetopmostentryintheparent'sbaseline
table.

在处理一给定的文本'text'
元素时,精图用户代理保持当前文本位置的轨迹。初始的当前文本位置由文本
'text'元素的属性x和y确定。In
processingagiven
'text'element,theSVGuseragentkeepstrackofthecurrenttextposition.Theinitialcurrenttextpositionisestablishedbythex
and
yattributesonthe
'text'element.

在每当构造一个图元之后将对当前文本位置进行调整确定一个用于渲染下一个图元新的当前文本位置。针对当前文本位置的调整是基于当前的内部-书写-方向,相对正被渲染的图元的图元方向特定图元的增量值,当前字体字距调整表和各种各样属性和特性的当前值,比如空白特性
和在'text','tspan',

'tref'或'altGlyph'元素上的任何x,y,

dx和
dy属性。如果一个图元不提供相对当前图元方向的显式增量值,那么将使用一种合适的近似值。对于竖式文本而言,一种推荐的近似值是图元的上升和下降的和。另一种可用于水平和垂直文本的图元增量值的推荐的近似值为一种em的尺寸(参见units-per-em).Thecurrent
textpositionisadjustedaftereachglyphtoestablishanewcurrenttextpositionatwhichthenextglyphshallberendered.Theadjustmenttothecurrenttextpositionisbasedonthecurrentinline-progression-direction,glyph-specific
advancevaluescorrespondingtotheglyphorientationoftheglyphjustrendered,kerningtablesinthefontandthecurrent
valuesofvariousattributesandproperties,suchasthespacingpropertiesandany

x,
y,
dxand
dyattributeson
'text',
'tspan',
'tref'or
'altGlyph'elements.Ifaglyphdoesnotprovideexplicitadvancevaluescorrespondingtothecurrentglyphorientation,
thenanappropriateapproximationshouldbeused.Forverticaltext,asuggestedapproximationisthesumoftheascentanddescentvaluesfortheglyph.Anothersuggestedapproximationforanadvancevalueforbothhorizontalandverticaltextisthesizeof
anem(see
units-per-em).

对于每个将被渲染的图元,精图用户代理确定在图元上一个适当的对齐-点,此图元将被严格安放在当前文本位置上。对齐-点由图元本身的图元小室度量,当前内部-书写-方向
和相对于内部-书写-方向的图元方向所决定。对于用的最多的拉丁文本(即,'writing-mode:lr',

'text-anchor:start',和
'alignment-baseline:baseline')图元中对齐-点为图元小室的左边缘(或某些其它图元特定x-轴坐标表示一种左边的原点)与图元的拉丁基线之交。对于很多从上到下的垂直文本布局的情形,参考点要么为一个基于字体的一套垂直基线的图元特定的原点或者为图元中心与其顶线(参见[CSS2-topline]关于顶线的定义)的交.
如果一个图元不提供相对当前图元方向的显式增量值,那么将使用一种合适的近似值,比如图元的左边缘与图元的适当的水平基线的交或者图元的上边缘与图元的适当的垂直基线的交.如果基线表不可用,用户代理将构建反应通常实际的基线表.Foreach
glyphtoberendered,theSVGuseragentdeterminesanappropriatealignment-pointontheglyphwhichwillbeplacedexactlyatthecurrenttextposition.Thealignment-pointisdeterminedbasedonglyphcellmetricsintheglyphitself,thecurrentinline-progression-directionand
the
glyphorientationrelativetotheinline-progression-direction.FormostusesofLatintext(i.e.,'writing-mode:lr',

'text-anchor:start',and
'alignment-baseline:baseline')thealignment-pointintheglyphwillbetheintersectionofleftedgeoftheglyphcell(orsomeotherglyph-specificx-axiscoordinateindicatingaleft-sideoriginpoint)withtheLatinbaselineoftheglyph.Formanycases
withtop-to-bottomverticaltextlayout,thereferencepointwillbeeitheraglyph-specificoriginpointbasedonthesetofverticalbaselinesforthefontortheintersectionofthecenteroftheglyphwithitstopline(see[CSS2-topline]
foradefinitionoftopline).Ifaglyphdoesnotprovideexplicitoriginpointscorrespondingtothecurrentglyphorientation,
thenanappropriateapproximationshouldbeused,suchastheintersectionoftheleftedgeoftheglyphwiththeappropriatehorizontalbaselinefortheglyphorintersectionofthetopedgeoftheglyphwiththeappropriateverticalbaseline.Ifbaselinetables
arenotavailable,useragentsshouldestablishbaselinetablesthatreflectcommonpractice.

对于当前文本位置的调整量要么为绝对位置调整量
要么为相对位置调整量.绝对位置调整量在下列情形中出现:Adjustmentstothecurrenttextpositionareeitherabsolutepositionadjustmentsorrelativepositionadjustments.Anabsolutepositionadjustmentoccursinthefollowingcircumstances:

在文本'text'元素的开始Atthestartofa'text'
element
在每个文本路径'textPath'元素的开始Atthestartofeach'textPath'
element
对于在具有显式指定x或y
属性值的
'text',
'tspan',
'tref'和
'altGlyph'元素中的每个字符Foreachcharacterwithina
'text',
'tspan',
'tref'and
'altGlyph'elementwhichhasan
xor
yattributevalueassignedtoitexplicitly

所有其它当前文本位置的调整量为相对位置调整量。Allotherpositionadjustmentstothecurrenttextpositionarerelativepositionadjustments.

每个绝对位置调整量定义了一个新的文本块。绝对位置调整量按下列方式影响文本布局:Eachabsolutepositionadjustmentdefinesanewtextchunk.Absolutepositionadjustmentsimpacttextlayoutinthefollowingways:

只有当可以映照到一个连字的一组字符都在此相同的文本块上时连字才出现。Ligaturesonlyoccurwhenasetofcharacterswhichmightmaptoaligatureareallinthesametextchunk.
每个文本块表示文本一个分开的块此块根据特性
'text-anchor'的值进行相应的排列。Eachtextchunkrepresentsaseparateblockoftextforalignmentdueto'text-anchor'property
values.
由于双向性而进行的字符的重新安排仅在一个文本块中进行。在跨文本块之间不发生重新安排。Reorderingofcharactersduetobidirectionality
onlyoccurswithinatextchunk.Reorderingdoesnothappenacrosstextchunks.

下列额外的规则用于连字格式:Thefollowingadditionalrulesapplytoligatureformation:

正如在[CSS2-spacing]一样,当两个字符之间的合成空白与其缺省空白不同时,用户代理不应该使用连字;于是如果特性'kerning'或'letter-spacing'的值不是缺省值时,用户代理不应该使用连字。As
in[CSS2-spacing],whentheresultantspacebetweentwocharactersisnotthesameasthedefaultspace,useragentsshouldnotuseligatures;thus,ifthere
arenon-defaultvaluesforproperties
'kerning'or
'letter-spacing',theuseragentshouldnotuseligatures.
对应于在不同的DOM文本节点上的字符的图元不能使用连字;于是,被标记分开的字符不应该使用连字。LigatureformationshouldnotbeenabledfortheglyphscorrespondingtocharacterswithindifferentDOMtextnodes;thus,charactersseparatedbymarkupshouldnotuseligatures.
正如上面所说,对应于不同文本块的字符的图元不应该使用连字格式。Asmentionedabove,ligatureformationshouldnotbeenabledfortheglyphscorrespondingtocharacterswithindifferenttextchunks.

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

特性'writing-mode'指定文本
'text'元素的初始的内部书写方向为从左到右,从右到左,或者从上到下.特性'writing-mode'只能用于文本
'text'元素上;对于
'tspan',
'tref',
'altGlyph'和'textPath'这些子元素此特性将被忽略.(注意内部书写方向能够在文本'text'
元素内发生改变因为双向性算法和特性'direction'和'unicode-bidi'.
关于双向性文本的更多信息,参见与双向性的关系.)The'writing-mode'propertyspecifieswhethertheinitialinline-progression-direction
fora'text'elementshallbeleft-to-right,right-to-left,ortop-to-bottom.The'writing-mode'propertyappliesonlyto'text'
elements;thepropertyisignoredfor
'tspan',
'tref',
'altGlyph'and
'textPath'sub-elements.(Notethattheinline-progression-directioncanchangewithina'text'elementduetotheUnicodebidirectionalalgorithm
andproperties
'direction'and
'unicode-bidi'.Formoreonbidirectionaltext,see
Relationshipwithbidirectionality.)

'writing-mode'

Value:

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

Initial:

lr-tb

Appliesto:

'text'elements

Inherited:

yes

Percentages:

N/A

Media:

visual

Animatable:

no

lr-tb|lr

设置初始内部书写方向为从左到右,就像通常大多数拉丁式文档所设置的方向一样。对于大多数字符,当前文本位置是在每个图元被渲染之后从左到右进行增加的.(当包含服从Unicode双向性算法的字符的字符数据时,文本增量规则更加复杂.参见与双向性的关系.).Sets
theinitialinline-progression-directiontoleft-to-right,asiscommoninmostLatin-baseddocuments.Formostcharacters,thecurrenttextpositionisadvancedfromlefttorightaftereachglyphisrendered.(Whenthecharacterdataincludescharacters
whicharesubjecttotheUnicodebidirectionalalgorithm,thetextadvancerulesaremorecomplex.SeeRelationshipwith
bidirectionality).

rl-tb|rl

设置初始内部书写方向为从右到左,就像通常阿拉伯或希伯来文本所设置的方向一样。(参见
与双向性的关系.).Setstheinitialinline-progression-directiontoright-to-left,asiscommoninArabicorHebrewscripts.(SeeRelationshipwith
bidirectionality.)

tb-rl|tb

设置初始内部书写方向为从上到下,就像通常某些亚洲文本所设置的方向一样,比如中文和日文。虽然没有象水平方式出现得那么频繁,但是这种形式的垂直布局也出现在拉丁式文档中,特别在表格的行或列的标题上。在大多数情况下,垂直基线贯穿进行排列的每个图元的中间。Setstheinitialinline-progression-directiontotop-to-bottom,asiscommoninsomeAsianscripts,suchasChineseandJapanese.Though
hardlyasfrequentashorizontal,thistypeofverticallayoutalsooccursinLatinbaseddocuments,particularlyintablecolumnorrowlabels.Inmostcases,theverticalbaselinesrunningthroughthemiddleofeachglypharealigned.

10.7.3文本实现中图元的方向Glyphorientationwithinatextrun

在某些情况下,要求改变字符序列相对于内部书写方向的方向。这种要求特别用于远东亚洲文档的垂直布局,而这种文档当中夹杂着拉丁文本时,拉丁文本有时水平显示有时垂直显示。Insomecases,itisrequiredtoaltertheorientationofasequenceofcharactersrelativetotheinline-progression-direction.Therequirementisparticularlyapplicableto
verticallayoutsofEastAsiandocuments,wheresometimesnarrow-cellLatintextistobedisplayedhorizontallyandothertimesvertically.

两个特性控制相对于两种可能的内部书写方向的参考方向的图元方向。当内部书写方向为垂直时'glyph-orientation-vertical'控制图元方向。当内部书写方向为水平时'glyph-orientation-horizontal'控制图元方向。Twopropertiescontroltheglyphorientationrelativetothereferenceorientationforeachofthetwopossibleinline-progression-directions.
'glyph-orientation-vertical'controlsglyphorientationwhentheinline-progression-directionisvertical.'glyph-orientation-horizontal'controlsglyphorientationwhentheinline-progression-directionishorizontal.

'glyph-orientation-vertical'

Value:

auto|
<angle>|
inherit

Initial:

auto

Appliesto:

textcontentelements

Inherited:

yes

Percentages:

N/A

Media:

visual

Animatable:

no

auto

·满宽的表意字和满宽拉丁文将被设置为与图元方向具有0度的方向。FullwidthideographicandfullwidthLatintextwillbesetwithaglyph-orientationof0-degrees.

具有交替的水平和垂直的表意字的标点符号和其它表意字符将使用图元的垂直形式。Ideographicpunctuationandotherideographiccharactershavingalternatehorizontalandverticalformswillusetheverticalformoftheglyph.

·不满宽的文本将被设置为与图元方向具有90度的方向。Textwhichisnotfullwidthwillbesetwithaglyph-orientationof90-degrees.

这种改变方向的规则只适用于第一级非表意文本。所有进一步书写方式的嵌套或双向处理将基于第一级的旋转。Thisreorientationruleappliesonlytothefirst-levelnon-ideographictext.Allfurtherembeddingofwriting-modesorbidiprocessingwillbebasedonthefirst-levelrotation.

注意:NOTE:

o这等价于设置非表意文本串水平遵从双向规则,然后将内部区域(图元方向的每一改变的一种区域)的结果序列顺时针旋转90度。Thisisequivalenttohavingsetthenon-ideographictextstringhorizontallyhonoringthebidi-rule,thenrotatingtheresultantsequenceofinline-areas(oneareaforeachchangeofglyphdirection)
90-degreesclockwise.

注意在这种"旋转"方式的文本设置中也许包括连字或别的图元组合和针对语言和文本的通常的重新排序。(这种"旋转"表示形式不会废止自动连字或类似上下文驱动的变更.)Itshouldbenotedthattextsetinthis"rotated"mannermaycontainligaturesorotherglyphcombiningandreorderingcommontothelanguageandscript.(This"rotated"presentation
formdoesnotdisableauto-ligatureformationorsimilarcontext-drivenvariations.)

o确定哪些字符将进行自动旋转可能依赖于特定的用户代理。此决定基于国家、语言、文本、字符特性、字体和字符上下文之间的复杂的相互作用。建议参考UnicodeTR11和各种JIS或者其它国家标准。Thedeterminationofwhichcharactersshouldbeauto-rotatedmayvaryacrossuseragents.Thedeterminationisbasedonacomplexinteractionbetweencountry,
language,script,characterproperties,font,andcharactercontext.ItissuggestedthatoneconsulttheUnicodeTR11andthevariousJISorothernationalstandards.

<angle>

角度的值限制在0,90,180,和270度。用户代理将角度值调整为最接近的允许值。Thevalueoftheangleisrestrictedto0,90,180,and270degrees.Theuseragentshallroundthevalueoftheangletotheclosestofthepermittedvalues.

值0deg表示将所有图元顶部设置为朝向参考方向的方向。值90deg表示与参考方向顺时针旋转90度的方向。A
valueof0degindicatesthatallglyphsaresetwiththetopoftheglyphsorientedtowardsthereferenceorientation.A
valueof90degindicatesanorientationof90degreesclockwisefromthereferenceorientation.

这一特性只用于在一个垂直
'writing-mode'下的文本的书写Thispropertyisappliedonlytotextwritteninavertical'writing-mode'.

当每个图元被渲染时图元的方向影响当前文本位置的增量。当内部书写方向为垂直并且'glyph-orientation-vertical'的方向角结果为180度的倍数时,那么当前文本位置按照图元的垂直度量进行增加。否则,如果'glyph-orientation-vertical'的方向角结果不是180度的倍数时,那么当前文本位置按照图元的水平度量进行增加。Theglyphorientationaffectstheamountthatthecurrenttextpositionadvances
aseachglyphisrendered.Whentheinline-progression-directionisverticalandthe'glyph-orientation-vertical'resultsinanorientationanglethatisamultipleof180degrees,thenthecurrenttextpositionisincrementedaccordingtotheverticalmetrics
oftheglyph.Otherwise,ifthe'glyph-orientation-vertical'resultsinanorientationanglethatisnotamultipleof180degrees,thenthecurrenttextpositionisincrementedaccordingtothehorizontalmetricsoftheglyph.

在本节中的文本布局图使用下列符号:Thetextlayoutdiagramsinthissectionusethefollowingsymbols:

-宽室图元(例如汉字):表示文本在渲染时的第n个图元wide-cellglyph(e.g.Han)whichisthe
n-thglyphinthetextrun

-窄室图元(例如拉丁字符):表示文本在渲染时的第n个图元narrow-cellglyph(e.g.Latin)whichisthen-thglyphinthetextrun

在上图中的上列符号的方向对应于它们打算表示的Unicode字符当在用户代理中准备进行渲染的方向。在图中的图元之间的间距除非有意改变通常为符号再加一个点。TheorientationwhichtheabovesymbolsassumeinthediagramscorrespondstotheorientationthattheUnicodecharacterstheyrepresentareintendedtoassumewhenrenderedinthe
useragent.Spacingbetweentheglyphsinthediagramsisusuallysymbolic,unlessintentionallychangedtomakeapoint.

下面的图解释了'glyph-orientation-vertical'的不同用法。左图显示当拉丁字符的特性'glyph-orientation-vertical'设置为auto或90时宽室表意图元与窄室拉丁图元的结果。右图显示当拉丁字符的特性'glyph-orientation-vertical'设置为0时宽室表意图元与窄室拉丁图元的结果。Thediagramsbelowillustratedifferentusesof'glyph-orientation-vertical'.Thediagram
ontheleftshowstheresultofthemixingoffull-widthideographicglyphswithnarrow-cellLatinglyphswhen'glyph-orientation-vertical'fortheLatincharactersiseitherautoor90.Thediagramontherightshowtheresultofmixingfull-widthideographic
glyphswithnarrow-cellLatinglyphswhenLatinglyphsarespecifiedtohavea'glyph-orientation-vertical'of0.

'glyph-orientation-horizontal'

Value:

<angle>|inherit

Initial:

0deg

Appliesto:

textcontentelements

Inherited:

yes

Percentages:

N/A

Media:

visual

Animatable:

no

<angle>

角度的值限制在0,90,180,和270度。用户代理将角度值调整为最接近的允许值。Thevalueoftheangleisrestrictedto0,90,180,and270degrees.Theuseragentshallroundthevalueoftheangletotheclosestofthepermittedvalues.

值0deg表示将所有图元顶部设置为朝向参考方向的方向。值90deg表示与参考方向顺时针旋转90度的方向。A
valueof0degindicatesthatallglyphsaresetwiththetopoftheglyphsorientedtowardsthereferenceorientation.A
valueof90degindicatesanorientationof90degreesclockwisefromthereferenceorientation.

这一特性只用于在一个水平
'writing-mode'下的文本的书写Thispropertyisappliedonlytotextwritteninahorizontal'writing-mode'.

当每个图元被渲染时图元的方向影响当前文本位置的增量。当参考方向为水平并且'glyph-orientation-horizontal'的方向角结果为180度的倍数时,那么当前文本位置按照图元的水平度量进行增加。否则,如果'glyph-orientation-horizontal'的方向角结果不是180度的倍数时,那么当前文本位置按照图元的垂直度量进行增加。Theglyphorientationaffectstheamountthatthecurrenttextpositionadvances
aseachglyphisrendered.Whenthereferenceorientationdirectionishorizontalandthe'glyph-orientation-horizontal'resultsinanorientationanglethatisamultipleof180degrees,thenthecurrenttextpositionisincrementedaccordingtothehorizontal
metricsoftheglyph.Otherwise,ifthe'glyph-orientation-horizontal'resultsinanorientationanglethatisnotamultipleof180degrees,thenthecurrenttextpositionisincrementedaccordingtotheverticalmetricsoftheglyph.

10.7.4与双向性的关系Relationshipwithbidirectionality

在某些文本中的字符是从右到左书写的。在某些文档中,特别是那些用阿拉伯或希伯来文书写的文本,和在某些混合语言上下文中,在一行当中的文本可能呈现混合的方向性。这种现象称之为双向性,或简短地"bidi"。Thecharactersincertainscriptsarewrittenfromrighttoleft.Insomedocuments,inparticularthosewrittenwiththeArabicorHebrewscript,andin
somemixed-languagecontexts,textinasinglelinemayappearwithmixeddirectionality.Thisphenomenoniscalledbidirectionality,or"bidi"forshort.

Unicode标准([UNICODE],章节3.11)为文本的合适的双向性定义了一种复杂的算法.此算法由基于字符特性的隐含部分和针对嵌入和覆盖的显式控制两部分组成.精图用户代理当确定一文本'text'
元素中的字符的布局时应用这一双向性算法.特性
'direction'和'unicode-bidi'允许作者取代从内容字符继承的方向性从而显式地控制文档语言的元素和属性如何映照到这一算法.对于那些与内部书写方向正交的图元,这两个特性是可以使用的.TheUnicodestandard
([UNICODE],section3.11)definesacomplexalgorithmfordeterminingtheproperdirectionalityoftext.Thealgorithmconsistsofanimplicitpartbasedoncharacter
properties,aswellasexplicitcontrolsforembeddingsandoverrides.TheSVGuseragentappliesthisbidirectionalalgorithmwhendeterminingthelayoutofcharacterswithina

'text'element.The
'direction'and
'unicode-bidi'propertiesallowauthorstooverridetheinherentdirectionalityofthecontentcharactersandthusexplicitlycontrolhowtheelementsandattributesofadocumentlanguagemaptothisalgorithm.Thesetwopropertiesareapplicabletoallcharacters
whoglyphsareperpendiculartotheinline-progression-direction.

在大多数情况下,[UNICODE]提供的双向算法自动产生期望的结果,并且完全取代此算法通常是相当的复杂。因此在大多数情况下劝阻作者不要为这些特性指派特定的值。Inmostcases,thebidirectionalalgorithmfrom[UNICODE]
producesthedesiredresultautomatically,andoverridingthisalgorithmproperlyisusuallyquitecomplex.Therefore,inmostcases,authorsarediscouragedfromassigningvaluestotheseproperties.

可以在"级联样式表(CSS)级别2"规范[CSS2-direction]中找到双向性更完整的讨论。Amorecompletediscussionofbidirectionalitycanbefoundinthe"CascadingStyleSheets(CSS)level2"
specification[CSS2-direction].

双向文本的处理模型如下所述.用户代理处理按逻辑顺序(即,出现在原始文档内的字符的顺序,要么通过直接的包含或者通过一个引用
'tref'元素间接引用)提供的字符.用户代理确定一组独立的文本块,而这每个文本块上将应用Unicode双向性算法.每个
文本块代表文本的一个独立的块.另外,由于对特性'glyph-orientation-horizontal'或'glyph-orientation-vertical'的处理所导致的图元方向的改变会进一步细分独立的文本块.
在处理Unicode双向性算法和每个独立文本块上的特性'direction'和'unicode-bidi'
之后,用户代理现在获得了一个可以从左到右进行渲染的重新定序的字符列表.在字符被重新定序的同时,在
'tspan'和'tref'元素上的属性dx,dy

rotate也被重新定序以便保持原来字符和属性值之间的对应关系.然而字距调整或连字处理也许与字符相关的,首选的模型是在字符串被重新定序之后再处理字符或图元的组合之间出现的字距调整和连字.Theprocessingmodelforbidirectionaltextisasfollows.Theuseragentprocessesthecharacterswhichareprovidedinlogicalorder(i.e.,
theorderthecharactersappearintheoriginaldocument,eitherviadirectinclusionorviaindirectreferenceduea'tref'element).
TheuseragentdeterminesthesetofindependentblockswithineachofwhichitshouldapplytheUnicodebidirectionalalgorithm.Eachtext
chunkrepresentsanindependentblockoftext.Additionally,anychangeinglyphorientationduetoprocessingofproperties'glyph-orientation-horizontal'
or
'glyph-orientation-vertical'willsubdividetheindependentblocksoftextfurther.AfterprocessingtheUnicodebidirectionalalgorithmandproperties'direction'
and
'unicode-bidi'oneachoftheindependenttextblocks,theuseragentwillhaveapotentiallyre-orderedlistofcharacterswhicharenowinleft-to-rightrenderingorder.Simultaneouswithre-orderingofthecharacters,thedx,

dyand
rotateattributesonthe
'tspan'and
'tref'elementsarealsore-orderedtomaintaintheoriginalcorrespondencebetweencharactersandattributevalues.Whilekerningorligatureprocessingmightbefont-specific,thepreferredmodelisthatkerningandligatureprocessingoccursbetweencombinations
ofcharactersorglyphsafterthecharactershavebeenre-ordered.

'direction'

Value:

ltr|rtl|
inherit

Initial:

ltr

Appliesto:

textcontentelements

Inherited:

yes

Percentages:

N/A

Media:

visual

Animatable:

no

此特性指定文本的基础书写方向和针对Unicode双向算法的嵌入和覆盖(参见
'unicode-bidi')的方向。为了对特性'direction'产生任何影响,特性'unicode-bidi'的值必须为'embed'或'bidi-override'.Thispropertyspecifies
thebasewritingdirectionoftextandthedirectionofembeddingsandoverrides(see

'unicode-bidi')fortheUnicodebidirectionalalgorithm.Forthe'direction'propertytohaveanyeffect,the'unicode-bidi'
property'svaluemustbe'embed'or'bidi-override'.

除了在此规范中提供的附加信息外,此特性的正式定义出现在[CSS2-direction]中.Exceptforanyadditionalinformationprovidedinthisspecification,thenormativedefinitionofthe
propertyisin[CSS2-direction].

特性'direction'只用于方向与内部-书写-方向正交的图元,它包含水平方向的拉丁或阿拉伯文本这种通常情况和相对于一个从上到下内部书写方向顺时针旋转90度的狭窄的小室拉丁或阿拉伯字符的这种情况。The
'direction'propertyappliesonlytoglyphsorientedperpendiculartothe
inline-progression-direction,whichincludestheusualcaseofhorizontally-orientedLatinorArabictextandthecaseofnarrow-cellLatinorArabiccharactersrotated90degreesclockwiserelativetoatop-to-bottominline-progression-direction.

'unicode-bidi'

Value:

normal|embed|bidi-override|
inherit

Initial:

normal

Appliesto:

textcontentelements

Inherited:

no

Percentages:

N/A

Media:

visual

Animatable:

no

除了在此规范中提供的附加信息外,此特性的正式定义出现在[CSS2-unicode-bidi]中.Exceptforanyadditionalinformationprovidedinthisspecification,thenormativedefinitionof
thepropertyisin[CSS2-unicode-bidi].

10.8文本渲染次序Textrenderingorder

在一个文本
'text'元素内的字符所关联的图元按照文档中字符的逻辑顺序进行渲染,而不考虑为了实现双向性所需要进行的重定序。于是,对于视觉上从右到左的文本,最右边的字符所对应的图元在与其它字符相对应的图元之前被渲染。Theglyphsassociatedwiththecharacterswithina'text'
elementarerenderedinthelogicalorderofthecharactersintheoriginaldocument,independentofanyre-orderingnecessarytoimplementbidirectionality.Thus,fortextthatgoesright-to-leftvisually,theglyphsassociatedwiththerightmostcharacterare
renderedbeforetheglyphsassociatedwiththeothercharacters.

另外,每个独特的图元在下一个图元得以渲染之前进行所有的渲染(即,按照特性
'fill'和'stroke'所指定方式进行填充和描边)。Additionally,eachdistinctglyphisrenderedinitsentirety(i.e.,itisfilledand
strokedasspecifiedbythe
'fill'and
'stroke'properties)beforethenextglyphgetsrendered.

10.9对齐特性Alignmentproperties

10.9.1文本对齐特性Textalignmentproperties

特性'text-anchor'被用来相对于一给定点对文本串进行对齐(开始-,中间-或结束-对齐)The'text-anchor'propertyisusedtoalign(start-,middle-orend-alignment)astringoftextrelativetoagivenpoint.

特性'text-anchor'用于一给定文本
'text'元素中的每个独立的文本块.每个文本块有一个初始的当前文本位置,它表示用户坐标系中的点,此点由文本'text'元素的属性x
y的应用所产生(依赖于上下文),在一个

'tspan',
'tref'或'altGlyph'元素上的任何x

y的属性值直接指派给在文本块中的第一个渲染字符,或者确定一个文本路径
'textPath'元素的初始当前文本位置.The'text-anchor'propertyisappliedtoeachindividualtextchunkwithinagiven

'text'element.Eachtextchunkhasaninitialcurrenttextposition,whichrepresentsthepointintheusercoordinatesystemresultingfrom(dependingoncontext)applicationofthex
and
yattributesonthe
'text'element,any
xor
yattributevaluesona
'tspan',
'tref'or
'altGlyph'elementassignedexplicitlytothefirstrenderedcharacterinatextchunk,ordeterminationoftheinitialcurrenttextpositionfora'textPath'
element.

'text-anchor'

Value:

start|middle|end|
inherit

Initial:

start

Appliesto:

textcontentelements

Inherited:

yes

Percentages:

N/A

Media:

visual

Animatable:

yes

值具有下列意义:Valueshavethefollowingmeanings:

start

被渲染的字符被对齐使得文本串的开始处位于初始的当前文本位置。对于常常水平渲染的拉丁文或阿拉伯文,这等同于左对齐。对于具有垂直主文本方向的亚洲文本,这等同于上对齐。Therenderedcharactersarealignedsuchthatthestartofthetextstringisattheinitialcurrenttextposition.ForLatinorArabic,whichisusuallyrenderedhorizontally,
thisiscomparabletoleftalignment.ForAsiantextwithaverticalprimarytextdirection,thisiscomparabletotopalignment.

middle

被渲染的字符被对齐使得文本串的中部处位于当前文本位置。(对于
路径上的文本,概念上说文本串首先被安置在直线上。在文本串的开始处和文本串的结束处之间的中点被确定.然后,文本串被映照到此路径上,而此路径的中点置于当前文本位置上.)Therenderedcharactersarealignedsuchthatthemiddleofthetextstringisatthecurrenttextposition.(Fortext
onapath,conceptuallythetextstringisfirstlaidoutinastraightline.Themidpointbetweenthestartofthetextstringandtheendofthetextstringisdetermined.Then,thetextstringismappedontothepathwiththismidpointplacedatthecurrent
textposition.)

end

被渲染的字符被对齐使得文本串的结束处位于初始的当前文本位置。对于平常方向的拉丁文,这等同于右对齐。Therenderedcharactersarealignedsuchthattheendofthetextstringisattheinitialcurrenttextposition.ForLatintextinitsusualorientation,thisiscomparabletorightalignment.

10.9.2基线对齐特性Baselinealignmentproperties

基线对齐和基线表可以在以前的字体,字体表和基线中找到。AnoverviewofbaselinealignmentandbaselinetablescanbefoundaboveinFonts,
fonttablesandbaselines.

国际文本的特征之一是在不同的文本中的图元具有不同放入基线(不同的对齐点)。例如水平书写的表意文本比如汉字、片假名、平假名和Hangul,对齐出现在接近图元的底部的基线;而对于基于字母的文本,比如拉丁文、斯拉夫文、希伯来文、阿拉伯文,按照大多数图元的底部进行对齐,而有些图元部分在基线的下面;印度语系的文本按接近图元的顶部进行对齐。Oneofthecharacteristicsofinternationaltextisthattherearedifferentbaselines
(differentalignmentpoints)forglyphsindifferentscripts.Forexample,inhorizontalwriting,ideographicscripts,suchasHanIdeographs,Katakana,Hiragana,andHangul,alignmentoccurswithabaselinenearthebottomsoftheglyphs;alphabeticbasedscripts,
suchasLatin,Cyrillic,Hebrew,Arabic,alignapointthatisthebottomofmostglyphs,butsomeglyphsdescendbelowthebaseline;andIndicbasedscriptsarealignedatapointthatisnearthetopoftheglyphs.

当一行文本中混合了各种不同的文本时,必须做必要的调整以保证在不同文本中的图元能够相互正确地对齐。OpenType[OPENTYPE]字体基线表(BASE)[OPENTYPE-BASETABLE]规定了替换基线与当前基线的偏移量.When
differentscriptsaremixedonalineoftext,anadjustmentmustbemadetoensurethattheglyphsinthedifferentscriptsarealignedcorrectlywithoneanother.OpenType[OPENTYPE]fonts
haveaBaselinetable(BASE)[OPENTYPE-BASETABLE]thatspecifiestheoffsetsofthealternativebaselinesfromthecurrentbaseline.

精图使用一种类似的基线表模型假定一种文本(具有相同的字体尺寸)在一个文本
'text'元素的处理期间是"支配运行"的,即所有其它基线是相对于此支配运行文本进行定义的。具有支配运行的文本的基线称之为支配基线。因此,例如,如果支配基线为字母基线,那么对于替换基线比如表意基线或印度基线而言在基线表中存在一种偏移量。对于某些使用了数学字体的数学基线也存在偏移量。注意对于水平和垂直书写方向而言存在分开的基线表。在这些水平或垂直书写方向上的表中的偏移量可以是不同的。SVGusesasimilarbaselinetablemodelthatassumesonescript
(atonefont-size)isthe"dominantrun"duringprocessingofaelement;thatis,allotherbaselinesaredefinedinrelationtothisdominantrun.Thebaselineofthescriptwiththedominantruniscalledthedominantbaseline.So,forexample,ifthedominantbaseline
isthealphabeticbaseline,therewillbeoffsetsinthebaselinetableforthealternatebaselines,suchastheideographicbaselineandtheIndicbaseline.Therewillalsobeanoffsetforthemathbaselinewhichisusedforsomemathfonts.Notethatthere
areseparatebaselinetablesforhorizontalandverticalwriting-modes.Theoffsetsinthesetablesmaybedifferentforhorizontalandverticalwriting.

在文本
'text'元素处理开始时所建立的基线表称之为支配基线表。Thebaselinetableestablishedatthestartofprocessingofa'text'elementiscalledthedominant
baselinetable.

因为特性'font-family'的值是字体的列表,为了确保一种对基线表的一致的选择,我们在一个字体列表中定义挂名字体作为此字体列表中的第一种其图元可用的字体。这是能够对于遇到的每一个字符都包含相应的图元的第一个字体。(对于这种定义,如果进行字体替换或此字体被合成时图元数据被假定是现成的.)
这一定义保证了将被使用的字体和基线表的选择与内容是不相关的。Becausethevalueofthe
'font-family'propertyisalistoffonts,toinsureaconsistentchoiceofbaselinetablewedefinethenominalfontinafontlistasthefirstfontinthelistforwhichaglyphisavailable.Thisisthefirst
fontthatcouldcontainaglyphforeachcharacterencountered.(Forthisdefinition,glyphdataisassumedtobepresentifafontsubstitutionismadeorifthefontissynthesized.)Thisdefinitioninsuresacontentindependentdeterminationofthefontand
baselinetablethatistobeused.

在文本
'text'元素上的特性'font-size'确定了支配基线表字体尺寸.Thevalueofthe'font-size'
propertyonthe
'text'elementestablishesthedominantbaselinetablefontsize.

模型假定每个图元具有一种'alignment-baseline'值此值规定了对齐图元所用的基线.('在OpenType基线表描述中alignment-baseline'被称之为"BaselineTag".)特性'alignment-baseline'
的初始值使用与给定图元相关的基线标识符.'alignment-baseline'的各种取值对于那些关于文本成员是模糊的比如"*"是可能有用的.The
modelassumesthateachglyphhasa'alignment-baseline'valuewhichspecifiesthebaselinewithwhichtheglyphistobealigned.(The'alignment-baseline'iscalledthe"BaselineTag"intheOpenTypebaselinetabledescription.)Theinitialvalueofthe'alignment-baseline'
propertyusesthebaselineidentifierassociatedwiththegivenglyph.Alternatevaluesfor'alignment-baseline'
canbeusefulforglyphssuchasa"*"whichareambiguouswithrespecttoscriptmembership.

模型假设将被绘制的图元的字体也具有一种基线表,字体基线表.此基线表具有从点(0,0)到所知道的字体的每个基线的以为units-per-em单位的偏移量.特别,它具有从图元的点(0,0)到由'alignment-baseline'所指定的基线的偏移量.Themodelassumesthatthefontfromwhichtheglyphisdrawnalsohasabaselinetable,thefontbaselinetable.Thisbaseline
tablehasoffsetsinunits-per-emfromthe(0,0)pointtoeachofthebaselinesthefontknowsabout.Inparticular,ithastheoffsetfromtheglyph's(0,0)pointtothebaselineidentifiedbythe'alignment-baseline'.

在基线表中的偏移量值是按照EM的百分比单位即"designunits"来表示的.CSS调用这些"units-per-em"[CSS2-UNITSPEREM].于是,当前的'font-size'
用来确定从支配基线到调整基线的实际偏移量.Theoffsetvaluesinthebaselinetablearein"designunits"whichmeansfractionalunitsoftheEM.CSScallsthese"units-per-em"[CSS2-UNITSPEREM].Thus,
thecurrent
'font-size'isusedtodeterminetheactualoffsetfromthedominantbaselinetothealternatebaselines.

图元被对齐使得由它的'alignment-baseline'所指定的基线与支配基线表中相同名字的基线进行对齐。Theglyphisalignedsothatitsbaselineidentifiedbyits'alignment-baseline'isalignedwiththebaselinewiththesamenamefromthedominantbaselinetable.

从祖先的支配基线到由指定的基线之间的偏移量通过支配基线表和支配基线表字体尺寸来计算。字体基线表和可用于图元的字体尺寸用来计算从指定的基线到图元的点(0,0)的偏移量。第二种偏移值从第一种偏移值中减掉得到在平移方向中的点(0,0)的位置。两种偏移量通过由基线表乘以适当的字体尺寸所得出的基线值相乘来计算。
Theoffsetfromthedominantbaselineoftheparenttothebaselineidentifiedbythe'alignment-baseline'iscomputedusingthedominantbaselinetableanddominantbaselinetablefontsize.Thefontbaselinetableandfontsizeapplicabletotheglyphareused
tocomputetheoffsetfromtheidentifiedbaselinetothe(0,0)pointoftheglyph.Thissecondoffsetissubtractedfromthefirstoffsettogetthepositionofthe(0,0)pointintheshift
direction.Bothoffsetsarecomputedbymultiplyingthebaselinevaluefromthebaselinetabletimestheappropriatefontsizevalue.

如果'alignment-baseline'指定支配基线,那么第一种偏移量为零并且图元与此支配基线对齐;否则图元与所选的替换基线对齐。Ifthe'alignment-baseline'identifiesthedominantbaseline,thenthefirstoffsetiszeroandtheglyphisalignedwiththedominantbaseline;otherwise,theglyphisalignedwiththechosen
alternatebaseline.

在此规范中使用下列基线标识符。其中一些由包含在一种如在[XSLdescriptionofFontsandFontData]中所描述的字体中的基线表所确定。其它的由如下所述的其它字体特征来计算。Thebaseline-identifiersbelowareusedin
thisspecification.Someofthesearedeterminedbybaseline-tablescontainedinafontasdescribedin[XSLdescriptionofFontsandFontData].Others
arecomputedfromotherfontcharacteristicsasdescribedbelow.

alphabetic

这指定由大多数字母和音节文本所使用的基线。这些文本包括但不限于许多西方的、南印度的、南亚(非-表意)文本。Thisidentifiesthebaselineusedbymostalphabeticandsyllabicscripts.Theseinclude,butarenotlimitedto,manyWestern,SouthernIndic,SoutheastAsian(non-ideographic)scripts.

ideographic

这指定由表意文本所使用的基线。由于历史的原因,这种基线位于表意EM框的底部而不在表意EM框的中心。参见"central"基线。表意文本包括中文、日文、朝鲜文和越南文。Thisidentifiesthebaselineusedbyideographicscripts.Forhistoricalreasons,thisbaselineisatthebottomoftheideographicEMboxandnotinthecenteroftheideographic
EMbox.Seethe"central"baseline.TheideographicscriptsincludeChinese,Japanese,Korean,andVietnameseChuNom.

hanging

这指定由某些印度文所使用的基线。这些文本包括梵文、果鲁穆奇文和孟加拉文。ThisidentifiesthebaselineusedbycertainIndicscripts.ThesescriptsincludeDevanagari,GurmukhiandBengali.

mathematical

这指定由数学符号所使用的基线。Thisidentifiesthebaselineusedbymathematicalsymbols.

central

这指定一种位于EM框中心的计算基线。这种基线位于text-before-edge和text-before-edge基线的中间。ThisidentifiesacomputedbaselinethatisatthecenteroftheEMbox.Thisbaselinelieshalfwaybetweenthetext-before-edgeandtext-after-edgebaselines.

注意:NOTE:

对于表意字体而言,这种基线常常用于对齐图元;它是表意基线的一种代替基线。Forideographicfonts,thisbaselineisoftenusedtoaligntheglyphs;itisanalternativetotheideographicbaseline.

middle

这指定一种在shift-direction上与alphabetic基线的偏移量为字体特征x-height的1/2的基线。这一基线的位置可以从字体数据中得到,或者对于具有"x-height"字体特征的字体来说,可以使用"x-height"的1/2来计算。如果缺乏这些信息,基线的位置可以由"central"基线来近似。Thisidentifiesabaselinethatisoffsetfromthealphabeticbaselineintheshift-direction
by1/2thevalueofthex-heightfontcharacteristic.Thepositionofthisbaselinemaybeobtainedfromthefontdataor,forfontsthathaveafontcharacteristicfor"x-height",itmaybecomputedusing1/2the"x-height".Lackingeitherofthesepiecesof
information,thepositionofthisbaselinemaybeapproximatedbythe"central"baseline.

text-before-edge

这指定EM框的前-边。这一基线的位置可以通过基线表来指定或通过计算得到。Thisidentifiesthebefore-edgeoftheEMbox.Thepositionofthisbaselinemaybespecifiedinthebaseline-tableoritmaybecalculated.

注意:NOTE:

这一基线的位置通常在高于x小写字母的顶部或附近,但是它也许不包含所有可能出现在图元上方的重音。对于这些字体"ascent"字体特征的值被使用。对于表意字体,这一基线的位置通常在"ideographic"基线上在shift-direction.上1个EM处。但是,某些表意字体在内部书写方向上具有减少的宽度允许较紧的设置。当设计用于垂直书写模式的字体用于水平书写模式时,"text-before-edge"基线也许比text-after-edge基线少1EM。Theposition
ofthisbaselineisnormallyaroundoratthetopoftheascenders,butitmaynotencompassallaccentsthatcanappearaboveaglyph.Forthesefontsthevalueofthe"ascent"fontcharacteristicisused.Forideographicfonts,thepositionofthisbaseline
isnormally1EMintheshift-directionfromthe"ideographic"baseline.However,someideographicfontshaveareducedwidthintheinline-progression-directiontoallowtightersetting.Whensuchafont,designedonlyforverticalwriting-modes,
isusedinahorizontalwriting-mode,the"text-before-edge"baselinemaybelessthan1EMfromthetext-after-edge.

text-after-edge

这指定EM框的后-边。这一基线的位置可以通过基线表来指定或通过计算得到。Thisidentifiestheafter-edgeoftheEMbox.Thepositionofthisbaselinemaybespecifiedinthebaseline-tableoritmaybecalculated.

注意:NOTE:

对于作为下标的字体,这一基线通常在字母下部的底部或其附近。对于这些字体"descent"字体特征的值被使用。对于表意字体,这一基线的位置通常在"ideographic"基线上.Forfontswithdescenders,thepositionofthisbaselineisnormallyaroundoratthebottomofthedescenders.Forthesefontsthevalueofthe"descent"fontcharacteristic
isused.Forideographicfonts,thepositionofthisbaselineisnormallyatthe"ideographic"baseline.

另外,存在只对线区域定义的两种计算基线。由于精图不支持基于线区域的计算概念,故这两种计算基线映照如下:Thereare,inaddition,twocomputedbaselinesthatareonlydefinedforlineareas.SinceSVGdoesnotsupportthenotionofcomputationsbasedonlineareas,thetwocomputedbaselinesaremappedasfollows:

before-edge

对于精图而言,这等价于text-before-edge.ForSVG,thisisequivalentto
text-before-edge
.

after-edge

对于精图而言,这等价于text-after-edge.ForSVG,thisisequivalentto
text-after-edge
.

同样存在只对水平书写模式进行定义的四种基线。Therearealsofourbaselinesthataredefinedonlyforhorizontalwriting-modes.

top

在水平书写模式下这一基线与"before-edge"基线相同并且在垂直书写模式下无定义。Thisbaselineisthesameasthe"before-edge"baselineinahorizontalwriting-modeandisundefinedinaverticalwritingmode.

text-top

在水平书写模式下这一基线与"text-before-edge"基线相同并且在垂直书写模式下无定义。Thisbaselineisthesameasthe"text-before-edge"baselineinahorizontalwriting-modeandisundefinedinaverticalwritingmode.

bottom

在水平书写模式下这一基线与"after-edge"基线相同并且在垂直书写模式下无定义。Thisbaselineisthesameasthe"after-edge"baselineinahorizontalwriting-modeandisundefinedinaverticalwritingmode.

text-bottom

在水平书写模式下这一基线与"text-after-edge"基线相同并且在垂直书写模式下无定义。Thisbaselineisthesameasthe"text-after-edge"baselineinahorizontalwriting-modeandisundefinedinaverticalwritingmode.

基线对齐特性如下。Thebaseline-alignmentpropertiesfollow.

'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

Appliesto:

textcontentelements

Inherited:

no

Percentages:

N/A

Media:

visual

Animatable:

yes

特性用于确定或重确定一个比例基线表。一个比例基线表为三种分量的合成值:针对支配基线的一个基线标识符,一个基线表和一个基线表字体尺寸。此特性的某些值重新确定所有这三个值;而其它的只重确定基线表字体尺寸。当初始值,"auto",给出一种不期望的结果时,这一特性用于明确地设置所期望的比例基线表。The"dominant-baseline"propertyisusedtodetermineorre-determineascaled-baseline-table.Ascaled-baseline-table
isacompoundvaluewiththreecomponents:abaseline-identifierforthedominant-baseline,abaseline-tableandabaseline-tablefont-size.Somevaluesofthepropertyre-determineallthreevalues;otheronlyre-establishthebaseline-tablefont-size.Whenthe
initialvalue,"auto",wouldgiveanundesiredresult,thispropertycanbeusedtoexplicitlysetthedesirescaled-baseline-table.

此特性的值具有下列意义:Valuesforthepropertyhavethefollowingmeaning:

auto

如果这一特性在一个文本'text'元素上出现,那么此计算值依赖于特性'writing-mode'
的值。如果'writing-mode'为水平,那么dominant-baseline分量的值为'alphabetic',否则如果'writing-mode'为垂直,那么dominant-baseline分量的值为'central'.Ifthispropertyoccursona'text'
element,thenthecomputedvaluedependsonthevalueofthe
'writing-mode'property.Ifthe'writing-mode'ishorizontal,thenthevalueofthedominant-baselinecomponentis'alphabetic',elseifthe'writing-mode'isvertical,thenthevalueofthedominant-baselinecomponent
is'central'.

如果这一特性在一个'tspan','tref',

'altGlyph'或'textPath'元素上出现,那么dominant-baseline和baseline-table分量保持与上级文本内容元素相同。如果的'baseline-shift'
计算值实际上平移了基线,那么基线表字体尺寸分量被设置为出现特性
'dominant-baseline'的元素上的特性
'font-size'的值,否则基线表字体尺寸保持与元素的相同。如果无上级文本内容元素,比例基线表值同上述文本'text'
元素一样构造。Ifthispropertyoccursona
'tspan',
'tref',
'altGlyph'or
'textPath'element,thenthedominant-baselineandthebaseline-tablecomponentsremainthesameasthoseoftheparenttextcontent
element.Ifthecomputed'baseline-shift'valueactuallyshiftsthebaseline,thenthebaseline-tablefont-sizecomponentissettothevalueofthe'font-size'
propertyontheelementonwhichthe'dominant-baseline'propertyoccurs,otherwise
thebaseline-tablefont-sizeremainsthesameasthatoftheelement.Ifthereisnoparenttextcontentelement,the
scaled-baseline-tablevalueisconstructedasabovefor'text'elements.

use-script

dominant-baseline和baseline-table分量由字符数据内容中所确定的主要脚本来设置。'writing-mode'无论为水平还是垂直都被用来选择适当的一组baseline-table和用来选择对应于基线的基线表的支配基线。baseline-tablefont-size分量被设置成出现特性'dominant-baseline'
的元素的特性
'font-size'的值。Thedominant-baselineandthebaseline-tablecomponentsaresetbydeterminingthepredominantscriptofthecharacterdatacontent.The'writing-mode',whetherhorizontalorvertical,isusedtoselect
theappropriatesetofbaseline-tablesandthedominantbaselineisusedtoselectthebaseline-tablethatcorrespondstothatbaseline.Thebaseline-tablefont-sizecomponentissettothevalueofthe'font-size'
propertyontheelementonwhichthe'dominant-baseline'propertyoccurs.

no-change

dominant-baseline,baseline-table和baseline-tablefont-size分量保持与上级文本内容元素相同。Thedominant-baseline,thebaseline-table,
andthebaseline-tablefont-sizeremainthesameasthatoftheparent
textcontentelement.

reset-size

dominant-baseline和baseline-table保持相同,而baseline-tablefont-size改变成这一元素上特性
'font-size'的值.这根据当前
'font-size'重新计算比例baseline-table.Thedominant-baselineandthebaseline-tableremainthesame,butthebaseline-tablefont-sizeischangedtothevalueofthe'font-size'
propertyonthiselement.Thisre-scalesthebaseline-tableforthecurrent'font-size'.

alphabetic

dominant-baseline的基线标识符被设置为'alphabetic',通过使用在挂名字体中的'alphabetic'基线表来构造导出的基线表,而基线表字体尺寸改变成此元素上特性'font-size'
的值。Thebaseline-identifierforthedominant-baselineissettobe'alphabetic',thederivedbaseline-tableisconstructedusingthe'alphabetic'baseline-tableinthenominalfont,andthebaseline-tablefont-sizeischangedtothevalueofthe

'font-size'propertyonthiselement.

hanging

dominant-baseline的基线标识符被设置为'hanging',通过使用在挂名字体中的'hanging'基线表来构造导出的基线表,而基线表字体尺寸改变成此元素上特性'font-size'
的值。Thebaseline-identifierforthedominant-baselineissettobe'hanging',thederivedbaseline-tableisconstructedusingthe'hanging'baseline-tableinthenominalfont,andthebaseline-tablefont-sizeischangedtothevalueofthe

'font-size'propertyonthiselement.

ideographic

dominant-baseline的基线标识符被设置为'ideographic',通过使用在挂名字体中的'ideographic'基线表来构造导出的基线表,而基线表字体尺寸改变成此元素上特性'font-size'
的值。Thebaseline-identifierforthedominant-baselineissettobe'ideographic',thederivedbaseline-tableisconstructedusingthe'ideographic'baseline-tableinthenominalfont,andthebaseline-tablefont-sizeischangedtothevalueofthe

'font-size'propertyonthiselement.

mathematical

dominant-baseline的基线标识符被设置为'mathematical',通过使用在挂名字体中的'mathematical'基线表来构造导出的基线表,而基线表字体尺寸改变成此元素上特性'font-size'
的值。Thebaseline-identifierforthedominant-baselineissettobe'mathematical',thederivedbaseline-tableisconstructedusingthe'mathematical'baseline-tableinthenominalfont,andthebaseline-tablefont-sizeischangedtothevalueofthe

'font-size'propertyonthiselement.

central

dominant-baseline的基线标识符被设置为'central',通过使用在挂名字体中的一种基线表来构造导出的基线表,这一字体基线表根据下列基线表名字的优先权顺序进行选择:'ideographic','alphabetic','hanging','mathematical'.而基线表字体尺寸改变成此元素上特性'font-size'
的值。Thebaseline-identifierforthedominant-baselineissettobe'central'.Thederivedbaseline-tableisconstructedfromthedefinedbaselinesinabaseline-tableinthenominalfont.Thatfontbaseline-tableischosenusingthefollowingpriorityorderof
baseline-tablenames:'ideographic','alphabetic','hanging','mathematical'.Thebaseline-tablefont-sizeischangedtothevalueofthe'font-size'
propertyonthiselement.

middle

dominant-baseline的基线标识符被设置为'middle',通过使用在挂名字体中的一种基线表来构造导出的基线表,这一字体基线表根据下列基线表名字的优先权顺序进行选择:'alphabetic','ideographic','hanging','mathematical'.而基线表字体尺寸改变成此元素上特性'font-size'
的值。Thebaseline-identifierforthedominant-baselineissettobe'middle'.Thederivedbaseline-tableisconstructedfromthedefinedbaselinesinabaseline-tableinthenominalfont.Thatfontbaseline-tableischosenusingthefollowingpriorityorderof
baseline-tablenames:'alphabetic','ideographic','hanging','mathematical'.Thebaseline-tablefont-sizeischangedtothevalueofthe'font-size'
propertyonthiselement.

text-after-edge

dominant-baseline的基线标识符被设置为'text-after-edge',通过使用在挂名字体中的一种基线表来构造导出的基线表,从挂名字体中的基线表中所用的字体基线表的选择由实现来定义.而基线表字体尺寸改变成此元素上特性'font-size'
的值。Thebaseline-identifierforthedominant-baselineissettobe'text-after-edge'.Thederivedbaseline-tableisconstructedfromthedefinedbaselinesinabaseline-tableinthenominalfont.Thechoiceofwhichfontbaseline-tabletousefromthebaseline-tables
inthenominalfontisimplementationdefined.Thebaseline-tablefont-sizeischangedtothevalueofthe'font-size'
propertyonthiselement.

注记:使用下列基线表名字的优先权顺序进行选择:'alphabetic','ideographic','hanging','mathematical'也许对于确定使用哪个字体基线表是一种较为合理的策略。NOTE:usingthefollowingpriorityorderofbaseline-tablenames:'alphabetic','ideographic','hanging','mathematical'isprobablyareasonablestrategyfor
determiningwhichfontbaseline-tabletouse.

text-before-edge

dominant-baseline的基线标识符被设置为'text-before-edge',通过使用在挂名字体中的一种基线表来构造导出的基线表,从挂名字体中的基线表中所用的字体基线表的选择由实现来定义.而基线表字体尺寸改变成此元素上特性'font-size'
的值。Thebaseline-identifierforthedominant-baselineissettobe'text-before-edge'.Thederivedbaseline-tableisconstructedfromthedefinedbaselinesinabaseline-tableinthenominalfont.Thechoiceofwhichbaseline-tabletousefromthebaseline-tables
inthenominalfontisimplementationdefined.Thebaseline-tablefont-sizeischangedtothevalueofthe'font-size'
propertyonthiselement.

注记:使用下列基线表名字的优先权顺序进行选择:'alphabetic','ideographic','hanging','mathematical'也许对于确定使用哪个字体基线表是一种较为合理的策略。NOTE:Usingthefollowingpriorityorderofbaseline-tablenames:'alphabetic','ideographic','hanging','mathematical'isprobablyareasonablestrategyfor
determiningwhichfontbaseline-tabletouse.

text-top

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

text-bottom

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

如果在挂名字体内无基线表或者基线表中缺乏所期望的基线,那么用户代理可以通过使用启发式来确定所期望的基线的位置。Ifthereisnobaselinetableinthenominalfontorifthebaselinetablelacksanentryforthedesiredbaseline,thentheuseragentmayuseheuristicstodeterminethepositionofthedesiredbaseline.

'alignment-baseline'

Value:

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

Initial:

auto

Appliesto:

'tspan','tref',

'altGlyph',
'textPath'elements

Inherited:

no

Percentages:

N/A

Media:

visual

Animatable:

yes

这一特性指定一个对象如何与它的祖先进行对齐。这一特性指定这一元素的哪个基线将与其祖先的相应基线进行对齐。例如,这允许在罗马文本的alphabetic基线在字体尺寸改变时仍然保持对齐。缺省情况下基线与alignment-baseline特性的计算值具有相同的名字。就是说,在block-progression-direction内的"ideographic"对齐点的位置是在被对齐对象的基线表中的"ideographic"基线的位置。Thispropertyspecifies
howanobjectisalignedwithrespecttoitsparent.Thispropertyspecifieswhichbaselineofthiselementistobealignedwiththecorrespondingbaselineoftheparent.Forexample,thisallowsalphabeticbaselinesinRomantexttostayalignedacrossfont
sizechanges.Itdefaultstothebaselinewiththesamenameasthecomputedvalueofthealignment-baselineproperty.Thatis,thepositionof"ideographic"alignment-pointintheblock-progression-directionisthepositionofthe"ideographic"
baselineinthebaseline-tableoftheobjectbeingaligned.

此特性的值具有下列意义:Valueshavethefollowingmeanings:

auto

此值为字符所属文本的支配基线-即使用祖先的支配基线。Thevalueisthedominant-baselineofthescripttowhichthecharacterbelongs-i.e.,usethedominant-baselineoftheparent.

baseline

将被对齐的对象的对齐点与祖先文本内容元素的支配基线对齐.Thealignment-pointoftheobjectbeingalignedisalignedwiththedominant-baseline
oftheparenttextcontentelement.

before-edge

将被对齐的对象的对齐点与祖先文本内容元素的"before-edge"基线对齐.Thealignment-pointoftheobjectbeingalignedisalignedwiththe"before-edge"
baselineoftheparent
textcontentelement.

text-before-edge

将被对齐的对象的对齐点与祖先文本内容元素的"text-before-edge"基线对齐.Thealignment-pointoftheobjectbeingalignedisalignedwiththe"text-before-edge"
baselineoftheparent
textcontentelement.

central

将被对齐的对象的对齐点与祖先文本内容元素的"central"基线对齐.Thealignment-pointoftheobjectbeingalignedisalignedwiththe"central"
baselineoftheparent
textcontentelement.

middle

将被对齐的对象的对齐点与祖先文本内容元素的"middle"基线对齐.Thealignment-pointoftheobjectbeingalignedisalignedwiththe"middle"
baselineoftheparent
textcontentelement.

after-edge

将被对齐的对象的对齐点与祖先文本内容元素的"after-edge"基线对齐.Thealignment-pointoftheobjectbeingalignedisalignedwiththe"after-edge"
baselineoftheparent
textcontentelement.

text-after-edge

将被对齐的对象的对齐点与祖先文本内容元素的"text-after-edge"基线对齐.Thealignment-pointoftheobjectbeingalignedisalignedwiththe"text-after-edge"
baselineoftheparent
textcontentelement.

ideographic

将被对齐的对象的对齐点与祖先文本内容元素的"ideographic"基线对齐.Thealignment-pointoftheobjectbeingalignedisalignedwiththe"ideographic"
baselineoftheparent
textcontentelement.

alphabetic

将被对齐的对象的对齐点与祖先文本内容元素的"alphabetic"基线对齐.Thealignment-pointoftheobjectbeingalignedisalignedwiththe"alphabetic"
baselineoftheparent
textcontentelement.

hanging

将被对齐的对象的对齐点与祖先文本内容元素的"hanging"基线对齐.Thealignment-pointoftheobjectbeingalignedisalignedwiththe"hanging"
baselineoftheparent
textcontentelement.

mathematical

将被对齐的对象的对齐点与祖先文本内容元素的"mathematical"基线对齐.Thealignment-pointoftheobjectbeingalignedisalignedwiththe"mathematical"
baselineoftheparent
textcontentelement.

top

如果书写模式为水平那么将被对齐的对象的对齐点与祖先文本内容元素的"top"基线对齐.否则使用支配基线。Thealignment-pointoftheobjectbeingalignedisaligned
withthe"top"baselineoftheparent
textcontentelementifthewriting-modeishorizontal.Otherwise,thedominant-baselineisused.

bottom

如果书写模式为水平那么将被对齐的对象的对齐点与祖先文本内容元素的"bottom"基线对齐.否则使用支配基线。Thealignment-pointoftheobjectbeingalignedisaligned
withthe"bottom"baselineoftheparent
textcontentelementifthewriting-modeishorizontal.Otherwise,thedominant-baselineisused.

text-top

如果书写模式为水平那么将被对齐的对象的对齐点与祖先文本内容元素的"text-top"基线对齐.否则使用支配基线。Thealignment-pointoftheobjectbeingalignedisaligned
withthe"text-top"baselineoftheparent
textcontentelementifthewriting-modeishorizontal.Otherwise,thedominant-baselineisused.

text-bottom

如果书写模式为水平那么将被对齐的对象的对齐点与祖先文本内容元素的"text-bottom"基线对齐.否则使用支配基线。Thealignment-pointoftheobjectbeingalignedis
alignedwiththe"text-bottom"baselineoftheparent
textcontentelementifthewriting-modeishorizontal.Otherwise,thedominant-baselineisused.

'baseline-shift'

Value:

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

Initial:

baseline

Appliesto:

'tspan','tref',

'altGlyph',
'textPath'elements

Inherited:

no

Percentages:

referstothe"line-height"ofthe
'text'element,whichinthecaseofSVGisdefinedtobeequaltothe
'font-size'

Media:

visual

Animatable:

yes

特性'baseline-shift'允许相对于祖先
文本内容元素的支配基线的支配基线的重定位。平移的对象也许为下标或上标。在平移的对象内,整个基线表是偏移;不刚好为单一的基线。平移的数量由祖先文本内容元素的信息,相对于祖先文本内容元素的挂名字体的下标或上标偏移量,祖先

文本内容元素的"行高"的百分比或一个绝对值来决定。The'baseline-shift'propertyallowsrepositioningofthedominant-baselinerelativetothedominant-baselineoftheparenttextcontent
element.Theshiftedobjectmightbeasub-orsuperscript.Withintheshiftedobject,thewholebaseline-tableisoffset;notjustasinglebaseline.Theamountoftheshiftisdeterminedfrominformationfromtheparenttextcontent
element,thesub-orsuperscriptoffsetfromthenominalfontoftheparent
textcontentelement,percentofthe"line-height"oftheparent
textcontentelementoranabsolutevalue.

在精图中,'baseline-shift'特性表示对基线表附加的调整.'baseline-shift'特性对每个图元平移基线表到一个新的临时位置,例如升高或降低图元到上标或下标的位置,可是它不影响当前文本位置.当在渲染一个图元之后当前文本位置考虑图元的增量值时,所发生的调整好像不存在基线平移一样。InSVG,the'baseline-shift'propertyrepresentsasupplementaladjustmenttothebaselinetables.
The'baseline-shift'propertyshiftsthebaselinetablesforeachglyphtotemporarynewpositions,forexampletolifttheglyphintosuperscriptorsubscriptposition,butitdoesnoteffectthecurrenttextposition.Whenthecurrenttextpositionisadjusted
afterrenderingaglyphtotakeintoaccountglyphadvancevalues,theadjustmenthappensasiftherewerenobaselineshift.

'baseline-shift'特性能够嵌套.每个嵌套的'baseline-shift'被加到上一个基线平移值.'baseline-shift'propertiescannest.Eachnested'baseline-shift'isaddedtopreviousbaselineshiftvalues.

此特性的值具有下列意义:Valuesforthepropertyhavethefollowingmeaning:

baseline

不存在基线平移,占优势的基线保留在它的原来的位置。Thereisnobaselineshift;thedominant-baselineremainsinitsoriginalposition.

sub

平移dominant-baseline到下标的缺省位置。到此位置的偏移量由挂名字体的字体数据所确定。因为大多数字体的下标位置通常是相对"alphabetic"基线来给定的,当某一其它基线为支配基线时用户代理也许需要计算下标的有效位置。推荐的计算方法为从下标位置减去支配基线的位置和"alphabetic"基线的位置之差。作为结果的偏移量由有效的下标位置乘以支配基线字体尺寸来确定。如果无可用的字体数据用户代理可以使用启发式确定这一偏移量。Thedominant-baselineisshiftedto
thedefaultpositionforsubscripts.Theoffsettothispositionisdeterminedusingthefontdataforthenominalfont.Becauseinmostfontsthesubscriptpositionisnormallygivenrelativetothe"alphabetic"baseline,theuseragentmaycomputetheeffective
positionforsubscriptsforsuperscriptswhensomeotherbaselineisdominant.Thesuggestedcomputationistosubtractthedifferencebetweenthepositionofthedominantbaselineandthepositionofthe"alphabetic"baselinefromthepositionofthesubscript.
Theresultingoffsetisdeterminedbymultiplyingtheeffectivesubscriptpositionbythedominantbaseline-tablefont-size.Ifthereisnoapplicablefontdatatheuseragentmayuseheuristicstodeterminetheoffset.

super

平移dominant-baseline到上标的缺省位置。到此位置的偏移量由挂名字体的字体数据所确定。因为大多数字体的上标位置通常是相对"alphabetic"基线来给定的,当某一其它基线为支配基线时用户代理也许需要计算上标的有效位置。推荐的计算方法为从上标位置减去支配基线的位置和"alphabetic"基线的位置之差。作为结果的偏移量由有效的上标位置乘以支配基线字体尺寸来确定。如果无可用的字体数据用户代理可以使用启发式确定这一偏移量。Thedominant-baselineisshiftedto
thedefaultpositionforsuperscripts.Theoffsettothispositionisdeterminedusingthefontdataforthenominalfont.Becauseinmostfontsthesuperscriptpositionisnormallygivenrelativetothe"alphabetic"baseline,theuseragentmaycomputetheeffective
positionforsuperscriptswhensomeotherbaselineisdominant.Thesuggestedcomputationistosubtractthedifferencebetweenthepositionofthedominantbaselineandthepositionofthe"alphabetic"baselinefromthepositionofthesuperscript.Theresulting
offsetisdeterminedbymultiplyingtheeffectivesuperscriptpositionbythedominantbaseline-tablefont-size.Ifthereisnoapplicablefontdatatheuseragentmayuseheuristicstodeterminetheoffset.

<percentage>

特性的这一计算值为这一百分数乘以文本'text'元素的所计算的"行高"。支配基线在祖先文本内容元素的

平移方向(正值)或与平移方向相反的方向(负值)平移所计算的值。值"0%"等价于"baseline".Thecomputedvalueofthepropertyisthispercentagemultiplied
bythecomputed"line-height"ofthe
'text'element.Thedominant-baselineisshiftedinthe
shiftdirection(positivevalue)oroppositetothe
shiftdirection(negativevalue)oftheparent
textcontentelementbythecomputedvalue.Avalueof"0%"isequivalentto"baseline".

<length>

将dominant-baseline在祖先文本内容元素的平移方向
(正值)或与平移方向相反的方向(负值)平移<length>值.值"0cm"等价于"baseline".Thedominant-baselineisshiftedintheshiftdirection
(positivevalue)oroppositetothe
shiftdirection(negativevalue)oftheparent
textcontentelementbythe<length>value.Avalueof"0cm"isequivalentto"baseline".

10.10字体挑选属性Fontselectionproperties

精图使用下列字体规范特性。除了本规范提供的任何附加的信息外,这些特性的正式定义在[CSS2-fonts]中给出。关于这些特性的任何精图特定的注记包含在下列描述中。SVGusesthefollowingfontspecificationproperties.Exceptforanyadditionalinformation
providedinthisspecification,thenormativedefinitionofthepropertyisin[CSS2-fonts].AnySVG-specificnotesaboutthesepropertiesarecontainedinthedescriptionsbelow.

'font-family'

Value:

[[<family-name>|

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

<generic-family>]|
inherit

Initial:

dependsonuseragent

Appliesto:

textcontentelements

Inherited:

yes

Percentages:

N/A

Media:

visual

Animatable:

yes

这一特性表示使用哪种字体渲染文本,它通过一个一定次序的字体名字或类属名字列表来指定。除了本规范提供的任何附加的信息外,这一特性的正式定义在[CSS2-font-family]中给出。表示CSS特性值的语法的规则在[CSS2-propdef]中可以找到。This
propertyindicateswhichfontfamilyistobeusedtorenderthetext,specifiedasaprioritizedlistoffontfamilynamesand/orgenericfamilynames.Exceptforanyadditionalinformationprovidedinthisspecification,thenormativedefinitionoftheproperty
isin[CSS2-font-family].TherulesforexpressingthesyntaxofCSSpropertyvaluescanbefoundat[CSS2-propdef].

'font-style'

Value:

normal|italic|oblique|
inherit

Initial:

normal

Appliesto:

textcontentelements

Inherited:

yes

Percentages:

N/A

Media:

visual

Animatable:

yes

这一特性指定是否使用正常、倾斜或歪斜外观来渲染文本。除了本规范提供的任何附加的信息外,这一特性的正式定义在[CSS2-font-style]中给出。Thispropertyspecifieswhetherthetextistoberenderedusinganormal,
italicorobliqueface.Exceptforanyadditionalinformationprovidedinthisspecification,thenormativedefinitionofthepropertyisin[CSS2-font-style].

'font-variant'

Value:

normal|small-caps|
inherit

Initial:

normal

Appliesto:

textcontentelements

Inherited:

yes

Percentages:

N/A

Media:

visual

Animatable:

yes

这一特性表示是否对小写字符使用正规图元或对小写字符使用small-caps图元来渲染文本。除了本规范提供的任何附加的信息外,这一特性的正式定义在[CSS2-font-variant]中给出。Thispropertyindicateswhetherthetextistoberendered
usingthenormalglyphsforlowercasecharactersorusingsmall-capsglyphsforlowercasecharacters.Exceptforanyadditionalinformationprovidedinthisspecification,thenormativedefinitionofthepropertyisin[CSS2-font-variant].

'font-weight'

Value:

normal|bold|bolder|lighter|100|200|300

|400|500|600|700|800|900|
inherit

Initial:

normal

Appliesto:

textcontentelements

Inherited:

yes

Percentages:

N/A

Media:

visual

Animatable:

yes

此特性指定引用图元的黑体或淡体来渲染文本,相对于同一字体族中的其它字体。除了本规范提供的任何附加的信息外,这一特性的正式定义在[CSS2-font-weight]中给出。Thispropertyreferstotheboldnessorlightnessoftheglyphs
usedtorenderthetext,relativetootherfontsinthesamefontfamily.Exceptforanyadditionalinformationprovidedinthisspecification,thenormativedefinitionofthepropertyisin[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

Appliesto:

textcontentelements

Inherited:

yes

Percentages:

N/A

Media:

visual

Animatable:

yes

这一特性表示使用所期望的在图元上进行特定量的收缩或膨胀来渲染文本。除了本规范提供的任何附加的信息外,这一特性的正式定义在[CSS2-font-stretch]中给出。Thispropertyindicatesthedesiredamountofcondensingorexpansion
intheglyphsusedtorenderthetext.Exceptforanyadditionalinformationprovidedinthisspecification,thenormativedefinitionofthepropertyisin[CSS2-font-stretch].

'font-size'

Value:

<absolute-size>|<relative-size>|

<length>|<percentage>|
inherit

Initial:

medium

Appliesto:

textcontentelements

Inherited:

yes,thecomputedvalueisinherited

Percentages:

refertoparentelement'sfontsize

Media:

visual

Animatable:

yes

这一特性引用当多行文本在一个多行布局环境中被设置为固定的从基线到基线的字体的尺寸。对于精图而言,如果<length>不带单位标识符(例如,一个没限制的数128),那么精图用户代理处理此<length>为当前用户坐标系中的一种高度值。Thispropertyreferstothesizeofthefontfrombaselinetobaselinewhenmultiplelinesoftextaresetsolidinamultilinelayoutenvironment.
ForSVG,ifa<length>isprovidedwithoutaunitidentifier(e.g.,anunqualifiednumbersuchas128),theSVGuseragentprocessesthe<length>asaheightvalueinthecurrentusercoordinatesystem.

如果所提供的带有单位标识符(比如,12pt或10%),那么精图用户代理根据在单位中所描述的规则将<length>转换成当前用户坐标系中对应的值。If
a<length>isprovidedwithoneofthe
unitidentifiers(e.g.,12ptor10%),thentheSVGuseragentconvertsthe<length>intoacorrespondingvalueinthecurrentusercoordinatesystembyapplyingtherulesdescribedinUnits.

除了本规范提供的任何附加的信息外,这一特性的正式定义在[CSS2-font-size]中给出。Exceptforanyadditionalinformationprovidedinthisspecification,thenormativedefinitionoftheproperty
isin[CSS2-font-size].

'font-size-adjust'

Value:

<number>|none|
inherit

Initial:

none

Appliesto:

textcontentelements

Inherited:

yes

Percentages:

N/A

Media:

visual

Animatable:

yes(non-additive,'set'and'animate'elementsonly)

这一特性允许作者为一个保存在一个备选字体中的第一个选择的字体的x-height的元素指定样式值。除了本规范提供的任何附加的信息外,这一特性的正式定义在[CSS2-font-size-adjust]中给出。Thispropertyallowsauthorstospecify
anaspectvalueforanelementthatwillpreservethex-heightofthefirstchoicefontinasubstitutefont.Exceptforanyadditionalinformationprovidedinthisspecification,thenormativedefinitionofthepropertyisin[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:

seeindividualproperties

Appliesto:

textcontentelements

Inherited:

yes

Percentages:

allowedon'font-size'and'line-height'(Note:forthepurposesofprocessingthe'font'propertyinSVG,'line-height'isassumedtobeequalthevalueforproperty'font-size')

Media:

visual

Animatable:

yes(non-additive,'set'and'animate'elementsonly)

这是用于设置'font-style','font-variant','font-weight','font-size','line-height'和'font-family'的速记特性。在精图的文本布局上特性'line-height'无效。对于特性'font'来说,'line-height'被假定等于特性'font-size'
的值。不要求精图兼容浏览器支持各种字体选项(标题,图标,菜单,消息框,小标题和状态条)并且可以用一个系统字体或通用字体来代替。Shorthandpropertyforsetting'font-style','font-variant',
'font-weight','font-size','line-height'and'font-family'.The'line-height'propertyhasnoeffectontextlayoutinSVG.Forthepurposesofthe'font'property,'line-height'isassumedtobeequaltothevalueofthe'font-size'
property.
ConformingSVGViewersarenotrequiredtosupportthevarioussystemfontoptions(caption,icon,menu,message-box,small-captionandstatus-bar)andcanuseasystemfontoroneofthegenericfontsinstead.

除了本规范提供的任何附加的信息外,这一特性的正式定义在[CSS2-font]中给出。表示CSS特性值的语法的规则在[CSS2-propdef]中可以找到。Except
foranyadditionalinformationprovidedinthisspecification,thenormativedefinitionofthepropertyisin[CSS2-font].Therulesforexpressingthesyntax
ofCSSpropertyvaluescanbefoundat[CSS2-propdef].

10.11空白属性Spacingproperties

三个特性影响字词之间的空白。Threepropertiesaffectthespacebetweencharactersandwords:

'kerning'表示用户代理是基于包含在相关字体中的字距调整表来调整图元间的空白(即,应用auto-kerning)还是不应用auto-kerning而代之以设置字符间空白为指定的长度(典型地,为零).'kerning'
indicateswhethertheuseragentshouldadjustinter-glyphspacingbasedonkerningtablesthatareincludedintherelevantfont(i.e.,enableauto-kerning)orinsteaddisableauto-kerningandinsteadsetinter-characterspacingtoaspecificlength(typically,
zero).
'letter-spacing'表示将加到文本字符之间的一定量的空白,它将由特性'kerning'所指定的空白进行补充。'letter-spacing'
indicatesanamountofspacethatistobeaddedbetweentextcharacterssupplementaltoanyspacingduetothe'kerning'property.

'word-spacing'表示单词间的补白行为。'word-spacing'
indicatesthespacingbehaviorbetweenwords.

'kerning'

Value:

auto|<length>|
inherit

Initial:

auto

Appliesto:

textcontentelements

Inherited:

yes

Percentages:

N/A

Media:

visual

Animatable:

yes

值auto表示用户代理基于包含在将被使用的字体中的字距调整表来调整图元间的空白(即,应用auto-kerning)。Thevalueofautoindicatesthattheuseragentshouldadjustinter-glyphspacingbasedonkerningtablesthatareincludedinthefontthatwillbeused(i.e.,enableauto-kerning).

当提供一个<length>,那么不用auto-kerning.代之以,字符间空白被设置为此给定的<length>.最通常的情形,除了auto,是设置'kerning'为0这样便能不用auto-kerning.Ifa<length>isprovided,thenauto-kerningisdisabled.Instead,inter-characterspacingissettothegiven<length>.Themostcommonscenario,
otherthanauto,istoset'kerning'toavalueof0sothatauto-kerningisdisabled.

如果<length>不带单位标识符(例如,一个没限制的数128),那么精图用户代理处理此<length>为当前用户坐标系中的一种高度值。Ifa<length>isprovidedwithoutaunitidentifier(e.g.,anunqualifiednumbersuchas128),theSVGuseragentprocessesthe<length>asawidthvalueinthecurrentusercoordinate
system.

如果所提供的带有单位标识符(比如,.25em或1%),那么精图用户代理根据在单位中所描述的规则将<length>转换成当前用户坐标系中对应的值。If
a<length>isprovidedwithoneofthe
unitidentifiers(e.g.,.25emor1%),thentheSVGuseragentconvertsthe<length>intoacorrespondingvalueinthecurrentusercoordinatesystembyapplyingtherulesdescribedinUnits.

当提供一个<length>,其值被加到由特性'letter-spacing'所指定的字符间的空白值中。Whena<length>isprovided,itsvalueisaddedtotheinter-character
spacingvaluespecifiedbythe
'letter-spacing'property.

'letter-spacing'

Value:

normal|<length>|
inherit

Initial:

normal

Appliesto:

textcontentelements

Inherited:

yes

Percentages:

N/A

Media:

visual

Animatable:

yes

这一特性指定文本字符之间的空白行为,它是对由特性
'kerning'指定的任何空白的补充。Thispropertyspecifiesspacingbehaviorbetweentextcharacterssupplementaltoanyspacingduetothe'kerning'
property.

对于精图而言,如果<length>不带单位标识符(例如,一个没限制的数128),那么精图用户代理处理此<length>为当前用户坐标系中的一种高度值。ForSVG,ifa<length>isprovidedwithoutaunitidentifier(e.g.,anunqualifiednumbersuchas128),theSVGuseragentprocessesthe<length>asawidthvalueinthecurrent
usercoordinatesystem.

如果所提供的带有单位标识符(比如,.25em或1%),那么精图用户代理根据在单位中所描述的规则将<length>转换成当前用户坐标系中对应的值。If
a<length>isprovidedwithoneofthe
unitidentifiers(e.g.,.25emor1%),thentheSVGuseragentconvertsthe<length>intoacorrespondingvalueinthecurrentusercoordinatesystembyapplyingtherulesdescribedinUnits.

除了本规范提供的任何附加的信息外,这一特性的正式定义在[CSS2-letter-spacing]中给出。Exceptforanyadditionalinformationprovidedinthisspecification,thenormativedefinition
ofthepropertyisin[CSS2-letter-spacing].

'word-spacing'

Value:

normal|<length>|
inherit

Initial:

normal

Appliesto:

textcontentelements

Inherited:

yes

Percentages:

N/A

Media:

visual

Animatable:

yes

这一特性指定单词之间的空白行为。对于精图而言,如果<length>不带单位标识符(例如,一个没限制的数128),那么精图用户代理处理此<length>为当前用户坐标系中的一种高度值。Thispropertyspecifiesspacingbehaviorbetweenwords.ForSVG,ifa<length>isprovidedwithoutaunitidentifier(e.g.,anunqualifiednumbersuchas128),the
SVGuseragentprocessesthe<length>asawidthvalueinthecurrentusercoordinatesystem.

如果所提供的带有单位标识符(比如,.25em或1%),那么精图用户代理根据在单位中所描述的规则将<length>转换成当前用户坐标系中对应的值。If
a<length>isprovidedwithoneofthe
unitidentifiers(e.g.,.25emor1%),thentheSVGuseragentconvertsthe<length>intoacorrespondingvalueinthecurrentusercoordinatesystembyapplyingtherulesdescribedinUnits.

除了本规范提供的任何附加的信息外,这一特性的正式定义在[CSS2-word-spacing]中给出。Exceptforanyadditionalinformationprovidedinthisspecification,thenormativedefinitionof
thepropertyisin[CSS2-word-spacing].

10.12文本修饰Textdecoration

'text-decoration'

Value:

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

Initial:

none

Appliesto:

textcontentelements

Inherited:

no(seeprose)

Percentages:

N/A

Media:

visual

Animatable:

yes

这一特性描述附加到一个元素的文本上的修饰。不要求精图兼容浏览器支持blink值。Thispropertydescribesdecorationsthatareaddedtothe
textofanelement.ConformingSVGViewersarenotrequiredtosupportthe
blinkvalue.

除了本规范提供的任何附加的信息外,这一特性的正式定义在[CSS2-text-decoration]中给出。表示CSS特性值的语法的规则在[CSS2-propdef]中可以找到。Except
foranyadditionalinformationprovidedinthisspecification,thenormativedefinitionofthepropertyisin[CSS2-text-decoration].Therulesforexpressing
thesyntaxofCSSpropertyvaluescanbefoundat[CSS2-propdef].

CSS2规范[CSS2]通过使用术语"block-levelelements"和"inlineelements"定义了特性'text-decoration'的行为.对于特性'text-decoration'的目的和精图而言,一个文本'text'
元素代表一个块级的元素而一个文本'text'元素的任何潜在的孩子(例如,一个'tspan')
表示内联元素.TheCSS2specification[CSS2]definesthebehaviorofthe'text-decoration'propertyusingtheterminology"block-levelelements"and"inlineelements".Forthepurposes
ofthe'text-decoration'propertyandSVG,a
'text'elementrepresentsablock-levelelementandanyofthepotentialchildrenofa'text'element(e.g.,a

'tspan')representinlineelements.

同时,'text-decoration'的CSS2定义规定"装饰的颜色"与它的后代元素保持一致.因为精图提供一个由使用既在文本内部(即,"填充")又在文本外部(即,"描边")各种类型绘制方式(参见绘画:填充,描边和标记符号)的能力组成绘制模型,
对于精图而言定义特性'text-decoration'使得,对于一个指定了特性'text-decoration'的值的元素,在它的内容和其后代的内容将使用此给定元素上呈现的相同的填充和描边特性来进行渲染.如果在一个后代元素上指定了特性'text-decoration',那么它将覆盖祖先的特性.Also,theCSS2definitionof'text-decoration'specifiesthatthe"colorofthedecorations"remain
thesameondescendantelements.SinceSVGoffersapaintingmodelconsistingoftheabilitytoapplyvarioustypesofpaint(seePainting:
Filling,StrokingandMarkerSymbols)toboththeinterior(i.e.,the"fill")andtheoutline(i.e.,the"stroke")oftext,forSVGthe'text-decoration'propertyisdefinedsuchthat,foranelementwhichhasaspecifiedvalueforthe'text-decoration'property,
alldecorationsonitscontentandthatofitsdescendantsarerenderedusingthesamefillandstrokepropertiesasarepresentonthegivenelement.Ifthe'text-decoration'propertyisspecifiedonadescendant,thenthatoverridestheancestor.

因为精图允许对文本进行填充和描边,在某些具有文本装饰的情形下绘制的次序比较重要。文本装饰的绘制次序应当如下:BecauseSVGallowstexttobebothfilledandstroked,drawingordermattersinsomecircumstanceswithtextdecorations.Textdecorationdrawingordershouldbeasfollows:

除了line-through所有文本装饰应该在文本被填充和描边之前进行绘制;于是,文本在这些装饰上面进行渲染。Alltextdecorationsexceptline-throughshouldbedrawnbeforethetextisfilledandstroked;thus,thetextisrenderedontopofthesedecorations.
Line-through应该在文本被填充和描边之后进行绘制;于是,Line-through在文本的上面进行渲染。Line-throughshouldbedrawnafterthetextisfilledandstroked;thus,theline-throughisrenderedontopofthetext.

例子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'元素的填充和描边特性(即,黄色填充,深绿描边)来进行渲染:Exampletextdecoration01providesexamplesfor'text-decoration'.
Thefirstlineoftexthasnovaluefor'text-decoration',sotheinitialvalueof'text-decoration:none'isused.Thesecondlineshows'text-decoration:line-through'.Thethirdlineshows'text-decoration:underline'.Thefourthlineillustratestherulewhereby
decorationsarerenderedusingthesamefillandstrokepropertiesasarepresentontheelementforwhichthe'text-decoration'isspecified.Since'text-decoration'isspecifiedonthe

'text'element,alltextwithinthe
'text'elementhasitsunderlinerenderedwiththesamefillandstrokepropertiesasexistonthe'text'element(i.e.,blue
fill,redstroke),eventhoughthevariouswordshavedifferentfillandstrokepropertyvalues.However,theword"different"explicitlyspecifiesavaluefor'text-decoration';thus,itsunderlineisrenderedusingthefillandstrokepropertiesasthe

'tspan'elementthatsurroundstheword"different"(i.e.,yellowfill,darkgreenstroke):


<?xmlversion="1.0"standalone="no"?>

<!DOCTYPEsvgPUBLIC"-//W3C//DTDSVG20010904//EN"

"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">

<svgwidth="12cm"height="4cm"viewBox="001200400"

xmlns="http://www.w3.org/2000/svg">

<desc>Exampletextdecoration01-behaviorof'text-decoration'property</desc>

<rectx="1"y="1"width="1198"height="398"fill="none"stroke="blue"stroke-width="2"/>

<gfont-size="60"fill="blue"stroke="red"stroke-width="1">

<textx="100"y="75">Normaltext</text>

<textx="100"y="165"text-decoration="line-through">Textwithline-through</text>

<textx="100"y="255"text-decoration="underline">Underlinedtext</text>

<textx="100"y="345"text-decoration="underline">

<tspan>One</tspan>

<tspanfill="yellow"stroke="purple">word</tspan>

<tspanfill="yellow"stroke="black">has</tspan>

<tspanfill="yellow"stroke="darkgreen"text-decoration="underline">different</tspan>

<tspanfill="yellow"stroke="blue">underlining</tspan>

</text>

</g>

</svg>

Exampletextdecoration01
ViewthisexampleasSVG(SVG-enabledandCSS-enabledbrowsersonly)

10.13路径文本Textonapath

10.13.1路径文本概述Introductiontotextonapath

除了将文本绘制在直线上外,精图也包括沿着一个路径
'path'元素安置文本的能力。为了指定一段文本沿着一'path'的形状进行渲染,需要使用一个包括属性xlink:href具有URI引用指向一个路径'path'元素的文本路径'textPath'
元素包括这一给定的文本。Inadditiontotextdrawninastraightline,SVGalsoincludestheabilitytoplacetextalongtheshapeofa'path'
element.Tospecifythatablockoftextistoberenderedalongtheshapeofa'path',includethegiventextwithina

'textPath'elementwhichincludesan
xlink:hrefattributewitha
URIreferencetoa
'path'element.

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


<!ENTITY%textPathExt"">

<!ELEMENTtextPath(#PCDATA|desc|title|metadata|tspan|tref|altGlyph|a|animate|set|animateColor

%textPathExt;)*>

<!ATTLISTtextPath

%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>

属性定义:Attributedefinitions:

startOffset="<length>"

初始的当前文本位置与'path'的开始的偏移量,此偏移量通过使用用户代理的沿着路径的距离算法来计算。An
offsetfromthestartofthe
'path'fortheinitialcurrenttextposition,calculatedusingtheuseragent'sdistancealongthepathalgorithm.

如果给出的<length>不是百分数,那么此startOffset表示按照当前用户坐标系进行测量的沿着此路径上的距离。Ifa<length>other
thanapercentageisgiven,thenthestartOffsetrepresentsadistancealongthepathmeasuredinthecurrentusercoordinatesystem.

如果给出的是百分数,那么此startOffset表示的沿着整个路径上的距离的百分比。于是,startOffset="0%"代表'path'的起始点而startOffset="100%"代表'path'的终止点。If
apercentageisgiven,thenthestartOffsetrepresentsapercentagedistancealongtheentirepath.Thus,startOffset="0%"indicatesthestartpointofthe'path'
andstartOffset="100%"indicatestheendpointofthe
'path'.

一个负值为一种错误(参见
错误处理).Anegativevalueisanerror(see
Errorprocessing).

如果不指定此属性,其效果相当于指定其值为"0"。Iftheattributeisnotspecified,theeffectisasifavalueof"0"werespecified.

Animatable:yes.

method="align|stretch"

表示将使用哪种方法沿着路径对文本进行渲染。Indicatesthemethodbywhichtextshouldberenderedalongthepath.

值align表示将使用不存在图元的拉伸或扭曲的简单2x3变换对图元进行渲染。典型情况下,对于每个渲染的图元进行附加的旋转、缩放和平移变换。作为align的一种结果,对于那些其图元被设计成可以连接的字体(例如,草体),当文本沿着路径进行渲染时,图元之间的连接也许不被适当对准。Avalueofalignindicatesthattheglyphsshouldberenderedusingsimple2x3transformationssuchthatthereisnostretching/warping
oftheglyphs.Typically,supplementalrotation,scalingandtranslationtransformationsaredoneforeachglyphtoberendered.Asaresult,withalign,fontswheretheglyphsaredesignedtobeconnected(e.g.,cursivefonts),theconnectionsmaynotalignproperly
whentextisrenderedalongapath.

值stretch表示图元轮廓将转换成路径,然后所有终点和控制点将沿着路径上的正交矢量进行调整,因此图元可能被拉伸或扭曲。使用这种方法,连接的图元,比如草书文本,将维持它们的连接。Avalueofstretchindicatesthattheglyphoutlineswillbeconvertedintopaths,andthenallendpointsandcontrolpointswillbeadjustedtobealongtheperpendicular
vectorsfromthepath,therebystretchingandpossiblywarpingtheglyphs.Withthisapproach,connectedglyphs,suchasincursivescripts,willmaintaintheirconnections.

如果不指定此属性,其效果相当于指定其值为align。Iftheattributeisnotspecified,theeffectisasifavalueofalignwerespecified.

Animatable:yes.

spacing="auto|exact"

表示用户代理将如何确定在沿着路径渲染的图元之间的空白。Indicateshowtheuseragentshoulddeterminethespacingbetweenglyphsthataretoberenderedalongapath.

值exact表示图元将按照在路径上的文本的布局规则中指定的空白规则进行渲染。Avalueofexactindicatesthattheglyphsshouldberenderedexactlyaccordingto
thespacingrulesasspecifiedin
Textonapathlayoutrules.

值auto表示用户代理将使用路径上文本布局算法调整图元之间的空白以便达到吸引人的视觉效果。Avalueofautoindicatesthattheuseragentshouldusetext-on-a-pathlayoutalgorithmstoadjustthespacingbetweenglyphsinordertoachievevisuallyappealingresults.

如果不指定此属性,其效果相当于指定其值为exact。Iftheattributeisnotspecified,theeffectisasifavalueofexactwerespecified.

Animatable:yes.

xlink:href="<uri>"

对图元将在其上进行渲染的路径'path'元素一种URI引用。如果<uri>为一种无效引用(例如,
这一元素不存在,或者被引用的元素不是一个路径'path'元素),那么此文本路径'textPath'元素是一种错误并且它的整个内容将不被用户代理所渲染。AURIreference
tothe
'path'elementontowhichtheglyphswillberendered.If<uri>isaninvalidreference(e.g.,nosuchelementexists,orthereferencedelementisnota'path'),
thenthe'textPath'elementisinerroranditsentirecontentsshallnotberenderedbytheuseragent.

Animatable:yes.

在别处定义的属性:Attributesdefinedelsewhere:

%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属性所导致的对当前用户坐标系的任何调整。例如,下列精图内容的片段:
Thepathdatacoordinateswithinthereferenced'path'elementareassumedtobeinthesamecoordinatesystemasthecurrent'text'element,
notinthecoordinatesystemwherethe'path'elementisdefined.The

transformattributeonthereferenced
'path'elementrepresentsasupplementaltransformationrelativetothecurrentusercoordinatesystemforthecurrent'text'
element,includinganyadjustmentstothecurrentusercoordinatesystemduetoapossibletransformattributeonthecurrent

'text'element.Forexample,thefollowingfragmentofSVGcontent:

<svgxmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink">

<gtransform="translate(25,25)">

<defs>

<pathid="path1"transform="scale(2)"d="..."fill="none"stroke="red"/>

</defs>

</g>

<texttransform="rotate(45)">

<textPathxlink:href="#path1">Textalongpath1</textPath>

</text>

</svg>

应该与下列片段具有相同的效果:shouldhavethesameeffectasthefollowing:

<svgxmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink">

<gtransform="rotate(45)">

<defs>

<pathid="path1"transform="scale(2)"d="..."fill="none"stroke="red"/>

</defs>

<text>

<textPathxlink:href="#path1">Textalongpath1</textPath>

</text>

</g>

</svg>

注意
transform="translate(25,25)"
在'textPath'元素上无任何效果,而
transform="rotate(45)"
既用于'text'也用于作为路径上文本所引用的形状的路径'path'元素.Notethat
the
transform="translate(25,25)"
hasnoeffectonthe'textPath'element,whereasthe
transform="rotate(45)"
appliestoboththe'text'and
theuseofthe'path'elementasthereferencedshapefortextonapath.

例子toap01提供一个路径上的文本的简单的例子:Exampletoap01providesasimpleexampleoftextonapath:


<?xmlversion="1.0"standalone="no"?>

<!DOCTYPEsvgPUBLIC"-//W3C//DTDSVG20010904//EN"

"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">

<svgwidth="12cm"height="3.6cm"viewBox="001000300"

xmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink">

<defs>

<pathid="MyPath"

d="M100200

C2001003000400100

C500200600300700200

C800100900100900100"/>

</defs>

<desc>Exampletoap01-simpletextonapath</desc>


<usexlink:href="#MyPath"fill="none"stroke="red"/>

<textfont-family="Verdana"font-size="42.5"fill="blue">

<textPathxlink:href="#MyPath">

Wegoup,thenwegodown,thenupagain

</textPath>

</text>


<!--Showoutlineofcanvasusing'rect'element-->

<rectx="1"y="1"width="998"height="298"

fill="none"stroke="blue"stroke-width="2"/>

</svg>

Exampletoap01
ViewthisexampleasSVG(SVG-enabledbrowsersonly)

例子toap02说明能够包含在文本'textPath'路径元素中的'tspan'元素是如何在渲染一个特殊图元之前调整样式属性和当前文本位置的.
单词"up"的第一次出现用红色填充.属性dy用来从基线上抬升单词"up".Exampletoap02showshow

'tspan'elementscanbeincludedwithin'textPath'elementstoadjuststylingattributesandadjustthecurrenttextpositionbeforerenderingaparticularglyph.Thefirstoccurrenceoftheword"up"isfilledwiththecolorred.Attributedy
isusedtolifttheword"up"fromthebaseline.


<?xmlversion="1.0"standalone="no"?>

<!DOCTYPEsvgPUBLIC"-//W3C//DTDSVG20010904//EN"

"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">

<svgwidth="12cm"height="3.6cm"viewBox="001000300"

xmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink">

<defs>

<pathid="MyPath"

d="M100200

C2001003000400100

C500200600300700200

C800100900100900100"/>

</defs>

<desc>Exampletoap02-tspanwithintextPath</desc>


<usexlink:href="#MyPath"fill="none"stroke="red"/>

<textfont-family="Verdana"font-size="42.5"fill="blue">

<textPathxlink:href="#MyPath">

Wego

<tspandy="-30"fill="red">

up

</tspan>

<tspandy="30">

,

</tspan>

thenwegodown,thenupagain

</textPath>

</text>


<!--Showoutlineofcanvasusing'rect'element-->

<rectx="1"y="1"width="998"height="298"

fill="none"stroke="blue"stroke-width="2"/>

</svg>

Exampletoap02
ViewthisexampleasSVG(SVG-enabledbrowsersonly)

例子toap03示范使用在文本路径'textPath'元素上属性startOffset指定文本字符串的开始位置为沿着路径的一个特定的位置。注意不对越过路径末端的图元进行渲染(参见路径上的文本的布局规则).Example
toap03demonstratestheuseofthestartOffsetattributeonthe'textPath'elementtospecifythestartpositionofthetextstringasaparticularpositionalongthepath.Noticethatglyphsthatfallofftheendofthepatharenotrendered(seetext
onapathlayoutrules).


<?xmlversion="1.0"standalone="no"?>

<!DOCTYPEsvgPUBLIC"-//W3C//DTDSVG20010904//EN"

"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">

<svgwidth="12cm"height="3.6cm"viewBox="001000300"

xmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink">

<defs>

<pathid="MyPath"

d="M100200

C2001003000400100

C500200600300700200

C800100900100900100"/>

</defs>

<desc>Exampletoap03-textonapathwithstartOffsetattribute</desc>


<usexlink:href="#MyPath"fill="none"stroke="red"/>

<textfont-family="Verdana"font-size="42.5"fill="blue">

<textPathxlink:href="#MyPath"startOffset="80%">

Wegoup,thenwegodown,thenupagain

</textPath>

</text>


<!--Showoutlineofcanvasusing'rect'element-->

<rectx="1"y="1"width="998"height="298"

fill="none"stroke="blue"stroke-width="2"/>

</svg>

Exampletoap03
ViewthisexampleasSVG(SVG-enabledbrowsersonly)

10.13.3路径文本的布局规则Textonapathlayoutrules

概念上说来,对于路径上的文本,目标路径要么被拉伸为一水平直线段要么被拉伸为垂直直线段。对于水平文本布局流而言,此路径被拉伸成为一假想的水平线段使得路径的起点被映射到直线段的左端。对于垂直文本布局流而言,此路径被拉伸成为一假想的垂直线段使得路径的起点被映射到直线段的顶端。标准的文本布局规则被用于这一假想的直线段上并且其结果被映照回目标路径上。垂直的和双向文本布局规则也用于路径上的文本。Conceptually,
fortextonapaththetargetpathisstretchedoutintoeitherahorizontalorverticalstraightlinesegment.Forhorizontaltextlayoutflows,thepathisstretchedoutintoahypotheticalhorizontallinesegmentsuchthatthestartofthepathismappedto
theleftofthelinesegment.Forverticaltextlayoutflows,thepathisstretchedoutintoahypotheticalverticallinesegmentsuchthatthestartofthepathismappedtothetopofthelinesegment.Thestandardtextlayout
rulesareappliedtothehypotheticalstraightlinesegmentandtheresultismappedbackontothetargetpath.Verticalandbidirectionaltext
layoutrulesalsoapplytotextonapath.

对于沿着路径渲染的每个图元而言它们各自确定自己的参考方向。对于水平文本布局流而言,给定图元的参考方向为矢量此矢量开始于缚上图元的路径上的交叉点并指向此曲线在交叉点的角度逆时针旋转90度的方向。对于垂直文本布局流而言,给定图元的参考方向为矢量此矢量开始于缚上图元的路径上的交叉点并指向此曲线在交叉点的角度旋转180度的方向。Thereferenceorientation
isdeterminedindividuallyforeachglyphthatisrenderedalongthepath.Forhorizontaltextlayoutflows,thereferenceorientationforagivenglyphisthevectorthatstartsattheintersectionpointonthepathtowhichtheglyphisattachedandwhichpoints
inthedirection90degreescounter-clockwisefromtheangleofthecurveattheintersectionpoint.Forverticaltextlayoutflows,thereferenceorientationforagivenglyphisthevectorthatstartsattheintersectionpointonthepathtowhichtheglyph
isattachedandwhichpointsinthedirection180degreesfromtheangleofthecurveattheintersectionpoint.

例子toap04将用于解释对于直线水平或垂直文本的基本
文本布局规则进行补充的特殊布局规则。Exampletoap04willbeusedtoillustratetheparticularlayoutrulesfortextonapaththatsupplementthebasictext
layoutrulesforstraightlinehorizontalorverticaltext.


<?xmlversion="1.0"standalone="no"?>

<!DOCTYPEsvgPUBLIC"-//W3C//DTDSVG20010904//EN"

"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">

<svgwidth="12cm"height="3.6cm"viewBox="001000300"

xmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink">

<defs>

<pathid="MyPath"

d="M100125

C150125250175300175

C350175450125500125

C550125650175700175

C750175850125900125"/>

</defs>

<desc>Exampletoap04-textonapathlayoutrules</desc>


<usexlink:href="#MyPath"fill="none"stroke="red"/>

<textfont-family="Verdana"font-size="60"fill="blue"letter-spacing="2">

<textPathxlink:href="#MyPath">

Chooseshameorgetwar

</textPath>

</text>


<!--Showoutlineofcanvasusing'rect'element-->

<rectx="1"y="1"width="998"height="298"

fill="none"stroke="blue"stroke-width="2"/>

</svg>

Exampletoap04
ViewthisexampleasSVG(SVG-enabledbrowsersonly)

下图显示对此文本'text'元素的第一个图元的一种初步的放大。Thefollowingpicturedoesaninitialzoominonthefirstglyphinthe'text'
element.

上图中的小圆点说明图元缚上路径的那个点。图元周围的方框说明对图元进行旋转使得它的水平轴与曲线在图元缚上路径的这个点上的切线平行。此方框也显示了图元的字符宽度(即,当图元使用水平文本布局进行绘制之后当前文本位置的增量).Thesmalldotaboveshowsthepointatwhichtheglyphisattachedtothepath.The
boxaroundtheglyphshowstheglyphisrotatedsuchthatitshorizontalaxisisparalleltothetangentofthecurveatthepointatwhichtheglyphisattachedtothepath.Theboxalsoshowstheglyph'scharwidth(i.e.,theamountwhichthecurrenttextposition
advanceshorizontallywhentheglyphisdrawnusinghorizontaltextlayout).

进行进一步放大的下一个图片示范了更详细的布局规则。Thenextpicturezoomsinfurthertodemonstratethedetailedlayoutrules.

对于沿着一个路径从左到右水平文本布局而言(即,当图元的方向正交于
内联-书写-方向时),布局规则如下:Forleft-to-righthorizontaltextlayoutalongapath(i.e.,whentheglyphorientationisperpendiculartotheinline-progression-direction),the
layoutrulesareasfollows:

确定使用属性
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为此路径上最左边的那个圆点.)Determinethestartpoint-on-the-pathforthefirstglyphusingattribute

startOffsetandproperty
'text-anchor'.For
'text-anchor:start',startpoint-on-the-pathisthepointonthepathwhichrepresentsthepointonthepathwhichisstartOffset
distancealongthepathfromthestartofthepath,calculatedusingtheuseragent'sdistancealongthepathalgorithm.
For
'text-anchor:middle',startpoint-on-the-pathisthepointonthepathwhichrepresentsthepointonthepathwhichis[startOffset
minushalfofthetotaladvancevaluesforalloftheglyphsinthe'textPath'element]distancealongthepathfromthestartofthepath,calculatedusingtheuseragent'sdistance
alongthepathalgorithm.For
'text-anchor:end',startpoint-on-the-pathisthepointonthepathwhichrepresentsthepointonthepathwhichis[startOffset
minusthetotaladvancevaluesforalloftheglyphsinthe'textPath'element].Beforerenderingthefirstglyph,thehorizontalcomponentofthestartpoint-on-the-pathisadjustedtotakeintoaccountvarioushorizontalalignmenttextpropertiesandattributes,
suchasa
dxattributevalueona
'tspan'element.(Inthepictureabove,thestartpoint-on-the-pathistheleftmostdotonthepath.)
确定图元的字符宽度(即,当图元使用水平文本布局进行绘制之后当前文本位置的在水平方向上的增量).(在上图中,字符宽度为方框的两边的两个点之间的距离.)Determinetheglyph'scharwidth(i.e.,theamountwhichthecurrenttextpositionadvanceshorizontallywhentheglyphisdrawnusinghorizontaltextlayout).(Inthepicture
above,thecharwidthisthedistancebetweenthetwodotsatthesideofthebox.)
确定从此图元路径上起始点沿着路径移动字符宽度的距离后曲线上的点,计算使用用户代理的
沿路径的距离算法.这一点被称为图元的路径上的终止点
endpoint-on-the-path.(在上图中,图元的在路径上的终止点(endpoint-on-the-path)为路径上最右边的圆点.)Determinethepointonthecurvewhichischarwidthdistancealongthepathfromthestartpoint-on-the-pathforthisglyph,calculatedusingtheuseragent's

distancealongthepathalgorithm.Thispointistheendpoint-on-the-pathfortheglyph.(Inthepictureabove,theendpoint-on-the-pathfortheglyphistherightmostdotonthepath.)
确定路径上的中点midpoint-on-the-path,它是路径上的一点此点在路径上的起点startpoint-on-the-path和路径上的终点endpoint-on-the-path之间的"半路"上(用户代理可以选择距离计算法或参量计算法).(在上图中,路径上的中点midpoint-on-the-path用白色的圆点表示.)Determinethe
midpoint-on-the-path,whichisthepointonthepathwhichis"halfway"(useragentscanchooseeitheradistancecalculationoraparametriccalculation)betweenthestartpoint-on-the-pathandtheendpoint-on-the-path.(Inthepictureabove,themidpoint-on-the-path
isshownasawhitedot.)
确定图元中线glyph-midline,
它是在图元坐标系中的贯穿图元x-轴中点的一根垂直线.(在上图中,图元中线显示为一根破折线.)Determinetheglyph-midline,whichistheverticallineintheglyph'scoordinatesystemthatgoesthroughtheglyph'sx-axismidpoint.(Inthepictureabove,theglyph-midlineisshownasadashedline.)

安置此图元使得图元中线通过路径上的中点midpoint-on-the-path并且与通过路径上的起点startpoint-on-the-path和路径上的终点endpoint-on-the-path的直线正交。Positiontheglyphsuchthattheglyph-midlinepassesthroughthemidpoint-on-the-pathandisperpendiculartothelinethroughthestartpoint-on-the-path
andtheendpoint-on-the-path.
相对于基于特性
'alignment-baseline'和在一个'tspan'元素上属性dy指定的任何值的路径上的中点midpoint-on-the-path垂直地对齐此图元.
在上面地例子中,特性
'alignment-baseline'没有指定,故使用初始值
'alignment-baseline:baseline'.无
'tspan'元素;于是,图元的基线与路径上的中点midpoint-on-the-path对齐.Aligntheglyphverticallyrelativetothemidpoint-on-the-pathbasedonproperty'alignment-baseline'
andanyspecifiedvaluesforattribute
dyona
'tspan'element.Intheexampleabove,the
'alignment-baseline'propertyisunspecified,sotheinitialvalueof
'alignment-baseline:baseline'willbeused.Thereareno
'tspan'elements;thus,thebaselineoftheglyphisalignedtothemidpoint-on-the-path.
对于每个随后的图元,设置前一个路径上的终止点endpoint-on-the-path为一个新的路径上起始点startpoint-on-the-path,但是要作适当的调整,这种调整要考虑字体内的水平字距调整表以及各种属性和特性(包括空白特性
和为属性
dx和
dy提供了值的
'tspan'元素)的当前值.所有调整按照沿着路径的距离调整来计算,计算使用用户代理的
沿着路径的距离算法.Foreachsubsequentglyph,setanewstartpoint-on-the-pathasthepreviousendpoint-on-the-path,butwithappropriateadjustmentstakingintoaccounthorizontalkerningtablesinthefontandcurrentvaluesofvariousattributesand
properties,including
spacingpropertiesand
'tspan'elementswithvaluesprovidedforattributes
dxand
dy.Alladjustmentsarecalculatedasdistanceadjustmentsalongthepath,calculatedusingtheuseragent'sdistancealong
thepathalgorithm.
那些路径上的中点(midpoint-on-the-path)位于路径的端点之外的图元不被渲染。Glyphswhosemidpoint-on-the-pathareoffeitherendofthepatharenotrendered.
连续渲染图元直到不存在更多的图元为止。Continuerenderingglyphsuntiltherearenomoreglyphs.

相比较的规则用于沿着一个路径从上到下垂直文本布局(即,当图元的方向平行于
内联-书写-方向时),布局规则如下:Comparablerulesareusedfortop-to-bottomverticaltextlayoutalongapath(i.e.,whentheglyphorientationisparallelwiththeinline-progression-direction),the
layoutrulesareasfollows:

使用与沿着路径的水平文本布局相同的方法确定路径上的起点startpoint-on-the-path,除了在渲染第一个图元之前,路径上的起点startpoint-on-the-path的水平分量被调整为考虑各种垂直对齐文本特性和属性,比如在一个'tspan'
元素上的属性dy。Determinethestartpoint-on-the-pathusingthesamemethodasforhorizontaltextlayoutalongapath,
exceptthatbeforerenderingthefirstglyph,thehorizontalcomponentofthestartpoint-on-the-pathisadjustedtotakeintoaccountvariousverticalalignmenttextpropertiesandattributes,suchasady
attributevalueona
'tspan'element.
确定图元的字符高度(即,当图元使用垂直文本布局进行绘制之后当前文本位置在垂直方向的增量).Determinetheglyph'scharheight(i.e.,theamountwhichthecurrenttextpositionadvancesverticallywhentheglyphisdrawnusingverticaltextlayout).
确定从此图元路径上起始点沿着路径移动字符高度的距离后曲线上的点,计算使用用户代理的
沿路径的距离算法.这一点被称为图元的路径上的终止点.Determinethepointonthecurvewhichischarheightdistancealongthepathfromthestartpoint-on-the-pathforthisglyph,calculatedusingtheuseragent'sdistance
alongthepathalgorithm.Thispointistheendpoint-on-the-pathfortheglyph.
确定路径上的中点midpoint-on-the-path,它是路径上的一点此点在路径上的起点startpoint-on-the-path和路径上的终点endpoint-on-the-path之间的"半路"上(用户代理可以选择距离计算法或参量计算法).Determinethemidpoint-on-the-path,whichisthepointonthepathwhichis"halfway"(useragentscanchooseeitheradistance
calculationoraparametriccalculation)betweenthestartpoint-on-the-pathandtheendpoint-on-the-path.
确定图元中线glyph-midline,它是在图元坐标系中的贯穿图元y-轴中点的一根水平线.Determinetheglyph-midline,whichisthehorizontallineintheglyph'scoordinatesystemthatgoesthroughtheglyph'sy-axismidpoint.
安置此图元使得图元中线通过路径上的中点midpoint-on-the-path并且与通过路径上的起点startpoint-on-the-path和路径上的终点endpoint-on-the-path的直线正交。Positiontheglyphsuchthattheglyph-midlinepassesthroughthemidpoint-on-the-pathandisperpendiculartothelinethroughthestartpoint-on-the-path
andtheendpoint-on-the-path.
相对于基于特性
'alignment-baseline'和在一个'tspan'元素上属性dx指定的任何值的路径上的中点midpoint-on-the-path水平地
(这里水平是相对于图元的坐标系)对齐此图元.Aligntheglyphhorizontally(wherehorizontalisrelativetotheglyph'scoordinatesystem)relativetothemidpoint-on-the-pathbasedonproperty'alignment-baseline'
andanyspecifiedvaluesforattribute
dxona
'tspan'element.
对于每个随后的图元,设置前一个路径上的终止点endpoint-on-the-path为一个新的路径上起始点startpoint-on-the-path,但是要作适当的调整,这种调整要考虑字体内的垂直字距调整表以及各种属性和特性(包括空白特性
和为属性
dx和
dy提供了值的
'tspan'元素)的当前值.所有调整按照沿着路径的距离调整来计算,计算使用用户代理的
沿着路径的距离算法.Foreachsubsequentglyph,setanewstartpoint-on-the-pathasthepreviousendpoint-on-the-path,butwithappropriateadjustmentstakingintoaccountverticalkerningtablesinthefontandcurrentvaluesofvariousattributesandproperties,
including
spacingpropertiesand
'tspan'elementswithvaluesprovidedforattributes
dxand
dy.Alladjustmentsarecalculatedasdistanceadjustmentsalongthepath,calculatedusingtheuseragent'sdistancealong
thepathalgorithm.
那些路径上的中点(midpoint-on-the-path)位于路径的端点之外的图元不被渲染。Glyphswhosemidpoint-on-the-pathareoffeitherendofthepatharenotrendered.
连续渲染图元直到不存在更多的图元为止。Continuerenderingglyphsuntiltherearenomoreglyphs.

在上述计算中,如果在路径上的起始点(startpoint-on-the-path)或在路径上的终止点(endpoint-on-the-path)越过路径的端点,那么用一平行于路径的端点的切线的直线在端点之外扩展此路径使得仍然能够计算路径上的中点(midpoint-on-the-path)。Inthecalculationsabove,ifeitherthestartpoint-on-the-pathortheendpoint-on-the-pathisofftheendof
thepath,thenextendthepathbeyonditsendpointswithastraightlinethatisparalleltothetangentatthepathatitsendpointsothatthemidpoint-on-the-pathcanstillbecalculated.

内联-书写-方向为水平方向时,那么在'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
属性将被忽略.Whenthe
inline-progression-directionishorizontal,thenany
xattributeson
'text',
'tspan',
'tref'or
'altGlyph'elementsrepresentnewabsoluteoffsetsalongthepath,thusprovidingexplicitnewvaluesforstartpoint-on-the-path.Anyy
attributeson
'text',
'tspan',
'tref'or
'altGlyph'elementsareignored.Whenthe
inline-progression-directionishorizontal,thenany
yattributeson
'text',
'tspan',
'tref'or
'altGlyph'elementsrepresentnewabsoluteoffsetsalongthepath,thusprovidingexplicitnewvaluesforstartpoint-on-the-path.Anyx
attributeson
'text',
'tspan',
'tref'or
'altGlyph'elementsareignored.

10.14备用图元Alternateglyphs

在某些情况下比如组合字符,特定用途的字体(例如,表示音乐符号的字体)或者关于亚洲文本串的替换图元此时除正常情况下对应于给定字符数据的图元外需要使用另一套不同的图元。Therearesituationssuchasligatures,special-purposefonts(e.g.,afontformusicsymbols)oralternateglyphsforAsiantextstringswhereitisrequiredthatadifferent
setofglyphsisusedthantheglyph(s)whichnormallycorrespondstothegivencharacterdata.

元素'altGlyph'提供对用于渲染特殊字符数据的图元的控制。The'altGlyph'elementprovidescontrolovertheglyphsusedtorenderparticularcharacterdata.


<!ENTITY%altGlyphExt"">

<!ELEMENTaltGlyph(#PCDATA%altGlyphExt;)*>

<!ATTLISTaltGlyph

%stdAttrs;

%xlinkRefAttrs;

xlink:href%URI;#IMPLIED

glyphRefCDATA#IMPLIED

formatCDATA#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>

属性定义:Attributedefinitions:

xlink:href="<uri>"

一个
URI引用它要么指向精图文档片段中的一个'glyph'元素要么指向一个'altGlyphDef'
元素.A
URIreferenceeithertoa
'glyph'elementinanSVGdocumentfragmentortoan'altGlyphDef'
element.

如果此引用指向一个'glyph'元素并且此图元可用,那么将替换'altGlyph'元素内部的字符而对此图元进行渲染.Ifthereferenceistoa'glyph'elementandthatglyphisavailable,thenthatglyphisrenderedinsteadofthecharacter(s)thatareinsideofthe'altGlyph'element.

如果此引用指向一个
'altGlyphDef'元素,那么如果从处理'altGlyphDef'元素能够定位一套适当的图元,那么那些替补图元将代替'altGlyph'元素内部的字符而被渲染.Ifthereferenceistoan'altGlyphDef'
element,thenifanappropriatesetofalternateglyphsislocatedfromprocessingthe'altGlyphDef'element,thenthosealternateglyphsarerenderedinsteadofthecharacter(s)thatareinsideofthe'altGlyph'element.

Animatable:no.

glyphRef="<string>"

图元标识符,其格式依赖于给定字体的格式
format.(与元素'glyphRef'上的属性glyphRef具有相同的意思.)
Theglyphidentifier,theformatofwhichisdependentonthe
formatofthegivenfont.(Samemeaningasthe
glyphRefattributeonthe
'glyphRef'element.)

Animatable:no.

format="<string>"

给定字体的格式.如果此字体为规范[CSS2-src]所列出的格式之一(例如,TrueDoc™PortableFontResource或者
EmbeddedOpenType),那么<string>必须包含定义在[CSS2-src]中的相应的字体格式串(例如,truedoc-pfr或者
embedded-opentype).(与元素'glyphRef'上的属性format具有相同的意思.)
Theformatofthegivenfont.Ifthefontisinoneoftheformatslistedinthe[CSS2-src]specification(e.g.,TrueDoc™PortableFontResourceor
EmbeddedOpenType),thenthe<string>mustcontainthecorrespondingfontformatstringdefinedin[CSS2-src](e.g.,truedoc-pfror
embedded-opentype).(Samemeaningasthe
formatattributeonthe
'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>valuesareprocessedinthesamemannerasthe

xattributeonthe
'tspan'element,withthefollowingexception:IfthereferencedalternateglyphsarerenderedinsteadoftheUnicodecharactersinsidethe'altGlyph'element,thenanyabsoluteXcoordinatesspecifiedviaanxattribute
onthiselementoranyancestor
'text'or
'tspan'elementsforUnicodecharacters2through<n>withinthe'altGlyph'elementareignored.AnyabsoluteXcoordinatespecifiedviaanxattributeonthiselementoranyancestor'text'
or
'tspan'elementsforthefirstUnicodecharacterwithinthe'altGlyph'elementsetsanewabsoluteXcoordinateforthecurrent
textpositionbeforerenderingthefirstalternateglyph.

Animatable:yes.

y="<coordinate>+"

用于渲染'altGlyph'元素所对应的绝对Y坐标。ThecorrespondingabsoluteYcoordinatesforrenderingthe'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>valuesareprocessedinthesamemannerasthe

dxattributeonthe
'tspan'element,withthefollowingexception:IfthereferencedalternateglyphsarerenderedinsteadoftheUnicodecharactersinsidethe'altGlyph'element,thenanyrelativeXcoordinatesspecifiedviaandxattribute
onthiselementoranyancestor
'text'or
'tspan'elementsforUnicodecharacters2through<n>withinthe'altGlyph'elementareignored.AnyrelativeXcoordinatespecifiedviaandxattributeonthiselementoranyancestor'text'
or
'tspan'elementsforthefirstUnicodecharacterwithinthe'altGlyph'elementsetsanewrelativeXcoordinateforthecurrent
textpositionbeforerenderingthefirstalternateglyph.

Animatable:yes.

dy="<length>+"

用于渲染'altGlyph'元素所对应的相对Y坐标。ThecorrespondingrelativeYcoordinatesforrenderingthe'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
areprocessedinthesamemannerasthe
rotateattributeonthe
'tspan'element,withthefollowingexception:IfthereferencedalternateglyphsarerenderedinsteadoftheUnicodecharactersinsidethe'altGlyph'element,thenanysupplementalrotationvaluesspecifiedviaanrotateattribute
onthiselementoranyancestor
'text'or
'tspan'elementsforUnicodecharacters2through<n>withinthe'altGlyph'elementareignored.Supplementalrotationvaluesspecifiedviaanrotateattributeonthiselementoranyancestor'text'
or
'tspan'elementsforthefirstUnicodecharacterwithinthe'altGlyph'elementsetsanewsupplementalrotationanglebeforerenderingthealternateglyphs.

Animatable:yes(无附加,只对'set'和'animate'元素).

在别处定义的属性:Attributesdefinedelsewhere:

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

如果对替换的图元的引用不能产生替换的图元成功的标识来用,那么在'altGlyph'元素里面的字符将被渲染就像此'altGlyph'元素被
'tspan'元素替换了一样.Ifthereferencestoalternateglyphsdonotresultinsuccessfulidentificationofalternateglyphstouse,thenthecharacter(s)thatareinsideofthe'altGlyph'elementarerenderedasifthe
'altGlyph'elementwerea
'tspan'elementinstead.

一个'altGlyph'元素要么引用一个
'glyph'元素要么经由它的
xlink:href属性引用一个'altGlyphDef'元素要么依靠依靠字体选择特性、一个图元标识符和一种字体格式来标识一个图元
.如果指定属性
xlink:href,则优先考虑此属性,并且其它图元标识属性和特性将被忽略.An'altGlyph'elementeitherreferencesa'glyph'
elementoran
'altGlyphDef'elementviaits
xlink:hrefattributeoridentifiesaglyphbymeansof
fontselectionproperties,aglyphidentifierandafontformat.Ifthe
xlink:hrefattributeisspecified,ittakesprecedence,andtheotherglyphidentificationattributesandpropertiesareignored.

元素'altGlyphDef'定义一套可能的图元替补.The'altGlyphDef'elementdefinesasetofpossibleglyphsubstitutions.


<!ENTITY%altGlyphDefExt"">

<!ELEMENTaltGlyphDef((glyphRef+|altGlyphItem+)%altGlyphDefExt;)>

<!ATTLISTaltGlyphDef

%stdAttrs;>

在别处定义的属性:Attributesdefinedelsewhere:

%stdAttrs;.

一个'altGlyphDef'可以包含下列之一:An'altGlyphDef'cancontaineitherofthefollowing:

在最简单的情况下,一个'altGlyphDef'包含一个或更多的
'glyphRef'元素.每个
'glyphRef'元素引用一个在特殊字体里的单一的图元.如果所有引用的图元是可用的,那么这些图元将被渲染来代替所引用的'altGlyph'元素内的字符.如果被引用的图元中任何一个不可用,那么'altGlyph'元素内的字符将被渲染好像在这些字符周围不存在'altGlyph'元素一样.Inthesimplestcase,an'altGlyphDef'contains
oneormore
'glyphRef'elements.Each
'glyphRef'elementreferencesasingleglyphwithinaparticularfont.Ifallofthereferencedglyphsareavailable,thentheseglyphsarerenderedinsteadofthecharacter(s)insideofthereferencing'altGlyph'element.
Ifanyofthereferencedglyphsareunavailable,thenthecharacter(s)thatareinsideofthe'altGlyph'elementarerenderedasiftherewerenotan'altGlyph'elementsurroundingthosecharacters.
在更复杂的情况下,一个'altGlyphDef'包含一个或更多的
'altGlyphItem'元素.每个
'altGlyphItem'表示一套候选的用于置换图元.每个
'altGlyphItem'包含一个或更多的
'glyphRef'元素.每个
'glyphRef'元素引用在特定字体下的一个单独的图元.将选择其引用的图元都可用的第一个'altGlyphItem'
.从这一'altGlyphItem'所引用的图元将被渲染而代替引用的'altGlyph'元素内部的字符.如果这些

'altGlyphItem'元素不能产生成功的匹配(即,没有一个
'altGlyphItem'元素它的所有引用的图元都是可用的),那么'altGlyph'元素内的字符将被渲染好像在这些字符周围不存在'altGlyph'元素一样.Inthemorecomplexcase,an'altGlyphDef'containsoneormore'altGlyphItem'
elements.Each
'altGlyphItem'representsacandidatesetofsubstituteglyphs.Each'altGlyphItem'
containsoneormore
'glyphRef'elements.Each
'glyphRef'elementreferencesasingleglyphwithinaparticularfont.Thefirst'altGlyphItem'
inwhichallreferencedglyphsareavailableischosen.Theglyphsreferencedfromthis'altGlyphItem'
arerenderedinsteadofthecharacter(s)thatareinsideofthereferencing'altGlyph'element.Ifnoneofthe'altGlyphItem'
elementsresultinasuccessfulmatch(i.e.,noneofthe'altGlyphItem'elements
hasallofitsreferencedglyphsavailable),thenthecharacter(s)thatareinsideofthe'altGlyph'elementarerenderedasiftherewerenotan'altGlyph'elementsurroundingthosecharacters.

元素'altGlyphItem'定义一套候选的可能的图元置换.引用的图元的第一个'altGlyphItem'元素都可以用于选择.它的图元被渲染以代替在引用'altGlyph'元素里面的字符The'altGlyphItem'elementdefinesacandidatesetofpossibleglyphsubstitutions.The
first'altGlyphItem'elementwhosereferencedglyphsareallavailableischosen.Itsglyphsarerenderedinsteadofthecharacter(s)thatareinsideofthereferencing'altGlyph'element


<!ENTITY%altGlyphItemExt"">

<!ELEMENTaltGlyphItem(glyphRef+%altGlyphItemExt;)>

<!ATTLISTaltGlyphItem

%stdAttrs;>

在别处定义的属性:Attributesdefinedelsewhere:

%stdAttrs;.

元素'glyphRef'定义一个可能将被使用的图元.The'glyphRef'elementdefinesapossibleglyphtouse.


<!ELEMENTglyphRefEMPTY>

<!ATTLISTglyphRef

%stdAttrs;

%xlinkRefAttrs;

xlink:href%URI;#IMPLIED

class%ClassList;#IMPLIED

style%StyleSheet;#IMPLIED

%PresentationAttributes-FontSpecification;

glyphRefCDATA#IMPLIED

formatCDATA#IMPLIED

x%Number;#IMPLIED

y%Number;#IMPLIED

dx%Number;#IMPLIED

dy%Number;#IMPLIED>

属性定义:Attributedefinitions:

xlink:href="<uri>"

一个指向在某个精图文档片段内的一个图元'glyph'元素的URI
引用.所引用的图元'glyph'将作为一个备选图元来渲染.A
URIreferencetoa
'glyph'elementinanSVGdocumentfragment.Thereferenced'glyph'isrenderedasanalternateglyph.

Animatable:no.

glyphRef="<string>"

图元标识符,其格式format依赖于所给定字体的格式
format.Theglyphidentifier,theformatofwhichisdependentonthe
formatofthegivenfont.

Animatable:no.

format="<string>"

给定字体的格式.如果此字体为规范[CSS2-src]所列出的格式之一(例如,TrueDoc™PortableFontResource或者
EmbeddedOpenType),那么<string>必须包含定义在[CSS2-src]中的相应的字体格式串(例如,truedoc-pfr或者
embedded-opentype).Theformatofthegivenfont.Ifthefontisinoneoftheformatslistedin[CSS2-src](e.g.,TrueDoc™PortableFontResource
orEmbeddedOpenType),thenthe<string>mustcontainthecorrespondingfontformatstringdefinedin[CSS2-src](e.g.,truedoc-pfror
embedded-opentype).

Animatable:no.

x="<number>"

这个值表示针对这一图元的字体的坐标系内的新的绝对X坐标.ThisvaluerepresentsthenewabsoluteXcoordinatewithinthefont'scoordinatesystemforthisglyph.

字体坐标系基于在"层叠样式表(CSS)级别2"规范[CSS2]的章节"字体"中所描述的emsquare模型.Thefontcoordinatesystem
isbasedontheemsquaremodeldescribedinthe"Fonts"chapterofthe"CascadingStyleSheets(CSS)level2"specification[CSS2].

如果未指定此属性,对于第一个'glyphRef'子元素而言,其效果相当于设置此属性为"0",而随后的'glyphRef'子元素,其效果相当于设置此属性为以前的'glyphRef'元素的末端的X坐标.Iftheattributeisnotspecified,forthefirst'glyphRef'childelement,theeffectisasiftheattributeweresetto"0",whereasforsubsequent
'glyphRef'childelements,theeffectisasiftheattributeweresettotheendXcoordinatefromtheprevious'glyphRef'element.

Animatable:no.

y="<number>"

针对这一图元的字体的坐标系内所对应的新的绝对Y坐标.ThecorrespondingnewabsoluteYcoordinatewithinthefont'scoordinatesystemforthisglyph.

Animatable:no.

dx="<number>"

这个值表示针对这一图元的字体的坐标系内的相对X坐标.于是图元沿着在字体坐标系内正的X轴平移<number>单位以补充由
x属性(要么由一个显式的
x属性要么由
x属性的缺省值处理)所建立的绝对X坐标.ThisvaluerepresentstherelativeXcoordinatewithinthefont'scoordinatesystemforthisglyph.Theglyphisthusshiftedby<number>unitsalongthepositiveXaxiswithinthefont'scoordinatesystemsupplementaltotheabsolute
Xcoordinateestablishedbythe
xattribute(eitherduetoanexplicit
xattributeorduetodefaultvalueprocessingforthe
xattribute).

字体坐标系基于在"层叠样式表(CSS)级别2"规范[CSS2]的章节"字体"中所描述的emsquare模型.Thefontcoordinate
systemisbasedontheemsquaremodeldescribedinthe"Fonts"chapterofthe"CascadingStyleSheets(CSS)level2"specification[CSS2].

如果未指定此属性,其效果相当于设置此属性为"0"。Iftheattributeisnotspecified,theeffectisasiftheattributeweresetto"0".

Animatable:no.

dy="<number>"

以在字体坐标系内的单位为单位沿着相对于由y属性所建立的绝对Y坐标的正的Y轴平移此图元所对应的数值。Thecorrespondingnumberofunitswithinthefont'scoordinate
systemtoshifttheglyphalongthepositiveYaxisrelativetotheabsoluteYcoordinateestablishedbytheyattribute.

Animatable:no.

在别处定义的属性:Attributesdefinedelsewhere:

%stdAttrs;,%xlinkRefAttrs;,class,style,

%PresentationAttributes-FontSpecification;.

一个'glyphRef'要么通过它的属性xlink:href引用精图文档片段中的一个'glyph'
元素或者依靠字体选择特性、一个图元标识符和一种字体格式来确定一个图元.如果给定不足够的属性和特性来标识一个图元,那么'glyphRef'按照当一个图元引用被充分给定时的相同方式进行处理,可是给定的图元是不可用的.
如果指定属性xlink:href,则优先考虑此属性,而其它的图元标识属性和特性将被忽略.A'glyphRef'eitherreferencesa'glyph'
elementinanSVGdocumentfragmentviaitsxlink:hrefattributeoridentifiesaglyphbymeansof

fontselectionproperties,aglyphidentifierandafontformat.Ifinsufficientattributesandpropertieshavebeenspecifiedtoidentifyaglyph,thenthe'glyphRef'isprocessedinthesamemanneraswhenaglyphreferenceisfullyspecified,butthegiven
glyphisnotavailable.Ifthe
xlink:hrefattributeisspecified,ittakesprecedence,andtheotherglyphidentificationattributesandpropertiesareignored.

10.15空白字符处理Whitespacehandling

精图支持标准的XML属性
xml:space来指定对在一给定的文本'text'元素的字符数据中的空白字符的处理方式.精图用户代理具有如下所述的与此属性相关的特殊的处理规则.这些是出现在随后的XML分析[XML10]和文档对象模型[DOM2]的任何构造中的行为
.SVGsupportsthestandardXMLattributexml:spacetospecifythehandlingofwhitespacecharacterswithinagiven'text'element'scharacterdata.TheSVGuseragenthasspecialprocessingrulesassociatedwiththisattribute
asdescribedbelow.ThesearebehaviorsthatoccursubsequenttoXMLparsing[XML10]andanyconstructionofaDocumentObjectModel[DOM2].

xml:space为一种可继承的属性它可以取下列两个值之一:xml:spaceisaninheritableattributewhichcanhaveoneoftwovalues:

default(xml:space的初始/缺省值)-当
xml:space="default"
时,精图用户代理将利用原来的字符数据内容的复制做下列事情.首先,去掉所有换行字符.然后将所有制表符替换成空白字符.接着,除去所有开头和尾部的空白字符.最后,将所有连续的空白字符合并成一个空白字符.default(theinitial/defaultvalueforxml:space)
-When
xml:space="default"
,theSVGuseragentwilldothefollowingusingacopyoftheoriginalcharacterdatacontent.First,itwillremoveallnewlinecharacters.Thenitwillconvertalltabcharactersintospacecharacters.Then,itwill
stripoffallleadingandtrailingspacecharacters.Then,allcontiguousspacecharacterswillbeconsolidated.
preserve-当
xml:space="preserve"
时,精图用户代理将利用原来的字符数据内容的复制做下列事情.将所有换行和制表符替换成空白字符.然后,将绘制所有空白字符,包括开头的,尾部的和多个连续的空白字符.于是,当按照
xml:space="preserve"
进行绘制时,字符串
"ab"
(在"a"和"b"之间有三个空白字符)将在"a"和"b"之间比
"ab"
(在"a"和"b"之间有一个空白字符)产生一个较大的分隔.preserve-When
xml:space="preserve"
,theSVGuseragentwilldothefollowingusingacopyoftheoriginalcharacterdatacontent.Itwillconvertallnewlineandtabcharactersintospacecharacters.Then,itwilldrawallspacecharacters,includingleading,
trailingandmultiplecontiguousspacecharacters.Thus,whendrawnwith
xml:space="preserve"
,thestring
"ab"
(threespacesbetween"a"and"b")willproducealargerseparationbetween"a"and"b"than
"ab"
(onespacebetween"a"and"b").

下列例子解释当使用
xml:space="default"
时行的缩排是重要的.下面的片段显示了两对类似文本'text'元素,这两个文本'text'元素都具有属性xml:space='default'.对于这些例子而言,在每行的尾部不存在额外的空白字符(即,在最后一个可见字符之后马上出现一个换行符).Thefollowingexampleillustratesthatlineindentationcanbeimportantwhenusing
xml:space="default"
.
Thefragmentbelowshowtwopairsofsimilar'text'elements,withboth'text'elementsusingxml:space='default'.Fortheseexamples,thereisnoextrawhitespaceattheendofanyofthelines(i.e.,thelinebreakoccursimmediatelyafterthelastvisible
character).


[01]<textxml:space='default'>

[02]WSexample

[03]indentedlines

[04]</text>

[05]<textxml:space='preserve'>WSexampleindentedlines</text>

[06]

[07]<textxml:space='default'>

[08]WSexample

[09]non-indentedlines

[10]</text>

[11]<textxml:space='preserve'>WSexamplenon-indentedlines</text>

上面第一对文本'text'元素说明缩进字符数据的效果.在第一个文本'text'元素的属性xml:space='default'指示用户代理进行下列处理:Thefirstpairof'text'elementsaboveshowtheeffectofindentedcharacterdata.Theattributexml:space='default'inthefirst'text'elementinstructstheuseragent
to:

将所有制表符(如果有的话)替换成空白字符,convertalltabs(ifany)tospacecharacters,
去掉所有换行字符(即,去掉在行[01],[02]和[03]尾部的换行符),stripoutalllinebreaks(i.e.,stripoutthelinebreaksattheendoflines[01],[02]and[03]),
除去所有开头的空白字符(即,除去行[02]上在"WSexample"之前的空白字符),stripoutallleadingspacecharacters(i.e.,stripoutspacecharactersbefore"WSexample"online[02]),
除去所有尾部的空白字符(即,除去行[04]上在"</text>"之前的空白字符),stripoutalltrailingspacecharacters(i.e.,stripoutspacecharactersbefore"</text>"online[04]),
合并所有中间的空白字符(即,行[03]上在"indentedlines"之前的空白字符)到一个单一的空白字符.consolidateallintermediatespacecharacters(i.e.,thespacecharactersbefore"indentedlines"online[03])intoasinglespacecharacter.

上面第二对文本'text'元素说明非缩进字符数据的效果.在第三个文本'text'元素的属性xml:space='default'指示用户代理进行下列处理:Thesecondpairof'text'elementsaboveshowtheeffectofnon-indentedcharacterdata.Theattributexml:space='default'inthethird'text'elementinstructstheuseragent
to:

将所有制表符(如果有的话)替换成空白字符,convertalltabs(ifany)tospacecharacters,
去掉所有换行字符(即,去掉在行[07],[08]和[09]尾部的换行符),stripoutalllinebreaks(i.e.,stripoutthelinebreaksattheendoflines[07],[08]and[09]),
除去所有开头的空白字符(在这个例子中没有开头的空白字符),stripoutallleadingspacecharacters(therearenoleadingspacecharactersinthisexample),
除去所有尾部的空白字符(即,除去行[10]上在"</text>"之前的空白字符),stripoutalltrailingspacecharacters(i.e.,stripoutspacecharactersbefore"</text>"online[10]),
合并所有中间的空白字符(在这个例子中没有中间的空白字符)到一个单一的空白字符.consolidateallintermediatespacecharactersintoasinglespacecharacter(inthisexample,therearenointermediatespacecharacters).

注意在将字符数据传给应用之前我们要求XML分析程序将换行标识(例如,两个字符的文字序列"#xD#xA"或单个文字#xD或#xA)转换成标准的表示即单个字符#xA.于是,在精图内的每个换行将由单个字符#xA表示,无论在原先的资源内用什么表示换行.(参见XMLend-of-linehandling.)Note
thatXMLparsersarerequiredtoconvertthestandardrepresentationsforanewlineindicator(e.g.,theliteraltwo-charactersequence"#xD#xA"orthestand-aloneliterals#xDor#xA)intothesinglecharacter#xAbeforepassingcharacterdatatotheapplication.
Thus,eachnewlineinSVGwillberepresentedbythesinglecharacter#xA,nomatterwhatrepresentationfornewlinesmighthavebeenusedintheoriginalresource.(SeeXML
end-of-linehandling.)

在精图语言或精图文档对象模型中的任何基于字符位置数的特征,比如在
'text',
'tspan',
'tref'
'altGlyph'元素上的属性
x,
y,
dx,
dy和
rotate,是基于在使用这里所描述的空白字符处理规则后的字符位置.特别,如果
xml:space="default"
,作为处理的一部分常常是空白字符被去掉.字符位置数将被索引到在被这一节中的规则所移去的空白字符之后的文本字符串.AnyfeaturesintheSVGlanguageortheSVGDOMthatarebasedoncharacterpositionnumber,suchasthex,

y,
dx,
dyand
rotateattributesonthe
'text',
'tspan',
'tref'
'altGlyph'elements,arebasedoncharacterpositionafterapplyingthewhitespacehandlingrulesdescribedhere.Inparticular,if
xml:space="default"
,itisoftenthecasethatwhitespacecharactersare
removedaspartofprocessing.Characterpositionnumbersindexintothetextstringafterthewhitespacecharactershavebeenremovedpertherulesinthissection.

属性xml:space具有性质:Thexml:spaceattributeis:

Animatable:no.

10.16文本的选择和剪贴板操作Textselectionandclipboardoperations

在具有文本选择能力(例如,装备了指点设备比如鼠标)并且其具有复制/粘贴操作的系统剪贴板的系统上的兼容精图浏览器要求支持:ConformingSVG
viewersonsystemswhichhavethecapacityfortextselection(e.g.,systemswhichareequippedwithapointerdevicesuchasamouse)andwhichhavesystemclipboardsforcopy/pasteoperationsarerequiredtosupport:

在精图内容中的文本串的用户选择userselectionoftextstringsinSVGcontent
复制所选文本串到系统剪切板的能力theabilitytocopyselectedtextstringstothesystemclipboard

当下列情况出现时一个文本选择操作开始:Atextselectionoperationstartswhenallofthefollowingoccur:

用户定位指点设备在作为文本'text'元素的一部分进行渲染的一个图元上,这时开始一个选择操作(例如,按下标准的系统鼠标按钮进行选择操作)然后在连续进行选择
操作的同时移动指点设备(例如,继续按着标准的系统鼠标按钮进行选择操作)theuserpositionsthepointingdeviceoveraglyphthathasbeenrenderedaspartofa'text'
element,initiatesaselectoperation(e.g.,pressingthestandardsystemmousebuttonforselectoperations)andthenmovesthepointingdevicewhilecontinuingtheselectoperation(e.g.,continuingtopressthestandardsystemmousebutton
forselectoperations)
在指点设备点击的点上的图元的上面无其它可视的图形元素noothervisiblegraphicselementhasbeenpaintedabovetheglyphatthepointatwhichthepointingdevicewasclicked
无任何已经指派给此
'text',
'tspan'或
'textPath',元素(s)(或它们的祖先)的
链接或
事件与此给定的图元相联系.no
linksor
eventshavebeenassignedtothe
'text',
'tspan'or
'textPath',element(s)(ortheirancestors)associatedwiththegivenglyph.

当进行文本选择操作的时候(例如,用户连续按着给定的鼠标按钮时),所有与其它图形元素相关的事件被忽略(即,文本选择操作是模式的)并且精图用户代理将动态地用适当的突出显示技术表示哪些字符已被选择,例如用相反的颜色重画所选的图元.在文本选择处理期间当移动指针时,文本选择操作的最后的图元为在相同的'text'
元素中其图元小室最接近此指针的图元.如果某一文本'text'元素位于介于选择的开始和选择的结束之间的一个文本'text'
元素之内那么所有在此文本元素内的字符将被突出显示,既不考虑画布上的位置也不考虑在选择点的尾部的上方的如何图形元素.Asthetextselectionoperationproceeds(e.g.,theusercontinuestopressthegivenmousebutton),allassociatedeventswithothergraphicselementsareignored(i.e.,thetextselectionoperation
ismodal)andtheSVGuseragentshalldynamicallyindicatewhichcharactersareselectedbyanappropriatehighlightingtechnique,suchasredrawingtheselectedglyphswithinversecolors.Asthepointerismovedduringthetextselectionprocess,theendglyph
forthetextselectionoperationistheglyphwithinthesame'text'elementwhoseglyph
cellisclosesttothepointer.Allcharacterswithinthe'text'elementwhosepositionwithin
the'text'elementisbetweenthestartofselectionandendofselectionshallbehighlighted,
regardlessofpositiononthecanvasandregardlessofanygraphicselementsthatmightbeabovetheendofselectionpoint.

一旦文本选择操作结束(例如,用户释放给定的鼠标按钮),所选择的文本仍然停留在突出显示的状态直到出现取消文本选择的事件,比如一个指点设备的活动事件(例如,按下一个鼠标按钮).Oncethetextselectionoperationends(e.g.,theuserreleasesthegivenmousebutton),theselectedtextwillstayhighlighteduntilaneventoccurswhichcancelstext
selection,suchasapointerdeviceactivationevent(e.g.,pressingamousebutton).

在文本选择操作期间如何确定对那些字符进行突出显示的详细规则在文本选择实现注记中提供。Detailedrulesfordeterminingwhichcharacterstohighlight
duringatextselectionoperationareprovidedin
Textselectionimplementationnotes.

对于那些提供系统剪切板功能的系统而言,要求精图用户代理提供一个用户接口用于当前选择文本的开始复制到系统剪切板.只要精图用户代理按照针对纯文本的系统的适当的剪切板格式传送所选的文本串就足够了,不过精图用户代理如果也能够传送捕获了与给定文本串相关的各种字体特性的一种可以代替的富文本那就更好.For
systemswhichhavesystemclipboards,theSVGuseragentisrequiredtoprovideauserinterfaceforinitiatingacopyofthecurrentlyselectedtexttothesystemclipboard.ItissufficientfortheSVGuseragenttoposttheselectedtextstringinthesystem's
appropriateclipboardformatforplaintext,butitispreferableiftheSVGuseragentalsopostsarichtextalternativewhichcapturesthevariousfontproperties
associatedwiththegiventextstring.

对于双向文本而言,用户代理必须支持按逻辑顺序进行文本选择,这样会导致不连续的图元的突出显示因为字符的双向重定序.用户代理可以提供一种替换的能力按照可视的渲染次序来选择双向文本(即,在bidirectional文本布局算法被使用之后),
从而所选的字符数据也许在逻辑上是不连续的.在这中情况下,如果用户要求将此双向文本复制到剪切板,那么要求用户代理做适当的调整只复制那些可见的被选择的字符到剪切板上.Forbidirectionaltext,theuseragentmustsupporttextselectioninlogicalorder,whichwillresultindiscontinuoushighlightingofglyphsduetothebidirectionalreordering
ofcharacters.Useragentscanprovideanalternativeabilitytoselectbidirectionaltextinvisualrenderingorder(i.e.,afterbidirectionaltext
layoutalgorithmshavebeenapplied),withtheresultthatselectedcharacterdatamightbediscontinuouslogically.Inthiscase,iftheuserrequeststhatbidirectionaltextbecopiedtotheclipboard,thentheuseragentisrequiredtomakeappropriateadjustments
tocopyonlythevisuallyselectedcharacterstotheclipboard.

当切实可行时,建议精图生成器应尝试对它们产生的文本串进行定序使得精图浏览应用比如网页浏览器可以较容易适当地确定文本选择的顺序。Whenfeasible,itisrecommendedthatgeneratorsofSVGattempttoordertheirtextstringstofacilitateproperlyorderedtextselectionwithinSVGviewingapplicationssuchasWebbrowsers.

10.17文档对象模型接口DOMinterfaces

Thefollowinginterfacesaredefinedbelow:
SVGTextContentElement,
SVGTextPositioningElement,
SVGTextElement,
SVGTSpanElement,
SVGTRefElement,
SVGTextPathElement,
SVGAltGlyphElement,
SVGAltGlyphDefElement,
SVGAltGlyphItemElement,
SVGGlyphRefElement.

InterfaceSVGTextContentElement

TheSVGTextContentElementinterfaceisinheritedbyvarioustext-relatedinterfaces,suchasSVGTextElement,

SVGTSpanElement,
SVGTRefElement,
SVGAltGlyphElementand
SVGTextPathElement.

IDLDefinition


interfaceSVGTextContentElement:

SVGElement,

SVGTests,

SVGLangSpace,

SVGExternalResourcesRequired,

SVGStylable,

events::EventTarget{


//lengthAdjustTypes

constunsignedshortLENGTHADJUST_UNKNOWN=0;

constunsignedshortLENGTHADJUST_SPACING=1;

constunsignedshortLENGTHADJUST_SPACINGANDGLYPHS=2;


readonlyattributeSVGAnimatedLengthtextLength;

readonlyattributeSVGAnimatedEnumerationlengthAdjust;


longgetNumberOfChars();

floatgetComputedTextLength();

floatgetSubStringLength(inunsignedlongcharnum,inunsignedlongnchars)

raises(DOMException);

SVGPointgetStartPositionOfChar(inunsignedlongcharnum)

raises(DOMException);

SVGPointgetEndPositionOfChar(inunsignedlongcharnum)

raises(DOMException);

SVGRectgetExtentOfChar(inunsignedlongcharnum)

raises(DOMException);

floatgetRotationOfChar(inunsignedlongcharnum)

raises(DOMException);

longgetCharNumAtPosition(inSVGPointpoint);

voidselectSubString(inunsignedlongcharnum,inunsignedlongnchars)

raises(DOMException);

};


DefinitiongrouplengthAdjustTypes

Definedconstants

LENGTHADJUST_UNKNOWN

Theenumerationwassettoavaluethatisnotoneofpredefinedtypes.Itisinvalidtoattempttodefineanewvalueofthistypeortoattempttoswitchanexistingvaluetothistype.

LENGTHADJUST_SPACING

Correspondstovaluespacing.

LENGTHADJUST_SPACINGANDGLYPHS

CorrespondstovaluespacingAndGlyphs.

Attributes

readonlySVGAnimatedLengthtextLength

CorrespondstoattributetextLengthonthegivenelement.

readonlySVGAnimatedEnumerationlengthAdjust

CorrespondstoattributelengthAdjustonthegivenelement.Thevaluemustbeoneofthelengthadjustconstantsspecifiedabove.

Methods

getNumberOfChars

Returnsthetotalnumberofcharacterstoberenderedwithinthecurrentelement.Includescharacterswhichareincludedviaa'tref'reference.

NoParameters

Returnvalue

long

Totalnumberofcharacters.

NoExceptions

getComputedTextLength

Thetotalsumofalloftheadvancevaluesfromrenderingallofthecharacterswithinthiselement,includingtheadvancevalueontheglyphs(horizontalorvertical),theeffectofproperties'kerning',

'letter-spacing'and
'word-spacing'andadjustmentsduetoattributes
dxand
dyon
'tspan'elements.Fornon-renderingenvironments,theuseragentshallmakereasonableassumptionsaboutglyphmetrics.

NoParameters

Returnvalue

float

Thetextadvancedistance.

NoExceptions

getSubStringLength

Thetotalsumofalloftheadvancevaluesfromrenderingthespecifiedsubstringofthecharacters,includingtheadvancevalueontheglyphs(horizontalorvertical),theeffectofproperties'kerning',

'letter-spacing'and
'word-spacing'andadjustmentsduetoattributes
dxand
dyon
'tspan'elements.Fornon-renderingenvironments,theuseragentshallmakereasonableassumptionsaboutglyphmetrics.

Parameters

inunsignedlongcharnum

Theindexofthefirstcharacterinthesubstring,wherethefirstcharacterhasanindexof0.

inunsignedlongnchars

Thenumberofcharactersinthesubstring.

Returnvalue

float

Thetextadvancedistance.

Exceptions

DOMException

INDEX_SIZE_ERR:Raisedifthecharnumisnegativeorifcharnum+ncharsisgreaterthanorequaltothenumberofcharactersatthisnode.

getStartPositionOfChar

Returnsthecurrenttextpositionbeforerenderingthecharacterintheusercoordinatesystemforrenderingtheglyph(s)thatcorrespondtothespecifiedcharacter.Thecurrenttextpositionhasalreadytakenintoaccounttheeffectsofanyinter-characteradjustments
duetoproperties
'kerning',
'letter-spacing'and
'word-spacing'andadjustmentsduetoattributes
x,
y,
dxand
dy.Ifmultipleconsecutivecharactersarerenderedinseparably(e.g.,asasingleglyphorasequenceofglyphs),theneachoftheinseparablecharacterswillreturnthestartpositionforthefirstglyph.

Parameters

inunsignedlongcharnum

Theindexofthecharacter,wherethefirstcharacterhasanindexof0.

Returnvalue

SVGPoint

Thecharacter'sstartposition.

Exceptions

DOMException

INDEX_SIZE_ERR:Raisedifthecharnumisnegativeorifcharnumisgreaterthanorequaltothenumberofcharactersatthisnode.

getEndPositionOfChar

Returnsthecurrenttextpositionafterrenderingthecharacterintheusercoordinatesystemforrenderingtheglyph(s)thatcorrespondtothespecifiedcharacter.Thiscurrenttextpositiondoesnottakeintoaccounttheeffectsofanyinter-character
adjustmentstoprepareforthenextcharacter,suchasproperties'kerning',

'letter-spacing'and
'word-spacing'andadjustmentsduetoattributes
x,
y,
dxand
dy.Ifmultipleconsecutivecharactersarerenderedinseparably(e.g.,asasingleglyphorasequenceofglyphs),theneachoftheinseparablecharacterswillreturntheendpositionforthelastglyph.

Parameters

inunsignedlongcharnum

Theindexofthecharacter,wherethefirstcharacterhasanindexof0.

Returnvalue

SVGPoint

Thecharacter'sendposition.

Exceptions

DOMException

INDEX_SIZE_ERR:Raisedifthecharnumisnegativeorifcharnumisgreaterthanorequaltothenumberofcharactersatthisnode.

getExtentOfChar

ReturnsatightestrectanglewhichdefinestheminimumandmaximumXandYvaluesintheusercoordinatesystemforrenderingtheglyph(s)thatcorrespondtothespecifiedcharacter.Thecalculationsassumethatallglyphsoccupythefullstandardglyphcell
forthefont.Ifmultipleconsecutivecharactersarerenderedinseparably(e.g.,asasingleglyphorasequenceofglyphs),theneachoftheinseparablecharacterswillreturnthesameextent.

Parameters

inunsignedlongcharnum

Theindexofthecharacter,wherethefirstcharacterhasanindexof0.

Returnvalue

SVGRect

Therectanglewhichenclosesalloftherenderedglyph(s).

Exceptions

DOMException

INDEX_SIZE_ERR:Raisedifthecharnumisnegativeorifcharnumisgreaterthanorequaltothenumberofcharactersatthisnode.

getRotationOfChar

Returnstherotationvaluerelativetothecurrentusercoordinatesystemusedtorendertheglyph(s)correspondingtothespecifiedcharacter.Ifmultipleglyph(s)areusedtorenderthegivencharacterandtheglyphseachhavedifferentrotations(e.g.,due
totext-on-a-path),theuseragentshallreturnanaveragevalue(e.g.,therotationangleatthemidpointalongthepathforallglyphsusedtorenderthischaracter).Therotationvaluerepresentstherotationthatissupplementaltoanyrotationduetoproperties'glyph-orientation-horizontal'
and
'glyph-orientation-vertical';thus,anyglyphrotationsduetothesepropertiesarenotincludedintothereturnedrotationvalue.Ifmultipleconsecutivecharactersarerenderedinseparably(e.g.,asasingleglyphorasequenceofglyphs),theneach
oftheinseparablecharacterswillreturnthesamerotationvalue.

Parameters

inunsignedlongcharnum

Theindexofthecharacter,wherethefirstcharacterhasanindexof0.

Returnvalue

float

Therotationangle.

Exceptions

DOMException

INDEX_SIZE_ERR:Raisedifthecharnumisnegativeorifcharnumisgreaterthanorequaltothenumberofcharactersatthisnode.

getCharNumAtPosition

Returnstheindexofthecharacterwhosecorrespondingglyphcellboundingboxcontainsthespecifiedpoint.Thecalculationsassumethatallglyphsoccupythefullstandardglyphcellforthefont.Ifnosuchcharacterexists,avalueof-1isreturned.If
multiplesuchcharactersexist,thecharacterwithintheelementwhoseglyphswererenderedlast(i.e.,takeintoaccountanyreorderingsuchasforbidirectionaltext)isused.Ifmultipleconsecutivecharactersarerenderedinseparably(e.g.,asasingleglyph
orasequenceofglyphs),thentheuseragentshallallocateanequalpercentageofthetextadvanceamounttoeachofthecontributingcharactersindeterminingwhichofthecharactersischosen.

Parameters

inSVGPointpoint

Apointinuserspace.

Returnvalue

long

Theindexofthecharacterwhichisatthegivenpoint,wherethefirstcharacterhasanindexof0.

NoExceptions

selectSubString

Causesthespecifiedsubstringtobeselectedjustasiftheuserselectedthesubstringinteractively.

Parameters

inunsignedlongcharnum

Theindexofthestartcharacterwhichisatthegivenpoint,wherethefirstcharacterhasanindexof0.

inunsignedlongnchars

Thenumberofcharactersinthesubstring.Ifncharsspecifiesmorecharactersthanareavailable,thenthesubstringwillconsistofallcharactersstartingwithcharnumuntiltheendofthelistofcharacters.

NoReturnValue

Exceptions

DOMException

INDEX_SIZE_ERR:Raisedifthecharnumisnegativeorifcharnumisgreaterthanorequaltothenumberofcharactersatthisnode.

InterfaceSVGTextPositioningElement

TheSVGTextPositioningElementinterfaceisinheritedbytext-relatedinterfaces:SVGTextElement,

SVGTSpanElement,
SVGTRefElementand
SVGAltGlyphElement.

IDLDefinition


interfaceSVGTextPositioningElement:SVGTextContentElement{

readonlyattributeSVGAnimatedLengthListx;

readonlyattributeSVGAnimatedLengthListy;

readonlyattributeSVGAnimatedLengthListdx;

readonlyattributeSVGAnimatedLengthListdy;

readonlyattributeSVGAnimatedNumberListrotate;

};


Attributes

readonlySVGAnimatedLengthListx

Correspondstoattributexonthegivenelement.

readonlySVGAnimatedLengthListy

Correspondstoattributeyonthegivenelement.

readonlySVGAnimatedLengthListdx

Correspondstoattributedxonthegivenelement.

readonlySVGAnimatedLengthListdy

Correspondstoattributedyonthegivenelement.

readonlySVGAnimatedNumberListrotate

Correspondstoattributerotateonthegivenelement.

InterfaceSVGTextElement

TheSVGTextElementinterfacecorrespondstothe'text'element.

IDLDefinition


interfaceSVGTextElement:

SVGTextPositioningElement,

SVGTransformable{};


InterfaceSVGTSpanElement

TheSVGTSpanElementinterfacecorrespondstothe'tspan'element.

IDLDefinition


interfaceSVGTSpanElement:SVGTextPositioningElement{};


InterfaceSVGTRefElement

TheSVGTRefElementinterfacecorrespondstothe'tref'element.

IDLDefinition


interfaceSVGTRefElement:

SVGTextPositioningElement,

SVGURIReference{};


InterfaceSVGTextPathElement

TheSVGTextPathElementinterfacecorrespondstothe'textPath'element.

IDLDefinition


interfaceSVGTextPathElement:

SVGTextContentElement,

SVGURIReference{


//textPathMethodTypes

constunsignedshortTEXTPATH_METHODTYPE_UNKNOWN=0;

constunsignedshortTEXTPATH_METHODTYPE_ALIGN=1;

constunsignedshortTEXTPATH_METHODTYPE_STRETCH=2;

//textPathSpacingTypes

constunsignedshortTEXTPATH_SPACINGTYPE_UNKNOWN=0;

constunsignedshortTEXTPATH_SPACINGTYPE_AUTO=1;

constunsignedshortTEXTPATH_SPACINGTYPE_EXACT=2;


readonlyattributeSVGAnimatedLengthstartOffset;

readonlyattributeSVGAnimatedEnumerationmethod;

readonlyattributeSVGAnimatedEnumerationspacing;

};


DefinitiongrouptextPathMethodTypes

Definedconstants

TEXTPATH_METHODTYPE_UNKNOWN

Theenumerationwassettoavaluethatisnotoneofpredefinedtypes.Itisinvalidtoattempttodefineanewvalueofthistypeortoattempttoswitchanexistingvaluetothistype.

TEXTPATH_METHODTYPE_ALIGN

Correspondstovaluealign.

TEXTPATH_METHODTYPE_STRETCH

Correspondstovaluestretch.

DefinitiongrouptextPathSpacingTypes

Definedconstants

TEXTPATH_SPACINGTYPE_UNKNOWN

Theenumerationwassettoavaluethatisnotoneofpredefinedtypes.Itisinvalidtoattempttodefineanewvalueofthistypeortoattempttoswitchanexistingvaluetothistype.

TEXTPATH_SPACINGTYPE_AUTO

Correspondstovalueauto.

TEXTPATH_SPACINGTYPE_EXACT

Correspondstovalueexact.

Attributes

readonlySVGAnimatedLengthstartOffset

CorrespondstoattributestartOffsetonthegiven'textPath'element.

readonlySVGAnimatedEnumerationmethod

Correspondstoattributemethodonthegiven'textPath'element.Thevaluemustbeoneofthemethodtypeconstantsspecifiedabove.

readonlySVGAnimatedEnumerationspacing

Correspondstoattributespacingonthegiven'textPath'element.Thevaluemustbeoneofthespacingtypeconstantsspecifiedabove.

InterfaceSVGAltGlyphElement

TheSVGAltGlyphElementinterfacecorrespondstothe'altGlyph'element.

IDLDefinition


interfaceSVGAltGlyphElement:

SVGTextPositioningElement,

SVGURIReference{


attributeDOMStringglyphRef;

//raisesDOMExceptiononsetting

attributeDOMStringformat;

//raisesDOMExceptiononsetting

};


Attributes

DOMStringglyphRef

CorrespondstoattributeglyphRefonthegivenelement.

Exceptionsonsetting

DOMException

NO_MODIFICATION_ALLOWED_ERR:Raisedonanattempttochangethevalueofareadonlyattribute.

DOMStringformat

Correspondstoattributeformatonthegivenelement.

Exceptionsonsetting

DOMException

NO_MODIFICATION_ALLOWED_ERR:Raisedonanattempttochangethevalueofareadonlyattribute.

InterfaceSVGAltGlyphDefElement

TheSVGAltGlyphDefElementinterfacecorrespondstothe'altGlyphDef'element.

IDLDefinition


interfaceSVGAltGlyphDefElement:SVGElement{};


InterfaceSVGAltGlyphItemElement

TheSVGAltGlyphItemElementinterfacecorrespondstothe'altGlyphItem'element.

IDLDefinition


interfaceSVGAltGlyphItemElement:SVGElement{};


InterfaceSVGGlyphRefElement

TheSVGGlyphRefElementinterfacecorrespondstothe'glyphRef'element.

IDLDefinition


interfaceSVGGlyphRefElement:

SVGElement,

SVGURIReference,

SVGStylable{


attributeDOMStringglyphRef;

//raisesDOMExceptiononsetting

attributeDOMStringformat;

//raisesDOMExceptiononsetting

attributefloatx;

//raisesDOMExceptiononsetting

attributefloaty;

//raisesDOMExceptiononsetting

attributefloatdx;

//raisesDOMExceptiononsetting

attributefloatdy;

//raisesDOMExceptiononsetting

};


Attributes

DOMStringglyphRef

CorrespondstoattributeglyphRefonthegivenelement.

Exceptionsonsetting

DOMException

NO_MODIFICATION_ALLOWED_ERR:Raisedonanattempttochangethevalueofareadonlyattribute.

DOMStringformat

Correspondstoattributeformatonthegivenelement.

Exceptionsonsetting

DOMException

NO_MODIFICATION_ALLOWED_ERR:Raisedonanattempttochangethevalueofareadonlyattribute.

floatx

Correspondstoattributexonthegivenelement.

Exceptionsonsetting

DOMException

NO_MODIFICATION_ALLOWED_ERR:Raisedonanattempttochangethevalueofareadonlyattribute.

floaty

Correspondstoattributeyonthegivenelement.

Exceptionsonsetting

DOMException

NO_MODIFICATION_ALLOWED_ERR:Raisedonanattempttochangethevalueofareadonlyattribute.

floatdx

Correspondstoattributedxonthegivenelement.

Exceptionsonsetting

DOMException

NO_MODIFICATION_ALLOWED_ERR:Raisedonanattempttochangethevalueofareadonlyattribute.

floatdy

Correspondstoattributedyonthegivenelement.

Exceptionsonsetting

DOMException

NO_MODIFICATION_ALLOWED_ERR:Raisedonanattempttochangethevalueofareadonlyattribute.

previousnext

contents
elements
attributes
properties
index
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: