I realize that you've found an answer to your word-wrapping problem - using a '�' instead of a '-' prevents hyphenated words from being split on the hyphen and wrapped - but I thought I'd comment on this for the archives.
This is simplified by the fact that you're using a fixed-pitch font:* get the width of a single character, in the current font
my $size = $font->maximumAdvancement();
For a variable-pitched font, you'd have to supply the glyph index:
my $size = $font->advancementForGlyph($glyphIndex);
In either case, the advancement returned can be either horizontal or vertical; it depends on the language in use. Since you're using English only, it's safe to assume horizontal advancement.
What is returned from the above is actually an NSSize, not an NSRect. NSSize (and NSRect, NSRange, and NSPoint, for that matter) are C structs, not objects. Even though they're not objects in ObjC, they are in Perl - they have no methods defined for them yet, but the plan is to provide accessor methods to get at individual components.* pull the coordinate values out of a "rectangle".
For now, I recommend using NSStringFromSize(), which returns a string of the form "{x, y}". You can then parse out the components with a regex:
my $str = NSStringFromSize($size);
my ($width, $height) = ($str =~ /{([\d]*\.[\d]*), ([\d]*\.[\d]*)/);
Note that the Cocoa documentation says that the string returned from this function is of the form "{width=x; height=y}" - with labels for the components and a semicolon, rather than a comma, separating them. The above is based on what I've observed, not the docs.
sherm--
"I have no special gift, I am only passionately curious." - Albert Einstein
