When rendering text we pick the font that best matches your fontdict. The way that different weights are encoded is effectively as different fonts (not as some scaling on a single font which is something I learned from @dorafc very recently). In the first case we always pick 'KaiTi' which you only have one variant of installed (or at least not any of the variants you are looking for) so you get both 汉字 and latin characters rendered, but always at the same weight. In the second case you are not selecting a font family so we fall back to the default font (which is likely dejavu sans) which does have multiple weights but does not have the Chinese code pages.
To get this to work you will need to install a font that both has multiple weights and support Chinese.
I am going to close this because there is nothing more we can do on the library side. If you have further questions can you please post at https://discourse.matplotlib.org/c/community ?
Actually I think the error message could be better in this case; we already log a warning when a font of the requested family is not present, we should likewise log when a font of the requested weight (or size, etc.) is not present.
Activity
timhoffm commented on Oct 26, 2019
Does it work in other programs? I suppose it's rather a problem with the font and not with matplotlib.
tacaswell commented on Oct 26, 2019
When rendering text we pick the font that best matches your fontdict. The way that different weights are encoded is effectively as different fonts (not as some scaling on a single font which is something I learned from @dorafc very recently). In the first case we always pick 'KaiTi' which you only have one variant of installed (or at least not any of the variants you are looking for) so you get both 汉字 and latin characters rendered, but always at the same weight. In the second case you are not selecting a font family so we fall back to the default font (which is likely dejavu sans) which does have multiple weights but does not have the Chinese code pages.
To get this to work you will need to install a font that both has multiple weights and support Chinese.
https://matplotlib.org/3.1.1/tutorials/text/text_props.html#text-with-non-latin-glyphs maybe helpful.
I am going to close this because there is nothing more we can do on the library side. If you have further questions can you please post at https://discourse.matplotlib.org/c/community ?
Good luck!
anntzer commented on Oct 27, 2019
Actually I think the error message could be better in this case; we already log a warning when a font of the requested family is not present, we should likewise log when a font of the requested weight (or size, etc.) is not present.
tacaswell commented on Jun 9, 2020
Pushing to 3.4 as that is where we re-milestoned the PR to.