Contents

underlineGlyphRange(_:underlineType:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:)

Calculates subranges to underline for the specified glyphs and draws the underlining as appropriate.

Declaration

func underlineGlyphRange(_ glyphRange: NSRange, underlineType underlineVal: NSUnderlineStyle, lineFragmentRect lineRect: NSRect, lineFragmentGlyphRange lineGlyphRange: NSRange, containerOrigin: NSPoint)

Parameters

  • glyphRange:

    A range of glyphs, which must belong to a single line fragment rectangle (as returned by Linefragmentrect(forglyphat:effectiverange:)).

  • underlineVal:

    The style of underlining to draw. This value is a mask derived from the value for Underlinestyle—for example, (NSUnderlinePatternDash | NSUnderlineStyleThick | NSUnderlineByWordMask). Subclasses can define custom underlining styles.

  • lineRect:

    The line fragment rectangle containing the glyphs to draw underlining for.

  • lineGlyphRange:

    The range of all glyphs within that line fragment rectangle.

  • containerOrigin:

    The origin of the line fragment rectangle’s NSTextContainer in its NSTextView.

Discussion

This method determines which glyphs actually need to be underlined based on underlineVal. With NSUnderlineStyleSingle, for example, leading and trailing whitespace isn’t underlined, but whitespace between visible glyphs is. A potential word-underline style would omit underlining on any whitespace. After determining which glyphs to draw underlining on, this method invokes drawUnderline(forGlyphRange:underlineType:baselineOffset:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:) for each contiguous range of glyphs that requires it.

See Also

Drawing