ReactOS  0.4.13-dev-464-g6b95727
font.c File Reference
#include <win32k.h>
#include <debug.h>
Include dependency graph for font.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

HFONT APIENTRY HfontCreate (IN PENUMLOGFONTEXDVW pelfw, IN ULONG cjElfw, IN LFTYPE lft, IN FLONG fl, IN PVOID pvCliData)
 
HFONT FASTCALL GreCreateFontIndirectW (LOGFONTW *lplf)
 
DWORD FASTCALL GreGetKerningPairs (HDC hDC, ULONG NumPairs, LPKERNINGPAIR krnpair)
 
ULONG FASTCALL FontGetObject (PTEXTOBJ plfont, ULONG cjBuffer, PVOID pvBuffer)
 
DWORD FASTCALL IntGetCharDimensions (HDC hdc, PTEXTMETRICW ptm, PDWORD height)
 
DWORD FASTCALL IntGetFontLanguageInfo (PDC Dc)
 
PTEXTOBJ FASTCALL RealizeFontInit (HFONT hFont)
 
INT APIENTRY NtGdiAddFontResourceW (IN WCHAR *pwcFiles, IN ULONG cwc, IN ULONG cFiles, IN FLONG fl, IN DWORD dwPidTid, IN OPTIONAL DESIGNVECTOR *pdv)
 
HANDLE APIENTRY NtGdiAddFontMemResourceEx (IN PVOID pvBuffer, IN DWORD cjBuffer, IN DESIGNVECTOR *pdv, IN ULONG cjDV, OUT DWORD *pNumFonts)
 
BOOL APIENTRY NtGdiRemoveFontMemResourceEx (IN HANDLE hMMFont)
 
DWORD APIENTRY NtGdiGetCharacterPlacementW (IN HDC hdc, IN LPWSTR pwsz, IN INT nCount, IN INT nMaxExtent, IN OUT LPGCP_RESULTSW pgcpw, IN DWORD dwFlags)
 
DWORD APIENTRY NtGdiGetFontData (HDC hDC, DWORD Table, DWORD Offset, LPVOID Buffer, DWORD Size)
 
DWORD APIENTRY NtGdiGetFontUnicodeRanges (IN HDC hdc, OUT OPTIONAL LPGLYPHSET pgs)
 
ULONG APIENTRY NtGdiGetGlyphOutline (IN HDC hdc, IN WCHAR wch, IN UINT iFormat, OUT LPGLYPHMETRICS pgm, IN ULONG cjBuf, OUT OPTIONAL PVOID UnsafeBuf, IN LPMAT2 pmat2, IN BOOL bIgnoreRotation)
 
DWORD APIENTRY NtGdiGetKerningPairs (HDC hDC, ULONG NumPairs, LPKERNINGPAIR krnpair)
 
ULONG APIENTRY NtGdiGetOutlineTextMetricsInternalW (HDC hDC, ULONG Data, OUTLINETEXTMETRICW *otm, TMDIFF *Tmd)
 
W32KAPI BOOL APIENTRY NtGdiGetFontResourceInfoInternalW (IN LPWSTR pwszFiles, IN ULONG cwc, IN ULONG cFiles, IN UINT cjIn, IN OUT LPDWORD pdwBytes, OUT LPVOID pvBuf, IN DWORD dwType)
 
BOOL APIENTRY NtGdiGetRealizationInfo (IN HDC hdc, OUT PREALIZATION_INFO pri, IN HFONT hf)
 
HFONT APIENTRY NtGdiHfontCreate (IN PENUMLOGFONTEXDVW pelfw, IN ULONG cjElfw, IN LFTYPE lft, IN FLONG fl, IN PVOID pvCliData)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Includes

Definition at line 15 of file font.c.

Function Documentation

◆ FontGetObject()

ULONG FASTCALL FontGetObject ( PTEXTOBJ  plfont,
ULONG  cjBuffer,
PVOID  pvBuffer 
)

Definition at line 293 of file font.c.

294 {
295  ULONG cjMaxSize;
296  ENUMLOGFONTEXDVW *plf;
297 
298  ASSERT(plfont);
299  plf = &plfont->logfont;
300 
301  if (!(plfont->fl & TEXTOBJECT_INIT))
302  {
304  DPRINT1("FontGetObject font not initialized!\n");
305 
306  Status = TextIntRealizeFont(plfont->BaseObject.hHmgr, plfont);
307  if (!NT_SUCCESS(Status))
308  {
309  DPRINT1("FontGetObject(TextIntRealizeFont) Status = 0x%lx\n", Status);
310  }
311  }
312 
313  /* If buffer is NULL, only the size is requested */
314  if (pvBuffer == NULL) return sizeof(LOGFONTW);
315 
316  /* Calculate the maximum size according to number of axes */
317  cjMaxSize = FIELD_OFFSET(ENUMLOGFONTEXDVW,
318  elfDesignVector.dvValues[plf->elfDesignVector.dvNumAxes]);
319 
320  if (cjBuffer > cjMaxSize) cjBuffer = cjMaxSize;
321 
322  RtlCopyMemory(pvBuffer, plf, cjBuffer);
323 
324  return cjBuffer;
325 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
LONG NTSTATUS
Definition: precomp.h:26
#define TEXTOBJECT_INIT
Definition: text.h:56
DWORD dvNumAxes
Definition: wingdi.h:2747
NTSTATUS FASTCALL TextIntRealizeFont(HFONT FontHandle, PTEXTOBJ pTextObj)
Definition: freetype.c:4902
FLONG fl
Definition: text.h:65
HGDIOBJ hHmgr(VOID)
Definition: baseobj.hpp:95
smooth NULL
Definition: ftsmooth.c:416
BASEOBJECT BaseObject
Definition: text.h:63
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct tagLOGFONTW LOGFONTW
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ENUMLOGFONTEXDVW logfont
Definition: text.h:70
Status
Definition: gdiplustypes.h:24
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define DPRINT1
Definition: precomp.h:8
DESIGNVECTOR elfDesignVector
Definition: wingdi.h:2758
unsigned int ULONG
Definition: retypes.h:1
_In_ ULONG cjBuffer
Definition: ntgdi.h:2860

Referenced by GreGetObject().

◆ GreCreateFontIndirectW()

HFONT FASTCALL GreCreateFontIndirectW ( LOGFONTW lplf)

Internal

Definition at line 23 of file font.c.

24 {
25  if (lplf)
26  {
27  ENUMLOGFONTEXDVW Logfont;
28 
29  RtlCopyMemory( &Logfont.elfEnumLogfontEx.elfLogFont, lplf, sizeof(LOGFONTW));
31  sizeof(Logfont.elfEnumLogfontEx.elfFullName));
33  sizeof(Logfont.elfEnumLogfontEx.elfStyle));
35  sizeof(Logfont.elfEnumLogfontEx.elfScript));
36 
37  Logfont.elfDesignVector.dvNumAxes = 0;
38 
39  RtlZeroMemory( &Logfont.elfDesignVector, sizeof(DESIGNVECTOR));
40 
41  return HfontCreate((PENUMLOGFONTEXDVW)&Logfont, 0, 0, 0, NULL );
42  }
43  else return NULL;
44 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
WCHAR elfFullName[LF_FULLFACESIZE]
Definition: wingdi.h:2681
DWORD dvNumAxes
Definition: wingdi.h:2747
WCHAR elfStyle[LF_FACESIZE]
Definition: wingdi.h:2682
WCHAR elfScript[LF_FACESIZE]
Definition: wingdi.h:2683
smooth NULL
Definition: ftsmooth.c:416
HFONT APIENTRY HfontCreate(IN PENUMLOGFONTEXDVW pelfw, IN ULONG cjElfw, IN LFTYPE lft, IN FLONG fl, IN PVOID pvCliData)
Definition: font.c:1135
DESIGNVECTOR elfDesignVector
Definition: wingdi.h:2758
LOGFONTW elfLogFont
Definition: wingdi.h:2680
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
ENUMLOGFONTEXW elfEnumLogfontEx
Definition: wingdi.h:2757

Referenced by IntPaintDesktop(), MENU_DrawPopupGlyph(), MenuInit(), UITOOLS95_DFC_ButtonCheckRadio(), UITOOLS95_DrawFrameCaption(), UITOOLS95_DrawFrameMenu(), and UITOOLS95_DrawFrameScroll().

◆ GreGetKerningPairs()

DWORD FASTCALL GreGetKerningPairs ( HDC  hDC,
ULONG  NumPairs,
LPKERNINGPAIR  krnpair 
)

Definition at line 48 of file font.c.

52 {
53  PDC dc;
54  PDC_ATTR pdcattr;
55  PTEXTOBJ TextObj;
56  PFONTGDI FontGDI;
57  DWORD Count;
58  KERNINGPAIR *pKP;
59 
60  dc = DC_LockDc(hDC);
61  if (!dc)
62  {
64  return 0;
65  }
66 
67  pdcattr = dc->pdcattr;
68  TextObj = RealizeFontInit(pdcattr->hlfntNew);
69  DC_UnlockDc(dc);
70 
71  if (!TextObj)
72  {
74  return 0;
75  }
76 
77  FontGDI = ObjToGDI(TextObj->Font, FONT);
78  TEXTOBJ_UnlockText(TextObj);
79 
80  Count = ftGdiGetKerningPairs(FontGDI,0,NULL);
81 
82  if ( Count && krnpair )
83  {
84  if (Count > NumPairs)
85  {
87  return 0;
88  }
90  if (!pKP)
91  {
93  return 0;
94  }
95  ftGdiGetKerningPairs(FontGDI,Count,pKP);
96 
97  RtlCopyMemory(krnpair, pKP, Count * sizeof(KERNINGPAIR));
98 
100  }
101  return Count;
102 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
HDC dc
Definition: cylfrac.c:34
DWORD FASTCALL ftGdiGetKerningPairs(PFONTGDI Font, DWORD cPairs, LPKERNINGPAIR pKerningPair)
Definition: freetype.c:5388
Definition: text.h:59
HANDLE hlfntNew
Definition: ntgdihdl.h:327
smooth NULL
Definition: ftsmooth.c:416
Definition: polytest.cpp:40
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
static HDC hDC
Definition: 3dtext.c:33
FONTOBJ * Font
Definition: text.h:66
#define GDITAG_TEXT
Definition: tags.h:171
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
PTEXTOBJ FASTCALL RealizeFontInit(HFONT hFont)
Definition: font.c:422
#define ObjToGDI(ClipObj, Type)
Definition: engobjects.h:180
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ HfontCreate()

HFONT APIENTRY HfontCreate ( IN PENUMLOGFONTEXDVW  pelfw,
IN ULONG  cjElfw,
IN LFTYPE  lft,
IN FLONG  fl,
IN PVOID  pvCliData 
)

Definition at line 1135 of file font.c.

1141 {
1142  HFONT hNewFont;
1143  PLFONT plfont;
1144 
1145  if (!pelfw)
1146  {
1147  return NULL;
1148  }
1149 
1150  plfont = LFONT_AllocFontWithHandle();
1151  if (!plfont)
1152  {
1153  return NULL;
1154  }
1155  hNewFont = plfont->BaseObject.hHmgr;
1156 
1157  plfont->lft = lft;
1158  plfont->fl = fl;
1159  RtlCopyMemory (&plfont->logfont, pelfw, sizeof(ENUMLOGFONTEXDVW));
1160  ExInitializePushLock(&plfont->lock);
1161 
1162  if (pelfw->elfEnumLogfontEx.elfLogFont.lfEscapement !=
1163  pelfw->elfEnumLogfontEx.elfLogFont.lfOrientation)
1164  {
1165  /* This should really depend on whether GM_ADVANCED is set */
1168  }
1169  LFONT_UnlockFont(plfont);
1170 
1171  if (pvCliData && hNewFont)
1172  {
1173  // FIXME: Use GDIOBJ_InsertUserData
1175  {
1176  INT Index = GDI_HANDLE_GET_INDEX((HGDIOBJ)hNewFont);
1178  Entry->UserData = pvCliData;
1179  }
1181  }
1182 
1183  return hNewFont;
1184 }
#define GDI_HANDLE_GET_INDEX(h)
Definition: gdi.h:28
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define LFONT_AllocFontWithHandle()
Definition: text.h:76
LONG lfEscapement
Definition: dimm.idl:61
int32_t INT
Definition: typedefs.h:56
#define LFONT_UnlockFont(plfnt)
Definition: text.h:79
_In_ FLONG fl
Definition: winddi.h:1279
Definition: text.h:59
LONG lfOrientation
Definition: dimm.idl:62
FLONG fl
Definition: text.h:65
HGDIOBJ hHmgr(VOID)
Definition: baseobj.hpp:95
smooth NULL
Definition: ftsmooth.c:416
#define ExInitializePushLock
Definition: ex.h:999
#define GdiHandleTable
Definition: win32nt.h:35
BASEOBJECT BaseObject
Definition: text.h:63
static const UCHAR Index[8]
Definition: usbohci.c:18
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
ENUMLOGFONTEXDVW logfont
Definition: text.h:70
Definition: gdi.h:1
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
LFTYPE lft
Definition: text.h:64
EX_PUSH_LOCK lock
Definition: text.h:71
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
LOGFONTW elfLogFont
Definition: wingdi.h:2680
ENUMLOGFONTEXW elfEnumLogfontEx
Definition: wingdi.h:2757
base of all file and directory entries
Definition: entries.h:82

Referenced by GreCreateFontIndirectW(), and NtGdiHfontCreate().

◆ IntGetCharDimensions()

DWORD FASTCALL IntGetCharDimensions ( HDC  hdc,
PTEXTMETRICW  ptm,
PDWORD  height 
)

Definition at line 329 of file font.c.

330 {
331  PDC pdc;
332  PDC_ATTR pdcattr;
333  PTEXTOBJ TextObj;
334  SIZE sz;
335  TMW_INTERNAL tmwi;
336  BOOL Good;
337 
338  static const WCHAR alphabet[] = {
339  'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q',
340  'r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H',
341  'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',0};
342 
343  if(!ftGdiGetTextMetricsW(hdc, &tmwi)) return 0;
344 
345  pdc = DC_LockDc(hdc);
346 
347  if (!pdc) return 0;
348 
349  pdcattr = pdc->pdcattr;
350 
351  TextObj = RealizeFontInit(pdcattr->hlfntNew);
352  if ( !TextObj )
353  {
354  DC_UnlockDc(pdc);
355  return 0;
356  }
357  Good = TextIntGetTextExtentPoint(pdc, TextObj, alphabet, 52, 0, NULL, 0, &sz, 0);
358  TEXTOBJ_UnlockText(TextObj);
359  DC_UnlockDc(pdc);
360 
361  if (!Good) return 0;
362  if (ptm) *ptm = tmwi.TextMetric;
363  if (height) *height = tmwi.TextMetric.tmHeight;
364 
365  return (sz.cx / 26 + 1) / 2;
366 }
TEXTMETRICW TextMetric
Definition: ntgdityp.h:369
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
Definition: text.h:59
unsigned int BOOL
Definition: ntddk_ex.h:94
HANDLE hlfntNew
Definition: ntgdihdl.h:327
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:319
Definition: polytest.cpp:40
__wchar_t WCHAR
Definition: xmlstorage.h:180
HDC hdc
Definition: main.c:9
BOOL FASTCALL ftGdiGetTextMetricsW(HDC hDC, PTMW_INTERNAL ptmwi)
Definition: freetype.c:4252
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
PTEXTOBJ FASTCALL RealizeFontInit(HFONT hFont)
Definition: font.c:422
LONG tmHeight
Definition: wingdi.h:2361
BOOL FASTCALL TextIntGetTextExtentPoint(PDC dc, PTEXTOBJ TextObj, LPCWSTR String, INT Count, ULONG MaxExtent, LPINT Fit, LPINT Dx, LPSIZE Size, FLONG fl)
Definition: freetype.c:3931

Referenced by co_IntInitializeDesktopGraphics(), IntGetDialogBaseUnits(), MENU_CalcItemSize(), and UserChangeDisplaySettings().

◆ IntGetFontLanguageInfo()

DWORD FASTCALL IntGetFontLanguageInfo ( PDC  Dc)

Definition at line 371 of file font.c.

372 {
373  PDC_ATTR pdcattr;
374  FONTSIGNATURE fontsig;
375  static const DWORD GCP_DBCS_MASK=0x003F0000,
376  GCP_DIACRITIC_MASK=0x00000000,
377  FLI_GLYPHS_MASK=0x00000000,
378  GCP_GLYPHSHAPE_MASK=0x00000040,
379  GCP_KASHIDA_MASK=0x00000000,
380  GCP_LIGATE_MASK=0x00000000,
381  GCP_USEKERNING_MASK=0x00000000,
382  GCP_REORDER_MASK=0x00000060;
383 
384  DWORD result=0;
385 
386  ftGdiGetTextCharsetInfo( Dc, &fontsig, 0 );
387 
388  /* We detect each flag we return using a bitmask on the Codepage Bitfields */
389  if( (fontsig.fsCsb[0]&GCP_DBCS_MASK)!=0 )
390  result|=GCP_DBCS;
391 
392  if( (fontsig.fsCsb[0]&GCP_DIACRITIC_MASK)!=0 )
394 
395  if( (fontsig.fsCsb[0]&FLI_GLYPHS_MASK)!=0 )
397 
398  if( (fontsig.fsCsb[0]&GCP_GLYPHSHAPE_MASK)!=0 )
400 
401  if( (fontsig.fsCsb[0]&GCP_KASHIDA_MASK)!=0 )
403 
404  if( (fontsig.fsCsb[0]&GCP_LIGATE_MASK)!=0 )
406 
407  if( (fontsig.fsCsb[0]&GCP_USEKERNING_MASK)!=0 )
409 
410  pdcattr = Dc->pdcattr;
411 
412  /* This might need a test for a HEBREW- or ARABIC_CHARSET as well */
413  if ( pdcattr->flTextAlign & TA_RTLREADING )
414  if( (fontsig.fsCsb[0]&GCP_REORDER_MASK)!=0 )
416 
417  return result;
418 }
#define FLI_GLYPHS
Definition: wingdi.h:845
#define GCP_DIACRITIC
Definition: wingdi.h:830
#define GCP_LIGATE
Definition: wingdi.h:836
#define GCP_KASHIDA
Definition: wingdi.h:835
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD fsCsb[2]
Definition: wingdi.h:1521
#define GCP_GLYPHSHAPE
Definition: wingdi.h:832
FLONG flTextAlign
Definition: ntgdihdl.h:321
#define GCP_REORDER
Definition: wingdi.h:842
#define GCP_DBCS
Definition: wingdi.h:827
#define TA_RTLREADING
Definition: wingdi.h:933
INT FASTCALL ftGdiGetTextCharsetInfo(PDC Dc, LPFONTSIGNATURE lpSig, DWORD dwFlags)
Definition: freetype.c:4071
GLuint64EXT * result
Definition: glext.h:11304
#define GCP_USEKERNING
Definition: wingdi.h:844

Referenced by NtGdiGetDCDword().

◆ NtGdiAddFontMemResourceEx()

HANDLE APIENTRY NtGdiAddFontMemResourceEx ( IN PVOID  pvBuffer,
IN DWORD  cjBuffer,
IN DESIGNVECTOR pdv,
IN ULONG  cjDV,
OUT DWORD pNumFonts 
)

Definition at line 498 of file font.c.

504 {
505  _SEH2_VOLATILE PVOID Buffer = NULL;
506  HANDLE Ret;
507  DWORD NumFonts = 0;
508 
509  DPRINT("NtGdiAddFontMemResourceEx\n");
512 
513  if (!pvBuffer || !cjBuffer)
514  return NULL;
515 
516  _SEH2_TRY
517  {
518  ProbeForRead(pvBuffer, cjBuffer, sizeof(BYTE));
520  RtlCopyMemory(Buffer, pvBuffer, cjBuffer);
521  }
523  {
524  if (Buffer != NULL)
525  {
527  }
528  _SEH2_YIELD(return NULL);
529  }
530  _SEH2_END;
531 
532  Ret = IntGdiAddFontMemResource(Buffer, cjBuffer, &NumFonts);
534 
535  _SEH2_TRY
536  {
537  ProbeForWrite(pNumFonts, sizeof(NumFonts), 1);
538  *pNumFonts = NumFonts;
539  }
541  {
542  /* Leak it? */
543  _SEH2_YIELD(return NULL);
544  }
545  _SEH2_END;
546 
547 
548  return Ret;
549 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
_In_ ULONG_PTR _In_opt_ DESIGNVECTOR * pdv
Definition: winddi.h:3723
PVOID NTAPI ExAllocatePoolWithQuotaTag(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag)
Definition: expool.c:2939
#define DBG_UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
#define TAG_FONT
Definition: tags.h:12
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4250
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
unsigned char BYTE
Definition: mem.h:68
_SEH2_END
Definition: create.c:4424
HANDLE FASTCALL IntGdiAddFontMemResource(PVOID Buffer, DWORD dwSize, PDWORD pNumAdded)
Definition: freetype.c:1500
_In_ ULONG cjBuffer
Definition: ntgdi.h:2860
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by AddFontMemResourceEx().

◆ NtGdiAddFontResourceW()

INT APIENTRY NtGdiAddFontResourceW ( IN WCHAR pwcFiles,
IN ULONG  cwc,
IN ULONG  cFiles,
IN FLONG  fl,
IN DWORD  dwPidTid,
IN OPTIONAL DESIGNVECTOR pdv 
)

Functions

Definition at line 446 of file font.c.

453 {
454  UNICODE_STRING SafeFileName;
455  INT Ret;
456 
458  DBG_UNREFERENCED_PARAMETER(dwPidTid);
460 
461  DPRINT("NtGdiAddFontResourceW\n");
462 
463  /* cwc = Length + trailing zero. */
464  if ((cwc <= 1) || (cwc > UNICODE_STRING_MAX_CHARS))
465  return 0;
466 
467  SafeFileName.MaximumLength = (USHORT)(cwc * sizeof(WCHAR));
468  SafeFileName.Length = SafeFileName.MaximumLength - sizeof(UNICODE_NULL);
469  SafeFileName.Buffer = ExAllocatePoolWithTag(PagedPool,
470  SafeFileName.MaximumLength,
471  TAG_STRING);
472  if (!SafeFileName.Buffer)
473  {
474  return 0;
475  }
476 
477  _SEH2_TRY
478  {
479  ProbeForRead(pwcFiles, cwc * sizeof(WCHAR), sizeof(WCHAR));
480  RtlCopyMemory(SafeFileName.Buffer, pwcFiles, SafeFileName.Length);
481  }
483  {
484  ExFreePoolWithTag(SafeFileName.Buffer, TAG_STRING);
485  _SEH2_YIELD(return 0);
486  }
487  _SEH2_END;
488 
489  SafeFileName.Buffer[SafeFileName.Length / sizeof(WCHAR)] = UNICODE_NULL;
490  Ret = IntGdiAddFontResource(&SafeFileName, fl);
491 
492  ExFreePoolWithTag(SafeFileName.Buffer, TAG_STRING);
493  return Ret;
494 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
_In_ ULONG_PTR _In_opt_ DESIGNVECTOR * pdv
Definition: winddi.h:3723
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define DBG_UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
#define TAG_STRING
Definition: oslist.c:24
int32_t INT
Definition: typedefs.h:56
_SEH2_TRY
Definition: create.c:4250
_In_ FLONG fl
Definition: winddi.h:1279
#define UNICODE_NULL
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
void DPRINT(...)
Definition: polytest.cpp:61
#define UNICODE_STRING_MAX_CHARS
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
INT FASTCALL IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics)
Definition: freetype.c:1388
_SEH2_END
Definition: create.c:4424
unsigned short USHORT
Definition: pedump.c:61
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by GdiAddFontResourceW().

◆ NtGdiGetCharacterPlacementW()

DWORD APIENTRY NtGdiGetCharacterPlacementW ( IN HDC  hdc,
IN LPWSTR  pwsz,
IN INT  nCount,
IN INT  nMaxExtent,
IN OUT LPGCP_RESULTSW  pgcpw,
IN DWORD  dwFlags 
)

Definition at line 566 of file font.c.

573 {
575  return 0;
576 #if 0
577  return GreGetCharacterPlacementW( hdc,
578  pwsz,
579  nCount,
580  nMaxExtent,
581  pgcpw,
582  dwFlags);
583 #endif
584 }
HDC hdc
Definition: main.c:9
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define UNIMPLEMENTED
Definition: debug.h:114

Referenced by NewGetCharacterPlacementW().

◆ NtGdiGetFontData()

DWORD APIENTRY NtGdiGetFontData ( HDC  hDC,
DWORD  Table,
DWORD  Offset,
LPVOID  Buffer,
DWORD  Size 
)

Definition at line 588 of file font.c.

594 {
595  PDC Dc;
596  PDC_ATTR pdcattr;
597  HFONT hFont;
598  PTEXTOBJ TextObj;
599  PFONTGDI FontGdi;
602 
603  if (Buffer && Size)
604  {
605  _SEH2_TRY
606  {
607  ProbeForRead(Buffer, Size, 1);
608  }
610  {
612  }
613  _SEH2_END
614  }
615 
616  if (!NT_SUCCESS(Status)) return Result;
617 
618  Dc = DC_LockDc(hDC);
619  if (Dc == NULL)
620  {
622  return GDI_ERROR;
623  }
624  pdcattr = Dc->pdcattr;
625 
626  hFont = pdcattr->hlfntNew;
627  TextObj = RealizeFontInit(hFont);
628  DC_UnlockDc(Dc);
629 
630  if (TextObj == NULL)
631  {
633  return GDI_ERROR;
634  }
635 
636  FontGdi = ObjToGDI(TextObj->Font, FONT);
637 
639 
640  TEXTOBJ_UnlockText(TextObj);
641 
642  return Result;
643 }
ASMGENDATA Table[]
Definition: genincdata.c:61
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
LONG NTSTATUS
Definition: precomp.h:26
HFONT hFont
Definition: main.c:53
_SEH2_TRY
Definition: create.c:4250
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
Definition: text.h:59
HANDLE hlfntNew
Definition: ntgdihdl.h:327
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
Definition: bufpool.h:45
Definition: polytest.cpp:40
DWORD FASTCALL ftGdiGetFontData(PFONTGDI FontGdi, DWORD Table, DWORD Offset, PVOID Buffer, DWORD Size)
Definition: freetype.c:4348
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
static HDC hDC
Definition: 3dtext.c:33
FONTOBJ * Font
Definition: text.h:66
_SEH2_END
Definition: create.c:4424
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
PTEXTOBJ FASTCALL RealizeFontInit(HFONT hFont)
Definition: font.c:422
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define ObjToGDI(ClipObj, Type)
Definition: engobjects.h:180
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define GDI_ERROR
Definition: wingdi.h:1291
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by GetFontData().

◆ NtGdiGetFontResourceInfoInternalW()

W32KAPI BOOL APIENTRY NtGdiGetFontResourceInfoInternalW ( IN LPWSTR  pwszFiles,
IN ULONG  cwc,
IN ULONG  cFiles,
IN UINT  cjIn,
IN OUT LPDWORD  pdwBytes,
OUT LPVOID  pvBuf,
IN DWORD  dwType 
)

Definition at line 952 of file font.c.

960 {
962  DWORD dwBytes, dwBytesRequested;
963  UNICODE_STRING SafeFileNames;
964  BOOL bRet = FALSE;
965  ULONG cbStringSize;
966  LPVOID Buffer;
967 
968  /* FIXME: Handle cFiles > 0 */
969 
970  /* Check for valid dwType values */
971  if (dwType > 5)
972  {
974  return FALSE;
975  }
976 
977  /* Allocate a safe unicode string buffer */
978  cbStringSize = cwc * sizeof(WCHAR);
979  SafeFileNames.MaximumLength = SafeFileNames.Length = (USHORT)cbStringSize - sizeof(WCHAR);
980  SafeFileNames.Buffer = ExAllocatePoolWithTag(PagedPool,
981  cbStringSize,
982  TAG_USTR);
983  if (!SafeFileNames.Buffer)
984  {
986  return FALSE;
987  }
988  RtlZeroMemory(SafeFileNames.Buffer, SafeFileNames.MaximumLength);
989 
990  /* Check buffers and copy pwszFiles to safe unicode string */
991  _SEH2_TRY
992  {
993  ProbeForRead(pwszFiles, cbStringSize, 1);
994  ProbeForWrite(pdwBytes, sizeof(DWORD), 1);
995  if (pvBuf)
996  ProbeForWrite(pvBuf, cjIn, 1);
997 
998  dwBytes = *pdwBytes;
999  dwBytesRequested = dwBytes;
1000 
1001  RtlCopyMemory(SafeFileNames.Buffer, pwszFiles, cbStringSize);
1002  if (dwBytes > 0)
1003  {
1005  }
1006  else
1007  {
1009  }
1010  }
1012  {
1014  }
1015  _SEH2_END
1016 
1017  if(!NT_SUCCESS(Status))
1018  {
1020  /* Free the string buffer for the safe filename */
1021  ExFreePoolWithTag(SafeFileNames.Buffer, TAG_USTR);
1022  return FALSE;
1023  }
1024 
1025  /* Do the actual call */
1026  bRet = IntGdiGetFontResourceInfo(&SafeFileNames,
1027  (pvBuf ? Buffer : NULL),
1028  &dwBytes, dwType);
1029 
1030  /* Check if succeeded */
1031  if (bRet)
1032  {
1033  /* Copy the data back to caller */
1034  _SEH2_TRY
1035  {
1036  /* Buffers are already probed */
1037  if (pvBuf && dwBytesRequested > 0)
1038  RtlCopyMemory(pvBuf, Buffer, min(dwBytesRequested, dwBytes));
1039  *pdwBytes = dwBytes;
1040  }
1042  {
1044  }
1045  _SEH2_END
1046 
1047  if(!NT_SUCCESS(Status))
1048  {
1050  bRet = FALSE;
1051  }
1052  }
1053 
1055  /* Free the string for the safe filenames */
1056  ExFreePoolWithTag(SafeFileNames.Buffer, TAG_USTR);
1057 
1058  return bRet;
1059 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TAG_FINF
Definition: text.h:3
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
USHORT MaximumLength
Definition: env_spec_w32.h:370
BOOL FASTCALL IntGdiGetFontResourceInfo(PUNICODE_STRING FileName, PVOID pBuffer, DWORD *pdwBytes, DWORD dwType)
Definition: freetype.c:5101
LONG NTSTATUS
Definition: precomp.h:26
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4250
unsigned int BOOL
Definition: ntddk_ex.h:94
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned long DWORD
Definition: ntddk_ex.h:95
static PWSTR PDWORD pdwBytes
Definition: layerapi.c:34
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
_In_ ULONG _In_ CLIPOBJ _In_ RECTL _In_ ULONG cjIn
Definition: winddi.h:3529
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
#define TAG_USTR
Definition: libsupp.c:111
Status
Definition: gdiplustypes.h:24
_SEH2_END
Definition: create.c:4424
unsigned short USHORT
Definition: pedump.c:61
#define min(a, b)
Definition: monoChain.cc:55
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2777
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

◆ NtGdiGetFontUnicodeRanges()

DWORD APIENTRY NtGdiGetFontUnicodeRanges ( IN HDC  hdc,
OUT OPTIONAL LPGLYPHSET  pgs 
)

Definition at line 650 of file font.c.

653 {
654  PDC pDc;
655  PDC_ATTR pdcattr;
656  HFONT hFont;
657  PTEXTOBJ TextObj;
658  PFONTGDI FontGdi;
659  DWORD Size = 0;
660  PGLYPHSET pgsSafe;
662 
663  pDc = DC_LockDc(hdc);
664  if (!pDc)
665  {
667  return 0;
668  }
669 
670  pdcattr = pDc->pdcattr;
671 
672  hFont = pdcattr->hlfntNew;
673  TextObj = RealizeFontInit(hFont);
674 
675  if ( TextObj == NULL)
676  {
678  goto Exit;
679  }
680  FontGdi = ObjToGDI(TextObj->Font, FONT);
681 
682  Size = ftGetFontUnicodeRanges( FontGdi, NULL);
683 
684  if (Size && pgs)
685  {
687  if (!pgsSafe)
688  {
690  Size = 0;
691  goto Exit;
692  }
693 
694  Size = ftGetFontUnicodeRanges( FontGdi, pgsSafe);
695 
696  if (Size)
697  {
698  _SEH2_TRY
699  {
700  ProbeForWrite(pgs, Size, 1);
701  RtlCopyMemory(pgs, pgsSafe, Size);
702  }
704  {
706  }
707  _SEH2_END
708 
709  if (!NT_SUCCESS(Status)) Size = 0;
710  }
711  ExFreePoolWithTag(pgsSafe, GDITAG_TEXT);
712  }
713 Exit:
714  TEXTOBJ_UnlockText(TextObj);
715  DC_UnlockDc(pDc);
716  return Size;
717 }
DWORD FASTCALL ftGetFontUnicodeRanges(PFONTGDI Font, PGLYPHSET glyphset)
Definition: freetype.c:4184
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
LONG NTSTATUS
Definition: precomp.h:26
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
HFONT hFont
Definition: main.c:53
_SEH2_TRY
Definition: create.c:4250
Definition: text.h:59
HANDLE hlfntNew
Definition: ntgdihdl.h:327
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
Definition: polytest.cpp:40
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static void Exit(void)
Definition: sock.c:1331
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
HDC hdc
Definition: main.c:9
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
FONTOBJ * Font
Definition: text.h:66
_SEH2_END
Definition: create.c:4424
#define GDITAG_TEXT
Definition: tags.h:171
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
PTEXTOBJ FASTCALL RealizeFontInit(HFONT hFont)
Definition: font.c:422
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define ObjToGDI(ClipObj, Type)
Definition: engobjects.h:180
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:2777
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

◆ NtGdiGetGlyphOutline()

ULONG APIENTRY NtGdiGetGlyphOutline ( IN HDC  hdc,
IN WCHAR  wch,
IN UINT  iFormat,
OUT LPGLYPHMETRICS  pgm,
IN ULONG  cjBuf,
OUT OPTIONAL PVOID  UnsafeBuf,
IN LPMAT2  pmat2,
IN BOOL  bIgnoreRotation 
)

Definition at line 721 of file font.c.

730 {
731  ULONG Ret = GDI_ERROR;
732  PDC dc;
733  PVOID pvBuf = NULL;
734  GLYPHMETRICS gm;
736 
737  dc = DC_LockDc(hdc);
738  if (!dc)
739  {
741  return GDI_ERROR;
742  }
743 
744  if (UnsafeBuf && cjBuf)
745  {
747  if (!pvBuf)
748  {
750  goto Exit;
751  }
752  }
753 
754  Ret = ftGdiGetGlyphOutline( dc,
755  wch,
756  iFormat,
757  pgm ? &gm : NULL,
758  cjBuf,
759  pvBuf,
760  pmat2,
761  bIgnoreRotation);
762 
763  if (pvBuf)
764  {
765  _SEH2_TRY
766  {
767  ProbeForWrite(UnsafeBuf, cjBuf, 1);
768  RtlCopyMemory(UnsafeBuf, pvBuf, cjBuf);
769  }
771  {
773  }
774  _SEH2_END
775 
777  }
778 
779  if (pgm)
780  {
781  _SEH2_TRY
782  {
783  ProbeForWrite(pgm, sizeof(GLYPHMETRICS), 1);
784  RtlCopyMemory(pgm, &gm, sizeof(GLYPHMETRICS));
785  }
787  {
789  }
790  _SEH2_END
791  }
792 
793  if (! NT_SUCCESS(Status))
794  {
796  Ret = GDI_ERROR;
797  }
798 
799 Exit:
800  DC_UnlockDc(dc);
801  return Ret;
802 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
LONG NTSTATUS
Definition: precomp.h:26
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
HDC dc
Definition: cylfrac.c:34
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4250
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
Definition: polytest.cpp:40
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static void Exit(void)
Definition: sock.c:1331
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_In_ DWORD cjBuf
Definition: winddi.h:3827
HDC hdc
Definition: main.c:9
_In_ SIZEL _In_ ULONG iFormat
Definition: winddi.h:3467
Status
Definition: gdiplustypes.h:24
_SEH2_END
Definition: create.c:4424
#define GDITAG_TEXT
Definition: tags.h:171
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
ULONG FASTCALL ftGdiGetGlyphOutline(PDC dc, WCHAR wch, UINT iFormat, LPGLYPHMETRICS pgm, ULONG cjBuf, PVOID pvBuf, LPMAT2 pmat2, BOOL bIgnoreRotation)
Definition: freetype.c:3456
unsigned int ULONG
Definition: retypes.h:1
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define GDI_ERROR
Definition: wingdi.h:1291
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by GetGlyphOutlineA(), and GetGlyphOutlineW().

◆ NtGdiGetKerningPairs()

DWORD APIENTRY NtGdiGetKerningPairs ( HDC  hDC,
ULONG  NumPairs,
LPKERNINGPAIR  krnpair 
)

Definition at line 806 of file font.c.

809 {
810  PDC dc;
811  PDC_ATTR pdcattr;
812  PTEXTOBJ TextObj;
813  PFONTGDI FontGDI;
814  DWORD Count;
815  KERNINGPAIR *pKP;
817 
818  dc = DC_LockDc(hDC);
819  if (!dc)
820  {
822  return 0;
823  }
824 
825  pdcattr = dc->pdcattr;
826  TextObj = RealizeFontInit(pdcattr->hlfntNew);
827  DC_UnlockDc(dc);
828 
829  if (!TextObj)
830  {
832  return 0;
833  }
834 
835  FontGDI = ObjToGDI(TextObj->Font, FONT);
836  TEXTOBJ_UnlockText(TextObj);
837 
838  Count = ftGdiGetKerningPairs(FontGDI,0,NULL);
839 
840  if ( Count && krnpair )
841  {
842  if (Count > NumPairs)
843  {
845  return 0;
846  }
848  if (!pKP)
849  {
851  return 0;
852  }
853  ftGdiGetKerningPairs(FontGDI,Count,pKP);
854  _SEH2_TRY
855  {
856  ProbeForWrite(krnpair, Count * sizeof(KERNINGPAIR), 1);
857  RtlCopyMemory(krnpair, pKP, Count * sizeof(KERNINGPAIR));
858  }
860  {
862  }
863  _SEH2_END
864  if (!NT_SUCCESS(Status))
865  {
867  Count = 0;
868  }
870  }
871  return Count;
872 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
LONG NTSTATUS
Definition: precomp.h:26
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
HDC dc
Definition: cylfrac.c:34
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4250
DWORD FASTCALL ftGdiGetKerningPairs(PFONTGDI Font, DWORD cPairs, LPKERNINGPAIR pKerningPair)
Definition: freetype.c:5388
Definition: text.h:59
HANDLE hlfntNew
Definition: ntgdihdl.h:327
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
Definition: polytest.cpp:40
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Status
Definition: gdiplustypes.h:24
static HDC hDC
Definition: 3dtext.c:33
FONTOBJ * Font
Definition: text.h:66
_SEH2_END
Definition: create.c:4424
#define GDITAG_TEXT
Definition: tags.h:171
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
PTEXTOBJ FASTCALL RealizeFontInit(HFONT hFont)
Definition: font.c:422
#define ObjToGDI(ClipObj, Type)
Definition: engobjects.h:180
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:2777
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by GetKerningPairsA(), and GetKerningPairsW().

◆ NtGdiGetOutlineTextMetricsInternalW()

ULONG APIENTRY NtGdiGetOutlineTextMetricsInternalW ( HDC  hDC,
ULONG  Data,
OUTLINETEXTMETRICW otm,
TMDIFF Tmd 
)

Definition at line 880 of file font.c.

884 {
885  PDC dc;
886  PDC_ATTR pdcattr;
887  PTEXTOBJ TextObj;
888  PFONTGDI FontGDI;
889  HFONT hFont = 0;
890  ULONG Size;
891  OUTLINETEXTMETRICW *potm;
893 
894  dc = DC_LockDc(hDC);
895  if (!dc)
896  {
898  return 0;
899  }
900  pdcattr = dc->pdcattr;
901  hFont = pdcattr->hlfntNew;
902  TextObj = RealizeFontInit(hFont);
903  DC_UnlockDc(dc);
904  if (!TextObj)
905  {
907  return 0;
908  }
909  FontGDI = ObjToGDI(TextObj->Font, FONT);
910  TextIntUpdateSize(dc, TextObj, FontGDI, TRUE);
911  TEXTOBJ_UnlockText(TextObj);
912  Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL);
913  if (!otm) return Size;
914  if (Size > Data)
915  {
917  return 0;
918  }
920  if (!potm)
921  {
923  return 0;
924  }
925  IntGetOutlineTextMetrics(FontGDI, Size, potm);
926  if (otm)
927  {
928  _SEH2_TRY
929  {
930  ProbeForWrite(otm, Size, 1);
931  RtlCopyMemory(otm, potm, Size);
932  }
934  {
936  }
937  _SEH2_END
938 
939  if (!NT_SUCCESS(Status))
940  {
942  Size = 0;
943  }
944  }
946  return Size;
947 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
LONG NTSTATUS
Definition: precomp.h:26
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
HDC dc
Definition: cylfrac.c:34
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
HFONT hFont
Definition: main.c:53
_SEH2_TRY
Definition: create.c:4250
BOOL FASTCALL TextIntUpdateSize(PDC dc, PTEXTOBJ TextObj, PFONTGDI FontGDI, BOOL bDoLock)
Definition: freetype.c:3334
Definition: text.h:59
HANDLE hlfntNew
Definition: ntgdihdl.h:327
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI FontGDI, UINT Size, OUTLINETEXTMETRICW *Otm)
Definition: freetype.c:2158
smooth NULL
Definition: ftsmooth.c:416
Definition: polytest.cpp:40
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
static HDC hDC
Definition: 3dtext.c:33
FONTOBJ * Font
Definition: text.h:66
_SEH2_END
Definition: create.c:4424
#define GDITAG_TEXT
Definition: tags.h:171
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
PTEXTOBJ FASTCALL RealizeFontInit(HFONT hFont)
Definition: font.c:422
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
unsigned int ULONG
Definition: retypes.h:1
#define ObjToGDI(ClipObj, Type)
Definition: engobjects.h:180
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:2777
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by GetOutlineTextMetricsW().

◆ NtGdiGetRealizationInfo()

BOOL APIENTRY NtGdiGetRealizationInfo ( IN HDC  hdc,
OUT PREALIZATION_INFO  pri,
IN HFONT  hf 
)

Definition at line 1066 of file font.c.

1070 {
1071  PDC pDc;
1072  PTEXTOBJ pTextObj;
1073  PFONTGDI pFontGdi;
1074  PDC_ATTR pdcattr;
1075  BOOL Ret = FALSE;
1076  INT i = 0;
1077  REALIZATION_INFO ri;
1078 
1079  pDc = DC_LockDc(hdc);
1080  if (!pDc)
1081  {
1083  return 0;
1084  }
1085  pdcattr = pDc->pdcattr;
1086  pTextObj = RealizeFontInit(pdcattr->hlfntNew);
1087  ASSERT(pTextObj != NULL);
1088  pFontGdi = ObjToGDI(pTextObj->Font, FONT);
1089  TEXTOBJ_UnlockText(pTextObj);
1090  DC_UnlockDc(pDc);
1091 
1092  Ret = ftGdiRealizationInfo(pFontGdi, &ri);
1093  if (Ret)
1094  {
1095  if (pri)
1096  {
1098  _SEH2_TRY
1099  {
1100  ProbeForWrite(pri, sizeof(REALIZATION_INFO), 1);
1101  RtlCopyMemory(pri, &ri, sizeof(REALIZATION_INFO));
1102  }
1104  {
1106  }
1107  _SEH2_END
1108 
1109  if(!NT_SUCCESS(Status))
1110  {
1112  return FALSE;
1113  }
1114  }
1115  do
1116  {
1117  if (GdiHandleTable->cfPublic[i].hf == hf)
1118  {
1119  GdiHandleTable->cfPublic[i].iTechnology = ri.iTechnology;
1120  GdiHandleTable->cfPublic[i].iUniq = ri.iUniq;
1121  GdiHandleTable->cfPublic[i].dwUnknown = ri.dwUnknown;
1122  GdiHandleTable->cfPublic[i].dwCFCount = GdiHandleTable->dwCFCount;
1123  GdiHandleTable->cfPublic[i].fl |= CFONT_REALIZATION;
1124  }
1125  i++;
1126  }
1127  while ( i < GDI_CFONT_MAX );
1128  }
1129  return Ret;
1130 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
LONG NTSTATUS
Definition: precomp.h:26
int32_t INT
Definition: typedefs.h:56
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4250
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
Definition: text.h:59
unsigned int BOOL
Definition: ntddk_ex.h:94
HANDLE hlfntNew
Definition: ntgdihdl.h:327
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define GdiHandleTable
Definition: win32nt.h:35
Definition: polytest.cpp:40
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
HDC hdc
Definition: main.c:9
#define GDI_CFONT_MAX
Definition: ntgdihdl.h:20
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
Status
Definition: gdiplustypes.h:24
FONTOBJ * Font
Definition: text.h:66
_SEH2_END
Definition: create.c:4424
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
PTEXTOBJ FASTCALL RealizeFontInit(HFONT hFont)
Definition: font.c:422
BOOL FASTCALL ftGdiRealizationInfo(PFONTGDI Font, PREALIZATION_INFO Info)
Definition: freetype.c:5369
#define CFONT_REALIZATION
Definition: ntgdityp.h:429
#define ObjToGDI(ClipObj, Type)
Definition: engobjects.h:180
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:2777
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by GdiRealizationInfo().

◆ NtGdiHfontCreate()

HFONT APIENTRY NtGdiHfontCreate ( IN PENUMLOGFONTEXDVW  pelfw,
IN ULONG  cjElfw,
IN LFTYPE  lft,
IN FLONG  fl,
IN PVOID  pvCliData 
)

Definition at line 1189 of file font.c.

1195 {
1196  ENUMLOGFONTEXDVW SafeLogfont;
1198 
1199  /* Silence GCC warnings */
1200  SafeLogfont.elfEnumLogfontEx.elfLogFont.lfEscapement = 0;
1201  SafeLogfont.elfEnumLogfontEx.elfLogFont.lfOrientation = 0;
1202 
1203  if (!pelfw)
1204  {
1205  return NULL;
1206  }
1207 
1208  _SEH2_TRY
1209  {
1210  ProbeForRead(pelfw, sizeof(ENUMLOGFONTEXDVW), 1);
1211  RtlCopyMemory(&SafeLogfont, pelfw, sizeof(ENUMLOGFONTEXDVW));
1212  }
1214  {
1216  }
1217  _SEH2_END
1218 
1219  if (!NT_SUCCESS(Status))
1220  {
1221  return NULL;
1222  }
1223 
1224  return HfontCreate(&SafeLogfont, cjElfw, lft, fl, pvCliData);
1225 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
LONG NTSTATUS
Definition: precomp.h:26
LONG lfEscapement
Definition: dimm.idl:61
_SEH2_TRY
Definition: create.c:4250
_In_ FLONG fl
Definition: winddi.h:1279
LONG lfOrientation
Definition: dimm.idl:62
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
HFONT APIENTRY HfontCreate(IN PENUMLOGFONTEXDVW pelfw, IN ULONG cjElfw, IN LFTYPE lft, IN FLONG fl, IN PVOID pvCliData)
Definition: font.c:1135
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
Status
Definition: gdiplustypes.h:24
_SEH2_END
Definition: create.c:4424
LOGFONTW elfLogFont
Definition: wingdi.h:2680
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
ENUMLOGFONTEXW elfEnumLogfontEx
Definition: wingdi.h:2757
return STATUS_SUCCESS
Definition: btrfs.c:2777

Referenced by CreateFontIndirectExA(), and CreateFontIndirectExW().

◆ NtGdiRemoveFontMemResourceEx()

BOOL APIENTRY NtGdiRemoveFontMemResourceEx ( IN HANDLE  hMMFont)

Definition at line 554 of file font.c.

556 {
557  return IntGdiRemoveFontMemResource(hMMFont);
558 }
BOOL FASTCALL IntGdiRemoveFontMemResource(HANDLE hMMFont)
Definition: freetype.c:1603

Referenced by RemoveFontMemResourceEx().

◆ RealizeFontInit()

PTEXTOBJ FASTCALL RealizeFontInit ( HFONT  hFont)

Definition at line 422 of file font.c.

423 {
425  PTEXTOBJ pTextObj;
426 
427  pTextObj = TEXTOBJ_LockText(hFont);
428 
429  if ( pTextObj && !(pTextObj->fl & TEXTOBJECT_INIT))
430  {
431  Status = TextIntRealizeFont(hFont, pTextObj);
432  if (!NT_SUCCESS(Status))
433  {
434  TEXTOBJ_UnlockText(pTextObj);
435  return NULL;
436  }
437  }
438  return pTextObj;
439 }
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
LONG NTSTATUS
Definition: precomp.h:26
FORCEINLINE PTEXTOBJ TEXTOBJ_LockText(HFONT hfont)
Definition: text.h:83
#define TEXTOBJECT_INIT
Definition: text.h:56
HFONT hFont
Definition: main.c:53
NTSTATUS FASTCALL TextIntRealizeFont(HFONT FontHandle, PTEXTOBJ pTextObj)
Definition: freetype.c:4902
Definition: text.h:59
FLONG fl
Definition: text.h:65
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24
return STATUS_SUCCESS
Definition: btrfs.c:2777

Referenced by ftGdiGetGlyphOutline(), ftGdiGetTextCharsetInfo(), ftGdiGetTextMetricsW(), GreGetKerningPairs(), GreGetTextExtentExW(), GreGetTextExtentW(), IntExtTextOutW(), IntGetCharDimensions(), NtGdiGetCharABCWidthsW(), NtGdiGetCharWidthW(), NtGdiGetFontData(), NtGdiGetFontUnicodeRanges(), NtGdiGetGlyphIndicesW(), NtGdiGetKerningPairs(), NtGdiGetOutlineTextMetricsInternalW(), NtGdiGetRealizationInfo(), NtGdiGetTextExtentExW(), and NtGdiGetTextFaceW().