[WIN32SS] Rewrite font selection code. Patch by Katayama Hirofumi MZ. CORE-6621

- Adding support for multiple font formats (including collections)
- Choosing a font based on weights as documented
- Adding support for loading fonts from memory
- Share font faces
- Emulation of Italic and Bold
- Support for Underline and Strike-out
- Localized font names
- Fix GetFontResourceInfoW
- Fix Registry settings
- Fix multiple font properties

svn path=/trunk/; revision=73900
This commit is contained in:
Mark Jansen 2017-02-25 10:10:25 +00:00
parent 8b594efa21
commit d5f4f99b0e
6 changed files with 2121 additions and 689 deletions

View file

@ -107,22 +107,31 @@ typedef struct _FLOATGDI {
ULONG Dummy;
} FLOATGDI;
typedef struct _SHARED_FACE {
FT_Face Face;
LONG RefCount;
} SHARED_FACE, *PSHARED_FACE;
typedef struct _FONTGDI {
FONTOBJ FontObj;
ULONG iUnique;
FLONG flType;
union{
DHPDEV dhpdev;
FT_Face face;
};
FONTOBJ FontObj;
ULONG iUnique;
FLONG flType;
LONG lMaxNegA;
LONG lMaxNegC;
LONG lMinWidthD;
DHPDEV dhpdev;
PSHARED_FACE SharedFace;
LPWSTR Filename;
BYTE Underline;
BYTE StrikeOut;
LONG lMaxNegA;
LONG lMaxNegC;
LONG lMinWidthD;
LPWSTR Filename;
BYTE RequestUnderline;
BYTE RequestStrikeOut;
BYTE RequestItalic;
LONG RequestWeight;
BYTE OriginalItalic;
LONG OriginalWeight;
BYTE CharSet;
} FONTGDI, *PFONTGDI;
typedef struct _PATHGDI {

View file

@ -1882,6 +1882,7 @@ RemoveFontResourceExW(LPCWSTR lpFileName,
/* FIXME the flags */
/* FIXME the pdv */
/* FIXME NtGdiRemoveFontResource handle flags and pdv */
DPRINT("RemoveFontResourceExW\n");
return 0;
}

View file

@ -584,13 +584,15 @@ WINAPI
GetFontResourceInfoW(
_In_z_ LPCWSTR lpFileName,
_Inout_ DWORD *pdwBufSize,
_Out_writes_to_(*pdwBufSize, *pdwBufSize) PVOID lpBuffer,
_Out_writes_to_opt_(*pdwBufSize, 1) PVOID lpBuffer,
_In_ DWORD dwType)
{
BOOL bRet;
UNICODE_STRING NtFileName;
if (!lpFileName || !pdwBufSize || !lpBuffer)
DPRINT("GetFontResourceInfoW: dwType = %lu\n", dwType);
if (!lpFileName || !pdwBufSize)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;

View file

@ -3,7 +3,9 @@
* LICENSE: GPL - See COPYING in the top level directory
* FILE: win32ss/gdi/ntgdi/font.c
* PURPOSE: Font
* PROGRAMMER:
* PROGRAMMERS: James Tabor <james.tabor@reactos.org>
* Timo Kreuzer <timo.kreuzer@reactos.org>
* Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
*/
/** Includes ******************************************************************/
@ -441,6 +443,8 @@ NtGdiAddFontResourceW(
DBG_UNREFERENCED_PARAMETER(dwPidTid);
DBG_UNREFERENCED_PARAMETER(pdv);
DPRINT("NtGdiAddFontResourceW\n");
/* cwc = Length + trailing zero. */
if (cwc <= 1 || cwc > UNICODE_STRING_MAX_CHARS)
return 0;
@ -823,6 +827,7 @@ NtGdiGetOutlineTextMetricsInternalW (HDC hDC,
return 0;
}
FontGDI = ObjToGDI(TextObj->Font, FONT);
TextIntUpdateSize(dc, TextObj, FontGDI, TRUE);
TEXTOBJ_UnlockText(TextObj);
Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
if (!otm) return Size;
@ -865,31 +870,25 @@ W32KAPI
BOOL
APIENTRY
NtGdiGetFontResourceInfoInternalW(
IN LPWSTR pwszFiles,
IN ULONG cwc,
IN ULONG cFiles,
IN UINT cjIn,
OUT LPDWORD pdwBytes,
OUT LPVOID pvBuf,
IN DWORD dwType)
IN LPWSTR pwszFiles,
IN ULONG cwc,
IN ULONG cFiles,
IN UINT cjIn,
IN OUT LPDWORD pdwBytes,
OUT LPVOID pvBuf,
IN DWORD dwType)
{
NTSTATUS Status = STATUS_SUCCESS;
DWORD dwBytes;
DWORD dwBytes, dwBytesRequested;
UNICODE_STRING SafeFileNames;
BOOL bRet = FALSE;
ULONG cbStringSize;
union
{
LOGFONTW logfontw;
WCHAR FullName[LF_FULLFACESIZE];
} Buffer;
LPVOID Buffer;
/* FIXME: Handle cFiles > 0 */
/* Check for valid dwType values
dwType == 4 seems to be handled by gdi32 only */
if (dwType == 4 || dwType > 5)
/* Check for valid dwType values */
if (dwType > 5)
{
EngSetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
@ -906,15 +905,28 @@ NtGdiGetFontResourceInfoInternalW(
EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
RtlZeroMemory(SafeFileNames.Buffer, SafeFileNames.MaximumLength);
/* Check buffers and copy pwszFiles to safe unicode string */
_SEH2_TRY
{
ProbeForRead(pwszFiles, cbStringSize, 1);
ProbeForWrite(pdwBytes, sizeof(DWORD), 1);
ProbeForWrite(pvBuf, cjIn, 1);
if (pvBuf)
ProbeForWrite(pvBuf, cjIn, 1);
dwBytes = *pdwBytes;
dwBytesRequested = dwBytes;
RtlCopyMemory(SafeFileNames.Buffer, pwszFiles, cbStringSize);
if (dwBytes > 0)
{
Buffer = ExAllocatePoolWithTag(PagedPool, dwBytes, TAG_FINF);
}
else
{
Buffer = ExAllocatePoolWithTag(PagedPool, sizeof(DWORD), TAG_FINF);
}
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
@ -931,16 +943,19 @@ NtGdiGetFontResourceInfoInternalW(
}
/* Do the actual call */
bRet = IntGdiGetFontResourceInfo(&SafeFileNames, &Buffer, &dwBytes, dwType);
bRet = IntGdiGetFontResourceInfo(&SafeFileNames,
(pvBuf ? Buffer : NULL),
&dwBytes, dwType);
/* Check if succeeded and the buffer is big enough */
if (bRet && cjIn >= dwBytes)
/* Check if succeeded */
if (bRet)
{
/* Copy the data back to caller */
_SEH2_TRY
{
/* Buffers are already probed */
RtlCopyMemory(pvBuf, &Buffer, dwBytes);
if (pvBuf && dwBytesRequested > 0)
RtlCopyMemory(pvBuf, Buffer, min(dwBytesRequested, dwBytes));
*pdwBytes = dwBytes;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
@ -956,6 +971,7 @@ NtGdiGetFontResourceInfoInternalW(
}
}
ExFreePoolWithTag(Buffer, TAG_FINF);
/* Free the string for the safe filenames */
ExFreePoolWithTag(SafeFileNames.Buffer, TAG_USTR);

File diff suppressed because it is too large Load diff

View file

@ -115,6 +115,7 @@ VOID FASTCALL IntLoadSystemFonts(VOID);
INT FASTCALL IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics);
ULONG FASTCALL ftGdiGetGlyphOutline(PDC,WCHAR,UINT,LPGLYPHMETRICS,ULONG,PVOID,LPMAT2,BOOL);
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI,UINT,OUTLINETEXTMETRICW *);
BOOL FASTCALL TextIntUpdateSize(PDC,PTEXTOBJ,PFONTGDI,BOOL);
BOOL FASTCALL ftGdiGetRasterizerCaps(LPRASTERIZER_STATUS);
BOOL FASTCALL TextIntGetTextExtentPoint(PDC,PTEXTOBJ,LPCWSTR,INT,ULONG,LPINT,LPINT,LPSIZE,FLONG);
BOOL FASTCALL ftGdiGetTextMetricsW(HDC,PTMW_INTERNAL);