Font fixes
Some checks failed
CI / React UI Build (push) Successful in 10s
CI / Native Windows Build And Tests (push) Failing after 1m50s
CI / Windows Release Package (push) Has been skipped

This commit is contained in:
2026-05-22 17:38:28 +10:00
parent be9f3b4e8b
commit c35ca8d61c
2 changed files with 12 additions and 3 deletions

View File

@@ -38,12 +38,14 @@ float4 shadeVideo(ShaderContext context)
float2 pixelTextUv = (1.0 / resolution) / safeTextSize;
float2 sampleOffset = pixelTextUv * 0.38;
float msdfDistance = sampleTitleTextMsdf(textUv);
float fill = (
float msdfFill = (
coverage(msdfDistance, edge, aa) * 2.0 +
coverage(sampleTitleTextMsdf(textUv + float2(sampleOffset.x, sampleOffset.y)), edge, aa) +
coverage(sampleTitleTextMsdf(textUv + float2(-sampleOffset.x, sampleOffset.y)), edge, aa) +
coverage(sampleTitleTextMsdf(textUv + float2(sampleOffset.x, -sampleOffset.y)), edge, aa) +
coverage(sampleTitleTextMsdf(textUv + float2(-sampleOffset.x, -sampleOffset.y)), edge, aa)) / 6.0;
float sdfFill = coverage(distance, edge, aa);
float fill = min(msdfFill, sdfFill);
float outlineEdge = edge - min(outlineWidth * 0.7, 0.48);
float outline = coverage(distance, outlineEdge, aa);
float outlineAlpha = saturate(outline - fill) * outlineColor.a;

View File

@@ -83,6 +83,13 @@ void SampleAtlasPixel(const FontAtlasBuildOutput& atlas, double x, double y, uns
}
}
double GlyphAtlasCoordinate(double minBound, double maxBound, double uv)
{
if (maxBound - minBound <= 1.0)
return (minBound + maxBound) * 0.5;
return minBound + 0.5 + uv * ((maxBound - 0.5) - (minBound + 0.5));
}
std::vector<unsigned char> ComposeTextTexture(
const FontAtlasBuildOutput& atlas,
const ShaderParameterDefinition& definition,
@@ -135,8 +142,8 @@ std::vector<unsigned char> ComposeTextTexture(
if (x < 0 || x >= static_cast<int>(width))
continue;
const double u = (static_cast<double>(x) + 0.5 - destLeft) / destWidth;
const double atlasX = glyph.atlasLeft + u * (glyph.atlasRight - glyph.atlasLeft);
const double atlasY = glyph.atlasTop + v * (glyph.atlasBottom - glyph.atlasTop);
const double atlasX = GlyphAtlasCoordinate(glyph.atlasLeft, glyph.atlasRight, u);
const double atlasY = GlyphAtlasCoordinate(glyph.atlasTop, glyph.atlasBottom, v);
unsigned char sample[4] = {};
SampleAtlasPixel(atlas, atlasX, atlasY, sample);
unsigned char* destination = texturePixels.data() + (static_cast<std::size_t>(y) * width + static_cast<std::size_t>(x)) * 4u;