From ca34f8de93d5feffa1fddbfe557cd3ad3aaabf57 Mon Sep 17 00:00:00 2001 From: Adrian-George Bostan Date: Tue, 26 Nov 2019 20:35:35 +0200 Subject: [PATCH 1/2] Preserve TOC line component style properties when setting links --- creator/toc_line.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/creator/toc_line.go b/creator/toc_line.go index 6de031c98..a82382b56 100644 --- a/creator/toc_line.go +++ b/creator/toc_line.go @@ -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. From 146f12a0917094087a8e379158239ed5a3fdeda6 Mon Sep 17 00:00:00 2001 From: Adrian-George Bostan Date: Tue, 26 Nov 2019 20:36:08 +0200 Subject: [PATCH 2/2] Adapt TOC test cases --- creator/creator_test.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/creator/creator_test.go b/creator/creator_test.go index 488cf383b..b5818d4a4 100644 --- a/creator/creator_test.go +++ b/creator/creator_test.go @@ -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()