diff --git a/NvimView/NvimView/AttributesRunDrawer.swift b/NvimView/NvimView/AttributesRunDrawer.swift index e4f68551..d0e5f135 100644 --- a/NvimView/NvimView/AttributesRunDrawer.swift +++ b/NvimView/NvimView/AttributesRunDrawer.swift @@ -24,6 +24,7 @@ final class AttributesRunDrawer { private(set) var cellSize: CGSize = .zero private(set) var baselineOffset: CGFloat = 0 + private(set) var ascent: CGFloat = 0 private(set) var descent: CGFloat = 0 private(set) var underlinePosition: CGFloat = 0 private(set) var underlineThickness: CGFloat = 0 @@ -181,8 +182,10 @@ final class AttributesRunDrawer { self.cellSize = FontUtils.cellSize( of: self.font, linespacing: self.linespacing, characterspacing: self.characterspacing ) - self.baselineOffset = self.cellSize.height - CTFontGetAscent(self.font) + + self.ascent = CTFontGetAscent(font) self.descent = CTFontGetDescent(font) + self.baselineOffset = (self.cellSize.height - ascent + descent) / 2 self.underlinePosition = CTFontGetUnderlinePosition(font) self.underlineThickness = CTFontGetUnderlineThickness(font) }