Support setting font feature values (#11898)

Now (on `macOS` and `Windows`) we can set font feature value:
```rust
  "buffer_font_features": {
    "cv01": true,
    "cv03": 3,
    "cv09": 1,
    "VSAH": 7,
    "VSAJ": 8
  }
```

And one can still use `"cv01": true`.



https://github.com/zed-industries/zed/assets/14981363/3e3fcf4f-abdb-4d9e-a0a6-71dc24a515c2




Release Notes:

- Added font feature values, now you can set font features like `"cv01":
7`.

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
张小白
2024-05-16 14:27:55 -07:00
committed by GitHub
co-authored by Mikayla
parent b6189b05f9
commit 80caa74866
3 changed files with 153 additions and 265 deletions
+2 -5
View File
@@ -30,14 +30,11 @@ pub fn apply_features(font: &mut Font, features: &FontFeatures) {
let native_font = font.native_font();
let mut feature_array =
CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
for (tag, enable) in features.tag_value_list() {
if !enable {
continue;
}
for (tag, value) in features.tag_value_list() {
let keys = [kCTFontOpenTypeFeatureTag, kCTFontOpenTypeFeatureValue];
let values = [
CFString::new(&tag).as_CFTypeRef(),
CFNumber::from(1).as_CFTypeRef(),
CFNumber::from(*value as i32).as_CFTypeRef(),
];
let dict = CFDictionaryCreate(
kCFAllocatorDefault,