1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-27 15:53:31 +03:00

vertically center-align text in linespacing, fixes #415

This commit is contained in:
bren 2020-04-20 19:03:47 +01:00
parent edb666e72d
commit b3877b0e92

View File

@ -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)
}