Hey all,
I was wondering if anybody had an idea on how to easily truncate a string based on the width of characters used (not the number of characters used). For example, after the text of a cell reaches a length of 350 pixels, replace the last 3 characters used with "...", and stop adding more. This won't work by using len() as character width varies as such - ::::: vs WWWWW
The only way I could think of doing this was to manually generate a dictionary of possible characters and assign each a value based on their respective pixel widths. Then, get a sum of the pixel width, and truncate appropriately. However, this seems like a fairly blunt approach to the goal. Any ideas?
Bookmarks