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

Skip to content

please kindly add some fonts which support Chinese #20342

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

Closed
DaisyLL opened this issue Jun 2, 2021 · 5 comments
Closed

please kindly add some fonts which support Chinese #20342

DaisyLL opened this issue Jun 2, 2021 · 5 comments

Comments

@DaisyLL
Copy link

DaisyLL commented Jun 2, 2021

HI:
I am in China. and we often need to display chinese on our plot. but there is any fonts which can support chinese, usually we can add a font to our computer to support chinese plotting. still there is some case we can't add extra fonts by our own. so
Will you kindly add some fonts which can support chinese in the original package?

lilu
best wish!

@story645
Copy link
Member

story645 commented Jun 2, 2021

This was also discussed in #12597 and #20251

Still there is some case we can't add extra fonts by our own

why not?

@DaisyLL
Copy link
Author

DaisyLL commented Jun 3, 2021

This was also discussed in #12597 and #20251

Still there is some case we can't add extra fonts by our own

why not?

@story645
hi thanks for reply.
the case I deal with is that I am ploting somedata by Dataworks and uploading the image to a api which can send message automatically to a chat app. Dataworks is Platform-as-a-Service base on Google Chrome. install matplolib on Dataworks it only have 19 fonts and none if them can support chinese. It has nothing to do with my own computer ,so i can not add fonts /change the set file .atc.
Have I got my case clearly to you?
many thanks!

@tacaswell
Copy link
Member

install matplolib on Dataworks it only have 19 fonts and none if them can support chinese.

Unfortunately, this is something you should take up with Dataworks. Bundling more than a minimal set of fonts with Matplotlib is starting to creep into packaging / distribution which is a different (and very hard!) problem than the core problem Matplotlib is solving (plotting!). This is obviously an important issue, however not one that Matplotlib is well situated to solve by its self.


While I see how it would be very convenient if Matplotlib shipped a Chinese (or Japanese, Korean, ...) font (as picking up unicode past the latin/latin-1 code page was one of the justifications for moving from vera sans to DejaVu as the default font), however I have several major concerns.
The first (that should be solved this summer by @aitikgupta ) is that we do not do per-glyph fallback so even if we shipped a CJK font, there would still be the need for manual intervention on the part of the user.

The second is the sheer size of the fonts, looking at the noto download page some of these fonts (that still do not cover the full unicode range!) weigh in at 120MB+ and we would probably want to include 4 of them (the JP, SC, TC, and KR versions). In contrast, if you strip out the test images the Matplotlib wheel is ~11M (2-4M of which which is the limited fonts we do ship, researching this response has made me think we should cut-back on those!) and ~35M with the test images. Adding almost half a gigabyte to either the repo or the artifacts on pypi is not really an option. Our repo is already too big, Matplotlib is downloaded 500,000 - 900,000 times per day so greatly expanding the size of artifacts would have significant impact on pypi's bandwidth, and finally there is a 60MB cap on the maxmimum size file that we can put on pypi (without negotiating with the pypa folks).

Finally, on the core Matplotlib team I do not think we currently have anyone who frequently works with CJK (my apologies to anyone if I am wrong!) and I do not have faith that we know enough to be confident that, even if we dispensed with the first two concerns, that we would be able to make an informed and correct decision about what font(s) to include.


@DaisyLL A practical path forward for you is to download the font of your choice with in Dataworks (using e.g requests or urllib ) and then by passing a pathlib.Path to specify the font (see) without having to make font manager/cache aware of the font (or install the fonts in to a system location, rebuilt the system font cache, rebuild our font cache, and then see https://matplotlib.org/stable/tutorials/text/text_props.html#text-with-non-latin-glyphs).

@DaisyLL
Copy link
Author

DaisyLL commented Jun 3, 2021

@DaisyLL A practical path forward for you is to download the font of your choice with in Dataworks (using e.g requests or urllib ) and then by passing a pathlib.Path to specify the font (see) without having to make font manager/cache aware of the font (or install the fonts in to a system location, rebuilt the system font cache, rebuild our font cache, and then see https://matplotlib.org/stable/tutorials/text/text_props.html#text-with-non-latin-glyphs).

@tacaswell
Thank you very much for the full explanation !!!And Thank you all for the great Matplotlib package. I will try use requests to solve my problem. Thank you again!

@DaisyLL DaisyLL closed this as completed Jun 3, 2021
@tacaswell
Copy link
Member

@DaisyLL Thank you for being understanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants