Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix that font files never pass the test on Win#24641

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
timhoffm merged 1 commit intomatplotlib:mainfromalmarklein:patch-1
Dec 6, 2022
Merged

Fix that font files never pass the test on Win#24641

timhoffm merged 1 commit intomatplotlib:mainfromalmarklein:patch-1
Dec 6, 2022

Conversation

almarklein
Copy link
Contributor

Hi! 👋

I am gratefully making use of MPL's font management code for our text rendering inPyGfx. While I was examining the code, I found what I think is a bug.

Theisfile() test is applied on the relative pathname and will thus always fail. This PR should fix that. I would expect that it should also test for the extension, but I'm not 100% sure so I did not add this yet.

Diving a bit deeper, this bug has likely gone unnoticed because the code to detect fonts follows two paths on Windows:

  • It checks the registry for known installed fonts in a small set of predefined directories.
  • It detects font filesin these same directories usingos.listdir oros.walk.

Why are these two paths followed? I can see how the second route can find fonts that are present but not known in the registry, but why check the registry at all then?

Copy link

@github-actionsgithub-actionsbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a while, please feel free to ping@matplotlib/developers or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join uson gitter for real-time discussion.

For details on testing, writing docs, and our review process, please seethe developer guide

We strive to be a welcoming and open project. Please follow ourCode of Conduct.

Copy link
Member

@oscargusoscargus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Cannot really tell the background, but realize that this should work. Thanks!

@timhoffmtimhoffm merged commitfedb162 intomatplotlib:mainDec 6, 2022
@almarkleinalmarklein deleted the patch-1 branchDecember 6, 2022 14:14
@almarklein
Copy link
ContributorAuthor

What about my comment about testing for the extension? The code path in theelse branch does test for it, while this one does not. This was not a problem, because the test never passed anyway, but IIUC right now fonts with different extensions could be included. I suspect this was an oversight rather than intentional, but I may be missing something...

@oscargus
Copy link
Member

I think that@anntzer may know more about it.

@anntzer
Copy link
Contributor

I suspect that the fix here is indeed incorrect as it will return files with incorrect extensions. The previous (wrong) code came in in#22909 to fix#22859, but given the discussion at#22859 I suspect that the correct approach on Windows is indeed toonly return fonts listed by _get_win32_installed_fonts and not bother calling list_fonts at all. (Can anyone open a new issue with that, if they agree with my analysis?)

@almarklein
Copy link
ContributorAuthor

almarklein commentedDec 7, 2022
edited
Loading

Thanks for the historic background!

given the discussion at#22859 I suspect that the correct approach on Windows is indeed to only return fonts listed by _get_win32_installed_fonts and not bother calling list_fonts at all. (Can anyone open a new issue with that, if they agree with my analysis?)

In the top post I stated my confusion for having two approaches that obtain (nearly) the same list of fonts. I think it would be good to pick one approach: either ask the registry, or scrape dirs withlist_fonts.

Indeed the discussion in#22859 seemed to be mostly about "what fonts are officially listed" (and show up in e.g. Word). I agree that this points towards asking the registry for a list (nolist_fonts). I'll make a PR:#24655

Sidenote: in PyGfx I now took the approach to always scrape directories, because that way we can easily test when fonts are added/removed by checking a dir's mtime.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@github-actionsgithub-actions[bot]github-actions[bot] left review comments

@timhoffmtimhoffmtimhoffm approved these changes

@oscargusoscargusoscargus approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.7.0
Development

Successfully merging this pull request may close these issues.

5 participants
@almarklein@oscargus@anntzer@timhoffm@tacaswell

[8]ページ先頭

©2009-2025 Movatter.jp