mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 06:06:09 -06:00
[GH-ISSUE #494] Feature: allow non-theme Calibri font #385
Labels
No labels
awaiting user feedback
bug
cmake
cmake
docs
feature request
in progress
long term
medium term
medium term
pull-request
question
question
ready to close
short term
under investigation
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/libxlsxwriter#385
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @wangjinyin7136 on GitHub (Nov 4, 2025).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/494
Description:
In
src/styles.c, the logic controlling whether to write the<font><scheme>element seems inconsistent with the comment above it.According to the comment, the
<scheme>element should only be written when the format is a hyperlink, but the actual condition writes it when it's not a hyperlink (&& !format->hyperlink).This looks like a logical inversion between the comment and the code.
Expected behavior:
If the intent is to include
<scheme>only for hyperlink fonts (as the comment says), the condition should be:Actual behavior:
Currently,
_write_font_scheme()is called for non-hyperlink formats using the default font.Impact:
This can result in incorrect
<font><scheme>behavior — e.g., fonts that should use explicit names like"Arial"or"Calibri"may end up using theme-dependent fonts unintentionally. In some cases, Excel may render them differently depending on theme settings.Environment:
Suggested fix:
Reverse the
hyperlinkcondition or clarify the intended logic in the comment.@jmcnamara commented on GitHub (Nov 4, 2025):
Thanks for the question.
The comment is wrong, It should read:
Only write the scheme element for the default font type if it isn't a hyperlink.
@wangjinyin7136 commented on GitHub (Nov 4, 2025):
Thanks! Just to confirm — if the user explicitly sets format_set_font_name(format, "Calibri"),
should it still write or use instead?
Right now it treats "Calibri" as default and writes , which makes the font follow the theme instead of staying fixed.
Would it make sense to only write when no font name is set?
@jmcnamara commented on GitHub (Nov 4, 2025):
What issue are you having or what are you trying to achieve?
@wangjinyin7136 commented on GitHub (Nov 4, 2025):
I’m trying to ensure that when explicitly setting the font name ("Calibri"), the generated XLSX should use a fixed font instead of following the theme.
Currently, libxlsxwriter still writes for "Calibri", which causes Excel to treat it as a themed font instead of a literal "Calibri" font.
@jmcnamara commented on GitHub (Nov 4, 2025):
Which means that any user defined "Calibri" fonts change when the theme changes. Is that the issue?
@wangjinyin7136 commented on GitHub (Nov 4, 2025):
Yes, exactly — that’s the issue.
@jmcnamara commented on GitHub (Nov 4, 2025):
Ok. I am currently reworking some of the default font handling in the Rust version so I will look into it.
See also: https://github.com/jmcnamara/rust_xlsxwriter/issues/158
@wangjinyin7136 commented on GitHub (Nov 4, 2025):
Thanks for checking it!