Add 'macfontfeatures' option for OpenType font features#1689
Open
humblehacker wants to merge 3 commits into
Open
Add 'macfontfeatures' option for OpenType font features#1689humblehacker wants to merge 3 commits into
humblehacker wants to merge 3 commits into
Conversation
Add a SetFontFeaturesMsgID message that carries a comma-separated list
of OpenType feature settings ("tag" or "tag=N" entries). The Core
Text renderer parses the list into a kCTFontFeatureSettingsAttribute
array and applies it when deriving the fonts used for drawing, so the
base, wide, bold and italic fonts all pick up the features. Requires
macOS 10.13 for the OpenType feature tag API; older systems ignore the
setting. The legacy renderer does not support font features.
Signed-off-by: David Whetstone <david@humblehacker.com>
The macfontfeatures option is a comma-separated list of OpenType font
features to enable, e.g.:
:set macfontfeatures=cv01,cv09,ss03=2
Each entry is a four-character feature tag optionally followed by "="
and a number; a bare tag is equivalent to "tag=1". This allows
selecting character variants and stylistic sets in fonts that provide
them, similar to font feature settings in other editors. Setting the
option to an empty string restores the font's default features.
Invalid values are rejected with E474. Includes tests for option
existence, validation and round-tripping.
Signed-off-by: David Whetstone <david@humblehacker.com>
Signed-off-by: David Whetstone <david@humblehacker.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This adds a new MacVim-specific string option
'macfontfeatures'for enabling OpenType font features — character variants, stylistic sets, etc. — in the Core Text renderer, similar to font feature settings in other editors (e.g. Zed'sbuffer_font_features, VS Code'sfontLigatures).Implementation
The option follows the existing
'macligatures'pattern end to end:did_set_macfontfeatures(each entry must be a four-character printable-ASCII tag, optionally=<number>; anything else fails withE474and the old value is restored).SetFontFeaturesMsgID(appended beforeLoopBackMsgIDso existing message IDs keep their values across version skew).MMCoreTextViewparses the list once into akCTFontFeatureSettingsAttributearray and applies it infontVariantForTextFlags:after bold/italic trait conversion, so the base, wide, bold, and italic fonts all pick up the features and they surviveNSFontManagertrait conversion. ThefontVariantsandcharacterLinescaches are invalidated when the option changes.kCTFontOpenTypeFeatureTag) requires macOS 10.13; older systems ignore the setting via the usual@availableguard. The legacy (non-Core Text) renderer ignores the option, matching'macligatures'.Testing
test_macvim.vim(option existence,E474validation, round-tripping) and value lists ingen_opt_test.vim; both pass, as doestest_codestyle.vim.cv01,cv09changes the rendered variants of@ $ & 7, features apply to bold/italic/wide variants, an unsupported tag renders unchanged, and clearing the option restores defaults.options.txt,gui_mac.txt,quickref.txt, doc tags, and the:optionswindow (optwin.vim).AI disclosure
This contribution was developed with AI assistance (Claude Code); the design, implementation, and documentation were AI-generated under my direction, and I reviewed and tested the result.
🤖 Generated with Claude Code