Skip to content
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

Style font setting doesn't appear to work. #27

Open
ronnyek opened this issue Jun 20, 2024 · 3 comments
Open

Style font setting doesn't appear to work. #27

ronnyek opened this issue Jun 20, 2024 · 3 comments

Comments

@ronnyek
Copy link

ronnyek commented Jun 20, 2024

I've taken from example, code where its setting font like so:

Style s = new Style();
s.Append(Style.BasicStyles.Font("Arial Black", 11));

And then call .AddNextCell("text", s);

No matter what I do, it always renders the text as "Calibri". Interestingly it does seem to take the font size from that, and render text smaller (I'm actually specifying "Arial Narrow" and 8 for the font) but doesn't change the font itself.

this is with version 3.2.1

@rabanti-github rabanti-github added the Investigate The issue must be investigated to determine whether it's a bug or not label Jun 21, 2024
@rabanti-github
Copy link
Owner

rabanti-github commented Jun 21, 2024

Hi,
Thanks for reporting the issue.
It looks, like it can be solved by the following code:

Style s = new Style();
s.CurrentFont.Scheme = Style.Font.SchemeValue.none;
s.Append(Style.BasicStyles.Font("Arial Black", 11));

I'm not entirely sure whether it is a bug or just a feature that should be better documented.
I will read into the documentation about the scheme value of the style font part.
With the information from above, you can set the font correctly, in the meantime.
I will reach back to you.

@rabanti-github rabanti-github added pending A solution is pending or long-term work is in progress and removed Investigate The issue must be investigated to determine whether it's a bug or not labels Jun 21, 2024
@rabanti-github
Copy link
Owner

rabanti-github commented Jun 25, 2024

Hi,
So, I was looking into the definition of the font scheme... But it was a little bit vague:

18.18.33 ST_FontScheme (Font scheme Styles)

Defines the font scheme, if any, to which this font belongs.
This simple type's contents are a restriction of the W3C XML Schema string datatype.
This simple type is restricted to the values listed in the following table:

Enumeration value Description
major (Major Font) This font is the major font for this theme.
minor (Minor Font) This font is the minor font for this theme.
none (None) This font is not a theme font.

It seems to be related to the theme of the worksheet. But to be honest, normally I completely neglect this, because I don't know anyone that actively uses theming. PicoXLSX and NanoXLSX are not even writing a theme definition in the current version (what is valid).
When I look into the default theme, generated by Excel, then is 'Calibri' listed under 'minor' fonts and 'Calibri Light' is listed under 'major' fonts. In the font section of the style definition, 'Calibri' is the default font, with the scheme 'minor' (what seems to be redundant).

The outcome of this is, if other fonts than the defined minor and major fonts (Calibri and Calibri Light) are set as font faces, then the scheme should always be 'None'.
I will adapt the default value in the next Version of PicoXLSX/NanoXLSX when creating a custom font to 'None', if it is not Calibri or Calibri Light. In this major version, I will just do a hardcoded check. In an upcoming major version, the theme will be provided and then a logical check between the style and the theme can be made.

@rabanti-github
Copy link
Owner

The issue should be fixed automatically with the new release v3.3.0 (NuGet package available in some minutes).
In this release, the scheme is automatically set, when a font name is defined.

  • Major will be: 'Calibri Light'
  • Minor ill be: 'Calibri'
  • All other fonts are: 'None'

The scheme value can be overwritten indeed after defining the font name.

@rabanti-github rabanti-github removed the pending A solution is pending or long-term work is in progress label Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants