-
Notifications
You must be signed in to change notification settings - Fork 3k
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
windows: Support all OpenType
font features
#10756
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
fd7bcc1
init
JunkuiZhang e4d92ce
update settings
JunkuiZhang 3eede9e
update editor
JunkuiZhang cb364a9
update editor
JunkuiZhang a3f0919
update search
JunkuiZhang e31c069
update outline
JunkuiZhang b31b4d5
update extension_ui
JunkuiZhang 819b7c8
update terminal view
JunkuiZhang b7a8b45
update assistant panel
JunkuiZhang 058eb15
update assistant
JunkuiZhang 303005a
update terminal
JunkuiZhang 223aa64
update collab
JunkuiZhang 289a32e
update collab panel
JunkuiZhang a4d6060
use these features
JunkuiZhang 0e392f5
refactor
JunkuiZhang a1e917e
update `serialize`
JunkuiZhang 781366d
properly handle error
JunkuiZhang c506828
add removed ;
JunkuiZhang 9c7daf9
make import windows only
JunkuiZhang 5d82c5b
fix macOS
JunkuiZhang 8fe2bb9
fix useless asref
JunkuiZhang ef029fd
update ui_text_field
JunkuiZhang 5b71fe6
special case for empty features
JunkuiZhang 0d14db4
Merge branch 'main' into font-features
mikayla-maki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these additional fields needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
other_enabled
andother_disabled
serve the same function asVec<FeatureName>
. Currently, Zed only supports 34 OpenType features fromcalt
tozero
, stored inenabled: u64
anddisabled: u64
as bitfields, allowing for a maximum of 64 features. In theory, there can be up to 36*36*36*36 OpenType features. For instance,Firacode
supports features likecv01
tocv30
, while some special fonts may even usecv99
for certain reasons. Therefore, to support all OpenType features, the currentFontFeatures
struct would need to introduce a structure similar toVec<T>
, which would not supportCopy
. Cloning operations withVec<T>
are relatively costly, soSharedString
is used here since its clone operation simply duplicates the pointer.This change might have some impact on the performance of macOS, but I guess it shouldn't be significant. In macOS,
FontFeatures
has only two members of typeu64
, so the performance gap between clone and copy should be minimal. Alternatively, I could separate the implementation ofFontFeatures
for macOS and Windows without altering the existing macOS code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is a correctness issue, where both implementation are wrong, then we shouldn't be hiding this behind a
#[cfg]
and should enable it for everything. As for an efficient representation, I think this packed representation makes sense. Maybe let's document the other_enabled / other_disabled format (e.g. 'a list of 4 character font feature values'). I think I'd want to use something like aArcCow<'static, [char; 4]>
, so that it's super explicit what's being stored, but I expect that's a lot more trouble to work with and it will be even less efficient than astr
representation, as the initial ascii characters won't be packed into a single u8.That said, I expect the common case is that there are no additional font features? For that case, I think it would be nice to special case the into call on 165. If the strings are empty, we can call
"".into()
to get a SharedString wrapping a static reference. Cloning that should be even cheaper than the Arc clone, and should mean there's next to no performance hit.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, I didn't fully follow you. Here, it's not just a correctness issue; currently, Zed only supports a subset of font features. The font features that Zed doesn't support but are supported by DirectWrite (
cv99
for example) are stored here.Assuming the user has the following settings:
The
FontFeature
:This is a nice idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I mean is:
Looking at wikipedia, it seems likely that OpenType can have more than 34 features on all platforms. As such, we should enable this change for all platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My idea is that the current PR only provides implementations for additional font features on the
Windows
platform, without addressing other platforms. Therefore, in this PR, minimize the impact, I only enabling it for Windows for now. If other platforms implement support in the future, we can then remove the correspondingcfg
tags.To be honest, Linux should be able to support other font features, but I'm unsure about macOS. On macOS,
Core Text
uses aselector
mechanism to enable specific font features. However, as I mentioned, theoretically, all 26 English letters and 10 numbers could be considered "valid" OpenType font features. For example, the Iosevka font usesVS**
andVL**
, which are not listed in wiki. It's challenging to toggle these font features on macOS.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, so you're saying it takes more work to fully utilize these on other platforms? That makes sense then. I'll merge this then :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Especially on macOS, I couldn't find the
selector
for toggling thesecv**
font features likecv01
, but almost every font is utilizingcv**
.