Skia paragraph does not support granular font weights

46 views
Skip to first unread message

Yosof

unread,
Nov 10, 2025, 5:06:55 PMNov 10
to skia-discuss
The paragraph has only three weights depending on the backend used.
On windows with direct write:
from 100 to 500 is thin
from 501 to 899 is thick
from 900 it is thicker

On linux with freetype and fontconfig:
from 100 to 549 is thin
from 550 to 899 is thick
from 900 it is thicker

How does apps depending on skia manage to get granular font weights?
Here is a fiddle demonstrating the problem:

And another question:
Does skia::textlayout::TextStyle::setFontSize(float) expect size in points or pixels because I'm getting slightly different size from what direct write layout is giving.

paul....@gmail.com

unread,
Nov 11, 2025, 11:41:04 PMNov 11
to skia-discuss
Hi Yosef

Are you using a variable font with a wght axis?  Then you could try using SkTypeface::makeClone(SkFontArguments) and use the setVariationDesignPostion() method on SkFontArguments.
I haven't tried it myself, but it looks like it'll do what you want.

If you are not using a variable font, then you are obviously limited to the font weights you have installed.

Paul



Yosof

unread,
Nov 15, 2025, 12:05:04 PMNov 15
to skia-discuss
The documentation of   setVariationDesignPosition  says:
Any axis not specified will use the default value.
Skia: SkFontArguments Struct Reference
So, I assume it is not necessary to set it manually, and I don't know how to use this setting with skia paragraph anyway because it does not receive SkTypeface as input but it takes the family name and searches for fonts and may fallback to other fonts.
The same fonts skia fails to use the proper weight with direct write uses more granular weights so I think the problem is not in the fonts but in skia or the way I'm using it.
Do you know how chrome, flutter and other skia based projects use more granular font weights?

paul....@gmail.com

unread,
Nov 17, 2025, 6:52:50 PMNov 17
to skia-discuss
Sorry Yosof.  No.  I haven't played with this stuff much.  Hopefully one of the good folks here can take over from me.
Reply all
Reply to author
Forward
0 new messages