caleb531 / jcanvas

A jQuery plugin that makes the HTML5 canvas easy to work with.
https://projects.calebevans.me/jcanvas/
MIT License
626 stars 192 forks source link

How to fit long words within a Elipse/Circle ? #133

Closed satya1907 closed 10 years ago

satya1907 commented 10 years ago

Hi, I have a doubt, I want to draw a Elipse of width 200 and height 120. Now I want to put a very long word like "hgfvdjvknnvbfsdnbgknsgknbskngvsbvjnsbnkvbnkfsvnnvbnsbvnbsnvbnsbvkkvjsvjsvjhsvsjvjhfvhjdvjkdvjsvjsvjkwjhfjewfjfjdfjdhfjdnhfbhdsvhdshvhdsvskjqaschscjsdvcjsdjd" . Now the Problem is while trying with "maxWidth" for drawing the text, its working if the Words are smaller. But if there is any word which is larger, then it comes out of the Elipse.

My requirement is to make the word fragmented so, that it can fit into the Elipse with 2-3 rows..

Please help me ..

Thanks

caleb531 commented 10 years ago

Currently, you will have to perform that separation yourself. jCanvas only wraps lines at every space in the text string.

Therefore, the simplest algorithm to wrap long words would require adding a space after every group of maxWidth characters in the string.

-Caleb