-
Notifications
You must be signed in to change notification settings - Fork 428
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
Add SDF HintingMode #1966
Add SDF HintingMode #1966
Conversation
I tried to apply and use this change on Windows with the default font (
0x13 is |
That's the main problem I was having with the prebuilt love-apple-dependencies on macOS. After building it myself from the official FreeType 2.12.0 source instead of from the megasource, it worked with no errors. From FreeType's changelog they state that SDF support is available since 2.11.0, is there a reason the megasource's FreeType could be different from the official source? |
It's the same source code. Maybe it's an opt-in compile time feature when building the library? If that's the case and it's not enabled by default in Linux distros, this gets a lot more complicated to support because we can't guarantee that it's available in every copy of a given love version. Speaking of Linux distros, I think Ubuntu 20.04 LTS may not provide 2.11+. |
I've investigated it further, and it looks like the Commenting out lines 303-309 in /* the rows and pitch must be valid after presetting the */
/* bitmap using outline */
//if ( !bitmap->rows || !bitmap->pitch )
//{
// FT_ERROR(( "ft_sdf_render: failed to preset bitmap\n" ));
// error = FT_THROW( Cannot_Render_Glyph );
// goto Exit;
//} Would it be possible and/or favorable to modify the FreeType source within the megasource (assuming this small change does not cause any other problems)? Also, I don't see how supporting Ubuntu 20.04 is relevant to this issue since the 12.x branch of the megasource already includes FreeType 2.12.0. |
Yeah that'd do it, love creates a glyph of the space character in Font constructors. It might be possible to modify TrueTypeRasterizer.cpp so it detects glyphs which would have invisible/zero-size bitmaps and has an alternate codepath that doesn't try rasterizing those. Or sdf support could only be turned on at runtime when a newer version of freetype with that fix is used - although I'm hesitant about doing that because of the versions used in package managers.
I don't think that's a good idea, it adds a burden for us to maintain the patch and it would only apply to one platform out of 5 (see below).
As I said (and is said in the readmes), megasource is primarily for Windows. It's not used for official builds on other platforms. Linux AppImages use a different build process, and Linux distro-maintained love packages use shared system dependencies which are not under our control at all. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's working for me in Windows now, thanks!
I think the hinting stuff still needs to be figured out, but aside from that it looks good. It's too bad Freetype doesn't have an option for a more advanced SDF technique since single-value SDFs can have some noticeable visual issues around corners of letters.
The |
Any update on this? I can take it over if needed. |
Sorry for the long delay, I forgot this wasn't finished. I can take care of the rest of the changes. |
It looks like mono hinting and sdf options cannot be used together since they use different rendermodes. If this is a problem, I can do further testing to see what can be done about it. |
I think that makes sense, you could make it cause an error (via |
It looks like there was no error needed to fix the rendermode problem. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
I was having trouble building this with the prebuilt FreeType macOS framework, I'm not sure why, so I had to build it myself to make sure this built correctly.