Skip to content

Commit

Permalink
Treat the given point size exactly
Browse files Browse the repository at this point in the history
  • Loading branch information
lhecker committed Aug 26, 2022
1 parent 90cc4b9 commit bc12e2f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/renderer/atlas/AtlasEngine.api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,8 @@ void AtlasEngine::_resolveFontMetrics(const wchar_t* requestedFaceName, const Fo
// Point sizes are commonly treated at a 72 DPI scale
// (including by OpenType), whereas DirectWrite uses 96 DPI.
// Since we want the height in px we multiply by the display's DPI.
const auto fontSizeInPx = std::roundf(requestedSize.Y / 72.0f * _api.dpi);
const auto fontSizeInDIP = requestedSize.Y / 72.0f * 96.0f;
const auto fontSizeInPx = requestedSize.Y / 72.0f * _api.dpi;

const auto designUnitsPerPx = fontSizeInPx / static_cast<float>(metrics.designUnitsPerEm);
const auto ascent = static_cast<float>(metrics.ascent) * designUnitsPerPx;
Expand Down Expand Up @@ -687,7 +688,7 @@ void AtlasEngine::_resolveFontMetrics(const wchar_t* requestedFaceName, const Fo

fontMetrics->fontCollection = std::move(fontCollection);
fontMetrics->fontName = std::move(fontName);
fontMetrics->fontSizeInDIP = fontSizeInPx / static_cast<float>(_api.dpi) * 96.0f;
fontMetrics->fontSizeInDIP = fontSizeInDIP;
fontMetrics->baselineInDIP = baseline / static_cast<float>(_api.dpi) * 96.0f;
fontMetrics->advanceScale = cellWidth / advanceWidth;
fontMetrics->cellSize = { cellWidth, cellHeight };
Expand Down

0 comments on commit bc12e2f

Please sign in to comment.