[CONSOLE.CPL] Fix the console screen preview when selecting TrueType fonts.

CORE-13182 CORE-13196

- Use the correct character height & width.
- Additions: use StringCch*() when initializing the dialog title.

[CONSRV:CONCFG] Minor fixes.

- When retrieving font characteristics in ConCfgReadUserSettings(),
  check for NULL/zero values that indicate that we should use default
  ones instead.
- Rename 'dwNumSubKeys' into 'dwNumValues'.
This commit is contained in:
Hermès Bélusca-Maïto 2019-05-05 01:10:39 +02:00
parent fa63416d87
commit 2ebda0e3d0
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
5 changed files with 59 additions and 47 deletions

View file

@ -120,7 +120,7 @@ ConCfgOpenUserSettings(
Status = RtlOpenCurrentUser(/*samDesired*/MAXIMUM_ALLOWED, (PHANDLE)&/*CurrentUserKeyHandle*/hKey);
if (!NT_SUCCESS(Status))
{
DPRINT1("RtlOpenCurrentUser failed, Status = 0x%08lx\n", Status);
DPRINT1("RtlOpenCurrentUser() failed, Status = 0x%08lx\n", Status);
SetLastError(RtlNtStatusToDosError(Status));
return FALSE;
}
@ -170,7 +170,7 @@ ConCfgReadUserSettings(
{
BOOLEAN Success = FALSE;
HKEY hKey;
DWORD dwNumSubKeys = 0;
DWORD dwNumValues = 0;
DWORD dwIndex;
DWORD dwColorIndex = 0;
DWORD dwType;
@ -183,21 +183,21 @@ ConCfgReadUserSettings(
if (!ConCfgOpenUserSettings(DefaultSettings ? L"" : ConsoleInfo->ConsoleTitle,
&hKey, KEY_READ, FALSE))
{
DPRINT("ConCfgOpenUserSettings failed\n");
DPRINT("ConCfgOpenUserSettings() failed\n");
return FALSE;
}
if (RegQueryInfoKeyW(hKey, NULL, NULL, NULL, NULL, NULL, NULL,
&dwNumSubKeys, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
&dwNumValues, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
{
DPRINT("ConCfgReadUserSettings: RegQueryInfoKeyW failed\n");
DPRINT("ConCfgReadUserSettings: RegQueryInfoKeyW() failed\n");
RegCloseKey(hKey);
return FALSE;
}
DPRINT("ConCfgReadUserSettings entered dwNumSubKeys %d\n", dwNumSubKeys);
DPRINT("ConCfgReadUserSettings() entered, dwNumValues %d\n", dwNumValues);
for (dwIndex = 0; dwIndex < dwNumSubKeys; dwIndex++)
for (dwIndex = 0; dwIndex < dwNumValues; dwIndex++)
{
dwValue = sizeof(Value);
dwValueName = ARRAYSIZE(szValueName);
@ -238,24 +238,36 @@ ConCfgReadUserSettings(
}
else if (!wcscmp(szValueName, L"FaceName"))
{
StringCchCopyNW(ConsoleInfo->FaceName, ARRAYSIZE(ConsoleInfo->FaceName),
szValue, ARRAYSIZE(szValue));
/* A NULL value means that the defaults should be used instead */
if (*szValue)
{
StringCchCopyNW(ConsoleInfo->FaceName, ARRAYSIZE(ConsoleInfo->FaceName),
szValue, ARRAYSIZE(szValue));
}
Success = TRUE;
}
else if (!wcscmp(szValueName, L"FontFamily"))
{
ConsoleInfo->FontFamily = Value;
/* A zero value means that the defaults should be used instead */
if (Value)
ConsoleInfo->FontFamily = Value;
Success = TRUE;
}
else if (!wcscmp(szValueName, L"FontSize"))
{
ConsoleInfo->FontSize.X = LOWORD(Value); // Width
ConsoleInfo->FontSize.Y = HIWORD(Value); // Height
/* A zero value means that the defaults should be used instead */
if (Value)
{
ConsoleInfo->FontSize.X = LOWORD(Value); // Width
ConsoleInfo->FontSize.Y = HIWORD(Value); // Height
}
Success = TRUE;
}
else if (!wcscmp(szValueName, L"FontWeight"))
{
ConsoleInfo->FontWeight = Value;
/* A zero value means that the defaults should be used instead */
if (Value)
ConsoleInfo->FontWeight = Value;
Success = TRUE;
}
else if (!wcscmp(szValueName, L"HistoryBufferSize"))