Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Can't you just render text to a canvas element then crop the canvas? That results in the exact bounding dimensions you need.


Not always. In my experience there are two things that tend to break when you try to render to canvas and apply the empirically measured dimensions to HTML text: (1) subpixel rendering because it does still exist despite high DPI displays, and (2) kerning and hinting don't always give you the same metrics inside/outside canvas, especially for non-Latin characters.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: