Adjust annotation position for all paragraph alignments

This commit is contained in:
Adrian-George Bostan 2018-11-30 18:21:47 +02:00
parent 09e41acdf9
commit 9ac309464a

View File

@ -654,12 +654,18 @@ func drawStyledParagraphOnBlock(blk *Block, p *StyledParagraph, ctx DrawContext)
}
} else if p.alignment == TextAlignmentCenter {
// Start with an offset of half of the remaining line space.
shift := (wrapWidth - width - spaceWidth) / 2 / defaultFontSize
offset := (wrapWidth - width - spaceWidth) / 2
shift := offset / defaultFontSize
objs = append(objs, core.MakeFloat(-shift))
currX += offset / 1000.0
} else if p.alignment == TextAlignmentRight {
// Push the text at the end of the line.
shift := (wrapWidth - width - spaceWidth) / defaultFontSize
offset := (wrapWidth - width - spaceWidth)
shift := offset / defaultFontSize
objs = append(objs, core.MakeFloat(-shift))
currX += offset / 1000.0
}
if len(objs) > 0 {