• R/O
  • SSH
  • HTTPS

ttssh2: Commit


Commit MetaInfo

Revision7379 (tree)
Time2019-01-03 01:58:18
Authorzmatsuo

Log Message

ダイアログフォント決定方法見直し

Change Summary

Incremental Difference

--- branches/cmake/TTProxy/ProxyWSockHook.h (revision 7378)
+++ branches/cmake/TTProxy/ProxyWSockHook.h (revision 7379)
@@ -32,6 +32,7 @@
3232 GetI18nStrU8("TTProxy", key, buf, buf_len, def, UILanguageFile);
3333 }
3434
35+#if 0
3536 int UTIL_get_lang_font(const char *key, HWND dlg, PLOGFONTA logfont, HFONT *font)
3637 {
3738 if (GetI18nLogfont("TTProxy", key, logfont,
@@ -46,6 +47,7 @@
4647
4748 return TRUE;
4849 }
50+#endif
4951
5052 class ProxyWSockHook {
5153 public:
@@ -741,7 +743,7 @@
741743 Window conn;
742744 Window erro;
743745 Window log;
744- HFONT DlgFont;
746+// HFONT DlgFont;
745747 protected:
746748 virtual bool dispatch(int message, int wParam, long lParam) {
747749 if (message == WM_COMMAND && wParam == MAKEWPARAM(IDC_REFER, BN_CLICKED)) {
@@ -793,11 +795,12 @@
793795 };
794796 TCHAR uimsg[MAX_UIMSG];
795797 // TCHAR uitmp[MAX_UIMSG];
796- LOGFONTA logfont;
797- HFONT font;
798+// LOGFONTA logfont;
799+// HFONT font;
798800
799801 Dialog::onInitDialog();
800802
803+#if 0
801804 font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
802805 GetObject(font, sizeof(logfont), &logfont);
803806 if (UTIL_get_lang_font("DLG_TAHOMA_FONT", HWND(), &logfont, &DlgFont)) {
@@ -828,6 +831,7 @@
828831 else {
829832 DlgFont = NULL;
830833 }
834+#endif
831835
832836 HWND hWnd = (HWND)this;
833837 hWnd = GetHWND();
@@ -937,15 +941,19 @@
937941
938942 logfile = log.GetWindowTextLength() > 0 ? log.GetWindowText() : NULL;
939943
944+#if 0
940945 if (DlgFont != NULL) {
941946 DeleteObject(DlgFont);
942947 }
948+#endif
943949 Dialog::onOK();
944950 }
945951 virtual void onCancel() {
952+#if 0
946953 if (DlgFont != NULL) {
947954 DeleteObject(DlgFont);
948955 }
956+#endif
949957 Dialog::onCancel();
950958 }
951959 public:
@@ -974,7 +982,7 @@
974982 EditBoxCtrl user;
975983 EditBoxCtrl pass;
976984 bool lock;
977- HFONT DlgFont;
985+// HFONT DlgFont;
978986 protected:
979987 virtual bool dispatch(int message, int wParam, long lParam) {
980988 if (message == WM_COMMAND) {
@@ -997,11 +1005,12 @@
9971005 virtual bool onInitDialog() {
9981006 TCHAR uimsg[MAX_UIMSG];
9991007 // TCHAR uitmp[MAX_UIMSG];
1000- LOGFONTA logfont;
1001- HFONT font;
1008+// LOGFONTA logfont;
1009+// HFONT font;
10021010
10031011 Dialog::onInitDialog();
10041012
1013+#if 0
10051014 font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
10061015 GetObject(font, sizeof(logfont), &logfont);
10071016 if (UTIL_get_lang_font("DLG_TAHOMA_FONT", HWND(), &logfont, &DlgFont)) {
@@ -1024,7 +1033,7 @@
10241033 else {
10251034 DlgFont = NULL;
10261035 }
1027-
1036+#endif
10281037 const static DlgTextInfo text_info[] = {
10291038 { 0, "DLG_SETUP_TITLE" },
10301039 { IDC_URL_LABEL, "DLG_SETUP_URL" },
@@ -1131,15 +1140,19 @@
11311140 return;
11321141 }
11331142 }
1143+#if 0
11341144 if (DlgFont != NULL) {
11351145 DeleteObject(DlgFont);
11361146 }
1147+#endif
11371148 Dialog::onOK();
11381149 }
11391150 virtual void onCancel() {
1151+#if 0
11401152 if (DlgFont != NULL) {
11411153 DeleteObject(DlgFont);
11421154 }
1155+#endif
11431156 Dialog::onCancel();
11441157 }
11451158 void onOptions() {
@@ -1251,6 +1264,7 @@
12511264 const TCHAR *ver;
12521265 int n, a, b, c, d, len;
12531266 TCHAR uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG], uimsg3[MAX_UIMSG];
1267+#if 0
12541268 LOGFONTA logfont;
12551269 HFONT font;
12561270
@@ -1263,6 +1277,7 @@
12631277 else {
12641278 DlgFont = NULL;
12651279 }
1280+#endif
12661281
12671282 GetWindowText(uimsg2, _countof(uimsg2));
12681283 UTIL_get_lang_msg("DLG_ABOUT_TITLE", uimsg, _countof(uimsg), uimsg2);
--- branches/cmake/teraterm/common/dlglib.c (revision 7378)
+++ branches/cmake/teraterm/common/dlglib.c (revision 7379)
@@ -459,9 +459,8 @@
459459 LONG height;
460460 } DialogFontLists;
461461
462-DWORD GetDialogFontCandidate(const DialogFontLists **candidate_list)
462+const DialogFontLists *GetDialogFontCandidate(BYTE char_set)
463463 {
464- DWORD char_set = GetCharSet();
465464 switch (char_set) {
466465 case SHIFTJIS_CHARSET: {
467466 static const DialogFontLists list[] = {
@@ -471,8 +470,7 @@
471470 { _T("MS ゴシック"), -9 }, // Windows 3.1以降
472471 0
473472 };
474- *candidate_list = list;
475- return char_set;
473+ return list;
476474 }
477475 case HANGUL_CHARSET: {
478476 // Korean
@@ -481,8 +479,7 @@
481479 { _T("굴림"), -10 },
482480 0
483481 };
484- *candidate_list = list;
485- return char_set;
482+ return list;
486483 }
487484 case GB2312_CHARSET: {
488485 // Simplified Chinese
@@ -491,8 +488,7 @@
491488 { _T("微软雅黑") , -10 },
492489 0
493490 };
494- *candidate_list = list;
495- return char_set;
491+ return list;
496492 }
497493 case CHINESEBIG5_CHARSET: {
498494 // Traditional Chinese
@@ -501,8 +497,7 @@
501497 { _T("新細明體") , -10 },
502498 0
503499 };
504- *candidate_list = list;
505- return char_set;
500+ return list;
506501 }
507502 default: {
508503 static const DialogFontLists list[] = {
@@ -509,8 +504,7 @@
509504 { _T("Tahoma"), -8 },
510505 0
511506 };
512- *candidate_list = list;
513- return char_set;
507+ return list;
514508 }
515509 }
516510 }
@@ -520,15 +514,33 @@
520514 */
521515 void SetDialogFont(const char *section, const char *UILanguageFile)
522516 {
517+ BYTE char_set = SYMBOL_CHARSET; // symbolを使うことはないだろう
518+
523519 // 明示的に指定されている場合はそれに従う
524520 {
521+ static const char *dlg_font_keys[] = {
522+ "DLG_FONT",
523+ "DLG_TAHOMA_FONT",
524+ "DLG_SYSTEM_FONT",
525+ };
525526 BOOL result = FALSE;
526527 LOGFONTA logfont;
528+ int i;
527529 if (section != NULL) {
528- result = GetI18nLogfont(section, "DLG_FONT", &logfont, 72, UILanguageFile);
530+ for (i = 0; i < _countof(dlg_font_keys); i++) {
531+ result = GetI18nLogfont(section, "DLG_FONT", &logfont, 72, UILanguageFile);
532+ if (result == TRUE) {
533+ break;
534+ }
535+ }
529536 }
530537 if (result == FALSE) {
531- result = GetI18nLogfont("Tera Term", "DLG_FONT", &logfont, 72, UILanguageFile);
538+ for (i = 0; i < _countof(dlg_font_keys); i++) {
539+ result = GetI18nLogfont("Tera Term", "DLG_FONT", &logfont, 72, UILanguageFile);
540+ if (result == TRUE) {
541+ break;
542+ }
543+ }
532544 }
533545 if (result == TRUE) {
534546 #if defined(UNICODE)
@@ -544,6 +556,9 @@
544556 return;
545557 }
546558 #endif
559+
560+ // 使用したかったフォントのCharSetを取得
561+ char_set = logfont.lfCharSet;
547562 // TODO フォントが見つからなかったときの処理
548563 // messagebox()出して下へ続くが妥当か?
549564 }
@@ -551,14 +566,18 @@
551566
552567 // 実際に存在するフォントを使用する
553568 {
554- DWORD charset;
555- const DialogFontLists *list;
556- charset = GetDialogFontCandidate(&list);
569+ if (char_set == SYMBOL_CHARSET) {
570+ // 未設定の場合
571+ char_set = GetCharSet();
572+ }
573+ const DialogFontLists *list = GetDialogFontCandidate(char_set);
557574 while(list->face != NULL) {
558- if (IsExistFont(list->face, (BYTE)charset, TRUE)) {
559- TTSetDlgFont(list->face, list->height, charset);
575+ if (IsExistFont(list->face, char_set, TRUE)) {
576+ // 候補内に存在するフォントが存在した
577+ TTSetDlgFont(list->face, list->height, char_set);
560578 return;
561579 }
580+ list++;
562581 }
563582 }
564583
--- branches/cmake/teraterm/common/i18n.c (revision 7378)
+++ branches/cmake/teraterm/common/i18n.c (revision 7379)
@@ -1,4 +1,4 @@
1-/*
1+/*
22 * Copyright (C) 2006-2018 TeraTerm Project
33 * All rights reserved.
44 *
@@ -52,7 +52,7 @@
5252 RestoreNewLine(buf);
5353 }
5454
55-// TODO: バッファ不足時の動作
55+// TODO: ?o?b?t?@?s?????̓???
5656 DllExport void GetI18nStrU8(const char *section, const char *key, char *buf, int buf_len, const char *def, const char *iniFile)
5757 {
5858 int r;
@@ -88,8 +88,8 @@
8888 static char tmp[MAX_UIMSG];
8989 static char font[LF_FACESIZE];
9090 int hight, charset;
91- GetPrivateProfileStringA(section, key, "-", tmp, MAX_UIMSG, iniFile);
92- if (strcmp(tmp, "-") == 0) {
91+ GetPrivateProfileStringA(section, key, "", tmp, MAX_UIMSG, iniFile);
92+ if (tmp[0] == '\0') {
9393 return FALSE;
9494 }
9595
Show on old repository browser