Re: Respecting tabs across applications
Re: Respecting tabs across applications
- Subject: Re: Respecting tabs across applications
- From: James Merkel <email@hidden>
- Date: Tue, 10 Jan 2012 17:45:30 -0800
On Jan 10, 2012, at 4:52 PM, Jens Alfke wrote:
>
> On Jan 10, 2012, at 2:00 PM, James Merkel wrote:
>
>> In fact, I am using multiple consecutive tab characters to force things to line up -- i.e. a sure recipe for disaster.
>
> The trouble with that is that the number of tabs you’ll need depends on the width of each item, and that’s highly dependent on not only the font, but on which typographic features (like kerning and ligatures) are enabled.
>
>> Where is this Word Processing 101 document that I should be reading?
>
> There was a great old book from the ‘80s called “The Mac Is Not A Typewriter” that went over all this stuff — tabs, spacing between sentences, curly vs straight quotes, dashes vs. hyphens and so on. Nowadays there must be some online tutorials, but I don’t know of anything specific.
>
> Anyway, if you want your layout to survive being transferred into TextEdit or a word processor, you should create an NSParagraphStyle with tab stops where you want them, then use a single tab between columns.
>
> If you want to paste it into a plain-text editor like Xcode/TextMate/TextWrangler/BBEdit, the task is entirely different. Use nothing but spaces as separators, because you can’t guess what width a tab is at the destination. Just assume the text is monospaced and count the number of characters in a column to figure out how many spaces to insert. Needless to say this will only look right in a monospaced font like Courier.
>
> —Jens
Ok, I probably should have explained more. All of the strings are precomposed and are in localized string files.
The strings are never intended to be edited.
So for example I have tag strings like the following in the strings file (English version):
"BitsPerSample" = "Bits Per Sample:\t\t";
"Compression" = "Compression:\t\t\t";
The strings are tabbed for Helvetica Regular 12 point font. So yes if the font is changed the tabs would change.
These tag strings are then concatenated with other strings (also in localized string files) and then each line has a CR added.
All of the strings are concatenated into one long NSMutableAttributedString and displayed in an NSTextView.
I would have thought that if the text were copied out of my App and pasted into a text editor that the tabs would still line things up assuming the text editor had the same font..
To some extent this happens -- i.e.. the tabs still line things up in the clipboard, however they don't line up in TextEdit (even when it's in the plain text mode).
In the Xcode editor the tabs do line things up.
Even this is somewhat of an improvement compared to older OSX versions -- in 10.5 the tabs didn't line things up correctly even in the clipboard. Now (in Lion version 10.7.2) the text does look good in the clipboard.
So some thing has chained in the way the text system works.
Also, I notice that the text attributes (bolding) are sometimes lost when copying to the clipboard. This seems to be a random thing -- not sure why.
Thanks for your help -- I'll check out NSParagraphStyle and the book you mentioned.
Jim Merkel
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden