mirror of
https://github.com/unidoc/unipdf.git
synced 2025-04-29 13:48:54 +08:00
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:
parent
d1a81d79d2
commit
1e26aa81f6
@ -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()
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user