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

Assign unicode ranges to fonts #1374

Open
classabbyamp opened this issue Dec 20, 2023 · 3 comments
Open

Assign unicode ranges to fonts #1374

classabbyamp opened this issue Dec 20, 2023 · 3 comments
Labels
enhancement New feature or request feature-request User requested features

Comments

@classabbyamp
Copy link

Abstract

nerd-fonts are a common way to add special symbols in terminal UIs (shell prompts, editors, etc). There are two ways this is implemented, a patched font or a symbols-only font. I prefer to use the symbols-only font because it allows for more flexibility and I don't need to install 2GB worth of duplicate fonts, but it does mean some form of fallback mechanism is necessary. It seems that currently this does partially work:

image

(kitty left, contour right; notice the incorrect symbol for the >)

Motivation

To ensure that certain ranges of codepoints have the correct font, I propose a configuration option that allows for assigning ranges to certain fonts. I suspect this assignment might already be possible under-the-hood, given the font.emoji config option.

Specification

My thought is something like:

font:
  symbols:
    - range: U+E5FA-U+E62B
      family: "Symbols Nerd Font"
    - range: U+E700-U+E7C5,U+F000-U+F2E0
      family: "Symbols Nerd Font"

Other Implementations

https://sw.kovidgoyal.net/kitty/conf/#opt-kitty.symbol_map

@classabbyamp classabbyamp added enhancement New feature or request feature-request User requested features labels Dec 20, 2023
@christianparpart
Copy link
Member

Ranges for custom assignment of codepoints to glyphs is AFAIK only available on Kitty, right? Or do we have other TEs allowing that as well?

If I am not mistaken, on Linux at least, you could use fontconfig to achieve the same.
Googling around, I found this: https://stackoverflow.com/questions/47501411/how-to-set-font-per-unicode-range-codepoint-in-fontconfig
I'd have to try it myself, but I think that would be a proper way to do it. Plus point: it would work on every application automatically then.

On the other hand, we planned to integrate "Symbols Nerd Font" (and others) for convenience into Contour natively anyways (#170).

@classabbyamp
Copy link
Author

Ranges for custom assignment of codepoints to glyphs is AFAIK only available on Kitty, right? Or do we have other TEs allowing that as well?

not sure, I've used kitty for a while and don't know the whole landscape.

If I am not mistaken, on Linux at least, you could use fontconfig to achieve the same.

I was going to say I already had a fontconfig conf for this but it seems it doesn't do that. Will try the fontconfig conf method.

@0x5c
Copy link
Contributor

0x5c commented Feb 26, 2024

So using fontconfig for that seems simply impossible (for an user) to do.

There's two ways to promote a font; locale shenanigans (can't work; "dev icons" isn't a locale) or carefully designing your font priority list like a bonzai garden, which is impossible since there's already font priorities set by the system fontconfigs.

Even if this worked, it wouldn't work on other platforms.

On the other hand, we planned to integrate "Symbols Nerd Font" (and others) for convenience into Contour natively anyways (#170).

While I don't have a strong opinion on that, it is not a suitable answer to the problem; It's a forever incomplete solution that only covers one potential use-case.
It's worth considering that supersizing the terminal for each special-use font that a user has requested will have undesirable effects, like causing the bundled fonts to not be skippable nor updateable without a terminal update. Some of these fonts can also break use-cases that aren't broken with a normal monospace font: for the entirety of Nerdfont's 2.x releases, it's Material Design Icons were located at incorrect codepoints, clobbering some asian scripts.
Preloading box-drawing characters in terminals doesn't have that problem, since the character set is extremely small, and is located in a dedicated and standardised Unicode block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature-request User requested features
Projects
None yet
Development

No branches or pull requests

3 participants