Skip to content

Commit

Permalink
Fix issue #2525: Diff renders incorrectly with "Cascadia Mono" varian…
Browse files Browse the repository at this point in the history
…t (3)
  • Loading branch information
sdottaka committed Nov 14, 2024
1 parent feda3e2 commit 2a5d7a1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Externals/crystaledit/editlib/renderers/ccrystalrenderergdi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ bool CCrystalRendererGDI::EndDraw()
return true;
}

static LONG GetFontWeight(const LOGFONT& lf, bool bold)
{
const long weight = bold ? (lf.lfWeight + 300) : lf.lfWeight;
if (weight <= 100) return FW_THIN;
else if (weight <= 200) return FW_EXTRALIGHT;
else if (weight <= 300) return FW_LIGHT;
else if (weight <= 400) return FW_NORMAL;
else if (weight <= 500) return FW_MEDIUM;
else if (weight <= 600) return FW_SEMIBOLD;
else if (weight <= 700) return FW_BOLD;
else if (weight <= 800) return FW_EXTRABOLD;
else return FW_BLACK;
}

void CCrystalRendererGDI::SetFont(const LOGFONT &lf)
{
m_lfBaseFont = lf;
Expand All @@ -54,7 +68,7 @@ void CCrystalRendererGDI::SetFont(const LOGFONT &lf)
CClientDC dc (CWnd::GetDesktopWindow());
m_lfBaseFont.lfHeight = -MulDiv (11, dc.GetDeviceCaps (LOGPIXELSY), 72);
}
m_lfBaseFont.lfWeight = bold ? FW_BOLD : FW_NORMAL;
m_lfBaseFont.lfWeight = GetFontWeight(lf, bold);
m_lfBaseFont.lfItalic = (BYTE) italic;
if (!m_apFonts[nIndex]->CreateFontIndirect(&m_lfBaseFont))
m_apFonts[nIndex].reset(nullptr);
Expand Down

0 comments on commit 2a5d7a1

Please sign in to comment.