diff --git a/Museion/ReadingSurface.swift b/Museion/ReadingSurface.swift index 38de8db..7148c32 100644 --- a/Museion/ReadingSurface.swift +++ b/Museion/ReadingSurface.swift @@ -141,13 +141,18 @@ final class ReadingCanvasView: NSTextView { override func draw(_ dirtyRect: NSRect) { super.draw(dirtyRect) + let origin = textContainerOrigin for bound in blockBounds { guard let decoration = bound.decoration else { continue } + // frames arrive in CONTAINER space; the view draws text at + // textContainerOrigin + frame (inset shifts it — the missing + // +origin.y drew every decoration 20pt too high). let frames = framesForRange(bound.docRange) + .map { CGRect(x: $0.minX + origin.x, y: $0.minY + origin.y, width: $0.width, height: $0.height) } guard let firstFrame = frames.first, let lastFrame = frames.last else { continue } switch decoration { case let .quote(indent): - let x = textContainerOrigin.x + (textContainer?.lineFragmentPadding ?? 0) + indent - 6 + let x = (textContainer?.lineFragmentPadding ?? 0) + indent - 6 let path = NSBezierPath() path.move(to: NSPoint(x: x, y: firstFrame.minY)) path.line(to: NSPoint(x: x, y: lastFrame.maxY)) @@ -157,13 +162,13 @@ final class ReadingCanvasView: NSTextView { case .rule: let y = (firstFrame.minY + firstFrame.maxY) / 2 let path = NSBezierPath() - path.move(to: NSPoint(x: textContainerOrigin.x, y: y)) - path.line(to: NSPoint(x: textContainerOrigin.x + (textContainer?.size.width ?? 0), y: y)) + path.move(to: NSPoint(x: 0, y: y)) + path.line(to: NSPoint(x: (textContainer?.size.width ?? 0), y: y)) path.lineWidth = 1 ProseTypography.tableBorderColor.setStroke() path.stroke() case let .table(columns): - let originX = textContainerOrigin.x + (textContainer?.lineFragmentPadding ?? 0) + let originX = (textContainer?.lineFragmentPadding ?? 0) let path = NSBezierPath() for offset in columns { let x = originX + offset