-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
feat: truetype font features #692
base: master
Are you sure you want to change the base?
Conversation
src/font.c
Outdated
CFNumberRef name = CFNumberCreate(default_allocator, kCFNumberIntType, &feat_name); | ||
CFNumberRef value = CFNumberCreate(default_allocator, kCFNumberIntType, &feat_value); | ||
|
||
descriptor = CTFontDescriptorCreateCopyWithFeature(descriptor, name, value); |
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 believe this causes a memory leak, because it copies the existing descriptor and then overwrites the pointer.
What we could think about would be to accept both the format you introduced, which is the „low-level“ syntax along with some common features which we give a sensible selector name and internally do the mapping for. What do you think? |
I hesitate to use our own namings of these features, as these selectors are very standardized. What about just manually creating a mapping from opentype features to truetype features? It would just include the most common few features, as there are way too many. This way, users could use some of the opentype names (as i believe opentype is much more prevalent outside of apple) ie, some sort of mapping like this: struct {
char opentype_tag[5];
int truetype_feature;
int truetype_selector;
};
// an array of:
{"pnum", kNumberSpacingType, kProportionalNumbersSelector},
{"tnum", kNumberSpacingType, kMonospacedNumbersSelector},
{"smcp", kLowerCaseType, kLowerCaseSmallCapsSelector},
{"onum", kNumberCaseType, kLowerCaseNumbersSelector}, and then, accept stuff like the CSS font-feature-settings, with something like sketchybar --set item label.font.features="tnum,ss07,ss13" |
Adds support for TrueType font features
You can use OpenType font features too, but you need to go through the docs, or
<CoreText/SFNTLayoutTypes.h>
to find the corresponding TrueType codes.For example, the C code is:
The corresponding way to do this now is:
I'm not sure if there is a nicer way of doing this though
Closes #670
In the above issue, the corresponding features string would be
"14:4"
(kTypographicExtras
,kSlashedZeroOnSelector
)Related: #187