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

印刷ページ設定ダイアログのフォントが巨大化する問題を修正 #1682

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions sakura_core/dlg/CDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,13 @@ BOOL CDialog::OnInitDialog( HWND hwndDlg, WPARAM wParam, LPARAM lParam )
// Modified by KEITA for WIN64 2003.9.6
::SetWindowLongPtr( m_hWnd, DWLP_USER, lParam );

m_hFontDialog = UpdateDialogFont( hwndDlg );

/* ダイアログデータの設定 */
SetData();

SetDialogPosSize();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この行もSetData()の前に移動した方が良さそうです。
👆ダイアログの表示位置を調整する処理なので、描画を行う前のほうが良いはずです。

PR趣旨とは関係なさそうなのでスルーでいいです。


m_hFontDialog = UpdateDialogFont( hwndDlg );

m_bInited = TRUE;
return TRUE;
}
Expand Down
20 changes: 8 additions & 12 deletions sakura_core/dlg/CDlgPrintSetting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,7 @@ BOOL CDlgPrintSetting::OnInitDialog( HWND hwndDlg, WPARAM wParam, LPARAM lParam
// ::SetTimer( GetHwnd(), IDT_PRINTSETTING, 500, NULL );
//UpdatePrintableLineAndColumn();

BOOL bRet = CDialog::OnInitDialog( GetHwnd(), wParam, lParam );

// ダイアログフォントの寸法を得ておく
LOGFONT lf;
::GetObject(GetDialogFont(), sizeof(LOGFONT), &lf);
m_nFontHeight = lf.lfHeight; // フォントサイズ

return bRet;
return CDialog::OnInitDialog( GetHwnd(), wParam, lParam );
}

BOOL CDlgPrintSetting::OnDestroy( void )
Expand Down Expand Up @@ -905,14 +898,17 @@ void CDlgPrintSetting::SetFontName( int idTxt, int idUse, LOGFONT& lf, int nPoin
CheckDlgButtonBool( GetHwnd(), idUse, bUseFont);
::EnableWindow( GetItemHwnd( idUse ), bUseFont );
if (bUseFont) {
LOGFONT lft;
lft = lf;
lft.lfHeight = m_nFontHeight; // フォントサイズをダイアログに合せる
// サイズだけはダイアログフォントに合わせ
// それ以外は引数lfで指定された設定を採用
LOGFONT lfCreate = lf;
LOGFONT lfDialogFont = {};
::GetObject( GetDialogFont(), sizeof(LOGFONT), &lfDialogFont );
lfCreate.lfHeight = lfDialogFont.lfHeight;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここは -abs(lfDialogFont.lfHeight) とかにしなくていいんでしたっけ?(自信ない

lfHeightに負数を指定すると対象フォントに指定サイズがなくても近似するサイズを選択してくれる、という仕様があった気がします(正数だと該当サイズがなければ失敗だったような。

自信ないのでコメントのみです。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここは #1421 反映前のこの箇所と同じやり方としました。

m_hFontDlg = (HFONT)::SendMessage( GetHwnd(), WM_GETFONT, 0, 0 ); // ダイアログのフォント
LOGFONT lf;
::GetObject(m_hFontDlg, sizeof(LOGFONT), &lf);
m_nFontHeight = lf.lfHeight; // フォントサイズ

なお、
https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-logfonta
こちらによると正/負どちらも近似サイズを選択するというのは共通していますが、

  • 正数の場合は「(character) cell height」 ("Â" 等の "^" が置かれる部分を含んだ高さ)
  • 負数の場合は「character height」("Â" 等の "^" の部分は除いた高さ)

ということでした。
正負が逆になると寸法が変わることを意味しますので、今回のケースではありのまま代入するのが正解のようです。


HFONT hFontOld = (HFONT)::SendMessage(GetItemHwnd( idTxt ), WM_GETFONT, 0, 0 );

// 論理フォントを作成
HFONT hFont = ::CreateFontIndirect( &lft );
HFONT hFont = ::CreateFontIndirect( &lfCreate );
if (hFont) {
// フォントの設定
::SendMessage( GetItemHwnd( idTxt ), WM_SETFONT, (WPARAM)hFont, MAKELPARAM(FALSE, 0) );
Expand Down
1 change: 0 additions & 1 deletion sakura_core/dlg/CDlgPrintSetting.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class CDlgPrintSetting final : public CDialog
PRINTSETTING m_PrintSettingArr[MAX_PRINTSETTINGARR];
int m_nLineNumberColumns; // 行番号表示する場合の桁数
bool m_bPrintableLinesAndColumnInvalid;
int m_nFontHeight; // ダイアログのフォントのサイズ

protected:
/*
Expand Down