• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Drawing text with alpha
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Drawing text with alpha (From: Phil <email@hidden>)

  • Prev by Date: Re: Detect legacy OSX
  • Next by Date: Re: Binding NSMenuItem 1 to 1
  • Previous by thread: Re: Drawing text with alpha
  • Next by thread: Re: Drawing Text with alpha
  • Index(es):
    • Date
    • Thread