Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Supporting fontweight options #31529

Open
Chirag3841 wants to merge 2 commits intomatplotlib:mainfrom
Chirag3841:fix-fontweight-asymmetry
Open

Supporting fontweight options #31529
Chirag3841 wants to merge 2 commits intomatplotlib:mainfrom
Chirag3841:fix-fontweight-asymmetry

Conversation

@Chirag3841
Copy link
Copy Markdown
Contributor

@Chirag3841 Chirag3841 commented Apr 19, 2026

PR summary

This PR fixes an inconsistency in how font weights are handled. Some weight names like extrabold, superbold, and ultrabold were already supported internally when parsing font metadata, but they were not accepted when passed directly as user input. This created a mismatch where these values could be read from fonts but not used explicitly.
To fix this, I added the missing weight names to weight_dict so that user input handling is consistent with internal parsing. This keeps existing behavior unchanged while resolving the asymmetry. I also updated the existing test to cover these cases.

AI Disclosure

PR checklist

@tacaswell
Copy link
Copy Markdown
Member

The weights for the same name do not match between the two dictionaries, that seems wrong.

When we look at the weights to do font matching to we look at the name or the numeric value?

@Chirag3841
Copy link
Copy Markdown
Contributor Author

Chirag3841 commented Apr 20, 2026

The weights for the same name do not match between the two dictionaries, that seems wrong.

When we look at the weights to do font matching to we look at the name or the numeric value?
@tacaswell
That’s a good point, I noticed there are some existing inconsistencies as well (for example with 'heavy') between _weight_regexes and weight_dict.
In this PR, I focused on adding the missing weight names like extrabold, superbold, and ultrabold so that user input is consistent with what’s already supported internally.
I didn’t change any of the existing mappings to keep the scope limited. Let me know if you’d like me to also look into standardizing those mappings.

@tacaswell
Copy link
Copy Markdown
Member

Ah, I missed the difference between ultrabold and ultrablack.

Please add all the obvious missing keys in this pass so we do this once rather than N times.


I'm going to also remind you have our LLM use policy (https://matplotlib.org/devdocs/devel/contribute.html#use-of-generative-ai).

@Chirag3841
Copy link
Copy Markdown
Contributor Author

Chirag3841 commented Apr 20, 2026

Ah, I missed the difference between ultrabold and ultrablack.

Please add all the obvious missing keys in this pass so we do this once rather than N times.

I'm going to also remind you have our LLM use policy (https://matplotlib.org/devdocs/devel/contribute.html#use-of-generative-ai).

I have added the remaining obvious missing keys specially black category ones which includes ultrablack, superblack and extrablack.
And I totally understood the LLM use policy too.
Just to confirm, I would to like to ask about is there any need to add these semilight,extralight and demilight too here which are indermediate weights here which are not following clean and symmetrical values as compared to bold and black category weights.

@tacaswell
Copy link
Copy Markdown
Member

https://gitlab.freedesktop.org/fontconfig/fontconfig/-/blob/main/src/fcfreetype.c#L944-968

Should be treated as the authoritative list of weight names and their equivalence unless from looking at the git history we can sort out a good reason why the other names were previously excluded (or why they should be excluded now).

@Chirag3841
Copy link
Copy Markdown
Contributor Author

Chirag3841 commented Apr 20, 2026

https://gitlab.freedesktop.org/fontconfig/fontconfig/-/blob/main/src/fcfreetype.c#L944-968

Should be treated as the authoritative list of weight names and their equivalence unless from looking at the git history we can sort out a good reason why the other names were previously excluded (or why they should be excluded now).

That makes sense, thanks for clarifying. Would you like me to extend weight_dict further to include additional names like thin and extralight, or keep this change limited to the current additions as per the requirement.

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

Successfully merging this pull request may close these issues.

[Doc]: fontweight options not documented correctly

2 participants