Preserve TOC line components style properties when setting links (#202)

* Preserve TOC line component style properties when setting links
* Adapt TOC test cases
This commit is contained in:
Adrian-George Bostan 2019-11-26 23:49:45 +02:00 committed by Gunnsteinn Hall
parent d1a81d79d2
commit 1e26aa81f6
2 changed files with 7 additions and 6 deletions

View File

@ -822,7 +822,7 @@ func TestSubchaptersSimple(t *testing.T) {
c.AddTOC = true
lineStyle := c.NewTextStyle()
lineStyle.Font = model.NewStandard14FontMustCompile(model.HelveticaBoldName)
lineStyle.Font = model.NewStandard14FontMustCompile(model.HelveticaName)
toc := c.TOC()
toc.SetLineStyle(lineStyle)
@ -898,9 +898,6 @@ func TestSubchaptersSimple(t *testing.T) {
toc.SetHeading("Table of Contents", style)
// Set style of TOC lines just before render.
lineStyle := c.NewTextStyle()
lineStyle.FontSize = 14
helveticaBold := model.NewStandard14FontMustCompile(model.HelveticaBoldName)
lines := toc.Lines()
@ -923,7 +920,6 @@ func TestSubchapters(t *testing.T) {
lineStyle := c.NewTextStyle()
lineStyle.Font = model.NewStandard14FontMustCompile(model.HelveticaName)
lineStyle.FontSize = 14
lineStyle.Color = ColorRGBFromArithmetic(0.5, 0.5, 0.5)
toc := c.TOC()

View File

@ -155,7 +155,12 @@ func (tl *TOCLine) SetLink(page int64, x, y float64) {
tl.linkY = y
tl.linkPage = page
tl.SetStyle(tl.sp.defaultLinkStyle)
// Set the color of the line components to the default link color.
linkColor := tl.sp.defaultLinkStyle.Color
tl.Number.Style.Color = linkColor
tl.Title.Style.Color = linkColor
tl.Separator.Style.Color = linkColor
tl.Page.Style.Color = linkColor
}
// getLineLink returns a new annotation if the line has a link set.