@@ -67,7 +67,7 @@ private extension LayoutManager {
6767
6868 enumerateLineFragments ( forGlyphRange: blockquoteGlyphRange) { ( rect, usedRect, textContainer, glyphRange, stop) in
6969
70- let startIndent = paragraphStyle. blockquoteIndent
70+ let startIndent = paragraphStyle. indentToFirst ( Blockquote . self ) - Metrics . listTextIndentation
7171
7272 let lineRange = self . characterRange ( forGlyphRange: glyphRange, actualGlyphRange: nil )
7373 let lineCharacters = textStorage. attributedSubstring ( from: lineRange) . string
@@ -78,13 +78,12 @@ private extension LayoutManager {
7878
7979 let nestDepth = paragraphStyle. blockquoteNestDepth
8080 for index in 0 ... nestDepth {
81- let indent = startIndent + CGFloat ( index) * Metrics. listTextIndentation
81+ let indent = paragraphStyle . indent ( to : index, of : Blockquote . self ) - Metrics. listTextIndentation
8282
83- let nestRect = self . blockquoteRect ( origin: origin, lineRect: rect, blockquoteIndent: indent, lineEndsParagraph: lineEndsParagraph)
83+ let nestRect = self . blockquoteRect ( origin: origin, lineRect: rect, blockquoteIndent: indent, lineEndsParagraph: lineEndsParagraph)
8484
85- self . drawBlockquoteBorder ( in: nestRect. integral, with: context, at: index)
85+ self . drawBlockquoteBorder ( in: nestRect. integral, with: context, at: index)
8686 }
87-
8887
8988 }
9089 }
@@ -100,7 +99,7 @@ private extension LayoutManager {
10099 return
101100 }
102101
103- let extraIndent = paragraphStyle. blockquoteIndent
102+ let extraIndent = paragraphStyle. indentToLast ( Blockquote . self )
104103 let extraRect = blockquoteRect ( origin: origin, lineRect: extraLineFragmentRect, blockquoteIndent: extraIndent, lineEndsParagraph: false )
105104
106105 drawBlockquoteBackground ( in: extraRect. integral, with: context)
@@ -121,11 +120,7 @@ private extension LayoutManager {
121120 private func blockquoteRect( origin: CGPoint , lineRect: CGRect , blockquoteIndent: CGFloat , lineEndsParagraph: Bool ) -> CGRect {
122121 var blockquoteRect = lineRect. offsetBy ( dx: origin. x, dy: origin. y)
123122
124- guard blockquoteIndent != 0 else {
125- return blockquoteRect
126- }
127-
128- let paddingWidth = Metrics . listTextIndentation * 0.5 + blockquoteIndent
123+ let paddingWidth = blockquoteIndent
129124 blockquoteRect. origin. x += paddingWidth
130125 blockquoteRect. size. width -= paddingWidth
131126
@@ -284,16 +279,16 @@ private extension LayoutManager {
284279 /// - location: Text Location that should get the marker rendered.
285280 ///
286281 private func drawItem( _ markerText: String , in rect: CGRect , styled paragraphAttributes: [ NSAttributedString . Key : Any ] , at location: Int ) {
287- guard let style = paragraphAttributes [ . paragraphStyle] as? NSParagraphStyle else {
282+ guard let style = paragraphAttributes [ . paragraphStyle] as? ParagraphStyle else {
288283 return
289284 }
290285 let markerAttributes = markerAttributesBasedOnParagraph ( attributes: paragraphAttributes)
291286 let markerAttributedText = NSAttributedString ( string: markerText, attributes: markerAttributes)
292287
293288 var yOffset = CGFloat ( 0 )
294289 var xOffset = CGFloat ( 0 )
295- let indentWidth = style. firstLineHeadIndent
296- let markerWidth = markerAttributedText. size ( ) . width
290+ let indentWidth = style. indentToLast ( TextList . self )
291+ let markerWidth = markerAttributedText. size ( ) . width * 1.5
297292
298293 if location > 0 {
299294 yOffset += style. paragraphSpacingBefore
@@ -315,10 +310,7 @@ private extension LayoutManager {
315310 ///
316311 private func markerAttributesBasedOnParagraph( attributes: [ NSAttributedString . Key : Any ] ) -> [ NSAttributedString . Key : Any ] {
317312 var resultAttributes = attributes
318- var indent : CGFloat = 0
319- if let style = attributes [ . paragraphStyle] as? ParagraphStyle {
320- indent = style. listIndent + Metrics. listTextIndentation - ( Metrics . listTextIndentation / 4 )
321- }
313+ let indent : CGFloat = CGFloat ( Metrics . tabStepInterval)
322314
323315 resultAttributes [ . paragraphStyle] = markerParagraphStyle ( indent: indent)
324316 resultAttributes. removeValue ( forKey: . underlineStyle)
@@ -336,10 +328,11 @@ private extension LayoutManager {
336328 /// Returns the Marker Paragraph Attributes
337329 ///
338330 private func markerParagraphStyle( indent: CGFloat ) -> NSParagraphStyle {
339- let tabStop = NSTextTab ( textAlignment : . right , location : indent , options : [ : ] )
331+
340332 let paragraphStyle = NSMutableParagraphStyle ( )
341-
342- paragraphStyle. tabStops = [ tabStop]
333+ paragraphStyle. alignment = . right
334+ paragraphStyle. tailIndent = - indent
335+ paragraphStyle. lineBreakMode = . byClipping
343336
344337 return paragraphStyle
345338 }
0 commit comments