W3C home > Mailing lists > Public > www-svg@w3.org > December 2011

RE: Text metrics with display:none

From: David Dailey <ddailey@zoominternet.net>
Date: Sun, 11 Dec 2011 09:31:41 -0500
To: "'Cameron McCormack'" <cam@mcc.id.au>, "'Brian Birtles'" <bbirtles@mozilla.com>
Cc: "'www-svg'" <www-svg@w3.org>
Message-ID: <001101ccb811$9987f240$cc97d6c0$@net>
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. 

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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:54:33 UTC