Skip to content

add SDF support when using stb_truetype backend#38

Open
wheybags wants to merge 1 commit into
memononen:masterfrom
wheybags:fons_sdf
Open

add SDF support when using stb_truetype backend#38
wheybags wants to merge 1 commit into
memononen:masterfrom
wheybags:fons_sdf

Conversation

@wheybags

Copy link
Copy Markdown

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

wheybags commented Nov 8, 2017

Copy link
Copy Markdown
Author

@memononen bump?

Comment thread 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
Copy Markdown
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;

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

Copy link
Copy Markdown
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

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

Copy link
Copy Markdown
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

suikki commented Dec 16, 2017

Copy link
Copy Markdown
Contributor

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

@wheybags

Copy link
Copy Markdown
Author

fixed
@memononen any chance of a merge?

@jimon

jimon commented Mar 24, 2018

Copy link
Copy Markdown

👍 would be nice to have this upstream!

@jimon

jimon commented Mar 24, 2018

Copy link
Copy Markdown

@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
Copy Markdown
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