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

Customized fonts not working #17061

Closed
ShaneLee-9 opened this issue Apr 15, 2024 · 17 comments
Closed

Customized fonts not working #17061

ShaneLee-9 opened this issue Apr 15, 2024 · 17 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

@ShaneLee-9
Copy link

ShaneLee-9 commented Apr 15, 2024

Windows Terminal version

1.19.10821.0

Windows build number

10.0.22631.3447

Other Software

No response

Steps to reproduce

Set the font, choose any one of the fonts

Expected Behavior

No response

Actual Behavior

PixPin_2024-04-15_17-12-36
PixPin_2024-04-15_17-13-09
PixPin_2024-04-15_17-14-28
I'm warned that I can't find the "D2Coding" font, but I used this font a week ago and it has now been removed from my system.

As you can see, I can't change the font whether I set it via the GUI or change it via the settings.json configuration file.

I tried reinstalling the lower version 1.19.10573.0 and it still has the above problem.

@ShaneLee-9 ShaneLee-9 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 15, 2024
@zadjii-msft
Copy link
Member

Did you install that font for all users? Or just for your current user/? We've had persistent problems with fonts that aren't installed for all users 🤷

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Apr 15, 2024
@inglepriyanka148867

This comment was marked as spam.

@ShaneLee-9
Copy link
Author

Did you install that font for all users? Or just for your current user/? We've had persistent problems with fonts that aren't installed for all users 🤷

The problem I'm having is that I've selected font A, but Windows Terminal tells me can't find font B!

@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 16, 2024
@zadjii-msft
Copy link
Member

Could you share your settings.json file/?

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

lhecker commented Apr 16, 2024

@zadjii-msft I believe this occurs because they're using DxRenderer. It gets the font family from the font file here:

[[nodiscard]] std::wstring DxFontInfo::_GetFontFamilyName(const gsl::not_null<IDWriteFontFamily*> fontFamily,
std::wstring& localeName)
{
// See: https://docs.microsoft.com/en-us/windows/win32/api/dwrite/nn-dwrite-idwritefontcollection
Microsoft::WRL::ComPtr<IDWriteLocalizedStrings> familyNames;
THROW_IF_FAILED(fontFamily->GetFamilyNames(&familyNames));
// First we have to find the right family name for the locale. We're going to bias toward what the caller
// requested, but fallback if we need to and reply with the locale we ended up choosing.
UINT32 index = 0;
BOOL exists = false;
// This returns S_OK whether or not it finds a locale name. Check exists field instead.
// If it returns an error, it's a real problem, not an absence of this locale name.
// https://docs.microsoft.com/en-us/windows/win32/api/dwrite/nf-dwrite-idwritelocalizedstrings-findlocalename
THROW_IF_FAILED(familyNames->FindLocaleName(localeName.data(), &index, &exists));
// If we tried and it still doesn't exist, try with the fallback locale.
if (!exists)
{
localeName = L"en-us";
THROW_IF_FAILED(familyNames->FindLocaleName(localeName.data(), &index, &exists));
}
// If it still doesn't exist, we're going to try index 0.
if (!exists)
{
index = 0;
// Get the locale name out so at least the caller knows what locale this name goes with.
UINT32 length = 0;
THROW_IF_FAILED(familyNames->GetLocaleNameLength(index, &length));
localeName.resize(length);
// https://docs.microsoft.com/en-us/windows/win32/api/dwrite/nf-dwrite-idwritelocalizedstrings-getlocalenamelength
// https://docs.microsoft.com/en-us/windows/win32/api/dwrite/nf-dwrite-idwritelocalizedstrings-getlocalename
// GetLocaleNameLength does not include space for null terminator, but GetLocaleName needs it so add one.
THROW_IF_FAILED(familyNames->GetLocaleName(index, localeName.data(), length + 1));
}
// OK, now that we've decided which family name and the locale that it's in... let's go get it.
UINT32 length = 0;
THROW_IF_FAILED(familyNames->GetStringLength(index, &length));
// Make our output buffer and resize it so it is allocated.
std::wstring retVal;
retVal.resize(length);
// FINALLY, go fetch the string name.
// https://docs.microsoft.com/en-us/windows/win32/api/dwrite/nf-dwrite-idwritelocalizedstrings-getstringlength
// https://docs.microsoft.com/en-us/windows/win32/api/dwrite/nf-dwrite-idwritelocalizedstrings-getstring
// Once again, GetStringLength is without the null, but GetString needs the null. So add one.
THROW_IF_FAILED(familyNames->GetString(index, retVal.data(), length + 1));
// and return it.
return retVal;
}

The warning pops up if that family name does not match the font name in the settings.

This issue has been solved in two ways:

@ShaneLee-9 As a workaround you can simply use AtlasEngine until 1.21 is released.

@lhecker lhecker closed this as completed Apr 16, 2024
@ShaneLee-9
Copy link
Author

Could you share your settings.json file/?

Hi, this is my settings.json

settings.json

@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 17, 2024
@lhecker
Copy link
Member

lhecker commented Apr 17, 2024

Now that you have AtlasEngine enabled, does the error go away? If it still happens for some reason, please feel free to temporarily use our Canary build (our nightly version): https://aka.ms/terminal-canary-installer

@ShaneLee-9
Copy link
Author

ShaneLee-9 commented Apr 18, 2024

Now that you have AtlasEngine enabled, does the error go away? If it still happens for some reason, please feel free to temporarily use our Canary build (our nightly version): https://aka.ms/terminal-canary-installer

AtlasEngine enabled, but the problem persists!
I installed the Canary version (our nightly version)
1
2
3

@lhecker
Copy link
Member

lhecker commented Apr 18, 2024

Hmm... I see, that's surprising.

Can you please provide a link to the font so I can download it?

@lhecker lhecker reopened this Apr 18, 2024
@ShaneLee-9
Copy link
Author

Hmm... I see, that's surprising.

Can you please provide a link to the font so I can download it?

https://github.com/ryanoasis/nerd-fonts/releases/download/v3.2.1/D2Coding.zip

@lhecker
Copy link
Member

lhecker commented Apr 19, 2024

Are you certain that this is the exact same font that you're using? It only contains an US English name which is "D2CodingLigature Nerd Font":
image

There's no mention of "FragmentMono". Do you have a different font installed which is called "FragmentMono"? If so, can you provide a download link for that font as well? I know that Fragment Mono exists, but there's no official "Nerd Font" variant for it.

"D2CodingLigature Nerd Font" does properly show up in Windows Terminal 1.19.10821.0 for me:
image

Selecting it doesn't result in any error messages for me either. If I manually enter "FragmentMono Nerd Font" the correct font name shows up in the error message:
image

@ShaneLee-9
Copy link
Author

ShaneLee-9 commented Apr 21, 2024

Are you certain that this is the exact same font that you're using? It only contains an US English name which is "D2CodingLigature Nerd Font": image

There's no mention of "FragmentMono". Do you have a different font installed which is called "FragmentMono"? If so, can you provide a download link for that font as well? I know that Fragment Mono exists, but there's no official "Nerd Font" variant for it.

"D2CodingLigature Nerd Font" does properly show up in Windows Terminal 1.19.10821.0 for me: image

Selecting it doesn't result in any error messages for me either. If I manually enter "FragmentMono Nerd Font" the correct font name shows up in the error message: image

The root cause of my problem is that I installed the font "D2CodingLigature Nerd Font Mono" about a week ago. One day I removed "D2CodingLigature Nerd Font Mono" from my computer and installed "FragmentMono Nerd Font". Then I wanted to change my Terminal font to "FragmentMono Nerd Font". Termina then shows the above error message. It actually can't find the "D2CodingLigature Nerd Font Mono" that I used and deleted. After that, no matter what fonts I select in Terminal's settings, it will report that it can't find "D2CodingLigature Nerd Font Mono".

PixPin_2024-04-21_16-09-55

@lhecker
Copy link
Member

lhecker commented Apr 21, 2024

Oh no. I hope this doesn't mean that your font cache is corrupted. 😣

Can you please try this series of steps? My hope is that this brings the cache back into a good state:

  • Open %LOCALAPPDATA%\Microsoft\Windows\Fonts and check if the folder is empty. If it's not empty, open the Fonts control panel (search for "fonts" in the start menu):
    image
    Find and delete each corresponding font until the %LOCALAPPDATA%\Microsoft\Windows\Fonts folder is empty.
  • Download the D2CodingLigature font (https://github.com/ryanoasis/nerd-fonts/releases/download/v3.2.1/D2Coding.zip) again and install it for all users.
  • Uninstall both, your "D2CodingLigature Nerd Font" and "FragmentMono Nerd Font" fonts simultaneously.

Afterwards, reboot your PC and try installing the "D2CodingLigature Nerd Font" (for all users).

@ShaneLee-9
Copy link
Author

Oh no. I hope this doesn't mean that your font cache is corrupted. 😣

Can you please try this series of steps? My hope is that this brings the cache back into a good state:

  • Open %LOCALAPPDATA%\Microsoft\Windows\Fonts and check if the folder is empty. If it's not empty, open the Fonts control panel (search for "fonts" in the start menu):
    image
    Find and delete each corresponding font until the %LOCALAPPDATA%\Microsoft\Windows\Fonts folder is empty.
  • Download the D2CodingLigature font (https://github.com/ryanoasis/nerd-fonts/releases/download/v3.2.1/D2Coding.zip) again and install it for all users.
  • Uninstall both, your "D2CodingLigature Nerd Font" and "FragmentMono Nerd Font" fonts simultaneously.

Afterwards, reboot your PC and try installing the "D2CodingLigature Nerd Font" (for all users).

I tried reinstalling "D2CodingLigature Nerd Font Mono" and it didn't pop up again, but I have a new problem: I can't select any font. It looks like some program is locking up my Terminal fonts!
PixPin_2024-04-22_16-00-56

@ShaneLee-9
Copy link
Author

Oh, I seem to have found the reason. I don’t know when the font of Powershell was set separately in my terminal.
image
image

@DHowett
Copy link
Member

DHowett commented Apr 22, 2024

Thanks for following up!

@lhecker
Copy link
Member

lhecker commented Apr 22, 2024

I'd like to apologize for not noticing the extra font face entry in your settings file. 😣
I'm glad however, that you were to able to resolve the issue!

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