Skip to content
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

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

Closed
YouveGotMeowxy opened this issue Apr 11, 2024 · 7 comments
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Attention The core contributors need to come back around and look at this ASAP. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting

Comments

@YouveGotMeowxy
Copy link

YouveGotMeowxy commented Apr 11, 2024

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

  • Reboot computer
  • start Windows Terminal
  • get error(s) (happens on both PowerShell and WSL (Ubuntu) tabs. Also, all special characters for addons like Oh My Zsh and Oh My Psh get screwed up.
  • No mnatter how many times I close/reopen or open new tabs, I get the same error until.....
  • I click the Settings cog and the settings window opens
  • No changes need to be made; don't even need to click the save button. Just click the X to close the settings page.
  • from there on (until next reboot) no more font errors, and the special character fonts for things like Omz/Omp show properly.

Expected Behavior

No errors and my fonts show properly. :)

Actual Behavior

Examples:

image

image

@YouveGotMeowxy YouveGotMeowxy added Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Apr 11, 2024
Copy link

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
Copy link
Member

lhecker commented Apr 11, 2024

Windows caches font information between reboots in two places:

  • %LOCALAPPDATA%\Microsoft\FontCache
  • C:\Windows\ServiceProfiles\LocalService\AppData\Local\FontCache

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:

  • either one of the two directories above is corrupted
  • the "Font Cache" service is not running
  • you installed fonts in the per-user directory

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:

  • %LOCALAPPDATA%\Microsoft\FontCache
  • C:\Windows\ServiceProfiles\LocalService\AppData\Local\FontCache

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:

  • Launch pwsh or powershell as admin
  • Exit all applications, including background applications. This step is crucial or the next one won't work consistently and your system may break.
  • sc stop FontCache
  • rm -Recurse -Force $env:LOCALAPPDATA\Microsoft\FontCache\*
  • sc start FontCache
  • Reboot, etc., to test whether it works

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.

@lhecker lhecker added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Apr 11, 2024
@DHowett
Copy link
Member

DHowett commented Apr 12, 2024

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

@lhecker
Copy link
Member

lhecker commented Apr 12, 2024

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
Copy link
Author

YouveGotMeowxy commented Apr 12, 2024

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!

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Apr 12, 2024
@Tgentil
Copy link

Tgentil commented Jul 16, 2024

@lhecker worked for me. Thank you so much.

@mgua
Copy link

mgua commented Aug 15, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Attention The core contributors need to come back around and look at this ASAP. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting
Projects
None yet
Development

No branches or pull requests

5 participants