精图规范1.0----10 文本 Text
2014-06-08 17:50
295 查看
contents
elements
attributes
properties
index
04September2001
10文本Text
内容Contents
10.1引言Introduction
作为精图文档片段的一部分进行渲染的文本通过使用文本元素'text'来进行说明。在文本元素
'text'中的将被绘制的字符按照XML字符数据[
element.ThecharacterstobedrawnareexpressedasXMLcharacterdata[
精图的文本元素
'text'按照其它图形元素的渲染方法进行渲染。因此,
坐标系变换,
绘制,
剪裁和
蒙版等特征可依照与应用于各种
和
长方形相同的方式应用到文本元素
'text'中。SVG's
'text'elementsarerenderedlikeothergraphicselements.Thus,
coordinatesystemtransformations,
and
maskingfeaturesapplyto
suchas
pathsand
rectangles.
每个文本元素
'text'产生一个将被渲染的单一的文本字符串。精图并不自动进行折行和断词处理.为了达到多行文本的效果,可以使用下列方法之一:Each
'text'elementcausesasinglestringoftexttoberendered.SVGperformsnoautomaticlinebreakingorwordwrapping.Toachievetheeffectofmultiplelinesoftext,useoneofthefollowingmethods:
创作者或者创作软件包需要事先计算折行的位置并使用多个文本元素
'text'(每一行一个文本元素).Theauthororauthoringpackageneedstopre-computethelinebreaksandusemultiple
foreachlineoftext).
创作者或者创作软件包需要事先计算折行的位置并使用单个文本元素
'text',而此文本元素具有一个或多个文本块子元素
'tspan',这些文本块子元素具有属性
x,
y,
dx和
dy的适当值,它们用来设置新行中的字符的新的起始位置.(这种方法允许用户进行多行的文本选择--参见
文本选择和剪贴板操作.)Theauthororauthoringpackageneedstopre-computethelinebreaksanduseasingle
more
'tspan'childelementswithappropriatevaluesforattributes
x,
y,
dxand
dytosetnewstartpositionsforthosecharacterswhichstartnewlines.(Thisapproachallowsusertextselectionacrossmultiplelinesoftext--seeText
selectionandclipboardoperations.)
将要渲染的文本用另一个XML命名空间如XHTML[
进行内联嵌入.(注意:此方法的精确语义此时不被完全定义.)ExpressthetexttoberenderedinanotherXMLnamespacesuchasXHTML[
element.(Note:theexactsemanticsofthisapproacharenotcompletelydefinedatthistime.)
在文本元素
的轮廓线进行渲染.对于直线上的文本或者路径上的文本精图支持下列国际文本处理特性:SVGsupportsthefollowinginternationaltextprocessingfeaturesforbothstraightlinetextandtextonapath:Thetextstringswithin
canberenderedinastraightlineorrenderedalongtheoutlineofa
textprocessingfeaturesforbothstraightlinetextandtextonapath:
文本的水平和垂直方向horizontalandverticalorientationoftext
从左到右或者双向文本(即,混合右到左以及左到右的文本的语言,如阿拉伯语和希伯来语)left-to-rightorbidirectionaltext(i.e.,languageswhichintermixright-to-leftandleft-to-righttext,suchasArabicandHebrew)
当使用
精图字体时,相应于
阿拉伯语和
汉语文本的当前形状的正确的图元将被自动选择。when
SVGfontsareused,automaticselectionofthecorrectglyphcorrespondingtothecurrentformfor
and
Hantext
(关于直线文本的布局规则在
(Thelayoutrulesforstraightlinetextaredescribedin
Textlayout.Thelayoutrulesfortextonapatharedescribedin
Textonapathlayoutrules.)
因为精图文本是以XML字符数据[
在精图内容中的文本对于弱视群体是易于阅读的(参见
易访问性支持)TextdatainSVGcontentisreadilyaccessibletothevisuallyimpaired(see
在很多浏览的场合,用户可以查找和选择文本串并且复制所选定的文本串到系统剪贴板(参见
文本选择和剪贴板操作)Inmanyviewingscenarios,theuserwillbeabletosearchforandselecttextstringsandcopyselectedtextstringstothesystemclipboard(seeText
selectionandclipboardoperations)
与XML兼容的环球网搜索引擎查找精图内容中的文本串,只需按照其它XML文档中进行搜索的方式进行搜索,而无须进行额外的工作。XML-compatibleWebsearchengineswillfindtextstringsinSVGcontentwithnoadditionaleffortoverwhattheyneedtodotofindtextstringsinotherXMLdocuments
通过
基于用户所选的语言替换不同的文本串,可以实现多种语言的精图内容.Multi-languageSVGcontentispossibleby
substitutingdifferenttextstringsbasedontheuser'spreferredlanguage.
基于易访问的原因,建议包含在文档中的文本有适当的语义标记表明其作用。更多的内容请参见
精图易访问性指南.Foraccessibilityreasons,itisrecommendedthattextwhichisincludedinadocumenthaveappropriatesemanticmarkuptoindicateitsfunction.SeeSVGaccessibility
guidelinesformoreinformation.
10.2字符及其相应的图元Charactersandtheircorrespondingglyphs
在XML[另一方面,字体由一套图元以及与之相关的信息例如
其它情况下为数值)以及此图元的用于渲染的绘制指令构成.InXML[
Fonts,ontheotherhand,consistsofacollectionofglyphsandotherassociatedinformation,suchas
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[
10.3字体、字体属性表和基线Fonts,
fonttablesandbaselines
一种字体是由一套图元以及在某些媒体中如何运用这些图元来表示字符所需的必要信息(字体属性表)组成.一套图元以及其相应的字体属性表的组合称之为字体数据.字体属性表包含将字符映射为图元所必需的信息,以及确定图元区域的尺寸及位置的信息.每一个字体属性表由一个或多个字体特性如粗体和字型组成.Afontconsistsofacollectionofglyphstogetherwiththeinformation(thefonttables)necessarytousethoseglyphstopresentcharactersonsomemedium.Thecombinationofthecollectionofglyphsandthefonttablesiscalledthefontdata.Thefonttablesincludetheinformationnecessarytomapcharacterstoglyphs,todeterminethesizeofglyph
areasandtopositiontheglypharea.Eachfonttableconsistsofoneormorefontcharacteristics,suchasthefont-weightandfont-style.
几何字体特征按照基于EM方框的坐标系统来表示的.(EM是对字体中的图元的一种相对测量;参见
CSS2em平方.)方框1EM高和1EM宽被称为设计空间.这种空间通过细分EM到一定数目的
units-per-em给出一种几何坐标.ThegeometricfontcharacteristicsareexpressedinacoordinatesystembasedontheEMbox.(TheEMisarelativemeasureoftheheightoftheglyphsinthefont;seeCSS2
emsquare.)Thebox1EMhighand1EMwideiscalledthedesignspace.Thisspaceisgivenageometriccoordinatesbysub-dividingtheEMintoanumberof
注记: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,the
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.The
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[和
双向性.The'text'elementdefinesagraphicselementconsistingoftext.TheXML[
mappingtableswithinthefontitself,definetheglyphstoberendered.(See
Charactersandtheircorrespondingglyphs.)Theattributesandpropertiesonthe'text'elementindicatesuchthingsasthewritingdirection,fontspecificationandpaintingattributeswhichdescribehowexactlytorenderthecharacters.Subsequentsections
ofthischapterdescribetherelevanttext-specificattributesandproperties,particular
bidirectionality.
由于对文本元素'text'的渲染采用与其它图形元素相同的渲染方法,所有应用到
形状如
路径和
长方形的同一
坐标系变换、
和
systemtransformations,
painting,
featuresthatapplyto
shapessuchas
pathsand
rectanglesalsoapplyto'text'elements.
可以对文本使用色彩渐变、模式填充、路径剪裁、蒙版或滤镜.当这些工具的某一种被用于文本时,关键字objectBoundingBox(参见
则对象边界方框单元在所有情况下按照整个文本元素'text'进行计算,即使不同的效果用于此文本元素'text'中的不同的文本块元素
clippingpath,maskorfiltertotext.WhenoneofthesefacilitiesisappliedtotextandkeywordobjectBoundingBoxisused(seeObject
boundingboxunits)tospecifyagraphicaleffectrelativetothe"objectboundingbox",thentheobjectboundingboxunitsarecomputedrelativetotheentire'text'elementinallcases,evenwhendifferenteffectsareappliedtodifferent
elementswithinthesame'text'element.
文本元素'text'在初始
重新排列之后),而初始当前文本位置由此文本元素'text'的
x和
y属性所确定(也许由于性质
'text-anchor'的取值,出现一个文本路径元素
'textPath'包含第一个字符,并且/或者在一个
'tspan',
'tref'或
y,
dx或
dy属性中包含第一个字符等原因会导致相应的调整).在相应于给定的字符的图元被渲染之后,当前文本位置被更新以对应于下一个字符.在最简单的情况下,新的当前文本位置为前一个当前文本位置加上图元的增量值(水平或垂直).请参见
The'text'elementrendersitsfirstglyph(after
bidirectionalityreordering)attheinitial
currenttextposition,whichisestablishedbythe
xand
yattributesonthe'text'element(withpossibleadjustmentsduetothevalueofthe
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).See
andglyphadvance.
<!ENTITY%textExt""> <!ELEMENT
%geExt;%textExt;)*> <!ATTLIST
|
x="
如果提供单一的
.Ifasingle
<coordinate>isprovided,thenthevaluerepresentsthenewabsoluteXcoordinateforthe
theglyphsthatcorrespondtothefirstcharacterwithinthiselementoranyofitsdescendants.
如果提供了由逗号或空格分隔的<n>个
<坐标>列表,那么这些值所表示新的绝对X坐标指定用于渲染此元素或任何子元素的第<n>个字符所对应的每个图元的
provided,thenthevaluesrepresentnewabsoluteXcoordinatesforthe
toeachofthefirst<n>characterswithinthiselementoranyofitsdescendants.
至于额外的处理规则,参见文本块元素
'tspan'的属性
attributeonthe
'tspan'element.
如果不设置此属性,则其效果等同于设置此属性的值为"0"效果.Iftheattributeisnotspecified,theeffectisasifavalueof"0"werespecified.
y="
在此元素内的字符所对应图元的绝对Y坐标的相应列表.针对属性'y'的处理规则与针对属性
'x'的一致.ThecorrespondinglistofabsoluteYcoordinatesfortheglyphscorrespondingtothecharacterswithinthiselement.Theprocessingrulesforthe'y'attributeparalleltheprocessingrulesforthe
attribute.
如果不设置此属性,则其效果等同于设置此属性的值为"0"效果.Iftheattributeisnotspecified,theeffectisasifavalueof"0"werespecified.
dx="
此元素或其子孙中的字符相对
textpositionalongthex-axisforthecharacterswithinthiselementoranyofitsdescendants.
参见对文本块元素
'tspan'的属性
attributeonthe
'tspan'element.
如果不设置此元素或其子元素的此属性,则不会出现沿着x-轴的偏移量.Iftheattributeisnotspecifiedonthiselementoranyofitsdescendants,nosupplementalshiftsalongthex-axiswilloccur.
dy="
此元素或其子孙中的字符相对
textpositionalongthey-axisforthecharacterswithinthiselementoranyofitsdescendants.
参见对文本块元素
'tspan'的属性
attributeonthe
'tspan'element.
如果不设置此元素或其子元素的此属性,则不会出现沿着y-轴的偏移量.Iftheattributeisnotspecifiedonthiselementoranyofitsdescendants,nosupplementalshiftsalongthey-axiswilloccur.
rotate="
在
textpositionthatwillbeappliedtoalloftheglyphscorrespondingtoeachcharacterwithinthiselement.
参见对文本块元素
'tspan'的属性
attributeonthe
'tspan'element.
如果不设置此元素或其子元素的此属性,则不会出现附加旋转.Iftheattributeisnotspecifiedonthiselementoranyofitsdescendants,nosupplementalrotationswilloccur.
textLength="
此文本元素中对应于所有字符数据的增量的总和的作者的计算值,包括图元(水平或垂直)的增量值,考虑性质
'kerning',
'letter-spacing'和
'word-spacing'的效果以及由于文本块元素
和
dy所作的调整.此值用于校准用户代理的计算与作者的计算.Theauthor'scomputationofthetotalsumofalloftheadvancevaluesthatcorrespondtocharacterdatawithinthiselement,includingtheadvancevalueontheglyph(horizontalorvertical),theeffectofproperties
'letter-spacing'and
'word-spacing'andadjustmentsduetoattributes
dxand
dyon
'tspan'elements.Thisvalueisusedtocalibratetheuseragent'sowncalculationswiththatoftheauthor.
这个属性的目的在于允许作者使得在任何
双向重新排列之后的依照可见的渲染次序,将对应于此元素的第一和最后一个被渲染的图元进行精确的对齐;于是,对于最后渲染的字符而言(在任何
双向重新排列之后的依照可见的渲染次序),当用户代理确定适当的数量以便对文本串进行适当伸缩满足textLength的长度时,正常图元增量之外的附加内部字符之间的空白增量将被忽略(在大多数情况下).Thepurposeofthisattributeistoallowtheauthortoachieveexactalignment,invisualrenderingorderafterany
forthefirstandlastrenderedglyphsthatcorrespondtothiselement;thus,forthelastrenderedcharacter(invisualrenderingorderafterany
anysupplementalinter-characterspacingbeyondnormalglyphadvancesareignored(inmostcases)whentheuseragentdeterminestheappropriateamounttoexpand/compressthetextstringtofitwithinalengthoftextLength.
一种负值是一种错误(参见
错误处理).Anegativevalueisanerror(see
Errorprocessing).
如果不设置此属性,其效果相当于作者的计算与用户代理的计算完全相等时所出现的情况;于是,无须此时进行进一步的调整.Iftheattributeisnotspecified,theeffectisasiftheauthor'scomputationexactlymatchedthevaluecalculatedbytheuseragent;thus,noadvanceadjustmentsaremade.
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(seedescriptionofattribute
whereasstretchingorcompressingoftheglyphswillbeappliedtoall<n>characters.
如果不设置此属性,其效果相当于设置了空白值.Iftheattributeisnotspecified,theeffectisasavalueofspacingwerespecified.
其它地方已经定义的属性Attributesdefinedelsewhere:
%PresentationAttributes-Color;,
在下面的例子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 |
10.5文本片段修饰元素'tspan'The'tspan'element
在一个文本元素'text'内,包含在文本块元素'tspan'中的文本和字体的性质以及
element,textandfontpropertiesandthe
currenttextpositioncanbeadjustedwithabsoluteorrelativecoordinatevaluesbyincludinga'tspan'element.
<!ENTITY%tspanExt""> <!ELEMENT %tspanExt;)*> <!ATTLIST
|
x="
如果提供单一的
.Ifasingle
<coordinate>isprovided,thenthevaluerepresentsthenewabsoluteXcoordinateforthe
theglyphsthatcorrespondtothefirstcharacterwithinthiselementoranyofitsdescendants.
如果提供了由逗号或空格分隔的<n>个
<坐标>列表,那么这些值所表示新的绝对X坐标指定用于渲染此元素或任何子元素的第<n>个字符所对应的每个图元的
listof<n>
textpositionforrenderingtheglyphscorrespondingtoeachofthefirst<n>characterswithinthiselementoranyofitsdescendants.
如果提供比字符还多的
将不会影响图元的位置.Ifmore
<coordinate>sareprovidedthancharacters,thentheextra
<coordinate>swillhavenoeffectonglyphpositioning.
如果字符数大于
<坐标值>的个数,那么对于每个多余的字符而言:(a)如果上级文本元素
'text'或者文本块元素
的最近进行渲染的图元所导出的
当前文本位置的X坐标.Ifmorecharactersexistthan
<coordinate>s,thenforeachoftheseextracharacters:(a)ifanancestor
'text'or
'tspan'elementspecifiesanabsoluteXcoordinateforthegivencharacterviaanxattribute,thenthatabsoluteXcoordinateisusedasthestartingXcoordinateforthatcharacter(nearestancestorhasprecedence),else(b)thestartingXcoordinatefor
renderingtheglyphscorrespondingtothegivencharacteristheXcoordinateoftheresulting
themostrecentlyrenderedglyphforthecurrent
'text'element.
如果不设置此属性:(a)如果一个上级文本元素
'text'或者文本块元素
的最近进行渲染的图元所导出的
or
'tspan'elementspecifiesanabsoluteXcoordinateforagivencharacterviaanxattribute,thenthatabsoluteXcoordinateisused(nearestancestorhasprecedence),else(b)thestartingXcoordinateforrenderingtheglyphscorrespondingtoagivencharacter
istheXcoordinateoftheresulting
currenttextpositionfromthemostrecentlyrenderedglyphforthecurrent
'text'element.
y="
在此元素内的字符所对应图元的绝对Y坐标的相应列表.针对属性'y'的处理规则与针对属性
'x'的一致.ThecorrespondinglistofabsoluteYcoordinatesfortheglyphscorrespondingtothecharacterswithinthiselement.Theprocessingrulesforthe'y'attributeparalleltheprocessingrulesforthe
attribute.
dx="
如果提供单一的
X坐标.而此
asingle
<length>isprovided,thisvaluerepresentsthenewrelativeXcoordinateforthe
theglyphscorrespondingtothefirstcharacterwithinthiselementoranyofitsdescendants.The
isshiftedalongthex-axisofthecurrentusercoordinatesystemby
如果提供了由逗号或空格分隔的<n>个
<长度值>列表,那么这些值表示用于渲染此元素或任何子元素的第<n>个字符所对应的图元相对于
<n>个字符所对应的图元之前沿着当前用户坐标系的x-轴平移的
<长度值>.Ifacomma-orspace-separatedlistof<n>
<length>sisprovided,thenthevaluesrepresentincrementalshiftsalongthex-axisforthe
renderingtheglyphscorrespondingtothefirst<n>characterswithinthiselementoranyofitsdescendants.Thus,beforetheglyphsarerenderedcorrespondingtoeachcharacter,thecurrent
textpositionresultingfromdrawingtheglyphsforthepreviouscharacterwithinthecurrent
theXaxisofthecurrentusercoordinatesystemby
如果提供比字符还多的
more
<length>sareprovidedthancharacters,thenanyextra
<length>swillhavenoeffectonglyphpositioning.
如果字符数大于
<长度值>的个数,那么对于每个多余的字符而言:(a)如果上级文本元素
'text'或者文本块元素
(最近的上级优先考虑),否则(b)沿着当前用户坐标系的x-轴的平移不会出现.Ifmorecharactersexistthan
<length>s,thenforeachoftheseextracharacters:(a)ifanancestor
'text'or
'tspan'elementspecifiesarelativeXcoordinateforthegivencharacterviaadxattribute,thenthe
isshiftedalongthex-axisofthecurrentusercoordinatesystembythatamount(nearestancestorhasprecedence),else(b)noextrashiftalongthex-axisoccurs.
如果不设置此属性:(a)如果上级文本元素
'text'或者文本块元素
(最近的上级优先考虑),否则(b)沿着当前用户坐标系的x-轴的平移不会出现.Iftheattributeisnotspecified:(a)ifanancestor
'tspan'elementspecifiesarelativeXcoordinateforagivencharacterviaadxattribute,thenthe
isshiftedalongthex-axisofthecurrentusercoordinatesystembythatamount(nearestancestorhasprecedence),else(b)noextrashiftalongthex-axisoccurs.
dy="
在此元素内的字符所对应图元的相对Y坐标的相应列表.针对属性'dy'的处理规则与针对属性
'dx'的一致.ThecorrespondinglistofrelativeYcoordinatesforthecharacterswithinthe'tspan'element.Theprocessingrulesforthe'dy'attributeparalleltheprocessingrulesforthe
attribute.
rotate="
在
textpositionthatwillbeappliedtoalloftheglyphscorrespondingtoeachcharacterwithinthiselement.
如果提供了由逗号或空格分隔的<n>个
<number>列表,那么第一个
<number>所表示用于渲染此元素或任何子元素的第一个字符所对应的每个图元的附加旋转,第二个
<number>所表示用于渲染此元素或任何子元素的第二个字符所对应的每个图元的附加旋转,等等.Ifacomma-orspace-separatedlistof
<number>representsthesupplementalrotationfortheglyphscorrespondingtothefirstcharacterwithinthiselementoranyofitsdescendants,thesecond
thesupplementalrotationfortheglyphsthatcorrespondtothesecondcharacter,andsoon.
如果提供比字符还多的
<number>,则多余的
<number>将被忽略.Ifmore
<number>sareprovidedthantherearecharacters,thentheextra
<number>swillbeignored.
如果字符数大于
或者文本块元素
foreachoftheseextracharacters:(a)ifanancestor
'text'or
'tspan'elementspecifiesasupplementalrotationforthegivencharacterviaarotateattribute,thenthegivensupplementalrotationisappliedtothegivencharacter,else(b)nosupplementalrotationoccurs.
如果不设置此属性:(a)如果一个上级文本元素
'text'或者文本块元素
(a)ifanancestor
'tspan'elementspecifiesasupplementalrotationforagivencharacterviaarotateattribute,thenthegivensupplementalrotationisappliedtothegivencharacter(nearestancestorhasprecedence),else(b)nosupplementalrotationoccurs.
这种附加旋转并不与图元渲染改变
或者
'垂直方向的图元'所导致的旋转的补充.Thissupplementalrotationhasnoimpactontherulesbywhich
glyphsgetrenderedandissupplementaltoanyrotationdueto
'glyph-orientation-horizontal'or
'glyph-orientation-vertical'.
textLength="
此文本元素中对应于所有字符数据的增量的总和的作者的计算值,包括图元(水平或垂直)的增量值,考虑性质
'kerning',
'letter-spacing'和
'word-spacing'的效果以及由于文本块元素
和
dy所作的调整.此值用于校准用户代理的计算与作者的计算.Theauthor'scomputationofthetotalsumofalloftheadvancevaluesthatcorrespondtocharacterdatawithinthiselement,includingtheadvancevalueontheglyph(horizontalorvertical),theeffectofproperties
'letter-spacing'and
'word-spacing'andadjustmentsduetoattributes
dxand
dyonthis
'tspan'elementoranydescendants.Thisvalueisusedtocalibratetheuseragent'sowncalculationswiththatoftheauthor.
这个属性的目的在于允许作者使得在任何
双向重新排列之后的依照可见的渲染次序,将对应于此元素的第一和最后一个被渲染的图元进行精确的对齐;于是,对于最后渲染的字符而言(在任何
双向重新排列之后的依照可见的渲染次序),当用户代理确定适当的数量以便对文本串进行适当伸缩满足textLength的长度时,正常图元增量之外的附加内部字符之间的空白增量将被忽略(在大多数情况下).Thepurposeofthisattributeistoallowtheauthortoachieveexactalignment,invisualrenderingorderafterany
forthefirstandlastrenderedglyphsthatcorrespondtothiselement;thus,forthelastrenderedcharacter(invisualrenderingorderafterany
anysupplementalinter-characterspacingbeyondnormalglyphadvancesareignored(inmostcases)whentheuseragentdeterminestheappropriateamounttoexpand/compressthetextstringtofitwithinalengthoftextLength.
如果一给定的元素及其上级都设置了属性textLength,则此元素上的所有字符数据的调整只由此元素的textLength的值来控制,可能的副作用是此元素的内容的调整比率与共享相同上级的其它内容的调整比率不同.用户代理必须假定在同一上级下的其它内容的整个增量值为上级增量值与此元素的增量值之差.IfattributetextLengthisspecifiedonagivenelementandalsospecifiedonanancestor,theadjustments
onallcharacterdatawithinthiselementarecontrolledbythevalueoftextLengthonthiselementexclusively,withthepossibleside-effectthattheadjustmentratioforthecontentsofthiselementmightbedifferentthantheadjustmentratiousedforother
contentthatsharesthesameancestor.Theuseragentmustassumethatthetotaladvancevaluesfortheothercontentwithinthatancestoristhedifferencebetweentheadvancevalueonthatancestorandtheadvancevalueforthiselement.
一种负值是一种错误(参见
错误处理).Anegativevalueisanerror(see
Errorprocessing).
如果不设置此属性,其效果相当于作者的计算与用户代理的计算完全相等时所出现的情况;于是,无须此时进行进一步的调整.Iftheattributeisnotspecifiedanywherewithina
effectisasiftheauthor'scomputationexactlymatchedthevaluecalculatedbytheuseragent;thus,noadvanceadjustmentsaremade.
其它地方已经定义的属性Attributesdefinedelsewhere:
在精密排印的场合文本块元素'tspan'的属性
x,
y,
dx,
dy和
rotate是有用的,因为这时要求对单个图元进行精确的安置.这些属性对于字符之间的位置较小的或者较大的调整是有用的,如移动
当前文本位置到一个新的位置以便达到文本换行的视觉效果.多行的文本元素
'text'可以为文本的每行定义不同的文本块元素'tspan',并使用属性
x,
y,
dx和
dy定义每个文本块元素'tspan'的位置.(这种方法的一个最大优点是用户可以进行多行的
y,
dx,
dyand
rotateonthe'tspan'elementareusefulinhigh-endtypographyscenarioswhereindividualglyphsrequireexactplacement.Theseattributesareusefulforminorpositioningadjustmentsbetweencharactersorformajorpositioningadjustments,suchasmoving
the
currenttextpositiontoanewlocationtoachievethevisualeffectofanewlineoftext.Multi-line
bydefiningdifferent'tspan'elementsforeachlineoftext,withattributes
y,
dxand/or
dydefiningthepositionofeach'tspan'.(Anadvantageofsuchanapproachisthatuserswillbeabletoperformmulti-linetext
selection.)
在需要微量位置调整的高级排字控制这种情况下,精图内容设计者需要保证必要的字体对所有文档浏览器是可用的(例如,以精图字体的形式将必要的字体数据打包或者存放在精图内容相同的位置上的另一种选择
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-thvalueforthe
y,
dx,
dyand
rotateattributesisappliedtotheglyphthatcorrespondstothei-thcharacter.
当单一的XML字符映照到多个的图元时(例如,当把重音图元加到一个底部图元的顶部时)-此时,属性
x,
y,
dx和
dy的第i个值在渲染第一个图元之前被使用(即,调整
当前文本位置).相应于第i个
rotate值的旋转变换应用于这些图元相应于这一字符在组基上的内部图元预先值(即,此旋转值创建一个新的旋转坐标系,而对应于字符的图元被渲染到此旋转坐标系).WhenasingleXMLcharactermapstomultipleglyphs(e.g.,whenanaccentglyphisplacedontopofabaseglyph)-Inthiscase,thei-thvalueforthe
y,
dxand
dyvaluesareapplied(i.e.,the
currenttextpositionisadjusted)beforerenderingthefirstglyph.Therotationtransformationcorrespondingtothei-th
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-thvalueforthe
y,
dx,
dyand
rotateattributesallapplywhenrenderingtheglyph.The(i+1)-thvalues,however,for
yand
rotateareignored(exception:thefinal
rotatevalueinthelistwouldstillapplytosubsequentcharacters),whereasthe
dyareappliedtothesubsequentXMLcharacter(i.e.,the(i+2)-thcharacter),ifoneexists,bytranslatingthecurrent
textpositionbythegivenamountsbeforerenderingthefirstglyphassociatedwiththatcharacter.
当字符和图元之间为多对多的关系时(例如,当三个字符映照为二个图元时,比如当第一个图元表示第一个字符和第二个字符的一半,而第二个图元表示第二个字符的一半加上第三个字符)-假设第i,第(i+1)和第(i+2)个XML字符映照到两个图元.此时,
y,
dxand
dy值的第i个值在渲染第一个图元之前被使用(即,
当前文本位置被调整).对应于第i个
rotate值的旋转变换既用于这两个图元也用于此群组中第一个图元的进一步的值(即,此旋转值创建一个新的临时旋转坐标系,而此两个图元被渲染到这一临时旋转坐标系).而对于属性
y和
rotate的第(i+1)个和第(i+2)个值不被使用(例外:列表中最后的
rotate值将仍然用于随后的字符),而属性
dx和
dy的第(i+1)个和第(i+2)个值被用于随后的XML字符(即,第(i+3)个字符),如果存在,则在渲染与此字符相关的第一个图元之前根据给定的数量变换
many-to-manymappingofcharacterstoglyphs(e.g.,whenthreecharactersmaptotwoglyphs,suchaswhenthefirstglyphexpressesthefirstcharacterandhalfofthesecondcharacter,andthesecondglyphexpressestheotherhalfofthesecondcharacter
plusthethirdcharacter)-Supposethatthei-th,(i+1)-thand(i+2)-thXMLcharactersmaptotwoglyphs.Inthiscase,thei-thvalueforthe
y,
dxand
dyvaluesareapplied(i.e.,the
currenttextpositionisadjusted)beforerenderingthefirstglyph.Therotationtransformationcorrespondingtothei-th
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)-thvaluesforthe
and
dyattributesareappliedtothesubsequentXMLcharacter(i.e.,the(i+3)-thcharacter),ifoneexists,bytranslatingthecurrent
textpositionbythegivenamountsbeforerenderingthefirstglyphassociatedwiththatcharacter.
与
双向性的关系-正如下面对
中的字符数据被重新排列,而在
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"并且属性
相应于字符的图元将使用标准的从左到右的布局规则来定位.andthattheword"Hebrew"willbedrawnright-to-left.First,thecharacterdataandthecorrespondingvaluesinthe
listwillbereordered,suchthatthetextstringwillbe"LatinandwerbeH"andthelistofvaluesforthe
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 |
例子tspan02使用文本块元素'tspan'的属性
dx和
dy来对一个文本元素
进行调整.Exampletspan02usesthe
dxand
dyattributesonthe'tspan'elementtoadjustthe
currenttextpositionhorizontallyandverticallyforparticulartextstringswithina