You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that even in the demo, the small-caps feature is not working. I tried switching fonts to STIXGeneral, and setting variant='small-caps' still had no effect.
This will basically not work (AFAICT) until we switch to using harfbuzz for font shaping (#14912). (Currently the way we detect small-caps fonts is just if their name is exactly (case-insensitively) either "capitals" or "small-caps", which of course fails to catch any relevant small caps font -- but it's not as if any simple regex on the font name would really be sufficient, see e.g. https://www.fontsc.com/font/tag/small-caps, https://www.fontsquirrel.com/fonts/list/tag/small%20caps.)
Given that it seems unlikely we'll switch to harfbuzz any time soon (well, it depends on whether someone picks up #14912), I think we should simply just document "variant: small-caps" as unsupported and emit a warning when the user requests that.
Actually there's a bit more, e.g. figuring out whether we need static linking (especially the situation on non-linux), fixing a version, and all that stuff...
Where are we tracking g the image comparison issue? I think we should just go low tech and have two repositories and let folks who want smaller downloads just limit the depth they pull off GitHub.
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
Are there any workarounds to get small caps fonts in text in matplotlib? Perhaps getting some LaTeX installation or something working with matplotlib? I would like to be able to use small caps as it is used a lot in high energy physics and our legends need to properly reflect the exact font formatting.
(The problem here is primarily that our internal mathtext engine cannot handle it, but with the correct preamble etc, anything that can be done in LaTeX can be done in Matplotlib.)
@dstansby pointed out that this didn't work in matplotlib/cheatsheets#183 (comment) Unfortunately, I had not noticed this property or I might have tried to do something with it in the font overhaul.
That being said, it should be possible to get small caps working in 3.11 by passing the right font features (small caps is the smcp feature): matplotlib/cheatsheets#183 (comment)
I do think that the font feature tag names are a bit unergonomic, so I wonder if we want to implement all the CSS options for font-variant (or at least the ones we are capable of providing.)
Activity
coderforlife commentedon Feb 7, 2021
This is still true.
jklymak commentedon Feb 7, 2021
Yes - recent version of docs: https://matplotlib.org/stable/gallery/text_labels_and_annotations/fonts_demo.html#sphx-glr-gallery-text-labels-and-annotations-fonts-demo-py
anntzer commentedon Feb 7, 2021
This will basically not work (AFAICT) until we switch to using harfbuzz for font shaping (#14912). (Currently the way we detect small-caps fonts is just if their name is exactly (case-insensitively) either "capitals" or "small-caps", which of course fails to catch any relevant small caps font -- but it's not as if any simple regex on the font name would really be sufficient, see e.g. https://www.fontsc.com/font/tag/small-caps, https://www.fontsquirrel.com/fonts/list/tag/small%20caps.)
Given that it seems unlikely we'll switch to harfbuzz any time soon (well, it depends on whether someone picks up #14912), I think we should simply just document "variant: small-caps" as unsupported and emit a warning when the user requests that.
jklymak commentedon Feb 7, 2021
It seems regenerating the images is the only hold up for harfbuzz?
anntzer commentedon Feb 7, 2021
Actually there's a bit more, e.g. figuring out whether we need static linking (especially the situation on non-linux), fixing a version, and all that stuff...
jklymak commentedon Feb 7, 2021
Where are we tracking g the image comparison issue? I think we should just go low tech and have two repositories and let folks who want smaller downloads just limit the depth they pull off GitHub.
anntzer commentedon Feb 7, 2021
#16447
github-actions commentedon Oct 9, 2023
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
AWildridge commentedon Apr 19, 2024
Are there any workarounds to get small caps fonts in text in matplotlib? Perhaps getting some LaTeX installation or something working with matplotlib? I would like to be able to use small caps as it is used a lot in high energy physics and our legends need to properly reflect the exact font formatting.
oscargus commentedon Apr 19, 2024
@AWildridge it should work if you use
usetex=Trueas that will use standard LaTeX to generate the text, see https://matplotlib.org/stable/users/explain/text/usetex.html(The problem here is primarily that our internal mathtext engine cannot handle it, but with the correct preamble etc, anything that can be done in LaTeX can be done in Matplotlib.)
QuLogic commentedon Apr 17, 2026
@dstansby pointed out that this didn't work in matplotlib/cheatsheets#183 (comment) Unfortunately, I had not noticed this property or I might have tried to do something with it in the font overhaul.
That being said, it should be possible to get small caps working in 3.11 by passing the right font features (small caps is the
smcpfeature): matplotlib/cheatsheets#183 (comment)I do think that the font feature tag names are a bit unergonomic, so I wonder if we want to implement all the CSS options for
font-variant(or at least the ones we are capable of providing.)