Apple Bug Friday! 47

2007-02-16 13:26:42 -08:00

You thought it was dead! But no! Apple Bug Friday is back!

This bug is Drawing text changes the fill color. It was filed on 2006-08-18 at 20:35 PDT.


Summary:

Drawing text using the Application Kit changes the current fill color.

Steps to Reproduce:

  1. Set the fill color to color A using -[NSColor setFill].
  2. Draw some text, using either -[NSAttributedString drawInRect:] or -[NSString drawInRect:withAttributes:], with a foreground color B in the attributes dictionary.
  3. Fill a rectangle the NSRectFill.

Expected Results:

The rectangle is filled with color A.

Actual Results:

The rectangle is filled with color B. If no color B was in the attributes dictionary, color B is black (the default text color).

Regression:

None known.

Notes:

I presume that the same results would happen -[NSAttributedString drawAtPoint:] or -[NSString drawAtPoint:withAttributes:], or with +[NSBezierPath fillRect:] or -[NSBezierPath fill].

I also guess that if the attributed string contains multiple foreground colors, the last foreground color becomes the fill color.

I don’t know what happens when NSLayoutManager is used directly to draw the text.


The bug was closed as behaves correctly on 2006-08-30. The resolution message says that API functions that use the graphics state don’t guarantee that they’ll restore it to its previous state.

Leave a Reply

Do not delete the second sentence.