uwerat / qskinny

A lightweight framework on top of the Qt scene graph and only few classes from Qt/Quick. It is usable from C++ and/or QML.
1.45k stars 293 forks source link

Material 3 font sizes #432

Closed uwerat closed 1 month ago

uwerat commented 1 month ago

The initialization of the M3 fonts defines the sizes in "pt". The implementation converts "pt" to "px" and finally to pixels. The second conversion uses qskDpToPixels instead of qskPxToPixels, what is probably wrong.

However without having a dp value in the conversion chain we won't have the density steps implemented in qskRoundedDpi ( QskPlatform.cpp ). So we might have to convert "pt" into "dp" instead of "px".

When doing this modification the fonts are obviously too big, what leads to 2 possible conclusions:

a) The initial sizes are not in "pt" b) The implementation of qskDpToPixels is wrong

peter-ha commented 1 month ago

To me it looks like Qt renders fonts bigger than M3 implementations, i.e. flutter (and possibly others).

When setting the font size to 200pt, Qt differs a lot from Skia, which is used internally in flutter:

Screenshot from 2024-10-24 14-41-19

I also verified that the fonts used in flutter are actually in pt, the flutter API is not very clear about this, but Skia is: https://api.skia.org/classSkFont.html#a7e28a156a517d01bc608c14c761346bf says "Constructs SkFont with default values with SkTypeface and size in points."

Qt renders fonts ~ 1.3x bigger than Skia, which happens to be roughly the same as the factor we get from our conversion, which seems to be only a coincidence.

I don't have a good solution to this problem though, other than accepting the difference and hardcoding it somewhere for us.

uwerat commented 1 month ago

Maybe the difference is because the given font sizes are sp -not dp - values. sp ( = scalable pixels ) are additionally scaled with a factor from the user settings:

IIRC there is something similar for Fluent2.

I already created https://github.com/uwerat/qskinny/issues/389 for this feature.

uwerat commented 1 month ago

After checking the specs I'm wandering whether the font sizes are indeed in dp - when interpreting them as pt the results look much more reasonable. So let's do this