-
Notifications
You must be signed in to change notification settings - Fork 0
Large amounts of "whitespace" around lowercase glyphs #2
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
Comments
Interesting, I'm currently using this in my other project (https://github.com/exezin/exengine) and the final rendering results seem correct. It's been a while since I have touched this project but I suspect I could be pre-scaling things to be the appropriate scale for what it is, so you don't have to store meta-data and scale anything when rendering them out at the end. I'll take a look at this 👍 Edit; Could this also be the result of using the 'autoframe' option? Could you also confirm that this actually presents issues when attempting to use the generated MSDF to render a line of text? Here is my implementation. |
I'm actually struggling to find the right metrics for the scale (line 975 msdf.c) using stb_truetype.h, as far as I can tell stb_truetype only supplies two functions to get this metric and the current one used produces the a larger glyph than the other function. As for the px_range value, does changing the iteration count here produce results that look closer to that of msdfgen?
|
The output only looks right when both Right now in main |
That's a valid point, I'll work on that soon and also have a look into the |
Hi, as of commit a2b0008 I have implemented auto-fit, this needs some testing though. There's no way to enable it via the command-line yet, I hadn't really planned for this to become a tool, just code one could use in their own projects but perhaps that will change soon. Anyway, change this line in main.c as shown here (last argument enables auto-fit) and give it a test, see how it works for you.
|
Here's my text shader, I have to dynamically calculate the scale factor See here for how I calculate #version 330 core
in vec2 uv;
out vec4 color;
uniform sampler2D u_texture;
uniform float u_scale;
float median(float r, float g, float b) {
return max(min(r, g), min(max(r, g), b));
}
void main()
{
vec3 sample = texture(u_texture, uv).rgb;
float dist = u_scale * (median(sample.r, sample.g, sample.b) - 0.5);
float o = clamp(dist + 0.5, 0.0, 1.0);
color = vec4(vec3(1.0), o);
} |
I've noticed that msdf-c generates some glyphs, mostly lower-case glyphs, with more space around the main character data than msdfgen provides.
Here are some examples. Glyphs generated from Roboto Regular at 32x32, a range of 1, and with autoframe.
Chars: a, @, h, c, -
Chlumsky/msdfgen:





exezin/msdf-c:





256x256 Example:


The text was updated successfully, but these errors were encountered: