Skip to content

Commit

Permalink
Merge pull request #99 from Tatsu-syo/tatsu_develop
Browse files Browse the repository at this point in the history
Windows 11 2023 Update title update
  • Loading branch information
Tatsu-syo authored Nov 12, 2023
2 parents b81b1ca + ee52e66 commit ef7986d
Show file tree
Hide file tree
Showing 12 changed files with 290 additions and 108 deletions.
14 changes: 11 additions & 3 deletions program/FontSel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ The sources for noMeiryoUI are distributed under the MIT open source license
#include <algorithm>
#include <functional>

#include "country/Japan.h"
#include "country/korea.h"

/** フォントのリスト */
std::vector<struct FontInfo> fontList;
/** 文字セットと対応するスタイルのリスト */
Expand Down Expand Up @@ -215,8 +218,8 @@ int CALLBACK EnumFontFamExProc(
// fontInfo.charsetList.clear();

_tcscpy(dispBuf, lpelfe->elfLogFont.lfFaceName);
if (isKorean) {
getKoreanFontName(dispBuf);
if (runningCountry == Korea) {
korea::getKoreanFontName(dispBuf);
}
_tcscpy(fontInfo.dispName, dispBuf);
fontList.push_back(fontInfo);
Expand Down Expand Up @@ -460,6 +463,11 @@ INT_PTR FontSel::OnCommand(WPARAM wParam)
void FontSel::applyResource()
{
HDC hDC = GetDC(this->hWnd);
tstring font = langResource[0];

if (runningCountry == Japan) {
font = japan::getJapaneseFontFallback(langResource[0]);
}

displayFont = CreateFont(
-MulDiv(APP_FONTSIZE, GetDeviceCaps(hDC, LOGPIXELSY), 72),
Expand All @@ -475,7 +483,7 @@ void FontSel::applyResource()
CLIP_DEFAULT_PRECIS,
PROOF_QUALITY, // CLEARTYPE_QUALITY,
FIXED_PITCH | FF_MODERN,
langResource[0].c_str());
font.c_str());

ReleaseDC(this->hWnd, hDC);

Expand Down
85 changes: 85 additions & 0 deletions program/country/japan.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#include <windows.h>
#include "japan.h"

namespace japan {

/**
* @brief 必要とされる文字列
*/
tstring _neededString;

/**
* Charsetに対するEnumFontFamiliesExのコールバック
*
* @param lpelfe 論理的なフォントデータ
* @param lpntme 物理的なフォントデータ
* @param FontType フォントの種類
* @param lParam アプリケーション定義のデータ
* @return 0:列挙を中止する 1:次のフォントを列挙する。
*/
int CALLBACK EnumFontCharsetProc(
ENUMLOGFONTEX *lpelfe, // 論理的なフォントデータ
NEWTEXTMETRICEX *lpntme, // 物理的なフォントデータ
DWORD FontType, // フォントの種類
LPARAM lParam // アプリケーション定義のデータ
)
{
if (_neededString == lpelfe->elfFullName) {
return 0;
}

return 1;

}

/**
* Charsetに対するフォントを取得する
*
* @return 0:フォントが存在する 1:フォントは存在しない
*/
int findCharsetFont()
{
LOGFONT lf;

lf.lfPitchAndFamily = 0;
lf.lfCharSet = DEFAULT_CHARSET;

HDC hDC;
hDC = GetDC(GetDesktopWindow());

int found = 1;
found = ::EnumFontFamiliesEx(
hDC,
&lf,
(FONTENUMPROC)EnumFontCharsetProc,
(LPARAM)0,
0
);

return found;
}

tstring getJapaneseFontFallback(tstring &settingString)
{
int result = 1;

_neededString = settingString;

result = findCharsetFont();
if (result == 0) {
return settingString;
}

_neededString = _T("游ゴシック");
result = findCharsetFont();
if (result == 0) {
return _neededString;
}

_neededString = _T("MS UI Gothic");

return _neededString;

}

}
16 changes: 16 additions & 0 deletions program/country/japan.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
noMeiryoUI (C) 2005,2012-2023 Tatsuhiko Shoji
The sources for noMeiryoUI are distributed under the MIT open source license
*/

#pragma once

#include <string.h>
#include <tchar.h>
#include <tstring.h>

namespace japan {

extern tstring getJapaneseFontFallback(tstring &settingString);

};
57 changes: 57 additions & 0 deletions program/country/korea.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
noMeiryoUI (C) 2005,2012-2023 Tatsuhiko Shoji
The sources for noMeiryoUI are distributed under the MIT open source license
*/
#include <string.h>
#include <tchar.h>
#include <tstring.h>

namespace korea {

/**
* 韓国語のフォント名を置き換える(韓国語専用)
*
* @param dispBuf 韓国語のフォント名
*/
void getKoreanFontName(TCHAR *dispBuf)
{
if (!_tcscmp(dispBuf, _T("Gulim"))) {
_tcscpy(dispBuf, _T("굴림"));
}

if (!_tcscmp(dispBuf, _T("GulimChe"))) {
_tcscpy(dispBuf, _T("굴림체"));
}

if (!_tcscmp(dispBuf, _T("Gungsuh"))) {
_tcscpy(dispBuf, _T("궁서"));
}

if (!_tcscmp(dispBuf, _T("GungsuhChe"))) {
_tcscpy(dispBuf, _T("궁서체"));
}

if (!_tcscmp(dispBuf, _T("Dotum"))) {
_tcscpy(dispBuf, _T("돋움"));
}

if (!_tcscmp(dispBuf, _T("DotumChe"))) {
_tcscpy(dispBuf, _T("돋움체"));
}

if (!_tcscmp(dispBuf, _T("Malgun Gothic"))) {
_tcscpy(dispBuf, _T("맑은 고딕"));
}

if (!_tcscmp(dispBuf, _T("Batang"))) {
_tcscpy(dispBuf, _T("바탕"));
}

if (!_tcscmp(dispBuf, _T("BatangChe"))) {
_tcscpy(dispBuf, _T("바탕체"));
}

}

}

9 changes: 9 additions & 0 deletions program/country/korea.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
noMeiryoUI (C) 2005,2012-2023 Tatsuhiko Shoji
The sources for noMeiryoUI are distributed under the MIT open source license
*/
namespace korea {

void getKoreanFontName(TCHAR *dispBuf);

};
59 changes: 39 additions & 20 deletions program/noMeiryoUI.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
noMeiryoUI (C) 2005,2012-2022 Tatsuhiko Shoji
noMeiryoUI (C) 2005,2012-2023 Tatsuhiko Shoji
The sources for noMeiryoUI are distributed under the MIT open source license
*/
// noMeiryoUI.cpp : アプリケーションのエントリ ポイントを定義します。
Expand All @@ -21,6 +21,9 @@ The sources for noMeiryoUI are distributed under the MIT open source license
#include "NCFileDialog.h"
#include "util.h"

// #include "country\japan.h"
#include "country\korea.h"

//
// ダイアログベースアプリケーションフレームワークと
// ユーザー実装のブリッジルーチン
Expand Down Expand Up @@ -134,8 +137,11 @@ void setResourceFileName(TCHAR * langFileName, TCHAR * helpFileName, char*system
}

// Language detection
if (wcsstr(langWork, L"ja-JP") != NULL) {
runningCountry = Japan;
}
if (wcsstr(langWork, L"ko-KR") != NULL) {
isKorean = true;
runningCountry = Korea;
}

_tcscpy(findPath, iniPath);
Expand Down Expand Up @@ -563,8 +569,8 @@ void NoMeiryoUI::adjustWindowSize(void)
int width;
int height;

width = 614 * scale + nowMetrics.iBorderWidth * 2;
height = 398 * scale +
width = 740 * scale + nowMetrics.iBorderWidth * 2;
height = 410 * scale +
nowMetrics.iCaptionHeight +
nowMetrics.iMenuHeight +
nowMetrics.iBorderWidth * 2;
Expand Down Expand Up @@ -810,6 +816,15 @@ void NoMeiryoUI::applyResource()
{
HDC hDC = GetDC(this->hWnd);

tstring font = langResource[0];

#if 0
// Under construction
if (runningCountry == Japan) {
font = japan::getJapaneseFontFallback(langResource[0]);
}
#endif

HFONT displayFont = CreateFont(
-MulDiv(APP_FONTSIZE, GetDeviceCaps(hDC, LOGPIXELSY), 72),
0,
Expand All @@ -824,7 +839,7 @@ void NoMeiryoUI::applyResource()
CLIP_DEFAULT_PRECIS,
PROOF_QUALITY, // CLEARTYPE_QUALITY,
FIXED_PITCH | FF_MODERN,
langResource[0].c_str());
font.c_str());

ReleaseDC(this->hWnd, hDC);

Expand Down Expand Up @@ -916,59 +931,59 @@ void NoMeiryoUI::updateDisplay(void)
TCHAR dispName[32];

allFontName = metricsAll.lfMenuFont.lfFaceName;
if (isKorean) {
if (runningCountry == Korea) {
_tcscpy(dispName, allFontName.c_str());
getKoreanFontName(dispName);
korea::getKoreanFontName(dispName);
allFontName = dispName;
}
point = getFontPointInt(&(metricsAll.lfMenuFont), this->getHwnd());
_stprintf(buf, _T(" %3dpt"), point);
allFontName = allFontName + buf;

titleFontName = metrics.lfCaptionFont.lfFaceName;
if (isKorean) {
if (runningCountry == Korea) {
_tcscpy(dispName, titleFontName.c_str());
getKoreanFontName(dispName);
korea::getKoreanFontName(dispName);
titleFontName = dispName;
}
point = getFontPointInt(&(metrics.lfCaptionFont), this->getHwnd());
_stprintf(buf, _T(" %3dpt"), point);
titleFontName = titleFontName + buf;

iconFontName = iconFont.lfFaceName;
if (isKorean) {
if (runningCountry == Korea) {
_tcscpy(dispName, iconFontName.c_str());
getKoreanFontName(dispName);
korea::getKoreanFontName(dispName);
iconFontName = dispName;
}
point = getFontPointInt(&iconFont, this->getHwnd());
_stprintf(buf, _T(" %3dpt"), point);
iconFontName = iconFontName + buf;

paletteFontName = metrics.lfSmCaptionFont.lfFaceName;
if (isKorean) {
if (runningCountry == Korea) {
_tcscpy(dispName, paletteFontName.c_str());
getKoreanFontName(dispName);
korea::getKoreanFontName(dispName);
paletteFontName = dispName;
}
point = getFontPointInt(&metrics.lfSmCaptionFont, this->getHwnd());
_stprintf(buf, _T(" %3dpt"), point);
paletteFontName = paletteFontName + buf;

hintFontName = metrics.lfStatusFont.lfFaceName;
if (isKorean) {
if (runningCountry == Korea) {
_tcscpy(dispName, hintFontName.c_str());
getKoreanFontName(dispName);
korea::getKoreanFontName(dispName);
hintFontName = dispName;
}
point = getFontPointInt(&metrics.lfStatusFont, this->getHwnd());
_stprintf(buf, _T(" %3dpt"), point);
hintFontName = hintFontName + buf;

messageFontName = metrics.lfMessageFont.lfFaceName;
if (isKorean) {
if (runningCountry == Korea) {
_tcscpy(dispName, messageFontName.c_str());
getKoreanFontName(dispName);
korea::getKoreanFontName(dispName);
messageFontName = dispName;
}
point = getFontPointInt(&metrics.lfMessageFont, this->getHwnd());
Expand All @@ -977,9 +992,9 @@ void NoMeiryoUI::updateDisplay(void)

// メニューと選択項目
menuFontName = metrics.lfMenuFont.lfFaceName;
if (isKorean) {
if (runningCountry == Korea) {
_tcscpy(dispName, menuFontName.c_str());
getKoreanFontName(dispName);
korea::getKoreanFontName(dispName);
menuFontName = dispName;
}
point = getFontPointInt(&metrics.lfMenuFont, this->getHwnd());
Expand Down Expand Up @@ -2483,7 +2498,11 @@ void NoMeiryoUI::getWin10Ver(TCHAR *buf, DWORD major, DWORD minor)
break;
case 11:
_tcscpy_s(calledVer, _T("11"));
if (buildNumber >= 22621) {
if (buildNumber > 22631) {
_tcscat_s(calledVer, _T(" Insider"));
} else if (buildNumber == 22631) {
_tcscat_s(calledVer, _T(" 2023 Update"));
} else if (buildNumber >= 22621) {
_tcscat_s(calledVer, _T(" 2022 Update"));
}
break;
Expand Down
Loading

0 comments on commit ef7986d

Please sign in to comment.