Apple Bug Friday! 47
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:
- Set the fill color to color A using -[NSColor setFill].
- Draw some text, using either -[NSAttributedString drawInRect:] or -[NSString drawInRect:withAttributes:], with a foreground color B in the attributes dictionary.
- 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.