text-to-styles icon indicating copy to clipboard operation
text-to-styles copied to clipboard

Text styles generating wrong weight

Open bitfactory-lasse-vandenboschchristensen opened this issue 4 years ago • 8 comments

Hi @tbrasington,

Just trying out your plugin. Sweet work 👍

I'm encountering a small issue when generating styles. For a specific style i'm specifying 'Heavy' as a weight. However upon generating the styles 'Extra Bold' is generated as a style. I manually override this for now, but just wanted to give you a heads up on the issue.

Cheers

Hi @bitfactory-lasse-vandenboschchristensen thank you for the heads up. Let me check if its resolvable – there was an issue with how Sketch was handling font weights that was being looked at.

tbrasington avatar Feb 24 '20 08:02 tbrasington

@tbrasington rock on :)

@tbrasington I am having a similar issue with a Light font. Instead of the Light weight, it is generating a Thin font.

rickcecil avatar Mar 24 '20 17:03 rickcecil

Hey folks, what typefaces are you using? I can hopefully expand them for my testing.

tbrasington avatar Mar 24 '20 18:03 tbrasington

Awesome. Thanks! Fonts are ... SF Pro Display and SF Pro Text

rickcecil avatar Mar 24 '20 18:03 rickcecil

Hey everyone. So it seems that isn’t going to be possible with the current Sketch JS API.

So for example in the San Francisco case thin and light both report back their weight is 3. This is as the internals in the sketch api are using this function (https://developer.apple.com/documentation/appkit/nsfontmanager/1462351-weightoffont?language=objc) here (https://github.com/sketch-hq/SketchAPI/blob/26b1fe92a89871e2db8ec04ccc8af49c735407cd/Source/dom/style/Text.js#L491)

This only gives an approximation of the font weight which falls down when the font file isn’t mapped out in a certain way.

tbrasington avatar Mar 25 '20 06:03 tbrasington

Just had this bug too with TT Commons. What a shame!

RussellBishop avatar Mar 16 '21 22:03 RussellBishop

Just had this bug too with TT Commons. What a shame!

It is possible to get around it if you have tools to adjust the font properties. Some reading here https://github.com/ingrammicro/puzzle-tokens/issues/19

tbrasington avatar Mar 17 '21 21:03 tbrasington