microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
94.78k stars 8.21k forks source link

After Reboot custom fonts give error until settings window is opened/closed #17042

Closed YouveGotMeowxy closed 4 months ago

YouveGotMeowxy commented 4 months ago

Windows Terminal version

1.19.10821.0

Windows build number

10.0.19045.4291

Other Software

I do have Ubuntu running in WSL, however, it happens in Ubuntu tabs as well as Powershell (I use Powershell 7)

Steps to reproduce

Expected Behavior

No errors and my fonts show properly. :)

Actual Behavior

Examples:

image

image

github-actions[bot] commented 4 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

lhecker commented 4 months ago

Windows caches font information between reboots in two places:

Additionally it also caches font information per process.

When you install a font, this causes Windows Terminal to not find it, because Terminal's internal (per process) font cache doesn't get invalidated when you install fonts. Once we address #17034 (an issue extremely similar to yours), that will be fixed, because we'll simply ask Windows "Hey, do you have new fonts installed?".

In your case on the other hand, the system font cache between reboots is broken. This can be due to 3 reasons:


Can you please check whether you have any files in %LOCALAPPDATA%\Microsoft\Windows\Fonts? If you do, don't delete them in Explorer, but instead open the "Fonts" control panel via the start menu, find each font there and remove it. If you delete font files via Explorer, you break the Font Cache service. Afterwards install the fonts again, but this time make sure to choose "Install for all users".

If that didn't fix the issue, can you please press Win+R and run services.msc? Then scroll down to "Windows Font Cache Service". It should be set to "Automatic" and should be running: image


If the above didn't work, the following may fix your issue. I have done it before and it fixed this exact issue for me, however it's very much unsafe. It may break your system. In fact, one time it did break my system and I had to restore the Font Cache service manually. This is because the Font Cache service really isn't particularly robust (which is also why it's broken for you and so many others).

If you know Windows, you know what the Font Cache service is and you trust yourself doing it, you could attempt it. If it breaks your system and you don't know how to restore it, no one may be able to help you.

So, to be absolutely clear: ⚠️ Doing this is not recommended. ⚠️

That said, the Font Cache uses the aforementioned directories for its databases:

Technically you need to delete both. 90% of the safety risk comes from deleting the 2nd database however. So we should first try to delete only the former and see if it fixes the issue.

To do so, you can do the following:

If that didn't fix the issue, you may have a corrupted system font cache. Fixing that one is dangerous and somewhat difficult. It consists of multiple layers and it's unclear which ones need to be deleted. This may leave your system in a broken state. It can be recovered by restoring the files from another system.

Most importantly though, DO NOT USE EXPLORER TO GAIN ACCESS. Do not modify the access rights of that directory in any way.

The per-user cache in the system font cache directory can be deleted by first stopping the FontCache service as before and then running something like this:

rm -Force "C:\Windows\ServiceProfiles\LocalService\AppData\Local\FontCache\*$((New-Object -ComObject Microsoft.DiskQuota).TranslateLogonNameToSID((Get-WmiObject -Class Win32_ComputerSystem).Username))*"

If that didn't work, you can still try to delete the entire FontCache directory contents (not the directory itself, only the contents!). However, I consider this an option of last resort. I'm not entirely sure if it restores the Fonts\fontset-2017-04.json file in that case. If it doesn't restore it you can get it here.

If none of that worked, you may have broken font files, although that's somewhat less likely to affect the font cache service.

DHowett commented 4 months ago

@lhecker wow, that’s comprehensive. I was just gonna guess that they’d installed their font “per user” rather than “for all users” :)

lhecker commented 4 months ago

Oh, I thought that it broke the font until you reinstalled it after a reboot, and that it can't be fixed by clicking Save in the settings. But looking through related issues that indeed doesn't seem true. I've edited my large comment above accordingly.

YouveGotMeowxy commented 4 months ago

Got it! Thank you both for pointing me in the right direction.

I was going to pass on the scary font cache deletions, but it sent me off on a deep investigation into the fonts. I'm not sure why, but I could see those particular fonts in c:\windows\fonts, but the weren't being shown in the Fonts Control Panel. I don't know if that might mean as @DHowett was saying; that it was installed for the User only, and not system?

Either way, I copied out those fonts to another folder, deleted them from that Windows path, and then dropped them onto the Fonts Control Panel which installed them again. Now, after testing with a reboot, no more errors. wewt!

thank you guys, that was incredibly annoying!

Tgentil commented 1 month ago

@lhecker worked for me. Thank you so much.

mgua commented 2 weeks ago

I had the issue. windows 11, admin account. windows terminal not showing hack nerd font anymore. font available and usable in other applications. I closed every istance of windows terminal, opened file explorer, and went to c:\windows\font. found the "hack" fonts: 3 icons, and simply copied them to an empty folder: 12 .ttf files appeared there. Then i deleted the 3 icons from the font folder, and they did not go away. had to repeat. then opened windows terminal and the hack fonts were not available. closed terminal, went back to font folder, and just dragged back the 12 ttf files there. After this windows terminal was able to "see" the hack fonts again without issues. Thank you YouveGotMeowxy Kacey