Re: Drawing text with alpha
Re: Drawing text with alpha
- Subject: Re: Drawing text with alpha
- From: Uli Kusterer <email@hidden>
- Date: Wed, 22 Aug 2007 20:23:26 +0200
On 22.08.2007, at 02:41, Phil wrote:
NSDictionary *attr = [NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects:[NSFont fontWithName:@"Chalkboard" size:
18.0], fg, bg, nil]
forKeys:
[NSArray arrayWithObjects:NSFontAttributeName,
NSForegroundColorAttributeName, NSBackgroundColorAttributeName, nil]];
What's so bad about
[NSDictionary dictionaryWithObjectsAndKeys: [NSFont
fontWithName:@"Chalkboard" size:18.0], NSFontAttributeName, fg,
NSForegroundColorAttributeName, bg, NSBackgroundColorAttributeName, nil]
? Makes for much readable lists and keeps objects with their values.
Apart from that, I'm afraid I don't know a fix. It looks like the
string background is really only intended for solid colors. If it
gets black, that means someone is using "copy" compositing mode,
because copy replaces whatever color was there before, and that means
transparency ends up "cutting a hole in your window". Since most
windows have their -isOpaque default to YES, they're composited to
the screen wthout transparency, which causes transparent areas to end
up black.
A workaround is drawing the background yourself using [NSBezierPath
fillRect] or another API that doesn't use copy mode (NSRectFill()
uses copy mode, but there's a variant that lets you specify a mode
somewhere), and then draw your text on top of that without a
background. Others have detailed how you'd do that.
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
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