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

Allow for the configuration of font fallback #2664

Closed
Tracked by #1790
onceSS opened this issue Sep 5, 2019 · 33 comments · Fixed by #16821
Closed
Tracked by #1790

Allow for the configuration of font fallback #2664

onceSS opened this issue Sep 5, 2019 · 33 comments · Fixed by #16821
Labels
Area-Fonts Related to the font Area-Settings Issues related to settings and customizability, for console or terminal Help Wanted We encourage anyone to jump in on these. In-PR This issue has a related PR Issue-Task It's a feature request, but it doesn't really need a major design. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal.
Milestone

Comments

@onceSS
Copy link

onceSS commented Sep 5, 2019

I am a Chinese developer, sometimes I have to use Chinese, or my Chinese version system will display some prompts in Chinese.

However, this terminal cannot specify multiple fonts in setting, for example: "editor.fontFamily": "DejaVu Sans Mono, Noto Sans CJK SC"(an example from vscode).

I hope this terminal can support multiple fonts setting in the future, thank you.

@onceSS onceSS added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Sep 5, 2019
@ghost ghost added Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Sep 5, 2019
@zadjii-msft zadjii-msft added Area-Fonts Related to the font Area-Settings Issues related to settings and customizability, for console or terminal Product-Terminal The new Windows Terminal. labels Sep 5, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Sep 5, 2019
@zadjii-msft zadjii-msft added this to the Terminal Backlog milestone Sep 5, 2019
@phuclv90
Copy link

phuclv90 commented Sep 5, 2019

I don't think you need to specify different fonts. Regardless of any locale you use, Chinese characters can always be displayed properly because there are font substitution, font linking and font fallback behind the scenes

@mdtauk
Copy link

mdtauk commented Sep 5, 2019

Fonts in the JSON file could be an array, like with CSS, where if a font is not available, or maybe even per glyph - it goes to the next font listed, and falls back.

@DHowett-MSFT DHowett-MSFT removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Sep 5, 2019
@DHowett-MSFT
Copy link
Contributor

This will be part of #1790.

@DHowett-MSFT DHowett-MSFT changed the title Multiple fonts support Allow for the configuration of font fallback Sep 5, 2019
@DHowett-MSFT DHowett-MSFT added Issue-Task It's a feature request, but it doesn't really need a major design. and removed Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. labels Sep 5, 2019
@mariusstrom
Copy link
Contributor

Adding the word fontFace in here to make it easier to find this issue.

@mariusstrom
Copy link
Contributor

It would be nice if VS Code and Terminal were more consistent on configuration parameters as well. This is a bigger problem, but this is a good example: vscode uses fontFamily, Terminal uses fontFace as the configuration parameter.

@tsukumijima
Copy link

tsukumijima commented Dec 7, 2020

671

It's been over a year since this issue was opened. Is there any progress in implementing font fallback?
Even for Japanese users like me, this feature is absolutely necessary.

For example, suppose you want to use Cascadia Code in Windows Terminal. For VS Code, you can specify an alternative font to display characters that Cascadia Code doesn't have.
This is not possible with current Windows Terminal, and characters that are not in Cascadia Code are always displayed in the system font (Yu Gothic UI in Japanese). However, the design of the Yu Gothic UI is thin and condensed (see image), there is too much space between the letters, and the weights do not match. At least I find it hard to see on Windows Terminal.

There are not many fonts for coding that contain Japanese characters. If font fallback is possible, you can easily combine alphabet fonts and Japanese fonts, expanding your font choices.
We hope that this feature will be implemented soon. Thank you.

@zadjii-msft
Copy link
Member

Nope. We'll make sure to update this thread when there is. In the meantime, might I recommend the Subscribe button?
image
That way you'll be notified of any updates to this thread, without needlessly pinging everyone on this thread ☺️

@guodong2005
Copy link

Is there any solution to this problem yet ?
My temporary solution is to merge 2 ttf files.

@microhobby
Copy link

This is the only issue that limits me from using Windows Terminal over other solutions now.

@zadjii-msft
Copy link
Member

zadjii-msft commented Apr 18, 2023

Note

Walkthrough

To do per-glyph (codepoint?) fallback you'd use IDWriteFontFallbackBuilder::AddMapping and use the resulting custom IDWriteFontFallback instead of the current one we get through IDWriteFactory2::GetSystemFontFallback. In other words, we can easily add per-codepoint fallback in the future!

From discussion on #14959, specifically this thread: #14959 (comment)

@xd003
Copy link

xd003 commented Sep 28, 2023

Why is something as important as this not implemented since 4 yrs, please this is something very barebones on linux if you ask me. I am using a Mono font for my Terminal but i needed to add a secondary font for better glyph/icons support in my prompt which is not possible at the moment

@Jaswir
Copy link
Contributor

Jaswir commented Oct 14, 2023

@xd003

Can you maybe make a gif of how this works in Linux the font fallback thing?
https://www.screentogif.com/

Having things in Gifs describing the issue helps me.
Maybe it'll help get this solved faster:

@Jaswir
Copy link
Contributor

Jaswir commented Oct 14, 2023

@mdtauk @onceSS @tsukumijima

So let me get this straight the normal font is Japanese (tsu) / Chinese (once) and it should fall back to English font if not available?

@tsukumijima
Copy link

tsukumijima commented Oct 14, 2023

@Jaswir No, it's preferable to initially set a beautiful monospace font for English console and programming tasks, and then render glyphs that are not implemented in that font, like Japanese hiragana and kanji, using a secondary monospace font that supports Japanese.
This is because, unlike fonts for English alphabets, Japanese fonts have a vast number of glyphs, limiting the options available, especially for free fonts.
Furthermore, the design of the English numerals and letters in Japanese fonts may not necessarily be suited for console environments. In other words, there's a need to "use a well-designed English font for English letters and numerals, and choose a Japanese font that stylistically matches that English font for hiragana and kanji".
While fonts that combine reputable open-source English and Japanese fonts like HackGen are available, creating such a composite font oneself is considerably laborious and generally not realistic.

@Jaswir
Copy link
Contributor

Jaswir commented Oct 14, 2023

@tsukumijima

Okay, so you have two fonts. One for the English alphabet and numbers and one for the Japanese characters? With current terminal you cannot have two fonts?

PS: I can play around a bit with vs code and the fonts and check the differences

@tsukumijima
Copy link

tsukumijima commented Oct 14, 2023

@Jaswir What does it mean?
English fonts are fonts such as Source Code Pro, while Japanese fonts (including half-width alphanumeric characters) are Kosugi, etc.
"Kosugi" is a monospaced Japanese font that also includes alphanumeric characters. However, the alphanumeric characters in "Source Code Pro" look better on the terminal.
Therefore, in this example, I think "Source Code Pro" should be used preferentially, and "Kosugi" should be used for the characters not included in "Source Code Pro".

@xd003
Copy link

xd003 commented Oct 15, 2023

@xd003

Can you maybe make a gif of how this works in Linux the font fallback thing? https://www.screentogif.com/

Having things in Gifs describing the issue helps me. Maybe it'll help get this solved faster:

Sure i can do that, but i am didn't quite understood if you need the part where this feature is coded in all the terminal emulators on linux or where exactly is the font fallback defined ? if you need the code part, sorry you will have to find it yourself on their respective github repos as i am not familiar with their codebase. i am linking github for the most preferred/famous linux terminals here - Konsole, Alacritty, Kitty, wezterm, foot, st. Do note that some of these terminals have windows OS support but their development is majorly focused on catering linux users except maybe just wezterm, it works pretty fine on windows i have heard.
If you were asking where is the font fallback defined by the user, each of the github repo i have linked has their own wiki section, it is defined in the respective config files used by the terminals. For example, kitty's font section here clearly shows how to define font fallback.
Good Luck

@newor0599
Copy link

You can try using a nerd font, it contains alot of unicode including chinese character!

@janderssonse
Copy link

janderssonse commented Nov 30, 2023

You can try using a nerd font, it contains alot of unicode including chinese character!

I guess that is precisley one of the many reasons that this issue exists. We would like to be able to have fallback font options, as to avoid using hacks like nerd fonts that are patch on fonts, sometimes with great results. sometimes with alignment issues.

@xd003
Copy link

xd003 commented Nov 30, 2023

You can try using a nerd font, it contains alot of unicode including chinese character!

I guess that is precisley one of the many reasons this issue exists. We wan't to be able to have fallback font as to avoid using hacks like nerd fonts that are patching a fonts, sometimes with great results. sometimes with alignment issues.

Moreover there are very limited number of fonts available within the Nerd Fonts apart from the occasional alignment issues, its not really a viable option as people think it to be

@abceleung
Copy link

abceleung commented Feb 16, 2024

+1 to this issue.

Since my choice of font (Sarasa Gothic) does not have a prepatched version with nerd font, I used font-patcher in the official nerd font repo to patch nerd font in manually.

Docker example:
docker run --rm -v ./SarasaFixedSlabHC-TTF-1.0.5/:/in:Z -v ./out:/out:Z -e "PN=10" nerdfonts/patcher --adjust-line-height --careful --complete
(Lower PN if you have a weak PC, otherwise it might use up all your RAM and freeze your computer)

Another option I have considered is to use Wezterm, which is cross platform, has tab support and has nerd font as fallback font by default (so you don't have to patch nerd font by yourself).

@zadjii-msft
Copy link
Member

For the subset of this thread that has been following along because they want the Powerline glyphs in their prompt but don't have a font with those glyphs: #16729 added some support for the Terminal drawing some of those glyphs itself, rather than relying on the font. That's available in Canary builds, if folks want to give that a try 😄

(understanding though, that this thread is mostly not about powerline glyphs, and there's still a lot of work to do here)

zadjii-msft pushed a commit that referenced this issue Feb 28, 2024
`wstring_case_insensitive_compare` is not a great name for what it
does as it's incorrect to use for regular (human readable) strings.
This PR thus renames it to `env_key_sorter`.

`compare_string_ordinal` was renamed to `compare_ordinal_insensitive`
to make sure callers know that the comparison is insensitive
(this may otherwise be incorrect in certain contexts after all).
The return value was changed to match `memcmp` so that the API
is detached from its underlying implementation (= NLS).

`compare_linguistic_insensitive` and `contains_linguistic_insensitive`
were added to sort and filter human-readable strings respectively.

`prefix_split` was extended to allow for needles that are just a
single character. This significantly improves the generated assembly
and is also usually what someone would want to actually use.
I've left the string-as-needle variant in just in case.

This PR is prep-work for #2664
@microsoft-github-policy-service microsoft-github-policy-service bot added the In-PR This issue has a related PR label Mar 5, 2024
github-merge-queue bot pushed a commit that referenced this issue Mar 26, 2024
This adds support for specifying more than one font family using a
syntax that is similar to CSS' `font-family` property.
The implementation is straight-forward and is effectively
just a wrapper around `IDWriteFontFallbackBuilder`.

Closes #2664

## PR Checklist
* Font fallback
  * Write "「猫」"
  * Use "Consolas" and remember the shape of the glyphs
  * Use "Consolas, MS Gothic" and check that it changed ✅
* Settings UI autocompletion
  * It completes ✅
  * It filters ✅
  * It recognizes commas and starts a new name ✅
* All invalid font names are listed in the warning message ✅

---------

Co-authored-by: Dustin L. Howett <duhowett@microsoft.com>
@github-project-automation github-project-automation bot moved this from Walkthrough in issue to Done in Terminal Walkthroughs Mar 26, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Tag-Fix Doesn't match tag requirements label Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Fonts Related to the font Area-Settings Issues related to settings and customizability, for console or terminal Help Wanted We encourage anyone to jump in on these. In-PR This issue has a related PR Issue-Task It's a feature request, but it doesn't really need a major design. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.