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

AtlasEngine: Better builtin glyphs #18179

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion src/renderer/atlas/BackendD3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,10 @@ void BackendD3D::_recreateConstBuffer(const RenderingPayload& p) const
data.underlineWidth = p.s->font->underline.height;
data.doubleUnderlineWidth = p.s->font->doubleUnderline[0].height;
data.curlyLineHalfHeight = _curlyLineHalfHeight;
data.shadedGlyphDotSize = std::max(1.0f, std::roundf(std::max(p.s->font->cellSize.x / 16.0f, p.s->font->cellSize.y / 32.0f)));
// The lightLineWidth used for drawing the built-in glyphs is `cellSize.x / 6.0f`.
// So this ends up using a quarter line width for the dotted glyphs.
// We use half that for the `cellSize.y`, because usually cells have an aspect ratio of 1:2.
data.shadedGlyphDotSize = std::max(1.0f, std::roundf(std::max(p.s->font->cellSize.x / 12.0f, p.s->font->cellSize.y / 24.0f)));
p.deviceContext->UpdateSubresource(_psConstantBuffer.get(), 0, nullptr, &data, 0, 0);
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/renderer/atlas/BuiltinGlyphs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,10 @@ void BuiltinGlyphs::DrawBuiltinGlyph(ID2D1Factory* factory, ID2D1DeviceContext*
const auto rectY = rect.top;
const auto rectW = rect.right - rect.left;
const auto rectH = rect.bottom - rect.top;
const auto lightLineWidth = std::max(1.0f, roundf(rectW / 8.0f));
// 1/6th of the cell width roughly matches the thin line width that Cascadia Mono
// uses for its box drawing characters. Same for the corner radius factor.
const auto lightLineWidth = std::max(1.0f, roundf(rectW / 6.0f));
const auto cornerRadius = std::min(lightLineWidth * 5.0f, std::min(rectW, rectH) * 0.5f);
D2D1_POINT_2F geometryPoints[2 * InstructionsPerGlyph];
size_t geometryPointsCount = 0;

Expand Down Expand Up @@ -1176,7 +1179,7 @@ void BuiltinGlyphs::DrawBuiltinGlyph(ID2D1Factory* factory, ID2D1DeviceContext*
}
case Shape_RoundRect:
{
const D2D1_ROUNDED_RECT rr{ { begXabs, begYabs, endXabs, endYabs }, lightLineWidth * 2, lightLineWidth * 2 };
const D2D1_ROUNDED_RECT rr{ { begXabs, begYabs, endXabs, endYabs }, cornerRadius, cornerRadius };
renderTarget->DrawRoundedRectangle(&rr, brush, lineWidth, nullptr);
break;
}
Expand Down
Loading