diff --git a/ChangeLog b/ChangeLog index 8270e08a5..d28c2414b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-11-01 18:19 Alexander Malmberg + + * Source/NSLayoutManager.m (-drawGlyphsForGlyphRange:atPoint:): + If a range of glyphs has no color set, use the default text color + (as returned by [NSColor textColor]) instead of assuming black. + 2003-10-30 00:38 Alexander Malmberg * Source/NSImage.m (iterate_reps_for_types, repd_for_rep): Make diff --git a/Source/NSLayoutManager.m b/Source/NSLayoutManager.m index 65e98a551..45976fae5 100644 --- a/Source/NSLayoutManager.m +++ b/Source/NSLayoutManager.m @@ -1292,6 +1292,14 @@ container NSGraphicsContext *ctxt = GSCurrentContext(); + /* + For performance, it might (if benchmarks or profiling backs it up) be + worthwhile to cache this across calls to this method. However, this + color can change at runtime, so care would have to be taken to keep the + cache in sync with the actual color. + */ + NSColor *defaultTextColor = [NSColor textColor]; + #define GBUF_SIZE 16 /* TODO: tweak */ NSGlyph gbuf[GBUF_SIZE]; int gbuf_len; @@ -1330,13 +1338,9 @@ container attributes = [_textStorage attributesAtIndex: char_pos effectiveRange: NULL]; color = [attributes valueForKey: NSForegroundColorAttributeName]; - if (color) - [color set]; - else - { - DPSsetgray(ctxt, 0.0); - DPSsetalpha(ctxt, 1.0); - } + if (!color) + color = defaultTextColor; + [color set]; f = glyph_run->font; [f set]; @@ -1378,6 +1382,8 @@ container attributes = [_textStorage attributesAtIndex: char_pos effectiveRange: NULL]; new_color = [attributes valueForKey: NSForegroundColorAttributeName]; + if (!new_color) + new_color = defaultTextColor; glyph = glyph_run->glyphs; if (glyph_run->font != f || new_color != color) { @@ -1391,13 +1397,7 @@ container if (color != new_color) { color = new_color; - if (color) - [color set]; - else - { - DPSsetgray(ctxt, 0.0); - DPSsetalpha(ctxt, 1.0); - } + [color set]; } if (f != glyph_run->font) {