Opened 13 years ago

Closed 12 years ago

#2502 closed enhancement (fixed)

[cla] [patch] getTextWidth methods for gfx (vml+svg) text

Reported by: nicola.rizzo+dojo@… Owned by: Eugene Lazutkin
Priority: high Milestone: 0.9
Component: gfx (svg+vml) Version: 0.4.1
Keywords: gfx text width Cc:
Blocked By: Blocking:

Description

In IE it is possible to get the text width with: rawNode.style.display = "inline".
In FF and Opera there is the "orphan issue": solved in FF cloning the text node; in Opera (at the moment) with a while loop: the width is valid when takes a value != 0.

Nicola

Attachments (4)

vml.diff (912 bytes) - added by nicola.rizzo+dojo@… 13 years ago.
svg.diff (1.3 KB) - added by nicola.rizzo+dojo@… 13 years ago.
svg.js.diff (1.2 KB) - added by guest 13 years ago.
without duplications is better :)
vml.js.diff (886 bytes) - added by guest 13 years ago.

Download all attachments as: .zip

Change History (9)

Changed 13 years ago by nicola.rizzo+dojo@…

Attachment: vml.diff added

Changed 13 years ago by nicola.rizzo+dojo@…

Attachment: svg.diff added

comment:1 Changed 13 years ago by Eugene Lazutkin

Status: newassigned

While this is a useful functionality, I am hesitant to update the code, because I don't like modifications of a node directly, or with a measurement node --- it make cause flickering in some cases. We have to make sure that all changes are completely invisible.

Changed 13 years ago by guest

Attachment: svg.js.diff added

without duplications is better :)

Changed 13 years ago by guest

Attachment: vml.js.diff added

comment:2 Changed 13 years ago by guest

Two duplications removed in my previous svg.diff
In vml.js now is dojo.gfx.pt2px(...) instead of dojo.gfx.vml.pt2px(...)

Nicola

comment:3 Changed 12 years ago by Tom Trenka

SVG (in FF at least) also supports "getComputedTextLength" on any SVG text element; this returns an integer.

comment:4 in reply to:  3 Changed 12 years ago by guest

Replying to ttrenka: Both getComputedTextLength() and getBBox().width have the "orphan issue" http://wiki.svg.org/GetBBox in FF and Opera
No flickering with this solution, because the original node and the cloned node have same position and dimensions

Nicola

comment:5 Changed 12 years ago by Eugene Lazutkin

Resolution: fixed
Status: assignedclosed

(In [9841]) Fixed the bug introduced with the previous check-in. Added Text.getTextWidth() method (thx, Nicola Rizzo!). A test file was updated to exercise the new functionality. Fixes #2502.

Note: See TracTickets for help on using tickets.