https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b539dd1c5a9b5f83a82e5…
commit b539dd1c5a9b5f83a82e57d9af4d3110e1e4eed8
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Fri Feb 14 10:47:20 2020 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Fri Feb 14 10:47:20 2020 +0900
[USETUP][BOOTDATA] Include optional CJK standard fonts (#2336)
This PR enables the developers to include the CJK standard fonts into ReactOS by
adding them in Folder modules/optional. This feature is for test purpose only. You may not
use the fonts illegally.
The embeddable font files are: mingliu.ttc, simsun.ttc, mssong.ttf, msgothic.ttc,
msmincho.ttc, gulim.ttc and batang.ttc.
CORE-9619
---
base/setup/lib/mui.c | 81 +++++++++++++++++++++++++++----
base/setup/lib/muifonts.h | 91 +++++++++++++++++++++++++++++++++++
base/setup/lib/setuplib.c | 11 ++++-
base/setup/lib/setuplib.h | 5 +-
base/setup/lib/substset.h | 15 ++++++
base/setup/usetup/usetup.c | 59 ++++++++++++++++++++++-
boot/bootdata/packages/reactos.dff.in | 7 +++
7 files changed, 256 insertions(+), 13 deletions(-)
diff --git a/base/setup/lib/mui.c b/base/setup/lib/mui.c
index 27b85b46b99..8b511cfa56a 100644
--- a/base/setup/lib/mui.c
+++ b/base/setup/lib/mui.c
@@ -31,6 +31,7 @@
#include "muifonts.h"
#include "muilanguages.h"
#include "registry.h"
+#include "substset.h"
#define NDEBUG
#include <debug.h>
@@ -498,17 +499,28 @@ AddFontsSettingsToRegistry(
while (MuiSubFonts[uIndex].FontName != NULL)
{
RtlInitUnicodeString(&ValueName, MuiSubFonts[uIndex].FontName);
- Status = NtSetValueKey(KeyHandle,
- &ValueName,
- 0,
- REG_SZ,
- (PVOID)MuiSubFonts[uIndex].SubFontName,
- (wcslen(MuiSubFonts[uIndex].SubFontName)+1) *
sizeof(WCHAR));
- if (!NT_SUCCESS(Status))
+ if (MuiSubFonts[uIndex].SubFontName)
{
- DPRINT1("NtSetValueKey() failed (Status = %lx, uIndex = %d)\n",
Status, uIndex);
- NtClose(KeyHandle);
- return FALSE;
+ Status = NtSetValueKey(KeyHandle,
+ &ValueName,
+ 0,
+ REG_SZ,
+ (PVOID)MuiSubFonts[uIndex].SubFontName,
+ (wcslen(MuiSubFonts[uIndex].SubFontName)+1) *
sizeof(WCHAR));
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("NtSetValueKey() failed (Status = %lx, uIndex = %d)\n",
Status, uIndex);
+ NtClose(KeyHandle);
+ return FALSE;
+ }
+ }
+ else
+ {
+ Status = NtDeleteValueKey(KeyHandle, &ValueName);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("NtDeleteValueKey failed, Status = %lx\n", Status);
+ }
}
uIndex++;
@@ -548,4 +560,53 @@ AddCodePage(
return FALSE;
}
+#ifdef __REACTOS__ /* HACK */
+BOOL
+DoRegistryFontFixup(PFONTSUBSTSETTINGS pSettings, LANGID LangID)
+{
+ if (pSettings->bFoundFontMINGLIU)
+ AddFontsSettingsToRegistry(FontFixupMINGLIU);
+ if (pSettings->bFoundFontSIMSUN)
+ AddFontsSettingsToRegistry(FontFixupSIMSUN);
+ if (pSettings->bFoundFontMSSONG)
+ AddFontsSettingsToRegistry(FontFixupMSSONG);
+ if (pSettings->bFoundFontMSGOTHIC)
+ AddFontsSettingsToRegistry(FontFixupMSGOTHIC);
+ if (pSettings->bFoundFontMSMINCHO)
+ AddFontsSettingsToRegistry(FontFixupMSMINCHO);
+ if (pSettings->bFoundFontGULIM)
+ AddFontsSettingsToRegistry(FontFixupGULIM);
+ if (pSettings->bFoundFontBATANG)
+ AddFontsSettingsToRegistry(FontFixupBATANG);
+
+ switch (PRIMARYLANGID(LangID))
+ {
+ case LANG_CHINESE:
+ if (SUBLANGID(LangID) == SUBLANG_CHINESE_SIMPLIFIED)
+ {
+ if (pSettings->bFoundFontSIMSUN)
+ AddFontsSettingsToRegistry(SimplifiedChineseFontFixup);
+ }
+ else
+ {
+ if (pSettings->bFoundFontMINGLIU)
+ AddFontsSettingsToRegistry(TraditionalChineseFontFixup);
+ }
+ break;
+
+ case LANG_JAPANESE:
+ if (pSettings->bFoundFontMSGOTHIC)
+ AddFontsSettingsToRegistry(JapaneseFontFixup);
+ break;
+
+ case LANG_KOREAN:
+ if (pSettings->bFoundFontBATANG)
+ AddFontsSettingsToRegistry(KoreanFontFixup);
+ break;
+ }
+
+ return TRUE;
+}
+#endif /* HACK */
+
/* EOF */
diff --git a/base/setup/lib/muifonts.h b/base/setup/lib/muifonts.h
index 45cca3f03eb..258cae7e1b5 100644
--- a/base/setup/lib/muifonts.h
+++ b/base/setup/lib/muifonts.h
@@ -407,3 +407,94 @@ MUI_SUBFONT HindiFonts[] =
{ L"Tms Rmn", L"Times New Roman" },
{ NULL, NULL }
};
+
+MUI_SUBFONT SimplifiedChineseFontFixup[] =
+{
+ { L"MS Shell Dlg", L"SimSun" },
+ { L"Tahoma", L"SimSun" },
+ { NULL, NULL }
+};
+
+MUI_SUBFONT TraditionalChineseFontFixup[] =
+{
+ { L"MS Shell Dlg", L"PMingLiU" },
+ { L"Tahoma", L"PMingLiU" },
+ { NULL, NULL }
+};
+
+MUI_SUBFONT JapaneseFontFixup[] =
+{
+ { L"MS Shell Dlg", L"MS UI Gothic" },
+ { L"Tahoma", L"MS UI Gothic" },
+ { NULL, NULL }
+};
+
+MUI_SUBFONT KoreanFontFixup[] =
+{
+ { L"MS Shell Dlg", L"Batang" },
+ { L"Tahoma", L"Batang" },
+ { NULL, NULL }
+};
+
+MUI_SUBFONT FontFixupMINGLIU[] =
+{
+ { L"MingLiU", NULL },
+ { L"PMingLiU", NULL },
+ { CTF_LocalName0, NULL },
+ { CTF_LocalName1, NULL },
+ { NULL, NULL }
+};
+
+MUI_SUBFONT FontFixupSIMSUN[] =
+{
+ { L"NSimSun", NULL },
+ { L"SimSun", NULL },
+ { CSF_LocalName0, NULL },
+ { CSF_LocalName1, NULL },
+ { CSF_LocalName2, NULL },
+ { NULL, NULL }
+};
+
+MUI_SUBFONT FontFixupMSSONG[] =
+{
+ { L"MS Song", NULL },
+ { CSF_LocalName4, NULL },
+ { NULL, NULL }
+};
+
+MUI_SUBFONT FontFixupMSGOTHIC[] =
+{
+ { L"MS Gothic", NULL },
+ { L"MS PGothic", NULL },
+ { L"MS UI Gothic", NULL },
+ { JF_LocalName2, NULL },
+ { JF_LocalName3, NULL },
+ { NULL, NULL }
+};
+
+MUI_SUBFONT FontFixupMSMINCHO[] =
+{
+ { L"MS Mincho", NULL },
+ { L"MS PMincho", NULL },
+ { JF_LocalName0, NULL },
+ { JF_LocalName1, NULL },
+ { NULL, NULL }
+};
+
+MUI_SUBFONT FontFixupGULIM[] =
+{
+ { L"Gulim", NULL },
+ { L"GulimChe", NULL },
+ { KF_LocalName4, NULL },
+ { KF_LocalName5, NULL },
+ { NULL, NULL }
+};
+
+MUI_SUBFONT FontFixupBATANG[] =
+{
+ { L"Batang", NULL},
+ { L"BatangChe", NULL},
+ { KF_LocalName0, NULL},
+ { KF_LocalName1, NULL},
+ { NULL, NULL }
+};
diff --git a/base/setup/lib/setuplib.c b/base/setup/lib/setuplib.c
index be71e8191c0..0c3590e38e4 100644
--- a/base/setup/lib/setuplib.c
+++ b/base/setup/lib/setuplib.c
@@ -917,7 +917,8 @@ UpdateRegistry(
/**/IN PPARTLIST PartitionList, /* HACK HACK! */
/**/IN WCHAR DestinationDriveLetter, /* HACK HACK! */
/**/IN PCWSTR SelectedLanguageId, /* HACK HACK! */
- IN PREGISTRY_STATUS_ROUTINE StatusRoutine OPTIONAL)
+ IN PREGISTRY_STATUS_ROUTINE StatusRoutine OPTIONAL,
+ IN PFONTSUBSTSETTINGS SubstSettings OPTIONAL)
{
ERROR_NUMBER ErrorNumber;
NTSTATUS Status;
@@ -1113,6 +1114,14 @@ DoUpdate:
SetMountedDeviceValues(PartitionList);
}
+#ifdef __REACTOS__
+ if (SubstSettings)
+ {
+ /* HACK */
+ DoRegistryFontFixup(SubstSettings, wcstoul(SelectedLanguageId, NULL, 16));
+ }
+#endif
+
Cleanup:
//
// TODO: Unload all the registry stuff, perform cleanup,
diff --git a/base/setup/lib/setuplib.h b/base/setup/lib/setuplib.h
index 97eac01236f..7149d1ffb31 100644
--- a/base/setup/lib/setuplib.h
+++ b/base/setup/lib/setuplib.h
@@ -137,6 +137,8 @@ extern BOOLEAN IsUnattendedSetup;
/* FUNCTIONS ****************************************************************/
+#include "substset.h"
+
VOID
CheckUnattendedSetup(
IN OUT PUSETUP_DATA pSetupData);
@@ -194,6 +196,7 @@ UpdateRegistry(
/**/IN PPARTLIST PartitionList, /* HACK HACK! */
/**/IN WCHAR DestinationDriveLetter, /* HACK HACK! */
/**/IN PCWSTR SelectedLanguageId, /* HACK HACK! */
- IN PREGISTRY_STATUS_ROUTINE StatusRoutine OPTIONAL);
+ IN PREGISTRY_STATUS_ROUTINE StatusRoutine OPTIONAL,
+ IN PFONTSUBSTSETTINGS SubstSettings OPTIONAL);
/* EOF */
diff --git a/base/setup/lib/substset.h b/base/setup/lib/substset.h
new file mode 100644
index 00000000000..4dbf385fa90
--- /dev/null
+++ b/base/setup/lib/substset.h
@@ -0,0 +1,15 @@
+#pragma once
+
+typedef struct _FONTSUBSTSETTINGS
+{
+ BOOL bFoundFontMINGLIU;
+ BOOL bFoundFontSIMSUN;
+ BOOL bFoundFontMSSONG;
+ BOOL bFoundFontMSGOTHIC;
+ BOOL bFoundFontMSMINCHO;
+ BOOL bFoundFontGULIM;
+ BOOL bFoundFontBATANG;
+} FONTSUBSTSETTINGS, *PFONTSUBSTSETTINGS;
+
+BOOL
+DoRegistryFontFixup(PFONTSUBSTSETTINGS pSettings, LANGID LangID);
diff --git a/base/setup/usetup/usetup.c b/base/setup/usetup/usetup.c
index 7ff48936626..cdd6a3e4f74 100644
--- a/base/setup/usetup/usetup.c
+++ b/base/setup/usetup/usetup.c
@@ -87,6 +87,59 @@ static FORMATMACHINESTATE FormatState = Start;
static PNTOS_INSTALLATION CurrentInstallation = NULL;
static PGENERIC_LIST NtOsInstallsList = NULL;
+#ifdef __REACTOS__ /* HACK */
+
+/* FONT SUBSTITUTION WORKAROUND *************************************************/
+
+/* For font file check */
+FONTSUBSTSETTINGS s_SubstSettings = { FALSE };
+
+static void
+DoWatchDestFileName(LPCWSTR FileName)
+{
+ if (FileName[0] == 'm' || FileName[0] == 'M')
+ {
+ if (wcsicmp(FileName, L"mingliu.ttc") == 0)
+ {
+ DPRINT("mingliu.ttc found\n");
+ s_SubstSettings.bFoundFontMINGLIU = TRUE;
+ }
+ else if (wcsicmp(FileName, L"msgothic.ttc") == 0)
+ {
+ DPRINT("msgothic.ttc found\n");
+ s_SubstSettings.bFoundFontMSGOTHIC = TRUE;
+ }
+ else if (wcsicmp(FileName, L"msmincho.ttc") == 0)
+ {
+ DPRINT("msmincho.ttc found\n");
+ s_SubstSettings.bFoundFontMSMINCHO = TRUE;
+ }
+ else if (wcsicmp(FileName, L"mssong.ttf") == 0)
+ {
+ DPRINT("mssong.ttf found\n");
+ s_SubstSettings.bFoundFontMSSONG = TRUE;
+ }
+ }
+ else
+ {
+ if (wcsicmp(FileName, L"simsun.ttc") == 0)
+ {
+ DPRINT("simsun.ttc found\n");
+ s_SubstSettings.bFoundFontSIMSUN = TRUE;
+ }
+ else if (wcsicmp(FileName, L"gulim.ttc") == 0)
+ {
+ DPRINT("gulim.ttc found\n");
+ s_SubstSettings.bFoundFontGULIM = TRUE;
+ }
+ else if (wcsicmp(FileName, L"batang.ttc") == 0)
+ {
+ DPRINT("batang.ttc found\n");
+ s_SubstSettings.bFoundFontBATANG = TRUE;
+ }
+ }
+}
+#endif /* HACK */
/* FUNCTIONS ****************************************************************/
@@ -4060,6 +4113,9 @@ FileCopyCallback(PVOID Context,
CONSOLE_SetStatusText(MUIGetString(STRING_COPYING),
DstFileName);
+#ifdef __REACTOS__ /* HACK */
+ DoWatchDestFileName(DstFileName);
+#endif
}
SetupUpdateMemoryInfo(CopyContext, FALSE);
@@ -4237,7 +4293,8 @@ RegistryPage(PINPUT_RECORD Ir)
PartitionList,
InstallPartition->DriveLetter,
SelectedLanguageId,
- RegistryStatus);
+ RegistryStatus,
+ &s_SubstSettings);
if (Error != ERROR_SUCCESS)
{
MUIDisplayError(Error, Ir, POPUP_WAIT_ENTER);
diff --git a/boot/bootdata/packages/reactos.dff.in
b/boot/bootdata/packages/reactos.dff.in
index 9fef574ae77..349953553fa 100644
--- a/boot/bootdata/packages/reactos.dff.in
+++ b/boot/bootdata/packages/reactos.dff.in
@@ -94,6 +94,13 @@ Signature = "$Windows NT$"
; Optional/proprietary files
"modules/optional/DroidSansFallback.ttf" 4 optional
+"modules/optional/mingliu.ttc" 4 optional
+"modules/optional/simsun.ttc" 4 optional
+"modules/optional/mssong.ttf" 4 optional
+"modules/optional/msgothic.ttc" 4 optional
+"modules/optional/msmincho.ttc" 4 optional
+"modules/optional/gulim.ttc" 4 optional
+"modules/optional/batang.ttc" 4 optional
"modules/optional/NOTICE_for_Droid_Font.txt" 1 optional
"modules/optional/netkvm.inf" 6 optional
"modules/optional/netkvm.cat" 6 optional