mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-21 05:49:57 -04:00
Let the launcher replace a cached font file it has registered.
A font file registered with Windows stays open, so writing it failed with Permission denied. When the cached title font was registered but its family could not be used, every start tried to decode it again, failed on the locked file and kept the system font. The registration is now given up before the fonts are decoded again, and an unchanged file is not rewritten. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -141,6 +141,17 @@ def register_font(path):
|
||||
return False
|
||||
|
||||
|
||||
def unregister_font(path):
|
||||
'''Give up a font file register_font added, so the file can be written again: Windows keeps a registered font
|
||||
file open, and writing it then fails with "Permission denied".'''
|
||||
if os.name != 'nt':
|
||||
return
|
||||
try:
|
||||
ctypes.windll.gdi32.RemoveFontResourceExW(ctypes.c_wchar_p(str(path)), 0x10, None) # FR_PRIVATE
|
||||
except (AttributeError, OSError):
|
||||
pass
|
||||
|
||||
|
||||
def open_path(path):
|
||||
path = str(path)
|
||||
if os.name == 'nt':
|
||||
|
||||
Reference in New Issue
Block a user