RE: Text metrics with display:none

Cameron wrote:

---------
Here is my go at a proposed behaviour:

* The indices that these methods work on are the textContent-like indices.

* When getSubStringLength includes characters that correspond to glyphs 
that are not rendered due to display:none (or say because they've fallen 
off the end of a <textPath>), then these characters don't contribute to 
the string length.  In an extreme case, calling getSubStringLength on 
<text display="none">abc</text> returns 0.

* getStartPositionOfChar and getEndPositionOfChar return NaN when given 
a character index that corresponds to a glyph not being displayed.

* getExtentOfChar returns 0 when given a character index that 
corresponds to a glyph not being displayed.

I choose 0 for getExtentOfChar to be consistent with getSubStringLength 
just ignoring the non-displayed characters.
------------

Well, I'm a bit nervous about this.

Oftentimes I have found myself drawing stuff invisibly first, so that I can measure it. Then after knowing how big it will be I position it.

Centering things relative to one another is difficult in SVG (unlike in HTML/CSS), and CSS doesn't seem to help with this issue (unless I'm missing something -- and I well may be), so when I start finding parts of the spec that tell me I cannot measure things unless they are visible, it makes me nervous. I recall a similar issue recently with getBBox and leprechaun-nodes. 

Regards
David

Received on Sunday, 11 December 2011 15:37:06 UTC