8000 Solve the issue that some fonts are not handled correctly by cy18 · Pull Request #8607 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Solve the issue that some fonts are not handled correctly #8607

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
wants to merge 3 commits into from
Closed

Solve the issue that some fonts are not handled correctly #8607

wants to merge 3 commits into from

Conversation

cy18
Copy link
@cy18 cy18 commented May 11, 2017

PR Summary

This pull request fixes the problems I found when I try to use "Noto Serif CJK" and "Source Han" font families.

  1. In some fonts the font information are not given by Platform ID 1, but by Platform ID 3.
  2. The weight "thin" and "demilight" are used by some fonts, which is not handled correctely.
  3. When judging weight, there's a problem that "demibold" may be judged as "bold", "ultralight" may be judged as "light". This can be fixed by testing weight names in the order of names' length.

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/whats_new.rst if major new feature
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@QuLogic QuLogic changed the title Font2 Solve the issue that some fonts are not handled correctly May 11, 2017
@dstansby
Copy link
Member

Could you post a short bit of code to demonstrate what specifically wasn't working before this fix?

@dstansby dstansby added this to the 2.1 (next point release) milestone Jun 19, 2017
@cy18
Copy link
Author
cy18 commented Jun 20, 2017

@dstansby
First, please download the otf files from https://noto-website.storage.googleapis.com/pkgs/NotoSerifCJKsc-hinted.zip

Don't forget deleting the cache file ".matplotlib/fontList.json" before each testing.

Run the following code:

from matplotlib import font_manager
print(font_manager.findfont('noto serif cjk sc'))

Before fixing, the result is 'C:\Windows\Fonts\NotoSerifCJKsc-Light.otf'.
After fixing, the result is 'C:\Windows\Fonts\NotoSerifCJKsc-Regular.otf'.

With following code:

from matplotlib import ft2font
ft = ft2font.FT2Font('C:\\Windows\\Fonts\\NotoSerifCJKsc-Regular.otf')
print(ft.get_sfnt())

We can see that the reason is that font informations are missing at (1,0,0,2) and (1,0,0,4). However the information could be found at (3,1,1033,2) and (3,1,1033,4).

@tacaswell
Copy link
Member

xref #8551

@cy18 cy18 mentioned this pull request Jun 26, 2017
5 tasks
@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.2 (next next feature release) Aug 29, 2017
@anntzer
Copy link
Contributor
anntzer commented May 28, 2020

Superseded by #16203; thanks for the pr.

@anntzer anntzer closed this May 28, 2020
@story645 story645 removed this from the future releases milestone Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0