-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenType font spacing differs after update of FreeType from 2.9.1 to 2.10.0 (Overpass font) #28335
Comments
Edit: The hardware I am stuck with ATM is not up to compiling Godot quite a few times in order to find the root commit |
Can you please check the difference between 3.1.0-stable and 3.1.1-rc1? |
OK, so this is a difference between 3.1.0-stable and 3.1.1-rc1? |
The issue is not present in 3.1.0 Stable but is present in 3.1.1 RC1 |
If you want to look at this yourself use git bisect between 3.1.0-stable and the tip of the 3.1 branch. You should find it with about 7 compilations currently. Then we know what backport caused it and we can see if there's a fix for it already or revert it in 3.1 before release of 3.1.1-stable. |
Oof I'm stuck on this under powered laptop for the time being... While I would like to try to fix this myself that just isn't practical. Editing my original comment about doing this myself. |
I don't see any difference with the attached project between Edit: I do get the issue in 3.1.1-rc1 though. Testing a |
Tested so far, all non-Mono on X11 64-bit:
So not sure what's left to test, but something is wrong only in the official 3.1.1-rc1 build. |
This is very puzzling as no changes were made to the build containers at all. |
This is probably due to the freetype version change. |
I'll test with the freetype version reverted. |
I can confirm that the update of the builtin freetype version is the problem. I've reverted it in the 3.1 branch, so the bug is fixed there, but we still need to figure out the issue for the master branch (especially as it means that linking against system freetype 2.10.0+ may trigger the issue again for 3.1.x or even 3.0.x). |
I tested freetype 2.9 and 2.10 I looked over various values inside @akien-mga would it be better to revert freetype 2.10? |
IIRC freetype 2.10 has been reverted? |
No, we need to find a way to configure things to work the same on 2.9 and 2.10. Distros for example will typically unbundle freetype and build against their system version, and we can't freeze on 2.9 forever. If we can't find a config option to fix this, we should probably contact upstream FreeType as this would be a compatibility breakage in 2.10. |
dug up for several hours more but still no clue. |
@hpvb OK with defaulting all stable branches to using builtin freetype on Linux for the time being? I've already done that on master as we now need libpng16 (which Ubuntu < 18.10 and matching Debian still don't have out of the box), and if we use builtin libpng then we also need to make freetype and zlib builtin. I think we should do the same on stable branches to be on the safe side, and so that users making custom builds don't get hit by this issue. Doesn't change much for distros who will have to opt-in for zlib, libpng and freetype, like they already have to do for all other vendored deps. |
Done that for all stable branches via cherry-picks of #29998. |
These might possibly useless/unrelated info.
These? godot/thirdparty/freetype/src/pcf/README Line 58 in 4f5a7eb
|
Good finds, thanks. I'd suggest to step through |
Info so far: Whenever this if block executes, ascender and decender values(not sure about other values) set in 3.1 and master: godot/scene/resources/dynamic_font.cpp Line 163 in 2293c61
Update: These ratios were co-incidence. |
Finally found the different values. Here is the same Overpass-SemiBold.ttf with just that checkbox "Really use Typo metrics" unchecked and saved. This has same button height in both 3.1 and master. |
so you modified ttf file instead of code? |
@akien-mga freetype released new 2.10.1 version. |
The changes are on Freetype's side so I couldn't do anything. |
I tested Godot with Freetype 2.10.1 stable source today. Issue persists just like 2.10.0 . Still not sure if this is their bug or feature. |
Probably a compat-breaking feature, judging from their changelog notes? |
@Zireael07 the problem is font is not vertically center aligned comparing to freetype 2.9 |
Nice work @Anutrix. So in the end it's an issue specific to OpenType fonts using the
Is there anything we can do at the engine side to mitigate breaking compat for those fonts, or should we simply document this as a change in 3.2 and how to adapt fonts whose behavior changed? |
Disclaimer: I don't much about fonts. Just started reading on it recently. |
As per @Anutrix's debugging, it seems to be an expected consequence of changes in FreeType's handling of some OpenType font metrics, which introduce this visual difference for fonts with invalid metrics. So that's an issue for font providers to handle on their end (or negotiate with FreeType devs if they feel this 2.10 change was incorrect). From our end, I think we should just document this in the 3.2 changelog (cc @Calinou), ideally with a workaround for affected users (e.g. how to fix the font, or adding extra spacing as shown by @volzhs). |
This is the change that you question: And the long discussion about it: There is no reason for FreeType to disobey the font flags. |
Thanks for digging this up :) We can close this as "not a bug" once this FreeType change is mentioned in our release notes (cc @Calinou). This is strictly something for font providers to handle so that their font metrics work as expected by the OpenType spec and FreeType implementation. |
@akien-mga I added a mention of this change in the changelog. |
Thanks, closing then. |
The typo metrics have some semantics attached to them, so it is the responsibility of the text layout engine to properly handle them: https://docs.microsoft.com/en-us/typography/opentype/spec/recom#tad. The appearance of text being "shifted up" usually comes from the typo metrics providing a more accurate but tighter bounding box, while the head metrics usually carry the line gap at the top for compatibility reasons. Take that away and you get a "shift upwards". The UseTypoMetrics flag really signals that the layout code must to take over. Trying to make vertical metrics the same across platforms is impossible, it is much better to expose controls to the designer to fully control line-spacing. |
Godot versions:
Godot Mono 3.1.0 Beta 11 and Godot Mono 3.1.1 RC1
OS/device including version:
Manjaro Linux x64 w/Intel Sandybridge Mobile iGPU running Mesa 19.0.2-1
Issue description:
Upon upgrading from Godot Mono 3.1.0 Beta 11 to Godot Mono 3.1.1 RC1 my game's buttons went from this:
to this:
Switching between GLES2 and GLES3 does not effect either version. For the sake of completeness I will mention that these are both Mono builds but that should (hopefully) not be related to this issue.
Here is a reproduction project: ButtonSizeBug.zip
Godot Mono 3.1.0 Beta 11:
Godot Mono 3.1.1 RC1:
The text was updated successfully, but these errors were encountered: