W3C home > Mailing lists > Public > www-svg@w3.org > March 2012

white space collapsing and glyph positioning

From: Cameron McCormack <cam@mcc.id.au>
Date: Fri, 16 Mar 2012 15:55:44 +1100
Message-ID: <4F62C7D0.2050100@mcc.id.au>
To: SVG public list <www-svg@w3.org>
Consider the following document:

   <svg xmlns="http://www.w3.org/2000/svg">
     <text x="100 200" y="100"> ab</text>
   </svg>

SVG currently requires glyph positioning to be applied to characters 
after white space transformation for xml:space="".  What that means is 
that the above document should render with the "a" at x=100 and the "b" 
at x=200.

In my proposal for reworking SVG text layout 
http://www.w3.org/Graphics/SVG/WG/wiki/Proposals/Text_layout I propose 
something different -- namely that the glyph positioning numbers 
correspond to the Unicode characters before any processing is done on 
the character (although including the inclusion of <tref>-referenced 
text).  So that would mean the above would result in the following 
positioning:

   char     x
   =======  ================
   (space)  100
   a        200
   b        200 + advance(a)

I argue that which characters glyph positions correspond to should at 
least not change based on the styles that apply to the elements -- just 
like they aren't affected by ligatures or other clusterisation that 
happens in the text run.  xml:space="" isn't style yet, but we might 
make it so in the future.  I would like xml:space="default" to be the 
same thing as white-space:normal (which I don't think I explicitly said 
in the other thread either), so really I would like to consider the 
white space collapsing that goes on in the above example to be as a 
result of white-space.

I think this makes more sense and is simpler (the glyph positioning 
assignment can be done independently of white space collapsing), but I'd 
like to hear what other people think.  Particularly because the current 
behaviour seems to have pretty good interop.  I can't see any tests in 
the test suite for positioning applied to collapsed-away white space, 
with a quick grep.

(The current behaviour is more difficult to implement, being that I want 
to utilise existing CSS text layout code, because it means I need to 
first compute which white space characters will be collapsed due to the 
white-space property on the SVG side, use that to decide which glyphs 
get the positioning values, and then invoke the CSS text layout which 
will do its own white collapsing.)

Note that this doesn't affect simpler usages of glyph positioning, such as

   <text x="100">  abc</text>
   <text x="100">
     some line of text
     <tspan x="100" y="200">a second line of text</tspan>
   </text>

because the first non-collapsed-away glyph in each line would still get 
placed at x=100.
Received on Friday, 16 March 2012 04:56:16 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:50 GMT