pop-os / cosmic-text

Pure Rust multi-line text handling

Home Page:https://pop-os.github.io/cosmic-text/cosmic_text/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't set font features and variations

CryZe opened this issue · comments

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.

See here for examples of OTF font features:

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

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

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.

commented

@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: zed-industries/zed#12176