SkiaSharp icon indicating copy to clipboard operation
SkiaSharp copied to clipboard

[FEATURE] Expose additional API for variable font support

Open cr4yz opened this issue 2 years ago • 5 comments

Is your feature request related to a problem? Please describe.

I'd like to paint text with font variation options but the needed API is not exposed to HarfBuzzSharp nor SkiaSharp.

Describe the solution you'd like

Requested Skia api: https://api.skia.org/structSkFontParameters.html https://api.skia.org/classSkTypeface.html#a01b379aa05f1d89af547e32ce3fabbe1

Requested HarfBuzz api: https://harfbuzz.github.io/harfbuzz-hb-font.html#hb-font-set-variations

We are looking to plumb font-variation-settings through to render variable fonts. To do this we need to be able to set variation values by their tags (wght, slnt, etc) in shaping and painting. I think exposing the above api should cover it, though this is new to me and I may be missing something.

cr4yz avatar Feb 23 '23 18:02 cr4yz

This is becoming a deal-breaker as a time goes on. Our users are attacking us with this feature request, and we can do nothing, sadly.

Please, add variable fonts support to the 3.0, if possible. Thanks in advance!

Mikolaytis avatar Sep 10 '24 04:09 Mikolaytis

Harfbuzz api can be called directly via pInvokes. All we actually need is sk_sp<SkTypeface> SkTypeface::makeClone (const SkFontArguments&) const https://api.skia.org/classSkTypeface.html#a01b379aa05f1d89af547e32ce3fabbe1

@mattleibow I hope it's not that hard to add a single api method and a struct into the api, please help us. SkiaSharp needs support for variable fonts for years.

Mikolaytis avatar Oct 06 '24 08:10 Mikolaytis

Adding the needed APIs to HarfBuzzSharp should be trivial. These just needs to be added via generator.

Gillibald avatar Oct 06 '24 13:10 Gillibald

What about implementing SkFontArguments / SkTypeface::makeClone for SkiaSharp 3.x? Needed for https://github.com/lay295/TwitchDownloader/issues/1504

superbonaci avatar Jul 25 '25 16:07 superbonaci

Making a comment to lift up the issue. Variable fonts support is mandatory for almost all apps.

Mikolaytis avatar Sep 02 '25 07:09 Mikolaytis