Skip to content

Commit 25f0416

Browse files
committed
プルリクエストに伴う修正
1 parent 6dc61a5 commit 25f0416

3 files changed

Lines changed: 26 additions & 19 deletions

File tree

XG_SettingsDialog.cpp

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ BOOL XG_SettingsDialog::OnInitDialog(HWND hwnd)
3333
::SetDlgItemTextW(hwnd, edt1, xg_szCellFont);
3434
::SetDlgItemTextW(hwnd, edt2, xg_szSmallFont);
3535
::SetDlgItemTextW(hwnd, edt3, xg_szUIFont);
36+
m_lfCellFont = xg_lfCellLogFont;
3637

3738
// スケルトンビューか?
3839
::CheckDlgButton(hwnd, chx1,
@@ -205,9 +206,7 @@ BOOL XG_SettingsDialog::OnOK(HWND hwnd)
205206
WCHAR szName[LF_FACESIZE];
206207

207208
// セルフォント。
208-
::GetDlgItemTextW(hwnd, edt1, szName, _countof(szName));
209-
StringCchCopy(xg_szCellFont, _countof(xg_szCellFont), szName);
210-
StringCchCopy(xg_lfCellLogFont.lfFaceName, _countof(xg_lfCellLogFont.lfFaceName), szName);
209+
xg_lfCellLogFont = m_lfCellFont;
211210

212211
// 小さい文字のフォント。
213212
::GetDlgItemTextW(hwnd, edt2, szName, _countof(szName));
@@ -324,12 +323,12 @@ BOOL XG_SettingsDialog::DoImportLooks(HWND hwnd, LPCWSTR pszFileName)
324323
std::vector<BYTE> data;
325324
XgHexToBin(data, szText);
326325
if (data.size() == sizeof(LOGFONTW)) {
327-
const LONG lfHeight = xg_lfCellLogFont.lfHeight;
328-
const LONG lfWidth = xg_lfCellLogFont.lfWidth;
329-
memcpy(&xg_lfCellLogFont, data.data(), sizeof(LOGFONTW));
330-
xg_lfCellLogFont.lfHeight = lfHeight;
331-
xg_lfCellLogFont.lfWidth = lfWidth;
332-
SetDlgItemTextW(hwnd, edt1, xg_lfCellLogFont.lfFaceName);
326+
const LONG lfHeight = m_lfCellFont.lfHeight;
327+
const LONG lfWidth = m_lfCellFont.lfWidth;
328+
memcpy(&m_lfCellFont, data.data(), sizeof(LOGFONTW));
329+
m_lfCellFont.lfHeight = lfHeight;
330+
m_lfCellFont.lfWidth = lfWidth;
331+
SetDlgItemTextW(hwnd, edt1, m_lfCellFont.lfFaceName);
333332
}
334333
}
335334

@@ -475,7 +474,7 @@ BOOL XG_SettingsDialog::DoExportLooks(HWND hwnd, LPCWSTR pszFileName)
475474
WritePrivateProfileStringW(L"Looks", L"CellFont", szName, pszFileName);
476475
// CellLogFontを保存する。
477476
{
478-
XGStringW strHex = XgBinToHex(&xg_lfCellLogFont, sizeof(xg_lfCellLogFont));
477+
XGStringW strHex = XgBinToHex(&m_lfCellFont, sizeof(m_lfCellFont));
479478
WritePrivateProfileStringW(L"Looks", L"CellLogFont", strHex.c_str(), pszFileName);
480479
}
481480

@@ -608,6 +607,7 @@ void XG_SettingsDialog::OnResetLooks(HWND hwnd)
608607
InvalidateRect(m_hwndMarked, nullptr, TRUE);
609608

610609
// フォント。
610+
m_lfCellFont = {};
611611
SetDlgItemTextW(hwnd, edt1, L"");
612612
SetDlgItemTextW(hwnd, edt2, L"");
613613
SetDlgItemTextW(hwnd, edt3, L"");
@@ -697,19 +697,21 @@ void XG_SettingsDialog::OnChange(HWND hwnd, int i)
697697
lf.lfCharSet = DEFAULT_CHARSET;
698698

699699
switch (i) {
700-
case 0:
700+
case 0: // マス フォント
701701
cf.Flags = CF_NOSCRIPTSEL | CF_NOVERTFONTS | CF_SCALABLEONLY |
702702
CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
703-
StringCchCopy(lf.lfFaceName, _countof(lf.lfFaceName), xg_szCellFont);
703+
lf = m_lfCellFont;
704+
lf.lfHeight = 24;
705+
lf.lfQuality = ANTIALIASED_QUALITY;
704706
if (::ChooseFontW(&cf)) {
705707
// 取得したフォントをダイアログへ格納する。
706708
::SetDlgItemTextW(hwnd, edt1, lf.lfFaceName);
707-
// xg_lfCellLogFontに反映する(サイズは変更しない)。
708-
const LONG lfHeight = xg_lfCellLogFont.lfHeight;
709-
const LONG lfWidth = xg_lfCellLogFont.lfWidth;
710-
xg_lfCellLogFont = lf;
711-
xg_lfCellLogFont.lfHeight = lfHeight;
712-
xg_lfCellLogFont.lfWidth = lfWidth;
709+
// m_lfCellFontに反映する(サイズは変更しない)。
710+
const LONG lfHeight = m_lfCellFont.lfHeight;
711+
const LONG lfWidth = m_lfCellFont.lfWidth;
712+
m_lfCellFont = lf;
713+
m_lfCellFont.lfHeight = lfHeight;
714+
m_lfCellFont.lfWidth = lfWidth;
713715
}
714716
break;
715717

@@ -909,7 +911,9 @@ XG_SettingsDialog::DialogProcDx(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar
909911
break;
910912

911913
case psh3:
914+
m_lfCellFont = {};
912915
::SetDlgItemTextW(hwnd, edt1, L"");
916+
PropSheet_Changed(GetParent(hwnd), hwnd);
913917
break;
914918

915919
case psh4:

XG_SettingsDialog.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88
class XG_SettingsDialog
99
{
1010
public:
11+
// マスフォントの一時キャッシュ。
12+
LOGFONT m_lfCellFont = {};
13+
1114
XG_SettingsDialog() noexcept
1215
{
16+
m_lfCellFont = xg_lfCellLogFont;
1317
}
1418

1519
// [設定]ダイアログの初期化。

_codeql_detected_source_root

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)