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

[WIN32SS][FONT] Fix the system logical stock font data #709

Merged
merged 17 commits into from Aug 10, 2018
Merged
Show file tree
Hide file tree
Changes from 10 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
1 change: 1 addition & 0 deletions win32ss/gdi/gdi32/objects/font.c
Expand Up @@ -1978,6 +1978,7 @@ TranslateCharsetInfo(
while (index < MAXTCIINDEX && !(*lpSrc>>index & 0x0001)) index++;
break;
case TCI_SRCCODEPAGE:
/* ciACP is also referred by IntCharSetFromCodePage() function */
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually I was thinking about adding the comment in IntCharSetFromCodePage(), not here.

while (index < MAXTCIINDEX && PtrToUlong(lpSrc) != FONT_tci[index].ciACP) index++;
break;
case TCI_SRCCHARSET:
Expand Down
27 changes: 27 additions & 0 deletions win32ss/gdi/ntgdi/freetype.c
Expand Up @@ -160,6 +160,33 @@ static const CHARSETINFO g_FontTci[MAXTCIINDEX] =
{ SYMBOL_CHARSET, CP_SYMBOL, {{0,0,0,0},{FS_SYMBOL,0}} }
};

#ifndef CP_OEMCP
#define CP_OEMCP 1
#define CP_MACCP 2
#endif

BYTE FASTCALL IntCharSetFromCodePage(UINT uCodePage)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest to add a comment that refers to gdi/gdi32/objects/font.c!TranslateCharsetInfo() function, in the TCI_SRCCODEPAGE case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK.

{
UINT i;

if (uCodePage == CP_OEMCP)
return OEM_CHARSET;

if (uCodePage == CP_MACCP)
return MAC_CHARSET;

for (i = 0; i < MAXTCIINDEX; ++i)
{
if (g_FontTci[i].ciACP == 0)
continue;

if (g_FontTci[i].ciACP == uCodePage)
return g_FontTci[i].ciCharset;
}

return DEFAULT_CHARSET;
}

/* list head */
static RTL_STATIC_LIST_HEAD(g_FontSubstListHead);

Expand Down
106 changes: 91 additions & 15 deletions win32ss/gdi/ntgdi/stockobj.c
Expand Up @@ -3,7 +3,8 @@
* LICENSE: GPL - See COPYING in the top level directory
* FILE: win32ss/gdi/ntgdi/stockobj.c
* PURPOSE: Stock objects functions
* PROGRAMMER:
* PROGRAMMERS: Colin Finck <colin@reactos.org>
* Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
*/

#include <win32k.h>
Expand Down Expand Up @@ -67,32 +68,32 @@ static LOGFONTW OEMFixedFont =
};

static LOGFONTW AnsiFixedFont =
{ 14, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
{ 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
OUT_DEFAULT_PRECIS, /*CLIP_DEFAULT_PRECIS*/ CLIP_STROKE_PRECIS, /*DEFAULT_QUALITY*/ PROOF_QUALITY, FF_DONTCARE | FIXED_PITCH, L"Courier"
};

static LOGFONTW AnsiVarFont =
{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
{ 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
OUT_DEFAULT_PRECIS, /*CLIP_DEFAULT_PRECIS*/ CLIP_STROKE_PRECIS, /*DEFAULT_QUALITY*/ PROOF_QUALITY, FF_DONTCARE | VARIABLE_PITCH, L"MS Sans Serif"
};

static LOGFONTW SystemFont =
{ 12, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET,
{ 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE | VARIABLE_PITCH, L"System"
};

static LOGFONTW DeviceDefaultFont =
{ 12, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE | VARIABLE_PITCH, L"System"
{ 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_SWISS | VARIABLE_PITCH, L"System"
};

static LOGFONTW SystemFixedFont =
{ 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
{ 15, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE | FIXED_PITCH, L"Fixedsys"
};

static LOGFONTW DefaultGuiFont =
{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
{ -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, /*DEFAULT_QUALITY*/ PROOF_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
};

Expand Down Expand Up @@ -140,6 +141,87 @@ IntCreateStockPen(DWORD dwPenStyle,
return hPen;
}

static VOID FASTCALL
CreateStockFonts(void)
{
USHORT ActiveCodePage, OemCodePage;
BYTE bActiveCharSet, bOemCharSet;
static const WCHAR SimSun[] = { 0x5B8B, 0x4F53, 0 };
static const WCHAR MingLiU[] = { 0x7D30, 0x660E, 0x9AD4 };
static const WCHAR Batang[] = { 0xBC14, 0xD0D5 };
Copy link
Member

Choose a reason for hiding this comment

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

Both MingLiU and Batang need a null-terminator, if they are used with wcscpy.


RtlGetDefaultCodePage(&ActiveCodePage, &OemCodePage);
bActiveCharSet = IntCharSetFromCodePage(ActiveCodePage);
bOemCharSet = IntCharSetFromCodePage(OemCodePage);

if (bOemCharSet == DEFAULT_CHARSET)
bOemCharSet = OEM_CHARSET;

switch (ActiveCodePage)
{
case 936:
/* Simplified Chinese */
wcscpy(DefaultGuiFont.lfFaceName, SimSun);
DefaultGuiFont.lfHeight = -12;
SystemFont.lfPitchAndFamily = FF_DONTCARE | VARIABLE_PITCH;
SystemFixedFont.lfPitchAndFamily = FF_DONTCARE | FIXED_PITCH;
OEMFixedFont.lfPitchAndFamily = FF_DONTCARE | FIXED_PITCH;
break;

case 950:
/* Traditional Chinese */
/* MingLiU */
wcscpy(DefaultGuiFont.lfFaceName, MingLiU);
DefaultGuiFont.lfHeight = -12;
SystemFont.lfPitchAndFamily = FF_DONTCARE | VARIABLE_PITCH;
SystemFixedFont.lfPitchAndFamily = FF_DONTCARE | FIXED_PITCH;
OEMFixedFont.lfPitchAndFamily = FF_DONTCARE | FIXED_PITCH;
break;

case 932:
/* Japanese */
wcscpy(DefaultGuiFont.lfFaceName, L"MS UI Gothic");
DefaultGuiFont.lfHeight = -12;
SystemFont.lfPitchAndFamily = FF_DONTCARE | VARIABLE_PITCH;
SystemFixedFont.lfPitchAndFamily = FF_DONTCARE | FIXED_PITCH;
OEMFixedFont.lfPitchAndFamily = FF_DONTCARE | FIXED_PITCH;
break;

case 949:
case 1361:
/* Korean */
wcscpy(DefaultGuiFont.lfFaceName, Batang);
DefaultGuiFont.lfHeight = -12;
SystemFont.lfPitchAndFamily = FF_DONTCARE | VARIABLE_PITCH;
SystemFixedFont.lfPitchAndFamily = FF_DONTCARE | FIXED_PITCH;
OEMFixedFont.lfPitchAndFamily = FF_DONTCARE | FIXED_PITCH;
break;

default:
/* Otherwise */
wcscpy(DefaultGuiFont.lfFaceName, L"Tahoma");
DefaultGuiFont.lfHeight = -11;
SystemFont.lfPitchAndFamily = FF_SWISS | VARIABLE_PITCH;
SystemFixedFont.lfPitchAndFamily = FF_MODERN | FIXED_PITCH;
OEMFixedFont.lfPitchAndFamily = FF_MODERN | FIXED_PITCH;
break;
}

OEMFixedFont.lfCharSet = bOemCharSet;
SystemFont.lfCharSet = bActiveCharSet;
DeviceDefaultFont.lfCharSet = bActiveCharSet;
SystemFixedFont.lfCharSet = bActiveCharSet;
DefaultGuiFont.lfCharSet = bActiveCharSet;

TextIntCreateFontIndirect(&OEMFixedFont, (HFONT*)&StockObjects[OEM_FIXED_FONT]);
TextIntCreateFontIndirect(&AnsiFixedFont, (HFONT*)&StockObjects[ANSI_FIXED_FONT]);
TextIntCreateFontIndirect(&AnsiVarFont, (HFONT*)&StockObjects[ANSI_VAR_FONT]);
TextIntCreateFontIndirect(&SystemFont, (HFONT*)&StockObjects[SYSTEM_FONT]);
TextIntCreateFontIndirect(&DeviceDefaultFont, (HFONT*)&StockObjects[DEVICE_DEFAULT_FONT]);
TextIntCreateFontIndirect(&SystemFixedFont, (HFONT*)&StockObjects[SYSTEM_FIXED_FONT]);
TextIntCreateFontIndirect(&DefaultGuiFont, (HFONT*)&StockObjects[DEFAULT_GUI_FONT]);
}

/*!
* Creates a bunch of stock objects: brushes, pens, fonts.
*/
Expand Down Expand Up @@ -168,13 +250,7 @@ CreateStockObjects(void)
StockObjects[20] = NULL; /* TODO: Unknown internal stock object */
StockObjects[DEFAULT_BITMAP] = GreCreateBitmap(1, 1, 1, 1, NULL);

(void) TextIntCreateFontIndirect(&OEMFixedFont, (HFONT*)&StockObjects[OEM_FIXED_FONT]);
(void) TextIntCreateFontIndirect(&AnsiFixedFont, (HFONT*)&StockObjects[ANSI_FIXED_FONT]);
(void) TextIntCreateFontIndirect(&AnsiVarFont, (HFONT*)&StockObjects[ANSI_VAR_FONT]);
(void) TextIntCreateFontIndirect(&SystemFont, (HFONT*)&StockObjects[SYSTEM_FONT]);
(void) TextIntCreateFontIndirect(&DeviceDefaultFont, (HFONT*)&StockObjects[DEVICE_DEFAULT_FONT]);
(void) TextIntCreateFontIndirect(&SystemFixedFont, (HFONT*)&StockObjects[SYSTEM_FIXED_FONT]);
(void) TextIntCreateFontIndirect(&DefaultGuiFont, (HFONT*)&StockObjects[DEFAULT_GUI_FONT]);
CreateStockFonts();

StockObjects[DEFAULT_PALETTE] = (HGDIOBJ)gppalDefault->BaseObject.hHmgr;

Expand Down
1 change: 1 addition & 0 deletions win32ss/gdi/ntgdi/text.h
Expand Up @@ -106,6 +106,7 @@ TEXTOBJ_UnlockText(PLFONT plfnt)
PTEXTOBJ FASTCALL RealizeFontInit(HFONT);
NTSTATUS FASTCALL TextIntRealizeFont(HFONT,PTEXTOBJ);
NTSTATUS FASTCALL TextIntCreateFontIndirect(CONST LPLOGFONTW lf, HFONT *NewFont);
BYTE FASTCALL IntCharSetFromCodePage(UINT uCodePage);
BOOL FASTCALL InitFontSupport(VOID);
BOOL FASTCALL IntIsFontRenderingEnabled(VOID);
BOOL FASTCALL IntIsFontRenderingEnabled(VOID);
Expand Down