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

Suppress run breaking for abs. differences < 0.001 in advance #4861

Merged
merged 1 commit into from
Mar 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/renderer/dx/CustomTextLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,12 @@ try
_glyphAdvances.cbegin() + clusterGlyphBegin + clusterGlyphLength,
0.0f);

// With certain font faces at certain sizes, the advances seem to be slightly more than
// the pixel grid; Cascadia Code at 13pt (though, 200% scale) had an advance of 10.000001.
// We don't want anything sub one hundredth of a cell to make us break up runs, because
// doing so results in suboptimal rendering.
// If what we expect is bigger than what we have... pad it out.
if (advanceExpected > advanceActual)
if ((advanceExpected - advanceActual) > 0.001f)
{
// Get the amount of space we have leftover.
const auto diff = advanceExpected - advanceActual;
Expand All @@ -657,7 +661,7 @@ try
_glyphAdvances.at(static_cast<size_t>(clusterGlyphBegin) + clusterGlyphLength - 1) += diff;
}
// If what we expect is smaller than what we have... rescale the font size to get a smaller glyph to fit.
else if (advanceExpected < advanceActual)
else if ((advanceExpected - advanceActual) < -0.001f)
{
const auto scaleProposed = advanceExpected / advanceActual;

Expand Down