2 * PROJECT: ReactOS win32 kernel mode subsystem
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: subsystems/win32/win32k/objects/font.c
9 /** Includes ******************************************************************/
16 /** Functions ******************************************************************/
20 NtGdiAddFontResourceW(
26 IN OPTIONAL DESIGNVECTOR
*pdv
)
28 UNICODE_STRING SafeFileName
;
33 /* FIXME - Protect with SEH? */
34 RtlInitUnicodeString(&SafeFileName
, pwszFiles
);
36 /* Reserve for prepending '\??\' */
37 SafeFileName
.Length
+= 4 * sizeof(WCHAR
);
38 SafeFileName
.MaximumLength
+= 4 * sizeof(WCHAR
);
40 src
= SafeFileName
.Buffer
;
41 SafeFileName
.Buffer
= (PWSTR
)ExAllocatePoolWithTag(PagedPool
, SafeFileName
.MaximumLength
, TAG_STRING
);
42 if(!SafeFileName
.Buffer
)
44 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
49 RtlCopyMemory(SafeFileName
.Buffer
, L
"\\??\\", 4 * sizeof(WCHAR
));
51 Status
= MmCopyFromCaller(SafeFileName
.Buffer
+ 4, src
, SafeFileName
.MaximumLength
- (4 * sizeof(WCHAR
)));
52 if(!NT_SUCCESS(Status
))
54 ExFreePool(SafeFileName
.Buffer
);
55 SetLastNtError(Status
);
59 Ret
= IntGdiAddFontResource(&SafeFileName
, (DWORD
)fl
);
61 ExFreePool(SafeFileName
.Buffer
);
70 NtGdiGetFontUnicodeRanges(
72 OUT OPTIONAL LPGLYPHSET pgs
)
81 NTSTATUS Status
= STATUS_SUCCESS
;
86 SetLastWin32Error(ERROR_INVALID_HANDLE
);
90 Dc_Attr
= pDc
->pDc_Attr
;
91 if(!Dc_Attr
) Dc_Attr
= &pDc
->Dc_Attr
;
93 hFont
= Dc_Attr
->hlfntNew
;
94 TextObj
= TEXTOBJ_LockText(hFont
);
98 SetLastWin32Error(ERROR_INVALID_HANDLE
);
101 FontGdi
= ObjToGDI(TextObj
->Font
, FONT
);
104 Size
= ftGetFontUnicodeRanges( FontGdi
, NULL
);
107 pgsSafe
= ExAllocatePoolWithTag(PagedPool
, Size
, TAG_GDITEXT
);
110 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
115 Size
= ftGetFontUnicodeRanges( FontGdi
, pgsSafe
);
121 ProbeForWrite(pgsSafe
, Size
, 1);
122 RtlCopyMemory(pgs
, pgsSafe
, Size
);
126 Status
= _SEH_GetExceptionCode();
130 if (!NT_SUCCESS(Status
)) Size
= 0;
132 ExFreePoolWithTag(pgsSafe
, TAG_GDITEXT
);
135 TEXTOBJ_UnlockText(TextObj
);
142 NtGdiGetGlyphOutline(
146 OUT LPGLYPHMETRICS pgm
,
148 OUT OPTIONAL PVOID UnsafeBuf
,
150 IN BOOL bIgnoreRotation
)
152 ULONG Ret
= GDI_ERROR
;
156 NTSTATUS Status
= STATUS_SUCCESS
;
161 SetLastWin32Error(ERROR_INVALID_HANDLE
);
165 if (UnsafeBuf
&& cjBuf
)
167 pvBuf
= ExAllocatePoolWithTag(PagedPool
, cjBuf
, TAG_GDITEXT
);
170 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
175 Ret
= ftGdiGetGlyphOutline( dc
,
188 ProbeForWrite(UnsafeBuf
, cjBuf
, 1);
189 RtlCopyMemory(UnsafeBuf
, pvBuf
, cjBuf
);
193 Status
= _SEH_GetExceptionCode();
197 ExFreePoolWithTag(pvBuf
, TAG_GDITEXT
);
204 ProbeForWrite(pgm
, sizeof(GLYPHMETRICS
), 1);
205 RtlCopyMemory(pgm
, &gm
, sizeof(GLYPHMETRICS
));
209 Status
= _SEH_GetExceptionCode();
214 if (! NT_SUCCESS(Status
))
216 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
227 NtGdiGetKerningPairs(HDC hDC
,
229 LPKERNINGPAIR krnpair
)
236 From "Undocumented Windows 2000 Secrets" Appendix B, Table B-2, page
237 472, this is NtGdiGetOutlineTextMetricsInternalW.
241 NtGdiGetOutlineTextMetricsInternalW (HDC hDC
,
243 OUTLINETEXTMETRICW
*otm
,
252 OUTLINETEXTMETRICW
*potm
;
258 SetLastWin32Error(ERROR_INVALID_HANDLE
);
261 Dc_Attr
= dc
->pDc_Attr
;
262 if(!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
263 hFont
= Dc_Attr
->hlfntNew
;
264 TextObj
= TEXTOBJ_LockText(hFont
);
268 SetLastWin32Error(ERROR_INVALID_HANDLE
);
271 FontGDI
= ObjToGDI(TextObj
->Font
, FONT
);
272 TEXTOBJ_UnlockText(TextObj
);
273 Size
= IntGetOutlineTextMetrics(FontGDI
, 0, NULL
);
274 if (!otm
) return Size
;
277 SetLastWin32Error(ERROR_INSUFFICIENT_BUFFER
);
280 potm
= ExAllocatePoolWithTag(PagedPool
, Size
, TAG_GDITEXT
);
283 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
286 IntGetOutlineTextMetrics(FontGDI
, Size
, potm
);
289 Status
= MmCopyToCaller(otm
, potm
, Size
);
290 if (! NT_SUCCESS(Status
))
292 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
304 IN PENUMLOGFONTEXDVW pelfw
,
310 ENUMLOGFONTEXDVW SafeLogfont
;
313 NTSTATUS Status
= STATUS_SUCCESS
;
322 ProbeForRead(pelfw
, sizeof(ENUMLOGFONTEXDVW
), 1);
323 RtlCopyMemory(&SafeLogfont
, pelfw
, sizeof(ENUMLOGFONTEXDVW
));
327 Status
= _SEH_GetExceptionCode();
331 if (!NT_SUCCESS(Status
))
336 TextObj
= TEXTOBJ_AllocTextWithHandle();
341 hNewFont
= TextObj
->BaseObject
.hHmgr
;
343 TextObj
->lft
= cjElfw
;
345 RtlCopyMemory (&TextObj
->logfont
, &SafeLogfont
, sizeof(ENUMLOGFONTEXDVW
));
347 if (SafeLogfont
.elfEnumLogfontEx
.elfLogFont
.lfEscapement
!=
348 SafeLogfont
.elfEnumLogfontEx
.elfLogFont
.lfOrientation
)
350 /* this should really depend on whether GM_ADVANCED is set */
351 TextObj
->logfont
.elfEnumLogfontEx
.elfLogFont
.lfOrientation
=
352 TextObj
->logfont
.elfEnumLogfontEx
.elfLogFont
.lfEscapement
;
354 TEXTOBJ_UnlockText(TextObj
);