Do you know if there is such a function for HTML strings (for given size and font)? Do I need to use JavaScript?