diff --git a/ChangeLog b/ChangeLog index 5a6a92b40..6ea4431e4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-07-03 Fred Kiefer + + * Source/NSLayoutManager.m (-drawGlyphsForGlyphRange:atPoint:, + -drawUnderlineForGlyphRange:...:): Add support for for link attributes. + 2011-07-03 Riccardo Mottola * Source/NSSliderCell.m: @@ -73,7 +78,6 @@ In particular, the action now deletes the newline character when the insertion point is at the end of a line. ->>>>>>> .r33429 2011-06-22 Fred Kiefer * Headers/AppKit/NSPrintPanel.h: Add missing APPKIT_EXPORT for new diff --git a/Source/NSLayoutManager.m b/Source/NSLayoutManager.m index f64128ae7..44e289030 100644 --- a/Source/NSLayoutManager.m +++ b/Source/NSLayoutManager.m @@ -1485,6 +1485,8 @@ attachmentSize(linefrag_t *lf, NSUInteger glyphIndex) */ NSColor *defaultTextColor = [NSColor textColor]; NSColor *selectedTextColor = defaultTextColor; + NSColor *link_color = nil; + id linkValue; #define GBUF_SIZE 16 /* TODO: tweak */ NSGlyph gbuf[GBUF_SIZE]; @@ -1544,6 +1546,18 @@ attachmentSize(linefrag_t *lf, NSUInteger glyphIndex) if (run_color == nil) run_color = defaultTextColor; + linkValue = [attributes objectForKey: NSLinkAttributeName]; + if (linkValue != nil) + { + if (link_color == nil) + { + NSDictionary *link_attributes = [[self firstTextView] linkTextAttributes]; + link_color = [link_attributes valueForKey: NSForegroundColorAttributeName]; + } + if (link_color != nil) + run_color = link_color; + } + if (selectedGlyphRange.length > 0) { /* Get the text view's color setting for selected text as we will @@ -1639,6 +1653,19 @@ attachmentSize(linefrag_t *lf, NSUInteger glyphIndex) { run_color = defaultTextColor; } + + linkValue = [attributes objectForKey: NSLinkAttributeName]; + if (linkValue != nil) + { + if (link_color == nil) + { + NSDictionary *link_attributes = [[self firstTextView] linkTextAttributes]; + link_color = [link_attributes valueForKey: NSForegroundColorAttributeName]; + } + if (link_color != nil) + run_color = link_color; + } + glyph = glyph_run->glyphs; /* If the font has changed or the color has changed (and we are @@ -1752,14 +1779,37 @@ for (i = 0; i < gbuf_len; i++) printf(" %3i : %04x\n", i, gbuf[i]); */ { const NSRange characterRange = [self characterRangeForGlyphRange: range actualGlyphRange: NULL]; + id linkUnderlineValue = nil; for (i=characterRange.location; i 0) + { + // do the actual underline + // FIXME: find the largest font within the range to underline - NSFont *largestFont = [self effectiveFontForGlyphAtIndex: glyphRangeToDraw.location // NOTE: GS private method - range: NULL]; + // NOTE: GS private method + NSFont *largestFont = [self effectiveFontForGlyphAtIndex: glyphRangeToDraw.location + range: NULL]; const CGFloat underlineWidth = [largestFont pointSize] * (((type & NSUnderlineStyleDouble) != 0) ? 0.05 : 0.07); NSPoint start = [self locationForGlyphAtIndex: glyphRangeToDraw.location]; - NSPoint end = [self locationForGlyphAtIndex: NSMaxRange(glyphRangeToDraw) - 1]; //FIXME: check length > 0 + NSPoint end = [self locationForGlyphAtIndex: NSMaxRange(glyphRangeToDraw) - 1]; // FIXME: remove this hack lowers the underline slightly start.y += [largestFont pointSize] * 0.07;