Created
February 13, 2012 23:58
-
-
Save erikhazzard/1821595 to your computer and use it in GitHub Desktop.
getbbox cs getcomputedlength
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<meta charset='utf-8' /> | |
<head> | |
</head> | |
<body> | |
<svg> | |
<text id='text_node' y="20px" text-anchor="start" opacity="1"> | |
<tspan>You</tspan> | |
<tspan dx='.5em'>shall</tspan> | |
<tspan dx='.5em' dy='.9em'>not</tspan> | |
<tspan dx='.4em' dy='.9em'>pass</tspan> | |
<tspan dx='.5em'>Fly</tspan> | |
<tspan dx='.4em' dy='.9em'>you</tspan> | |
<tspan dx='.4em' dy='.9em'>fools</tspan> | |
</text> | |
</svg> | |
<script> | |
var bbox = document.getElementById('text_node').getBBox(); | |
var computed_text_length = document.getElementById('text_node').getComputedTextLength(); | |
console.log('BBOX width: ', bbox.width); | |
console.log('Computed text length: ', computed_text_length); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment