How do I render multi-line centered text, limited to a specific frame size, along with inserting the … (ellipsis) char when the text doesn't fit?
Background:
I am developing a custom view that mimicks OS X Finder's "as Icons" view, with the Label position set to "Bottom". In this view mode, file names appear below icons in two rows, like this (with ASCII art for the bounding frame):
+------------------------+
| long file name that |
| gets centered…rest.jpg |
+------------------------+
I understand that an NSTextField can almost accomplish that, but not completely: With the settings "Wrap" and "Truncate Last Visible Line" (as offered in Xcode's IB), it ends up like this:
+------------------------+
| long file name that |
| gets centered and mor… |
+------------------------+
I.e, it truncates the text at the end and not in the middle of the last visible line.
Also, I cannot use a NSControl but need to render the text into a graphics context instead.
Is there any framework function that can do this, or is this code private to the Finder and I'll need to rewrite all that myself?