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

Unable to use some Noto fonts on Windows in Visual Studio Code #9

Open
theperiscope opened this issue Dec 19, 2021 · 4 comments
Open

Comments

@theperiscope
Copy link

Defect Report

Unable to use some Noto fonts on Windows in Visual Studio Code

Font

Seemingly the ones that have long names (e.g. Noto Sans Mono SemiCondensed Medium)

Where the font came from, and when

Google Fonts, 2021-12-06

Font Version

2.006

OS name and version

Windows 10 Pro, 10.0.19043

Application name and version

Visual Studio Code 1.62.3

Issue

  1. Open settings.json
  2. Try to change font to Noto Sans Mono SemiCondensed - this should be ok
  3. Try to change Noto Sans Mono SemiCondensed Light - not changed

Details

  • I use my own little tool to list all installed mono fonts - it lists the font in question above as Noto Sans Mono SemiCondensed Li, which matches what Visual Studio Professional lists under Tools > Options > Fonts and colors
  • The issue appears to be due to length of font name as all Noto Sans Mono fonts that have long names are chopped off at exactly 31 characters
    • Noto Sans Mono
    • Noto Sans Mono Black
    • Noto Sans Mono Condensed
    • Noto Sans Mono Condensed Black
    • Noto Sans Mono Condensed ExtraB
    • Noto Sans Mono Condensed ExtraL
    • Noto Sans Mono Condensed Light
    • Noto Sans Mono Condensed Medium
    • Noto Sans Mono Condensed SemiBo
    • Noto Sans Mono Condensed Thin
    • Noto Sans Mono ExtraBold
    • Noto Sans Mono ExtraCondensed
    • Noto Sans Mono ExtraCondensed B
    • Noto Sans Mono ExtraCondensed E
    • Noto Sans Mono ExtraCondensed L
    • Noto Sans Mono ExtraCondensed M
    • Noto Sans Mono ExtraCondensed S
    • Noto Sans Mono ExtraCondensed T
    • Noto Sans Mono ExtraLight
    • Noto Sans Mono Light
    • Noto Sans Mono Medium
    • Noto Sans Mono SemiBold
    • Noto Sans Mono SemiCondensed
    • Noto Sans Mono SemiCondensed Bl
    • Noto Sans Mono SemiCondensed Ex
    • Noto Sans Mono SemiCondensed Li
    • Noto Sans Mono SemiCondensed Me
    • Noto Sans Mono SemiCondensed Se
    • Noto Sans Mono SemiCondensed Th
    • Noto Sans Mono Thin
@raghuvanshr
Copy link

Could this be related to #10? I noticed that most of the fonts "look the same" when trying to change them in VSCode, but it could also be that the font isn't actually changing when I set it.

@theperiscope
Copy link
Author

theperiscope commented Dec 21, 2021

@raghuvanshr not 100% sure, I saw and read through the issue but feels different because despite what Windows shows in #10 I can use the font - that is, if the particular variant has a short name. I even tried downloading the previous (2019) version because it was mentioned somewhere that font tooling was changed - that also did not help.

@ashemedai
Copy link

ashemedai commented Feb 6, 2022

Did a quick test under Visual Studio Code (Windows 10, 1.64.0) to see if there might be an issue with the configuration parser, however it does not truncate font names:

Consolas, 'Courier New', monospace, Noto Sans Mono SemiCondensed Light

This is output from a simple TypeScript extension:

const config: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration('editor');
const fonts = config.get('fontFamily');
console.log(fonts);

This leads me to believe it is not a Visual Studio Code issue. Just checked with LibreOffice Writer on Windows as well, a font such as e.g. Noto Sans SemiCondensed SemiBold gets truncated to Noto Sans SemiCondensed SemiBol. Which is, indeed, 31 characters. I wonder if this is a matter of running against the 31 character limit of some Windows API.

Wordpad also suffers from this (apologies for the transparency, it fades away when noticing any keystrokes):
image

The default Windows 10 Font Settings seems to parse the data differently. It recognises Noto Sans as the family and then presents a drop-down box for the various weights:
image

After some digging I am pretty sure this is because some applications use the GDI EnumFontFamiliesEx*() family of API calls for enumerating the available fonts on a Windows system. These API calls use the LOGFONT structures. Inside these structures is a field called lfFaceName which is:

[a] null-terminated string that specifies the typeface name of the font. The length of this string must not exceed 32 TCHAR values, including the terminating NULL.

So if an application uses the string you provided to fill in lfFaceName, which then gets truncated to 31 TCHAR + \0 then you run into the scenario you mentioned.

@theperiscope
Copy link
Author

@ashemedai I think it is hitting some Windows API limitation, the tool I have returns the short names, and I already excluded as a root cause the font tooling (updated in 2019). FWIW, I think for best compatibility seems like the solution for this issue may be to keep all font names at or under 31 characters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants