Skip to content

Not able to specify font family on the title of a chart #2102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
jebirch opened this issue Mar 16, 2025 · 1 comment · Fixed by #2103
Closed
2 tasks done

Not able to specify font family on the title of a chart #2102

jebirch opened this issue Mar 16, 2025 · 1 comment · Fixed by #2103
Labels
bug Something isn't working

Comments

@jebirch
Copy link

jebirch commented Mar 16, 2025

Description

When I specify the font family for the title on a chart then I am getting a nil pointer exception:

...
Title: []excelize.RichTextRun{{Text: "Test", Font: &excelize.Font{Size: 11, Family: "Aptos"}}},
...

For me it looks like the problem is here:

diff --git a/drawing.go b/drawing.go
index 7241dac..8c336f2 100644
--- a/drawing.go
+++ b/drawing.go
@@ -1198,6 +1198,9 @@ func drawChartFont(fnt *Font, r *aRPr) {
                r.SolidFill.SrgbClr = &attrValString{Val: stringPtr(strings.ReplaceAll(strings.ToUpper(fnt.Color), "#", ""))}
        }
        if fnt.Family != "" {
+               if r.Latin == nil {
+                       r.Latin = &xlsxCTTextFont{}
+               }
                r.Latin.Typeface = fnt.Family
        }
        if fnt.Size > 0 {

Steps to reproduce the issue

Add Family parameter to title of a chart

Describe the results you received

Getting a nil pointer exception

Describe the results you expected

No exceptions

Go version

1.24

Excelize version or commit ID

2.9.0

Environment

Linux

Validations

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.
@xuri xuri added the bug Something isn't working label Mar 16, 2025
@xuri xuri moved this to Bugfix in Excelize v2.9.1 Mar 16, 2025
@xuri xuri linked a pull request Mar 16, 2025 that will close this issue
10 tasks
@xuri xuri closed this as completed in 2bb89f4 Mar 16, 2025
@xuri
Copy link
Member

xuri commented Mar 16, 2025

Thanks for your issue. This issue has been fixed, please upgrade to the master branch code by go get -u github.com/xuri/excelize/v2@master, and this patch will be released in the next version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Status: Bugfix
Development

Successfully merging a pull request may close this issue.

2 participants