pop-os / cosmic-text

Pure Rust multi-line text handling
https://pop-os.github.io/cosmic-text/cosmic_text/
Apache License 2.0
1.6k stars 103 forks source link

Can't set font features and variations #229

Open CryZe opened 8 months ago

CryZe commented 8 months ago

At the moment it's not possible to set any font features (kerning, alternates, ligatures, capitals, tabular nums, ...) nor can you set any variation axis.

narodnik commented 5 months ago

See here for examples of OTF font features:

https://rsms.me/inter/#features

peppidesu commented 3 months ago

Hi, is anyone working on this as we speak? I would contribute but I am afraid I might lack the knowledge to do so.

jackpot51 commented 3 months ago

This is an issue I am interested in working on, but still need some more information on how it would be used by users of cosmic-text.

t9t commented 3 months ago

@jackpot51 Do you think it could be helpful to look at the Zed editor code? It implements font features for Mac and Windows, but not yet for Linux (using cosmic-text). Perhaps by analyzing how it does it for Mac and Windows, and how it uses cosmic-text for Linux, you can get an idea of how it could be used? It seems like a perfect showcase with ample comparison material.

The primary cosmic-text usage seems to be here: https://github.com/zed-industries/zed/blob/main/crates/gpui/src/platform/cosmic_text/text_system.rs

The Mac implementation of font features is around here: https://github.com/zed-industries/zed/blob/f15a441c9d78c9687c1400d14c8a7991fb6db08a/crates/gpui/src/platform/mac/text_system.rs#L230

The Windows DirectWrite implementation of font features is here: https://github.com/zed-industries/zed/blob/f15a441c9d78c9687c1400d14c8a7991fb6db08a/crates/gpui/src/platform/windows/direct_write.rs#L295

The code is a bit hard to follow for me, a Rust novice and zero experience with font rendering or the Zed codebase. But I think taking some time browsing the code could give some hints as to how font features could fit in the cosmic-text usage in the Zed codebase. I was primarily looking at the different implementations of PlatformTextSystem.

Alternatively of course, someone from the Zed team might be able to assist. I entered this rabbit hole via: https://github.com/zed-industries/zed/issues/12176

Jackaed commented 4 weeks ago

Did this end up going anywhere? I'm also going down the zed rabbit hole, and this issue seems to have gotten stale.

Xori71 commented 3 days ago

Hopefully it will get worked-on. Zed on Linux is kinda crippled right now for users using ligatures.

jackpot51 commented 3 days ago

It is likely we will be using variable fonts for COSMIC soon, and that will involve implementing this. I have not yet researched the requirements.

Xori71 commented 3 days ago

It is likely we will be using variable fonts for COSMIC soon, and that will involve implementing this. I have not yet researched the requirements.

Oh, that’s pretty cool. Take your time with this, and thanks for your time.