Alan Third writes: > That function is a real mess of calls to ns_focus and ns_unfocus. I > think there's no good reason for them to be called as often as they > are, and some related functions (ns_dumpglyphs_stretch) don't need to > call them themselves either. > I think we need to have a rethink of how clipping is handled here. We > don't need to use ns_focus to clip and we repeatedly call ns_focus on > the same rectangle. For a lot of those calls we could replace them > with a single clipping rectangle and adjust it as required for > overhangs or whatever. > I also think you misunderstood what I was saying about the performance > problems with calling saveGraphicsState. Calling it when not required > is frowned upon by Apple as they say it causes performance problems. > Your code is now calling it in ns_focus whether it's required or not. > Ideally we only call it when modifying the clipping rectangle, because > there are times ns_focus is called where we don't modify the clipping > rectangle and therefore we don't need to save the graphics context. I understand what you mean now, thanks. > I understand what you did, but I think the better solution is for us > is to try to untangle ns_draw_glyph_string, even if that means saving > the context there directly on occasion. > If you want me to have a look at it let me know, I think I know what > needs to be done, but I probably won't get round to it as soon as you > could. Thanks. I had a try at it, cleaning up much of what appeared obviously unnecessary. (Though I did not dare change what seemed to be mysterious to me.) Though, OTOH, I think calling saveGraphicsState inside the overhang draw process is not too much of a problem as it happens infrequently enough to not be relevant.