0.19pre, DraftWB ShapeString font sizes vary among differnt font files

A forum dedicated to the Draft, Arch and BIM workbenches development.
fc_tofu
Posts: 285
Joined: Sun Jan 05, 2020 4:56 pm

0.19pre, DraftWB ShapeString font sizes vary among differnt font files

Postby fc_tofu » Fri Feb 14, 2020 3:02 pm

Version: FreeCAD_0.19.19510_x64_LP_12.1.2_PY3QT5-WinVS2015 /GIMP 2.10
OS: win10 x64

Summary:
DraftWB ShapeString font size varies in differnt font files. While in other apps, font sizes keep consistent between different font files.
fsc_2020-02-14_223622.jpg
fsc_2020-02-14_223622.jpg (205.41 KiB) Viewed 204 times
fsc_2020-02-14_223524.jpg
fsc_2020-02-14_223524.jpg (156.99 KiB) Viewed 204 times
Font file: HYSWLongFangSong.ttf
http://gd.ddooo.com:8081/uuauth/hycfst_ ... df9717.rar
Attachments
gimp210_fontsize_test.zip
(35.11 KiB) Downloaded 2 times
fc019pre_shapestring_fontsize_test.FCStd
(111.39 KiB) Downloaded 3 times
User avatar
wandererfan
Posts: 3674
Joined: Tue Nov 06, 2012 5:42 pm

Re: 0.19pre, DraftWB ShapeString font sizes vary among differnt font files

Postby wandererfan » Tue Feb 18, 2020 1:05 am

fc_tofu wrote:
Fri Feb 14, 2020 3:02 pm
DraftWB ShapeString font size varies in differnt font files. While in other apps, font sizes keep consistent between different font files.
My understanding is that it is normal for different fonts to have different actual sizes for the same nominal size. This explains it fairly well.

I guess GIMP scales the font to match the nominal point size. We could do that(??), but it has never come up before.
vocx
Posts: 3344
Joined: Thu Oct 18, 2018 9:18 pm

Re: 0.19pre, DraftWB ShapeString font sizes vary among differnt font files

Postby vocx » Tue Feb 18, 2020 1:16 am

wandererfan wrote:
Tue Feb 18, 2020 1:05 am
My understanding is that it is normal for different fonts to have different actual sizes for the same nominal size. This explains it fairly well.
...
Yes, if you learn LaTeX you often have to read a lot about fonts. It seems that there isn't a standard for many things, for example, "1 ex" is the height of the letter "x". For one font, this 1 ex is one size in millimeters, and for a different font, it has a different value. So they are both 1 ex, but with different real sizes. Same with the value "1 em" which is the value of the width of the letter "M".

And the typographical world uses all sorts of strange units like points (pt), big points (Adobe points?), and picas (pc).
Always add the important information to your posts if you need help.
To support the documentation effort, and code development, your donation is appreciated: paypal.
fc_tofu
Posts: 285
Joined: Sun Jan 05, 2020 4:56 pm

Re: 0.19pre, DraftWB ShapeString font sizes vary among differnt font files

Postby fc_tofu » Tue Feb 18, 2020 4:40 pm

wandererfan wrote:
Tue Feb 18, 2020 1:05 am
...
I guess GIMP scales the font to match the nominal point size. We could do that(??), but it has never come up before.
Thank you and vocx, you are always warm hearted.
I've read you recommended article, and can understand that font design affect font size.
But in this case, the variation level obviously exceeds the font design factor.
fsc_2020-02-19_000650b.jpg
fsc_2020-02-19_000650b.jpg (54.57 KiB) Viewed 110 times
In my new test, all weird size fonts are Chinese fonts.
- HYSWLongFangSong.ttf
- minliub.ttc (Win10 stock)
- simsun.ttc (Win10 stock)
But there are still normal size Chinese fonts.
- no.3 = msyh.ttc (Win10 stock)
- no.6 = msjh.ttc (Win10 stock)

So, this time, it turns out to be a new Chinese/CJK/DBCS font issue? I'm not quite sure. I'll do more tests.
Below is a weird size Chinese font download, siumsun.ttc (url is WinXP version, but same effect as Win10 version).
http://117.128.6.36/cache/down.font5.co ... d690a34c2d

Attachment is this time new test.
fc019pre_shapestring_fontsize_test2.FCStd
(75.21 KiB) Downloaded 2 times
Last edited by fc_tofu on Wed Feb 19, 2020 11:37 am, edited 1 time in total.
User avatar
wandererfan
Posts: 3674
Joined: Tue Nov 06, 2012 5:42 pm

Re: 0.19pre, DraftWB ShapeString font sizes vary among differnt font files

Postby wandererfan » Tue Feb 18, 2020 9:31 pm

fc_tofu wrote:
Tue Feb 18, 2020 4:40 pm
But in this case, the variation level obviously exceeds the font design factor.
Can't download your fonts, so I am using others with similar names.

Arial renders to almost perfect height, hysw is about double what it should be and simsun is a massive 7x what it should be.

If I compare hysw, simsun and arial in fontforge, the parameters (em size, ascender, descender, advance etc) are vastly different, so I'm not completely surprised that they render differently.

We only do a simple scaling of desired_height / em_size, so if the font uses an unusual em size or draws the glyphs in only part of the em square we won't get the intended size. We could use a more complex scaling algorithm, but it still would not guarantee the right size.

Another issue is that some fonts have bitmaps (which we don't use) for various sizes inside the font file, so if a program uses the bitmap(s) to render the glyphs, there is no guarantee that we (using the contours) will generate the same size glyphs.

You can make a feature request for more accurate font scaling, but I imagine it will be a long wait.