| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Actually, a test needs to be updated too.
____________________________ test_user_fonts_win32 ____________________________
[gw1] win32 -- Python 3.10.8 C:\hostedtoolcache\windows\Python\3.10.8\x64\python.exe
@pytest.mark.skipif(sys.platform != 'win32', reason='Windows only')
def test_user_fonts_win32():
if not (os.environ.get('APPVEYOR') or os.environ.get('TF_BUILD')):
pytest.xfail("This test should only run on CI (appveyor or azure) "
"as the developer's font directory should remain "
"unchanged.")
font_test_file = 'mpltest.ttf'
# Precondition: the test font should not be available
fonts = findSystemFonts()
if any(font_test_file in font for font in fonts):
pytest.skip(f'{font_test_file} already exists in system fonts')
user_fonts_dir = MSUserFontDirectories[0]
# Make sure that the user font directory exists (this is probably not the
# case on Windows versions < 1809)
os.makedirs(user_fonts_dir)
# Copy the test font to the user font directory
shutil.copy(Path(__file__).parent / font_test_file, user_fonts_dir)
# Now, the font should be available
fonts = findSystemFonts()
> assert any(font_test_file in font for font in fonts)
E assert False
E + where False = any(<generator object test_user_fonts_win32.<locals>.<genexpr> at 0x000002364CB2A8F0>)
The failure is definitely caused by this change |
Sorry, something went wrong.
There was a problem hiding this comment.
both loops return the same fonts1 with extensions [".afm", ".ttf", ".otf", ".ttc" ] and the hkey points to C:\WINDOWS\Fonts
ETA: I'm now confused how that test failed since both of the keys in the fontpath are in the windows installed search function, unless it's a permissions thing?
matplotlib/lib/matplotlib/font_manager.py
Lines 223 to 226 in 65e54af
the old loop returns {'', '.CompositeFont', '.TTF', '.dat', '.fon', '.ini', '.ttc', '.ttf', '.xml'} because there's no extension filtering. ↩
Sorry, something went wrong.
|
Also, I dunno if this is sensible but I modified the test to run it on my local machine, and I'm now getting the same failure, w/ the same message: @pytest.mark.skipif(sys.platform != 'win32', reason='Windows only')
def test_user_fonts_win32():
font_test_file = 'mpltest.ttf'
# Precondition: the test font should not be available
fonts = findSystemFonts()
if any(font_test_file in font for font in fonts):
pytest.skip(f'{font_test_file} already exists in system fonts')
user_fonts_dir = Path(MSUserFontDirectories[0])
# Make sure that the user font directory exists (this is probably not the
# case on Windows versions < 1809)
user_fonts_dir.mkdir(exist_ok=True)
# Copy the test font to the user font directory
shutil.copy(Path(__file__).parent / font_test_file, user_fonts_dir)
assert (user_fonts_dir/font_test_file).exists()
# Now, the font should be available
fonts = findSystemFonts()
assert any(font_test_file in font for font in fonts)
(Path(user_fonts_dir)/font_test_file).unlink()
assert not (Path(user_fonts_dir)/font_test_file).exists()ETA: if this is sensible, then I'll wrap up "temp copy" in a context manager. ETA2: I have no idea why the test is failing b/c the directory for writing the tempfile is identical when fontpaths is set or when it's empty
while this is flipped:
and I checked and yeah the file is in AppData |
Sorry, something went wrong.
Ah, are you saying the test is wrong? I think we maybe should be calling AddFontResourceEx for that test instead of directly copying the file. |
Sorry, something went wrong.
No, just that I'm not sure why I can't run it locally if I create and clean-up the file during the test? |
Sorry, something went wrong.
|
I guess what I would like to confirm is; if you use Explorer to copy a new font there, does it get added to the registry? Does it only do so if you use the Install button on the font viewer? What about if you have a Python script that copies the font there; does the registry update automatically, or do you have to open the directory in Explorer to refresh it, or does nothing update the registry? |
Sorry, something went wrong.
No
Yup
nope
that doesn't seem to work either ETA: as far as I can tell, that test works because it's checking if a file put into a folder is found in the folder, completely bypassing the registry. |
Sorry, something went wrong.
|
Per discussion on this weeks dev call:
|
Sorry, something went wrong.
1. we are moving to registry only for finding fonts on windows 2. our test just drops the font in the correct directory 3. this is not enough to get the registry to agree it is there We will xfail this test for now.
per need for changes as discussed on the call.
There was a problem hiding this comment.
but I wrote the behavior change note so this review should be taken with a grain of salt.
Sorry, something went wrong.
|
@story645 Can you please confirm that this works as expected for fonts installed as Windows expects and merge if you are satisfied? |
Sorry, something went wrong.
|
heads up that I won't be able to get to this til tomorrow night/sunday |
Sorry, something went wrong.
There was a problem hiding this comment.
tiny what's new nit. I don't think the failing tests are related to this PR, but I'm not comfortable merging while so many tests are failing.
Sorry, something went wrong.
Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com> Co-authored-by: hannah <story645@gmail.com>
…655-on-v3.7.x Backport PR #24655 on branch v3.7.x (Update font_manager to only use registry on Win)
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.