-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Language-specific OpenType Feature Names for Programming Ligatures #6918
Comments
for Code, this feature can be impelmented in CSS only: Assign token.js{
--webkit-font-feature-settings: "XJS_" 1;
font-feature-settings: "XJS_" 1;
} Perhaps these CSSes can be automatically built from syntax extension list registered. |
Is there a place where one can write some custom CSS to be added to the editor? Maybe a "user_css" file? I'm asking because there are many tweaks that need custom CSS, for example custom font feature sets (such as Right now we're adding stuff to |
@tobia @be5invis prettify-symbols-mode might also meet your needs. |
If we standardize on the font feature settings name (language id -> font feature setting name table), this is something we could add to our language configurations (in the API) and then the editor could dynamically create these styles with the right selectors to pass on the setting to fonts. Is there a limit on these things? Why are they all 4 letters wide? |
@alexandrudima All font “tags” are exactly four ASCII letters. Feature name is a kind of “Tag”. And as purposed in OpenType Spec, all custom feature names should use capital letters only. |
@alexandrudima Spec
Source: https://www.microsoft.com/typography/otspec/chapter2.htm |
@alexandrudima And according to Adobe, a Tag is a four-letter identifier. In feature files (used by MakeOTF) it should follow the glyph name specification (section 2.f). For tags shorter than four characters, it will be extended to four with spaces (so |
@alexandrudima My proposals:
Notes
|
@alexandrudima @be5invis The feature names being proposed are nonstandard, so I think fixing them is a bad idea because some fonts may use them for other [private] features now or in the future. |
@siegebell I know, there is a better way is to use the OpenType’s script-language system. That is, assign |
@alexandrudima @be5invis It should be up to the user to select the appropriate font and font-features per language. I propose the following two features be added to settings.json:
|
@siegebell For the feature tag, I think exporting an API to extension makers is enough. They can register the tag to the file type and users can actually not focusing on these configurations. Once someone REALLY want to override, use things like this: { "editor.languageSpecificFontFeatureSettings": {"source.haskell" : "XHS_"}} |
@be5invis Custom feature tags are specific to the font family. An extension that specifies a [nonstandard] feature tag will break any user-selected font that happens to define a conflicting tag -- this will be highly confusing and unintuitive for the user to diagnose. How are they supposed to figure out that they need to either override the feature settings, choose another font, or else uninstall the extension? Thus this setting should be provided by the user. If you really want, I believe an extension can contribute arbitrary settings, e.g. |
@siegebell I've investigated all existing programming fonts I can find and there is no conflict with the purposed feature tags (actually most of them do not support any ligature). I know your consideration, and it can be simplified into a bool setting which turn on/off the entire L-S thing: {
"editor.languageSpecificFontFeatures": true,
"editor.languageSpecificFontFeatureOverride": {"source.haskell" : "XHS_"}
} cc. @larsenwork @tonsky |
@be5invis If an override is added to the configuration options and an extension is already able to contribute configuration options, why not just have everything specified in the configuration options instead of providing an extension API that is redundant, OpenType-standards-breaking*, and opaque to the user? *OpenType allows nonstandard tags, but my interpretation is that they should only be invoked by users that know what they're doing or programs/interfaces that do not use arbitrary fonts. I do not believe that "all existing programming fonts I can find" is a sufficient metric, although I do agree that encountering a conflict is unlikely. |
@siegebell There is an option to turn off the entire thing, and it is off by default. So it is an opt-in, not an opt-out. I do not think that standardizing a “non-standard” tag set is a bad idea. |
@be5invis can you be clear: are you proposing that this feature be off by default by providing |
@siegebell Yes. |
@be5invis @larsenwork @tonsky Can multiple language ligature support be implemented via font fallbacks? For example, given a base font
(I'm not necessarily advocating this approach, but I do wonder if it is feasible and what its drawback may be.) |
@siegebell I'd prolly use stylistic alternates within a font for programming-language-specific custom ligatures — so you'd only have the haskell ligature with e.g. ss01 turned on. I've never used vscode so I don't know how a font stack there behaves |
As a potential user of this feature, I would like to add my 2¢, because I've seen some wild ideas in this thread that don't make much practical sense. First things first: Font features are 4-byte tags that are chosen and/or invented by the font designer and are baked into the font file. They allow the user to choose among stylistic variations of the font, mixing and matching the variations they like the best, or that are most appropriate for the task at hand. These features are usually small things that don't warrant creating an entirely different font file, such as empty vs. slashed zero, or fixed-width vs. proportional decimal digits, or increased character spacing. The name of a feature is a 4-byte ASCII string and the value is a small integer (not just true and false!) The font standard defines names for common features, such as More and more fonts are supporting features, especially those managed as open source projects, because different people have different ideas on what the best shape for some character is, including which (if any) common character combinations that are usually read together, such as My original post in this thread was asking whether there is a user setting for font features, because I wanted to turn on the slashed Given what features are, I'm pretty sure the best place for them would be a user setting right among the other font-related ones:
In particular, I fail to see what the table posted by @be5invis is supposed to represent. Font features are chosen by the font designer, so it makes no sense at all for an editor to come up with its own custom names. As far as language-specific configuration, there might be value in configuring different editor settings depending on the current language, but it's not limited to font features. I'm pretty sure it should be split into a specific issue. For example, I might want to use different values for Hope this helps to clear things up. |
@tobia |
@tobia since font feature settings don't seem to be implemented as yet, could you please advise how you added the |
See tonsky/FiraCode#628 - I would like something like this for Ada. |
Don't control the flags, just let me put in what I need. I should be able to enable stylistic sets (of any kind) for any language. If I want to have haskell ligatures in C that's my own business. I should also be able to turn on SS12 for markdown so that I can use the pragmatapro ligatures. I don't think we should need extensions to use OpenType standards compliant font configuration. |
I'm happy to let you know that different font features per language now works on Insiders with the work done for #82153 With the following settings:
The editor is configured to turn on |
Given the fact that in different languages, the symbol combination should be combined into a ligature are different, is it possible to provide a language-specific feature name to distinct them? For example, in C++,
>>=
should not be combined together, and we can assign a featureXCPP
to combine>>
only. In Haskell,>>=
should be combined, and featureXHS_
will be applied. The defaultcalt
can be restricted to "most-common" languages only.cf. tonsky/FiraCode#192, atom/atom#11846, #6918, source-foundry/Hack#211, larsenwork/monoid#155
The text was updated successfully, but these errors were encountered: