Skip to content
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 support when using stb_truetype backend #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wheybags
Copy link

uses the builtin sdf generation in stb_truetype, disabled when using freetype

@wheybags wheybags force-pushed the fons_sdf branch 2 times, most recently from aa13118 to 34cf562 Compare October 27, 2017 17:14
@wheybags
Copy link
Author

wheybags commented Nov 8, 2017

@memononen bump?

src/fontstash.h Outdated
float pixelDistScale; // what value the SDF should increase by when moving one SDF "pixel" away from the edge (on the 0..255 scale)
// if positive, > onedge_value is inside; if negative, < onedge_value is inside
};
typedef struct FONSsdfSettings;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be:

typedef struct FONSsdfSettings FONSsdfSettings;

src/fontstash.h Outdated
{
FONSsdfSettings sdfSettings;
memset(&sdfSettings, 0, sizeof(FONSsdfSettings));
sdfSettings.sdfEnabled = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to change false to 0 to build with C

src/fontstash.h Outdated
{
FONSsdfSettings sdfSettings;
memset(&sdfSettings, 0, sizeof(FONSsdfSettings));
sdfSettings.sdfEnabled = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to change false to 0 to build with C

@suikki
Copy link
Contributor

suikki commented Dec 16, 2017

Seemed to work after those changes. Would be very nice to have this

@wheybags
Copy link
Author

fixed
@memononen any chance of a merge?

@jimon
Copy link

jimon commented Mar 24, 2018

👍 would be nice to have this upstream!

@jimon
Copy link

jimon commented Mar 24, 2018

@wheybags also it would be super useful to be able to provide two different text sizes: one for glyph size under SDF font and another for actual text size. Because SDF fonts don't really work that well under small pt sizes.

@wheybags
Copy link
Author

@jimon What I do is pass in a constant value to fonstash (30px), and then scale the font metrics I get back according to the difference between the constant and the actual size.
I also scale the resulting vertex buffer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants