From f34624c1f52841fb94b1f5c53d917445cb626f64 Mon Sep 17 00:00:00 2001 From: Tae Won Ha Date: Thu, 21 Feb 2019 21:44:04 +0100 Subject: [PATCH] Draw underline --- NvimView/NvimView/AttributesRunDrawer.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/NvimView/NvimView/AttributesRunDrawer.swift b/NvimView/NvimView/AttributesRunDrawer.swift index 584361be..66bd74e7 100644 --- a/NvimView/NvimView/AttributesRunDrawer.swift +++ b/NvimView/NvimView/AttributesRunDrawer.swift @@ -89,6 +89,18 @@ final class AttributesRunDrawer { ) } + if run.attrs.fontTrait.contains(.underline) { + guard let lastPosition = fontGlyphRuns.last?.positions.last?.x else { + return + } + + let x1 = lastPosition + self.cellSize.width + let x0 = fontGlyphRuns[0].positions[0].x + let y0 = fontGlyphRuns[0].positions[0].y + CGRect(x: x0, y: y0 + self.underlinePosition, + width: x1, height: self.underlineThickness).fill() + } + // TODO: GH-666: Draw underline/curl }