Skip to content

Commit

Permalink
Preserve fractional font size settings whenever possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Aug 5, 2018
1 parent ff80f2d commit 4fe9414
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Styles.c
Original file line number Diff line number Diff line change
Expand Up @@ -2306,9 +2306,10 @@ BOOL Style_SelectFont(HWND hwnd, LPWSTR lpszStyle, int cchStyle, BOOL bDefaultSt
if (Style_StrGetColor(TRUE, lpszStyle, &iValue)) {
cf.rgbColors = iValue;
}
if (Style_StrGetSize(lpszStyle, &iValue)) {
if (Style_StrGetSizeEx(lpszStyle, &iValue)) {
HDC hdc = GetDC(hwnd);
lf.lfHeight = -MulDiv(iValue, GetDeviceCaps(hdc, LOGPIXELSY), 72);
cf.iPointSize = iValue / (SC_FONT_SIZE_MULTIPLIER / 10);
lf.lfHeight = -MulDiv(iValue, GetDeviceCaps(hdc, LOGPIXELSY), 72*SC_FONT_SIZE_MULTIPLIER);
ReleaseDC(hwnd, hdc);
}
lf.lfWeight = (StrStrI(lpszStyle, L"bold")) ? FW_BOLD : FW_NORMAL;
Expand Down Expand Up @@ -2347,6 +2348,13 @@ BOOL Style_SelectFont(HWND hwnd, LPWSTR lpszStyle, int cchStyle, BOOL bDefaultSt
lstrcat(szNewStyle, L"; size:");
wsprintf(tch, L"%i", cf.iPointSize / 10);
lstrcat(szNewStyle, tch);
iValue = cf.iPointSize % 10;
if (iValue != 0) {
tch[0] = '.';
tch[1] = (WCHAR)(L'0' + iValue);
tch[2] = 0;
lstrcat(szNewStyle, tch);
}
if (cf.nFontType & BOLD_FONTTYPE) {
lstrcat(szNewStyle, L"; bold");
}
Expand Down

0 comments on commit 4fe9414

Please sign in to comment.