- Backported font initialization code with fixed memory leaks from my unfinished font handling rewrite patch.
svn path=/trunk/; revision=9734
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: driver.c,v 1.39 2004/04/09 20:39:10 navaraf Exp $
+/* $Id: driver.c,v 1.40 2004/06/20 00:45:36 navaraf Exp $
*
* GDI Driver support routines
* (mostly swiped from Wine)
BOOL DRIVER_RegisterDriver(LPCWSTR Name, PGD_ENABLEDRIVER EnableDriver)
{
- PGRAPHICS_DRIVER Driver = ExAllocatePoolWithTag(NonPagedPool, sizeof(*Driver), TAG_DRIVER);
+ PGRAPHICS_DRIVER Driver = ExAllocatePoolWithTag(PagedPool, sizeof(*Driver), TAG_DRIVER);
DPRINT( "DRIVER_RegisterDriver( Name: %S )\n", Name );
if (!Driver) return FALSE;
Driver->ReferenceCount = 0;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: object.c,v 1.11 2004/02/26 22:23:54 weiden Exp $
+/* $Id: object.c,v 1.12 2004/06/20 00:45:36 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
PVOID ObjectBody;
DWORD Status;
- ObjectHeader = (PUSER_OBJECT_HEADER)ExAllocatePool(NonPagedPool,
+ ObjectHeader = (PUSER_OBJECT_HEADER)ExAllocatePool(PagedPool,
ObjectSize + sizeof(USER_OBJECT_HEADER));
if (!ObjectHeader)
{
/*
* Add a new Handle block to the end of the list
*/
- NewBlock = (PUSER_HANDLE_BLOCK)ExAllocatePool(NonPagedPool,
+ NewBlock = (PUSER_HANDLE_BLOCK)ExAllocatePool(PagedPool,
sizeof(USER_HANDLE_BLOCK));
if (!NewBlock)
{
{
PUSER_HANDLE_TABLE HandleTable;
- HandleTable = (PUSER_HANDLE_TABLE)ExAllocatePool(NonPagedPool,
+ HandleTable = (PUSER_HANDLE_TABLE)ExAllocatePool(PagedPool,
sizeof(USER_HANDLE_TABLE));
if (!HandleTable)
{
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: class.c,v 1.57 2004/05/27 11:47:42 weiden Exp $
+/* $Id: class.c,v 1.58 2004/06/20 00:45:36 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
Length = 0;
Status = RtlQueryAtomInAtomTable(WinStaObject->AtomTable,
WindowObject->Class->Atom, NULL, NULL, NULL, &Length);
- Name = ExAllocatePoolWithTag(NonPagedPool, Length + sizeof(UNICODE_NULL), TAG_STRING);
+ Name = ExAllocatePoolWithTag(PagedPool, Length + sizeof(UNICODE_NULL), TAG_STRING);
Status = RtlQueryAtomInAtomTable(WinStaObject->AtomTable,
WindowObject->Class->Atom, NULL, NULL, Name, &Length);
if (!NT_SUCCESS(Status))
}
/* Allocate memory for the string */
- Buf = ExAllocatePoolWithTag(NonPagedPool, cchMaxCount * sizeof(WCHAR), TAG_STRING);
+ Buf = ExAllocatePoolWithTag(PagedPool, cchMaxCount * sizeof(WCHAR), TAG_STRING);
if(!Buf)
{
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
-/* $Id: misc.c,v 1.78 2004/06/16 06:09:40 gvg Exp $
+/* $Id: misc.c,v 1.79 2004/06/20 00:45:36 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
if(Dest->Length > 0 && Src)
{
Dest->MaximumLength = Dest->Length;
- Dest->Buffer = ExAllocatePoolWithTag(NonPagedPool, Dest->MaximumLength, TAG_STRING);
+ Dest->Buffer = ExAllocatePoolWithTag(PagedPool, Dest->MaximumLength, TAG_STRING);
if(!Dest->Buffer)
{
return STATUS_NO_MEMORY;
if(Dest->Length > 0 && Src)
{
Dest->MaximumLength = Dest->Length + sizeof(WCHAR);
- Dest->Buffer = ExAllocatePoolWithTag(NonPagedPool, Dest->MaximumLength, TAG_STRING);
+ Dest->Buffer = ExAllocatePoolWithTag(PagedPool, Dest->MaximumLength, TAG_STRING);
if(!Dest->Buffer)
{
return STATUS_NO_MEMORY;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: window.c,v 1.238 2004/06/19 20:18:09 navaraf Exp $
+/* $Id: window.c,v 1.239 2004/06/20 00:45:37 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
WCHAR *buf;
/* safely copy the class name string (NULL terminated because class-lookup
depends on it... */
- buf = ExAllocatePoolWithTag(NonPagedPool, ClassName.Length + sizeof(WCHAR), TAG_STRING);
+ buf = ExAllocatePoolWithTag(PagedPool, ClassName.Length + sizeof(WCHAR), TAG_STRING);
if(!buf)
{
SetLastWin32Error(STATUS_INSUFFICIENT_RESOURCES);
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: winpos.c,v 1.116 2004/05/16 13:57:49 weiden Exp $
+/* $Id: winpos.c,v 1.117 2004/06/20 00:45:37 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
else
IntGetDesktopWorkArea(Desktop, &WorkArea);
- WindowObject->InternalPos = ExAllocatePoolWithTag(NonPagedPool, sizeof(INTERNALPOS), TAG_WININTLIST);
+ WindowObject->InternalPos = ExAllocatePoolWithTag(PagedPool, sizeof(INTERNALPOS), TAG_WININTLIST);
if(!WindowObject->InternalPos)
{
DPRINT1("Failed to allocate INTERNALPOS structure for window 0x%x\n", WindowObject->Self);
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: winsta.c,v 1.63 2004/05/22 21:12:15 weiden Exp $
+ * $Id: winsta.c,v 1.64 2004/06/20 00:45:37 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
FullName->Length += WinStaName->Length + sizeof(WCHAR);
if (DesktopName != NULL)
FullName->Length += DesktopName->Length + sizeof(WCHAR);
- FullName->Buffer = ExAllocatePoolWithTag(NonPagedPool, FullName->Length, TAG_STRING);
+ FullName->Buffer = ExAllocatePoolWithTag(PagedPool, FullName->Length, TAG_STRING);
if (FullName->Buffer == NULL)
{
return FALSE;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: bezier.c,v 1.8 2004/05/10 17:07:20 weiden Exp $ */
+/* $Id: bezier.c,v 1.9 2004/06/20 00:45:37 navaraf Exp $ */
#include <w32k.h>
{
if(*nPtsOut == *dwOut) {
*dwOut *= 2;
- *PtsOut = ExAllocatePoolWithTag(NonPagedPool, *dwOut * sizeof(POINT), TAG_BEZIER);
+ *PtsOut = ExAllocatePoolWithTag(PagedPool, *dwOut * sizeof(POINT), TAG_BEZIER);
}
if(!level || BezierCheck(level, Points)) {
return NULL;
}
*nPtsOut = 0;
- out = ExAllocatePoolWithTag(NonPagedPool, dwOut * sizeof(POINT), TAG_BEZIER);
+ out = ExAllocatePoolWithTag(PagedPool, dwOut * sizeof(POINT), TAG_BEZIER);
for(Bezier = 0; Bezier < (count-1)/3; Bezier++) {
POINT ptBuf[4];
memcpy(ptBuf, Points + Bezier * 3, sizeof(POINT) * 4);
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: bitmaps.c,v 1.73 2004/05/14 16:50:44 navaraf Exp $ */
+/* $Id: bitmaps.c,v 1.74 2004/06/20 00:45:37 navaraf Exp $ */
#include <w32k.h>
#define IN_RECT(r,x,y) \
{
char *buf;
- buf = ExAllocatePoolWithTag (NonPagedPool, bm.bmWidthBytes * bm.bmHeight, TAG_BITMAP);
+ buf = ExAllocatePoolWithTag (PagedPool, bm.bmWidthBytes * bm.bmHeight, TAG_BITMAP);
NtGdiGetBitmapBits (hBitmap, bm.bmWidthBytes * bm.bmHeight, buf);
NtGdiSetBitmapBits (res, bm.bmWidthBytes * bm.bmHeight, buf);
ExFreePool (buf);
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: dc.c,v 1.138 2004/06/18 15:18:56 navaraf Exp $
+/* $Id: dc.c,v 1.139 2004/06/20 00:45:37 navaraf Exp $
*
* DC.C - Device context functions
*
return 0;
}
- SafeBuf = ExAllocatePoolWithTag(NonPagedPool, count, TAG_GDIOBJ);
+ SafeBuf = ExAllocatePoolWithTag(PagedPool, count, TAG_GDIOBJ);
if(!SafeBuf)
{
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
/*
- * $Id: dib.c,v 1.50 2004/05/30 14:01:13 weiden Exp $
+ * $Id: dib.c,v 1.51 2004/06/20 00:45:37 navaraf Exp $
*
* ReactOS W32 Subsystem
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
bm.bmBits = EngAllocUserMem(totalSize, 0);
}
-/* bm.bmBits = ExAllocatePool(NonPagedPool, totalSize); */
+/* bm.bmBits = ExAllocatePool(PagedPool, totalSize); */
if(usage == DIB_PAL_COLORS)
memcpy(bmi->bmiColors, (UINT *)DIB_MapPaletteColors(dc, bmi), sizeof(UINT *));
if(bi->biBitCount == 4) { Entries = 16; } else
if(bi->biBitCount == 8) { Entries = 256; }
- bmp->ColorMap = ExAllocatePoolWithTag(NonPagedPool, sizeof(RGBQUAD)*Entries, TAG_COLORMAP);
+ bmp->ColorMap = ExAllocatePoolWithTag(PagedPool, sizeof(RGBQUAD)*Entries, TAG_COLORMAP);
RtlCopyMemory(bmp->ColorMap, bmi->bmiColors, sizeof(RGBQUAD)*Entries);
}
nNumColors = min(nNumColors, lpbmi->bmiHeader.biClrUsed);
}
- lpRGB = (RGBQUAD *)ExAllocatePoolWithTag(NonPagedPool, sizeof(RGBQUAD) * nNumColors, TAG_COLORMAP);
+ lpRGB = (RGBQUAD *)ExAllocatePoolWithTag(PagedPool, sizeof(RGBQUAD) * nNumColors, TAG_COLORMAP);
lpIndex = (USHORT *)&lpbmi->bmiColors[0];
for (i = 0; i < nNumColors; i++)
if (PAL_INDEXED == *paletteType)
{
- palEntries = ExAllocatePoolWithTag(NonPagedPool, sizeof(PALETTEENTRY)*ColorCount, TAG_COLORMAP);
+ palEntries = ExAllocatePoolWithTag(PagedPool, sizeof(PALETTEENTRY)*ColorCount, TAG_COLORMAP);
DIBColorTableToPaletteEntries(palEntries, bmi->bmiColors, ColorCount);
}
hPal = PALETTE_AllocPalette( *paletteType, ColorCount, (ULONG*)palEntries, 0, 0, 0 );
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: fillshap.c,v 1.49 2004/05/14 16:55:18 navaraf Exp $ */
+/* $Id: fillshap.c,v 1.50 2004/06/20 00:45:37 navaraf Exp $ */
#include <w32k.h>
/*
SetLastWin32Error(ERROR_INVALID_HANDLE);
else
{
- Safept = ExAllocatePoolWithTag(NonPagedPool, sizeof(POINT) * Count, TAG_SHAPE);
+ Safept = ExAllocatePoolWithTag(PagedPool, sizeof(POINT) * Count, TAG_SHAPE);
if(!Safept)
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
else
if(Count > 0)
{
- Safept = ExAllocatePoolWithTag(NonPagedPool, (sizeof(POINT) + sizeof(INT)) * Count, TAG_SHAPE);
+ Safept = ExAllocatePoolWithTag(PagedPool, (sizeof(POINT) + sizeof(INT)) * Count, TAG_SHAPE);
if(!Safept)
{
DC_UnlockDc(hDC);
/*
* GDIOBJ.C - GDI object manipulation routines
*
- * $Id: gdiobj.c,v 1.67 2004/05/10 17:07:20 weiden Exp $
+ * $Id: gdiobj.c,v 1.68 2004/06/20 00:45:37 navaraf Exp $
*
*/
#include <w32k.h>
#endif
handleTable->wTableSize = Size;
handleTable->AllocationHint = 1;
- handleTable->LookasideLists = ExAllocatePoolWithTag(NonPagedPool,
+ handleTable->LookasideLists = ExAllocatePoolWithTag(PagedPool,
OBJTYPE_COUNT * sizeof(PAGED_LOOKASIDE_LIST),
TAG_GDIHNDTBLE);
if (NULL == handleTable->LookasideLists)
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: line.c,v 1.32 2004/06/18 15:18:57 navaraf Exp $ */
+/* $Id: line.c,v 1.33 2004/06/20 00:45:37 navaraf Exp $ */
#include <w32k.h>
// Some code from the WINE project source (www.winehq.com)
else /* We'll do it using PolyBezier */
{
POINT *npt;
- npt = ExAllocatePoolWithTag(NonPagedPool, sizeof(POINT) * (Count + 1), TAG_BEZIER);
+ npt = ExAllocatePoolWithTag(PagedPool, sizeof(POINT) * (Count + 1), TAG_BEZIER);
if ( npt )
{
npt[0].x = dc->w.CursPosX;
return PATH_Polyline ( dc, pt, Count );
//Allocate "Count" bytes of memory to hold a safe copy of pt
- pts = (POINT*)ExAllocatePoolWithTag ( NonPagedPool, sizeof(POINT)*Count, TAG_SHAPE );
+ pts = (POINT*)ExAllocatePoolWithTag ( PagedPool, sizeof(POINT)*Count, TAG_SHAPE );
if ( pts )
{
// safely copy pt to local version
}
else /* do it using Polyline */
{
- POINT *pts = ExAllocatePoolWithTag(NonPagedPool, sizeof(POINT) * (Count + 1), TAG_SHAPE);
+ POINT *pts = ExAllocatePoolWithTag(PagedPool, sizeof(POINT) * (Count + 1), TAG_SHAPE);
if ( pts )
{
pts[0].x = dc->w.CursPosX;
if(Count > 0)
{
- Safept = ExAllocatePoolWithTag(NonPagedPool, sizeof(POINT) * Count, TAG_BEZIER);
+ Safept = ExAllocatePoolWithTag(PagedPool, sizeof(POINT) * Count, TAG_BEZIER);
if(!Safept)
{
DC_UnlockDc(hDC);
if(Count > 0)
{
- Safept = ExAllocatePoolWithTag(NonPagedPool, sizeof(POINT) * Count, TAG_BEZIER);
+ Safept = ExAllocatePoolWithTag(PagedPool, sizeof(POINT) * Count, TAG_BEZIER);
if(!Safept)
{
DC_UnlockDc(hDC);
if(Count >= 2)
{
- Safept = ExAllocatePoolWithTag(NonPagedPool, sizeof(POINT) * Count, TAG_SHAPE);
+ Safept = ExAllocatePoolWithTag(PagedPool, sizeof(POINT) * Count, TAG_SHAPE);
if(!Safept)
{
DC_UnlockDc(hDC);
if(Count > 0)
{
- Safept = ExAllocatePoolWithTag(NonPagedPool, sizeof(POINT) * Count, TAG_SHAPE);
+ Safept = ExAllocatePoolWithTag(PagedPool, sizeof(POINT) * Count, TAG_SHAPE);
if(!Safept)
{
DC_UnlockDc(hDC);
if(Count > 0)
{
- Safept = ExAllocatePoolWithTag(NonPagedPool, (sizeof(POINT) + sizeof(DWORD)) * Count, TAG_SHAPE);
+ Safept = ExAllocatePoolWithTag(PagedPool, (sizeof(POINT) + sizeof(DWORD)) * Count, TAG_SHAPE);
if(!Safept)
{
DC_UnlockDc(hDC);
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: palette.c,v 1.18 2004/05/10 17:07:20 weiden Exp $ */
+/* $Id: palette.c,v 1.19 2004/06/20 00:45:37 navaraf Exp $ */
#include <w32k.h>
#ifndef NO_MAPPING
if (NULL != Colors)
{
- PalGDI->IndexedColors = ExAllocatePoolWithTag(NonPagedPool, sizeof(PALETTEENTRY) * NumColors, TAG_PALETTE);
+ PalGDI->IndexedColors = ExAllocatePoolWithTag(PagedPool, sizeof(PALETTEENTRY) * NumColors, TAG_PALETTE);
if (NULL == PalGDI->IndexedColors)
{
PALETTE_UnlockPalette(NewPalette);
const PALETTEENTRY* __sysPalTemplate = (const PALETTEENTRY*)COLOR_GetSystemPaletteTemplate();
// create default palette (20 system colors)
- palPtr = ExAllocatePoolWithTag(NonPagedPool, sizeof(LOGPALETTE) + (NB_RESERVED_COLORS * sizeof(PALETTEENTRY)), TAG_PALETTE);
+ palPtr = ExAllocatePoolWithTag(PagedPool, sizeof(LOGPALETTE) + (NB_RESERVED_COLORS * sizeof(PALETTEENTRY)), TAG_PALETTE);
if (!palPtr) return FALSE;
palPtr->palVersion = 0x300;
palObj = (PALOBJ*)PALETTE_LockPalette(hpalette);
if (palObj)
{
- if (!(palObj->mapping = ExAllocatePool(NonPagedPool, sizeof(int) * 20)))
+ if (!(palObj->mapping = ExAllocatePool(PagedPool, sizeof(int) * 20)))
{
DbgPrint("Win32k: Can not create palette mapping -- out of memory!");
return FALSE;
//mapping = HeapReAlloc( GetProcessHeap(), 0, palPtr->mapping,
// sizeof(int)*palPtr->logpalette->palNumEntries);
ExFreePool(palPtr->mapping);
- mapping = ExAllocatePoolWithTag(NonPagedPool, sizeof(int)*palGDI->NumColors, TAG_PALETTEMAP);
+ mapping = ExAllocatePoolWithTag(PagedPool, sizeof(int)*palGDI->NumColors, TAG_PALETTEMAP);
palPtr->mapping = mapping;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: path.c,v 1.21 2004/05/10 17:07:20 weiden Exp $ */
+/* $Id: path.c,v 1.22 2004/06/20 00:45:37 navaraf Exp $ */
#include <w32k.h>
#include <win32k/float.h>
numStrokes++;
/* Allocate memory for number-of-points-in-stroke array */
- pNumPointsInStroke=(int *)ExAllocatePoolWithTag(NonPagedPool, sizeof(int) * numStrokes, TAG_PATH);
+ pNumPointsInStroke=(int *)ExAllocatePoolWithTag(PagedPool, sizeof(int) * numStrokes, TAG_PATH);
if(!pNumPointsInStroke)
{
// SetLastError(ERROR_NOT_ENOUGH_MEMORY);
numEntriesToAllocate=numEntries;
/* Allocate new arrays */
- pPointsNew=(POINT *)ExAllocatePoolWithTag(NonPagedPool, numEntriesToAllocate * sizeof(POINT), TAG_PATH);
+ pPointsNew=(POINT *)ExAllocatePoolWithTag(PagedPool, numEntriesToAllocate * sizeof(POINT), TAG_PATH);
if(!pPointsNew)
return FALSE;
- pFlagsNew=(BYTE *)ExAllocatePoolWithTag(NonPagedPool, numEntriesToAllocate * sizeof(BYTE), TAG_PATH);
+ pFlagsNew=(BYTE *)ExAllocatePoolWithTag(PagedPool, numEntriesToAllocate * sizeof(BYTE), TAG_PATH);
if(!pFlagsNew)
{
ExFreePool(pPointsNew);
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: print.c,v 1.17 2004/05/10 17:07:20 weiden Exp $ */
+/* $Id: print.c,v 1.18 2004/06/20 00:45:37 navaraf Exp $ */
#include <w32k.h>
INT
if ( InSize && UnsafeInData )
{
- SafeInData = ExAllocatePoolWithTag ( NonPagedPool, InSize, TAG_PRINT );
+ SafeInData = ExAllocatePoolWithTag ( PagedPool, InSize, TAG_PRINT );
if ( !SafeInData )
{
DC_UnlockDc(hDC);
if ( OutSize && UnsafeOutData )
{
- SafeOutData = ExAllocatePoolWithTag ( NonPagedPool, OutSize, TAG_PRINT );
+ SafeOutData = ExAllocatePoolWithTag ( PagedPool, OutSize, TAG_PRINT );
if ( !SafeOutData )
{
if ( SafeInData )
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: text.c,v 1.96 2004/06/18 15:18:58 navaraf Exp $ */
+/* $Id: text.c,v 1.97 2004/06/20 00:45:37 navaraf Exp $ */
#include <w32k.h>
#include <ft2build.h>
static LIST_ENTRY FontListHead;
static FAST_MUTEX FontListLock;
-static INT FontsLoaded = 0; /* number of all fonts loaded (including private fonts */
static BOOL RenderingEnabled = TRUE;
static PWCHAR ElfScripts[32] = { /* these are in the order of the fsCsb[0] bits */
{ SYMBOL_CHARSET, CP_SYMBOL, FS(31)},
};
+VOID FASTCALL
+IntLoadSystemFonts(VOID);
+
+INT FASTCALL
+IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics);
+
+BOOL FASTCALL
+InitFontSupport(VOID)
+{
+ ULONG ulError;
+
+ InitializeListHead(&FontListHead);
+ ExInitializeFastMutex(&FontListLock);
+ ExInitializeFastMutex(&FreeTypeLock);
+
+ ulError = FT_Init_FreeType(&library);
+ if (ulError)
+ return FALSE;
+
+ IntLoadSystemFonts();
+
+ return TRUE;
+}
+
+/*
+ * IntLoadSystemFonts
+ *
+ * Search the system font directory and adds each font found.
+ */
+
+VOID FASTCALL
+IntLoadSystemFonts(VOID)
+{
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ UNICODE_STRING Directory, SearchPattern, FileName, TempString;
+ IO_STATUS_BLOCK Iosb;
+ HANDLE hDirectory;
+ BYTE *DirInfoBuffer;
+ PFILE_DIRECTORY_INFORMATION DirInfo;
+ BOOL bRestartScan = TRUE;
+ NTSTATUS Status;
+
+ RtlInitUnicodeString(&Directory, L"\\SystemRoot\\Media\\Fonts\\");
+ /* FIXME: Add support for other font types */
+ RtlInitUnicodeString(&SearchPattern, L"*.ttf");
+
+ InitializeObjectAttributes(
+ &ObjectAttributes,
+ &Directory,
+ OBJ_CASE_INSENSITIVE,
+ NULL,
+ NULL);
+
+ Status = ZwOpenFile(
+ &hDirectory,
+ SYNCHRONIZE | FILE_LIST_DIRECTORY,
+ &ObjectAttributes,
+ &Iosb,
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ FILE_SYNCHRONOUS_IO_NONALERT | FILE_DIRECTORY_FILE);
+
+ if (NT_SUCCESS(Status))
+ {
+ DirInfoBuffer = ExAllocatePool(PagedPool, 0x4000);
+ if (DirInfoBuffer == NULL)
+ {
+ ZwClose(hDirectory);
+ return;
+ }
+
+ FileName.Buffer = ExAllocatePool(PagedPool, MAX_PATH);
+ if (FileName.Buffer == NULL)
+ {
+ ExFreePool(DirInfoBuffer);
+ ZwClose(hDirectory);
+ return;
+ }
+ FileName.Length = 0;
+ FileName.MaximumLength = MAX_PATH;
+
+ while (1)
+ {
+ Status = ZwQueryDirectoryFile(
+ hDirectory,
+ NULL,
+ NULL,
+ NULL,
+ &Iosb,
+ DirInfoBuffer,
+ 0x4000,
+ FileDirectoryInformation,
+ FALSE,
+ &SearchPattern,
+ bRestartScan);
+
+ if (!NT_SUCCESS(Status) || Status == STATUS_NO_MORE_FILES)
+ {
+ break;
+ }
+
+ for (DirInfo = (PFILE_DIRECTORY_INFORMATION)DirInfoBuffer;
+ DirInfo->NextEntryOffset != 0;
+ DirInfo = (PFILE_DIRECTORY_INFORMATION)((ULONG_PTR)DirInfo + DirInfo->NextEntryOffset))
+ {
+ TempString.Buffer = DirInfo->FileName;
+ TempString.Length =
+ TempString.MaximumLength = DirInfo->FileNameLength;
+ RtlCopyUnicodeString(&FileName, &Directory);
+ RtlAppendUnicodeStringToString(&FileName, &TempString);
+ IntGdiAddFontResource(&FileName, 0);
+ }
+
+ bRestartScan = FALSE;
+ }
+
+ ExFreePool(FileName.Buffer);
+ ExFreePool(DirInfoBuffer);
+ ZwClose(hDirectory);
+ }
+}
+
+/*
+ * IntGdiAddFontResource
+ *
+ * Adds the font resource from the specified file to the system.
+ */
+
+INT FASTCALL
+IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics)
+{
+ HFONT NewFont;
+ FONTOBJ *FontObj;
+ PFONTGDI FontGDI;
+ NTSTATUS Status;
+ HANDLE FileHandle;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ FILE_STANDARD_INFORMATION FileStdInfo;
+ PVOID Buffer;
+ IO_STATUS_BLOCK Iosb;
+ INT Error;
+ FT_Face Face;
+ ANSI_STRING AnsiFaceName;
+ PFONT_ENTRY Entry;
+
+ /* Create handle for the font */
+
+ NewFont = (HFONT)CreateGDIHandle(
+ sizeof(FONTGDI),
+ sizeof(FONTOBJ),
+ (PVOID*)&FontGDI,
+ (PVOID*)&FontObj);
+
+ if (NewFont == 0)
+ {
+ DPRINT("Could not allocate a new GDI font object\n");
+ return 0;
+ }
+
+ /* Open the font file */
+
+ InitializeObjectAttributes(&ObjectAttributes, FileName, 0, NULL, NULL);
+ Status = ZwOpenFile(
+ &FileHandle,
+ GENERIC_READ | SYNCHRONIZE,
+ &ObjectAttributes,
+ &Iosb,
+ 0,
+ FILE_SYNCHRONOUS_IO_NONALERT);
+
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("Could not font file: %wZ\n", Filename);
+ NtGdiDeleteObject(NewFont);
+ return 0;
+ }
+
+ /* Get the size of the file */
+
+ Status = NtQueryInformationFile(
+ FileHandle,
+ &Iosb,
+ &FileStdInfo,
+ sizeof(FileStdInfo),
+ FileStandardInformation);
+
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("Could not get file size\n");
+ NtGdiDeleteObject(NewFont);
+ ZwClose(FileHandle);
+ return 0;
+ }
+
+ /* Allocate pageable memory for the font */
+
+ Buffer = ExAllocatePoolWithTag(
+ PagedPool,
+ FileStdInfo.EndOfFile.u.LowPart,
+ TAG_GDITEXT);
+
+ if (Buffer == NULL)
+ {
+ DPRINT("Could not allocate memory for font");
+ NtGdiDeleteObject(NewFont);
+ ZwClose(FileHandle);
+ return 0;
+ }
+
+ /* Load the font into memory chunk */
+
+ Status = ZwReadFile(
+ FileHandle,
+ NULL,
+ NULL,
+ NULL,
+ &Iosb,
+ Buffer,
+ FileStdInfo.EndOfFile.u.LowPart,
+ NULL,
+ NULL);
+
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("Could not read the font file into memory");
+ ExFreePool(Buffer);
+ NtGdiDeleteObject(NewFont);
+ ZwClose(FileHandle);
+ return 0;
+ }
+
+ ZwClose(FileHandle);
+
+ IntLockFreeType;
+ Error = FT_New_Memory_Face(
+ library,
+ Buffer,
+ FileStdInfo.EndOfFile.u.LowPart,
+ 0,
+ &Face);
+ IntUnLockFreeType;
+
+ if (Error)
+ {
+ if (Error == FT_Err_Unknown_File_Format)
+ DPRINT("Unknown font file format\n");
+ else
+ DPRINT("Error reading font file (error code: %u)\n", Error);
+ ExFreePool(Buffer);
+ NtGdiDeleteObject(NewFont);
+ return 0;
+ }
+
+ Entry = ExAllocatePoolWithTag(PagedPool, sizeof(FONT_ENTRY), TAG_FONT);
+ if (!Entry)
+ {
+ FT_Done_Face(Face);
+ ExFreePool(Buffer);
+ SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
+ return 0;
+ }
+
+ /* FontGDI->Filename = FileName; perform strcpy */
+ FontGDI->face = Face;
+
+ /* FIXME: Complete text metrics */
+ FontGDI->TextMetric.tmAscent = (Face->size->metrics.ascender + 32) >> 6; /* units above baseline */
+ FontGDI->TextMetric.tmDescent = (32 - Face->size->metrics.descender) >> 6; /* units below baseline */
+ FontGDI->TextMetric.tmHeight = FontGDI->TextMetric.tmAscent + FontGDI->TextMetric.tmDescent;
+
+ DPRINT("Font loaded: %s (%s)\n", face->family_name, face->style_name);
+ DPRINT("Num glyphs: %u\n", face->num_glyphs);
+
+ /* Add this font resource to the font table */
+
+ Entry->hFont = NewFont;
+ Entry->NotEnum = (Characteristics & FR_NOT_ENUM);
+ RtlInitAnsiString(&AnsiFaceName, (LPSTR)Face->family_name);
+ RtlAnsiStringToUnicodeString(&Entry->FaceName, &AnsiFaceName, TRUE);
+
+ if (Characteristics & FR_PRIVATE)
+ {
+ PW32PROCESS Win32Process = PsGetWin32Process();
+ IntLockProcessPrivateFonts(Win32Process);
+ InsertTailList(&Win32Process->PrivateFontListHead, &Entry->ListEntry);
+ IntUnLockProcessPrivateFonts(Win32Process);
+ }
+ else
+ {
+ IntLockGlobalFonts;
+ InsertTailList(&FontListHead, &Entry->ListEntry);
+ IntUnLockGlobalFonts;
+ }
+
+ return 1;
+}
BOOL FASTCALL
IntIsFontRenderingEnabled(VOID)
}
return FT_RENDER_MODE_MONO;
}
-
-int FASTCALL
-IntGdiAddFontResource(PUNICODE_STRING Filename, DWORD fl)
-{
- HFONT NewFont;
- FONTOBJ *FontObj;
- PFONTGDI FontGDI;
- NTSTATUS Status;
- HANDLE FileHandle;
- OBJECT_ATTRIBUTES ObjectAttributes;
- FILE_STANDARD_INFORMATION FileStdInfo;
- PVOID buffer;
- ULONG size;
- INT error;
- FT_Face face;
- ANSI_STRING StringA;
- IO_STATUS_BLOCK Iosb;
- PFONT_ENTRY entry;
-
- NewFont = (HFONT)CreateGDIHandle(sizeof( FONTGDI ), sizeof( FONTOBJ ), (PVOID*)&FontGDI, (PVOID*)&FontObj);
- if(NewFont == 0)
- {
- DPRINT1("Could not allocate a new GDI font object\n");
- return 0;
- }
-
- // Open the Module
- InitializeObjectAttributes(&ObjectAttributes, Filename, 0, NULL, NULL);
-
- Status = ZwOpenFile(&FileHandle,
- GENERIC_READ|SYNCHRONIZE,
- &ObjectAttributes,
- &Iosb,
- 0, //ShareAccess
- FILE_SYNCHRONOUS_IO_NONALERT);
-
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("Could not open module file: %wZ\n", Filename);
- return 0;
- }
-
- // Get the size of the file
- Status = NtQueryInformationFile(FileHandle, &Iosb, &FileStdInfo, sizeof(FileStdInfo), FileStandardInformation);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("Could not get file size\n");
- return 0;
- }
-
- // Allocate nonpageable memory for driver
- size = FileStdInfo.EndOfFile.u.LowPart;
- buffer = ExAllocatePoolWithTag(NonPagedPool, size, TAG_GDITEXT);
-
- if (buffer == NULL)
- {
- DPRINT1("could not allocate memory for module");
- return 0;
- }
-
- // Load driver into memory chunk
- Status = ZwReadFile(FileHandle,
- NULL,
- NULL,
- NULL,
- &Iosb,
- buffer,
- FileStdInfo.EndOfFile.u.LowPart,
- NULL,
- NULL);
-
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("could not read module file into memory");
- ExFreePool(buffer);
- return 0;
- }
-
- ZwClose(FileHandle);
-
- IntLockFreeType;
- error = FT_New_Memory_Face(library, buffer, size, 0, &face);
- IntUnLockFreeType;
- if (error == FT_Err_Unknown_File_Format)
- {
- DPRINT1("Unknown font file format\n");
- return 0;
- }
- else if (error)
- {
- DPRINT1("Error reading font file (error code: %u)\n", error); // 48
- return 0;
- }
-
- entry = ExAllocatePoolWithTag(NonPagedPool, sizeof(FONT_ENTRY), TAG_FONT);
- if(!entry)
- {
- SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
- return 0;
- }
-
- // FontGDI->Filename = Filename; perform strcpy
- FontGDI->face = face;
-
- // FIXME: Complete text metrics
- FontGDI->TextMetric.tmAscent = (face->size->metrics.ascender + 32) >> 6; // units above baseline
- FontGDI->TextMetric.tmDescent = (32 - face->size->metrics.descender) >> 6; // units below baseline
- FontGDI->TextMetric.tmHeight = FontGDI->TextMetric.tmAscent + FontGDI->TextMetric.tmDescent;
-
- DPRINT("Font loaded: %s (%s)\n", face->family_name, face->style_name);
- DPRINT("Num glyphs: %u\n", face->num_glyphs);
-
- // Add this font resource to the font table
- entry->hFont = NewFont;
- entry->NotEnum = (fl & FR_NOT_ENUM);
- RtlInitAnsiString(&StringA, (LPSTR)face->family_name);
- RtlAnsiStringToUnicodeString(&entry->FaceName, &StringA, TRUE);
-
- if(fl & FR_PRIVATE)
- {
- PW32PROCESS Win32Process = PsGetWin32Process();
-
- IntLockProcessPrivateFonts(Win32Process);
- InsertTailList(&Win32Process->PrivateFontListHead, &entry->ListEntry);
- FontsLoaded++;
- IntUnLockProcessPrivateFonts(Win32Process);
- }
- else
- {
- IntLockGlobalFonts;
- InsertTailList(&FontListHead, &entry->ListEntry);
- FontsLoaded++;
- IntUnLockGlobalFonts;
- }
-
- return 1;
-}
-
-BOOL FASTCALL InitFontSupport(VOID)
-{
- ULONG ulError;
- UNICODE_STRING cchDir, cchFilename, cchSearchPattern ;
- OBJECT_ATTRIBUTES obAttr;
- IO_STATUS_BLOCK Iosb;
- HANDLE hDirectory;
- NTSTATUS Status;
- PFILE_DIRECTORY_INFORMATION iFileData;
- PVOID pBuff;
- BOOLEAN bRestartScan = TRUE;
- BOOLEAN Result = FALSE;
-
- InitializeListHead(&FontListHead);
- ExInitializeFastMutex(&FontListLock);
- ExInitializeFastMutex(&FreeTypeLock);
-
- ulError = FT_Init_FreeType(&library);
-
- if(!ulError)
- {
- RtlInitUnicodeString(&cchDir, L"\\SystemRoot\\Media\\Fonts\\");
-
- RtlInitUnicodeString(&cchSearchPattern,L"*.ttf");
- InitializeObjectAttributes( &obAttr,
- &cchDir,
- OBJ_CASE_INSENSITIVE,
- NULL,
- NULL );
-
- Status = ZwOpenFile( &hDirectory,
- SYNCHRONIZE | FILE_LIST_DIRECTORY,
- &obAttr,
- &Iosb,
- FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
- FILE_SYNCHRONOUS_IO_NONALERT | FILE_DIRECTORY_FILE );
- if( NT_SUCCESS(Status) )
- {
- while(1)
- {
- if (bRestartScan)
- {
- pBuff = ExAllocatePool(NonPagedPool,0x4000);
- if (pBuff == NULL)
- {
- break;
- }
- RtlInitUnicodeString(&cchFilename,0);
- cchFilename.MaximumLength = 0x1000;
- cchFilename.Buffer = ExAllocatePoolWithTag(PagedPool,cchFilename.MaximumLength, TAG_STRING);
- if (cchFilename.Buffer == NULL)
- {
- ExFreePool(pBuff);
- break;
- }
- }
-
- Status = NtQueryDirectoryFile( hDirectory,
- NULL,
- NULL,
- NULL,
- &Iosb,
- pBuff,
- 0x4000,
- FileDirectoryInformation,
- FALSE,
- &cchSearchPattern,
- bRestartScan );
-
- if( !NT_SUCCESS(Status) || Status == STATUS_NO_MORE_FILES )
- {
- ExFreePool(pBuff);
- ExFreePool(cchFilename.Buffer);
- break;
- }
- bRestartScan = FALSE;
- iFileData = (PFILE_DIRECTORY_INFORMATION)pBuff;
- while(1)
- {
- UNICODE_STRING tmpString;
- tmpString.Buffer = iFileData->FileName;
- tmpString.Length = tmpString.MaximumLength = iFileData->FileNameLength;
- RtlCopyUnicodeString(&cchFilename, &cchDir);
- RtlAppendUnicodeStringToString(&cchFilename, &tmpString);
- cchFilename.Buffer[cchFilename.Length / sizeof(WCHAR)] = 0;
- if (0 != IntGdiAddFontResource(&cchFilename, 0))
- {
- Result = TRUE;
- }
- if (iFileData->NextEntryOffset == 0)
- {
- break;
- }
- iFileData = (PVOID)iFileData + iFileData->NextEntryOffset;
- }
- }
- }
- }
- ZwClose(hDirectory);
- return Result;
-}
-
static NTSTATUS STDCALL
GetFontObjectsFromTextObj(PTEXTOBJ TextObj, HFONT *FontHandle, FONTOBJ **FontObj, PFONTGDI *FontGDI)
{