Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Draw Outlined Font

Draw Outlined Font
Thread Tools
3R1C
Mac Enthusiast
Join Date: Oct 2001
Status: Offline
Reply With Quote
Sep 15, 2004, 03:33 PM
 
Id like to draw some text the same as the finder draws text on the desktop (white bold text with a black blurred border all around). At first I thought they were just using white text with a black NSShadow but upon further inspection I dont think they are since the black edges are all around the text. The black portion is actually bigger than the white portion. Using NSShadow poduces a shadow of the same size as the text above. So if I make an NSShadow with no offset in an attempt to get the shadow to appear all around, the shadow is completely obscured by the text above it.

In the past Ive done this by drawing my string offset by a pixel or so in all four directions: up down, left and right. Then drawing the text in the middle with the contrasting color. This seems kinda hackish and Im almost sure I remember seeing something about a new class or something to do with outlined fonts, but I cant remember for sure. Ive searched mamasam to no avail as well as the docs. does 10.3 offer what I think I remember? any ideas?
3R1C
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Sep 15, 2004, 06:19 PM
 
NSAttributedString has a stroke attribute as of 10.3 (I think), but if you want the behavior from the Finder and the Dock, you're going to have to write custom filter code, because it isn't a built-in function as far as I can tell.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
arekkusu
Mac Enthusiast
Join Date: Jul 2002
Status: Offline
Reply With Quote
Sep 15, 2004, 08:13 PM
 
I've also been wondering how to accomplish this. My shadows always come out too faint compared to the Finder.

If you come upon a good solution, please post the details.
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Sep 15, 2004, 08:20 PM
 
Now that I think about it, Nathan Day has an ImageConvolution class intended to help with creating this effect, though it looks like you'll still have to figure out the appropriate parameters on your own.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
3R1C  (op)
Mac Enthusiast
Join Date: Oct 2001
Status: Offline
Reply With Quote
Sep 15, 2004, 09:25 PM
 
I didnt know about NSStrokeWidthAttributeName and after futzing with it a little, Ive got my text looking pretty much like the dock/desktop. What I did was first draw an attributed string with a black NSStrokeColorAttributeName and a fat NSStrokeWidthAttributeName and a shadow. Then on top of that I drew the same string in white with no shadow and no stroke. Im using this as a custom drag image for reordering my tableView rows. I first draw a semiTransparent rounded rect ala a finder label in gray. then i layer on my black stroke with shadow, then the bold white string. looks sweet. Thanx alot.

Your pointing me at that attribute clued me on some other attributes i didnt know about. Ive got a custom about box class with nib that I drop into my apps and it grabs all the info like the apps name and stuff and slaps it into textfields in the about box in a nice way. When i noticed all those attributes like NSToolTipAttributeName, NSCursorAttributeName and NSLinkAttributeName, it gave me the idea to "linkify" the textfield that holds the apps name in the aboutbox. So I added the attributes but I got no love. No tooltip, no cursor change and no click to open my NSURL. Do those attributes only work in textViews? Any Ideas? I suppose I shoulda started a new thread... =)
3R1C
     
   
Thread Tools
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 02:02 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,