ReactOS  0.4.15-dev-1187-g119f102
text.c File Reference
#include <win32k.h>
#include <debug.h>
Include dependency graph for text.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID FASTCALL IntTMWFixUp (HDC hDC, TMW_INTERNAL *ptm)
 
BOOL FASTCALL GreTextOutW (HDC hdc, int nXStart, int nYStart, LPCWSTR lpString, int cchString)
 
BOOL FASTCALL GreGetTextExtentW (HDC hDC, LPCWSTR lpwsz, INT cwc, LPSIZE psize, UINT flOpts)
 
BOOL FASTCALL GreGetTextExtentExW (HDC hDC, LPCWSTR String, ULONG Count, ULONG MaxExtent, PULONG Fit, PULONG Dx, LPSIZE pSize, FLONG fl)
 
BOOL WINAPI GreGetTextMetricsW (_In_ HDC hdc, _Out_ LPTEXTMETRICW lptm)
 
DWORD APIENTRY NtGdiGetCharSet (HDC hDC)
 
BOOL APIENTRY NtGdiGetRasterizerCaps (OUT LPRASTERIZER_STATUS praststat, IN ULONG cjBytes)
 
INT APIENTRY NtGdiGetTextCharsetInfo (IN HDC hdc, OUT OPTIONAL LPFONTSIGNATURE lpSig, IN DWORD dwFlags)
 
W32KAPI BOOL APIENTRY NtGdiGetTextExtentExW (IN HDC hDC, IN OPTIONAL LPWSTR UnsafeString, IN ULONG Count, IN ULONG MaxExtent, OUT OPTIONAL PULONG UnsafeFit, OUT OPTIONAL PULONG UnsafeDx, OUT LPSIZE UnsafeSize, IN FLONG fl)
 
BOOL APIENTRY NtGdiGetTextExtent (HDC hdc, LPWSTR lpwsz, INT cwc, LPSIZE psize, UINT flOpts)
 
BOOL APIENTRY NtGdiSetTextJustification (HDC hDC, int BreakExtra, int BreakCount)
 
W32KAPI INT APIENTRY NtGdiGetTextFaceW (IN HDC hDC, IN INT Count, OUT OPTIONAL LPWSTR FaceName, IN BOOL bAliasName)
 
W32KAPI BOOL APIENTRY NtGdiGetTextMetricsW (IN HDC hDC, OUT TMW_INTERNAL *pUnsafeTmwi, IN ULONG cj)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Includes

Definition at line 13 of file text.c.

Function Documentation

◆ GreGetTextExtentExW()

BOOL FASTCALL GreGetTextExtentExW ( HDC  hDC,
LPCWSTR  String,
ULONG  Count,
ULONG  MaxExtent,
PULONG  Fit,
PULONG  Dx,
LPSIZE  pSize,
FLONG  fl 
)

Definition at line 135 of file text.c.

144 {
145  PDC pdc;
146  PDC_ATTR pdcattr;
147  BOOL Result;
148  PTEXTOBJ TextObj;
149 
150  if ( (!String && Count ) || !pSize )
151  {
153  return FALSE;
154  }
155 
156  if ( !Count )
157  {
158  if ( Fit ) Fit = 0;
159  return TRUE;
160  }
161 
162  pdc = DC_LockDc(hDC);
163  if (NULL == pdc)
164  {
166  return FALSE;
167  }
168  pdcattr = pdc->pdcattr;
169 
170  TextObj = RealizeFontInit(pdcattr->hlfntNew);
171  if ( TextObj )
172  {
174  TextObj,
175  String,
176  Count,
177  MaxExtent,
178  (LPINT)Fit,
179  (LPINT)Dx,
180  pSize,
181  fl);
182  TEXTOBJ_UnlockText(TextObj);
183  }
184  else
185  Result = FALSE;
186 
187  DC_UnlockDc(pdc);
188  return Result;
189 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define TRUE
Definition: types.h:120
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1223
static WCHAR String[]
Definition: stringtable.c:55
_In_ FLONG fl
Definition: winddi.h:1279
#define FALSE
Definition: types.h:117
Definition: text.h:59
unsigned int BOOL
Definition: ntddk_ex.h:94
HANDLE hlfntNew
Definition: ntgdihdl.h:334
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: polytest.cpp:40
static HDC hDC
Definition: 3dtext.c:33
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
PTEXTOBJ FASTCALL RealizeFontInit(HFONT hFont)
Definition: font.c:422
BOOL FASTCALL TextIntGetTextExtentPoint(PDC dc, PTEXTOBJ TextObj, LPCWSTR String, INT Count, ULONG MaxExtent, LPINT Fit, LPINT Dx, LPSIZE Size, FLONG fl)
Definition: freetype.c:4218
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
int * LPINT
Definition: windef.h:178

Referenced by TEXT_Ellipsify(), TEXT_NextLineW(), TEXT_PathEllipsify(), TEXT_WordBreak(), and UserDrawCaptionText().

◆ GreGetTextExtentW()

BOOL FASTCALL GreGetTextExtentW ( HDC  hDC,
LPCWSTR  lpwsz,
INT  cwc,
LPSIZE  psize,
UINT  flOpts 
)

Definition at line 78 of file text.c.

84 {
85  PDC pdc;
86  PDC_ATTR pdcattr;
87  BOOL Result;
88  PTEXTOBJ TextObj;
89 
90  if (!cwc)
91  {
92  psize->cx = 0;
93  psize->cy = 0;
94  return TRUE;
95  }
96 
97  pdc = DC_LockDc(hDC);
98  if (!pdc)
99  {
101  return FALSE;
102  }
103 
104  pdcattr = pdc->pdcattr;
105 
106  TextObj = RealizeFontInit(pdcattr->hlfntNew);
107  if ( TextObj )
108  {
110  TextObj,
111  lpwsz,
112  cwc,
113  0,
114  NULL,
115  0,
116  psize,
117  flOpts);
118  TEXTOBJ_UnlockText(TextObj);
119  }
120  else
121  Result = FALSE;
122 
123  DC_UnlockDc(pdc);
124  return Result;
125 }
_Must_inspect_result_ _Out_ LPSIZE psize
Definition: ntgdi.h:1569
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define TRUE
Definition: types.h:120
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define FALSE
Definition: types.h:117
Definition: text.h:59
unsigned int BOOL
Definition: ntddk_ex.h:94
HANDLE hlfntNew
Definition: ntgdihdl.h:334
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
LONG cx
Definition: windef.h:334
Definition: polytest.cpp:40
static HDC hDC
Definition: 3dtext.c:33
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
PTEXTOBJ FASTCALL RealizeFontInit(HFONT hFont)
Definition: font.c:422
BOOL FASTCALL TextIntGetTextExtentPoint(PDC dc, PTEXTOBJ TextObj, LPCWSTR String, INT Count, ULONG MaxExtent, LPINT Fit, LPINT Dx, LPSIZE Size, FLONG fl)
Definition: freetype.c:4218
LONG cy
Definition: windef.h:335
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by DrawTextExWorker(), IntPaintDesktop(), and TEXT_DrawUnderscore().

◆ GreGetTextMetricsW()

BOOL WINAPI GreGetTextMetricsW ( _In_ HDC  hdc,
_Out_ LPTEXTMETRICW  lptm 
)

Definition at line 193 of file text.c.

196 {
197  TMW_INTERNAL tmwi;
198  if (!ftGdiGetTextMetricsW(hdc, &tmwi)) return FALSE;
199  IntTMWFixUp(hdc, &tmwi);
200  *lptm = tmwi.TextMetric;
201  return TRUE;
202 }
TEXTMETRICW TextMetric
Definition: ntgdityp.h:370
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
VOID FASTCALL IntTMWFixUp(HDC hDC, TMW_INTERNAL *ptm)
Definition: text.c:30
HDC hdc
Definition: main.c:9
BOOL FASTCALL ftGdiGetTextMetricsW(HDC hDC, PTMW_INTERNAL ptmwi)
Definition: freetype.c:4542
static LPTEXTMETRICW lptm
Definition: font.c:42

Referenced by DrawTextExWorker().

◆ GreTextOutW()

BOOL FASTCALL GreTextOutW ( HDC  hdc,
int  nXStart,
int  nYStart,
LPCWSTR  lpString,
int  cchString 
)

Functions

Definition at line 61 of file text.c.

67 {
68  return GreExtTextOutW(hdc, nXStart, nYStart, 0, NULL, lpString, cchString, NULL, 0);
69 }
smooth NULL
Definition: ftsmooth.c:416
BOOL APIENTRY GreExtTextOutW(IN HDC hDC, IN INT XStart, IN INT YStart, IN UINT fuOptions, IN OPTIONAL PRECTL lprc, IN LPCWSTR String, IN INT Count, IN OPTIONAL LPINT Dx, IN DWORD dwCodePage)
Definition: freetype.c:6601
HDC hdc
Definition: main.c:9

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

◆ IntTMWFixUp()

VOID FASTCALL IntTMWFixUp ( HDC  hDC,
TMW_INTERNAL ptm 
)

Definition at line 30 of file text.c.

33 {
34  LOGFONTW lf;
35  HFONT hCurrentFont;
36 
37  hCurrentFont = NtGdiGetDCObject(hDC, GDI_OBJECT_TYPE_FONT);
38  GreGetObject(hCurrentFont, sizeof(LOGFONTW), &lf);
39 
40  /* To compensate for the GetTextMetricsW call changing the PitchAndFamily
41  * to a TrueType one when we have a 'Raster' font as our input we filter
42  * out the problematic TrueType and Vector bits.
43  * Our list below checks for Raster Font Facenames. */
44  DPRINT("Font Facename is '%S'.\n", lf.lfFaceName);
45  if ((wcsicmp(lf.lfFaceName, L"Helv") == 0) ||
46  (wcsicmp(lf.lfFaceName, L"Courier") == 0) ||
47  (wcsicmp(lf.lfFaceName, L"MS Sans Serif") == 0) ||
48  (wcsicmp(lf.lfFaceName, L"MS Serif") == 0) ||
49  (wcsicmp(lf.lfFaceName, L"Times New Roman") == 0) ||
50  (wcsicmp(lf.lfFaceName, L"MS Shell Dlg") == 0) ||
51  (wcsicmp(lf.lfFaceName, L"System") == 0) ||
52  (wcsicmp(lf.lfFaceName, L"Terminal") == 0))
53  {
55  }
56 }
TEXTMETRICW TextMetric
Definition: ntgdityp.h:370
#define TMPF_TRUETYPE
Definition: wingdi.h:1312
BYTE tmPitchAndFamily
Definition: wingdi.h:2400
void DPRINT(...)
Definition: polytest.cpp:61
__kernel_entry W32KAPI HANDLE APIENTRY NtGdiGetDCObject(_In_ HDC hdc, _In_ INT itype)
#define wcsicmp
Definition: compat.h:15
static const WCHAR L[]
Definition: oid.c:1250
#define TMPF_VECTOR
Definition: wingdi.h:1311
static HDC hDC
Definition: 3dtext.c:33
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
#define GDI_OBJECT_TYPE_FONT
Definition: gdi.h:50
INT NTAPI GreGetObject(IN HGDIOBJ hobj, IN INT cbCount, OUT PVOID pvBuffer)
Definition: gdiobj.c:1261

Referenced by GreGetTextMetricsW(), and NtGdiGetTextMetricsW().

◆ NtGdiGetCharSet()

DWORD APIENTRY NtGdiGetCharSet ( HDC  hDC)

Definition at line 206 of file text.c.

207 {
208  PDC Dc;
209  PDC_ATTR pdcattr;
210  DWORD cscp;
211  // If here, update everything!
212  Dc = DC_LockDc(hDC);
213  if (!Dc)
214  {
216  return 0;
217  }
218  cscp = ftGdiGetTextCharsetInfo(Dc, NULL, 0);
219  pdcattr = Dc->pdcattr;
220  pdcattr->iCS_CP = cscp;
221  pdcattr->ulDirty_ &= ~DIRTY_CHARSET;
222  DC_UnlockDc( Dc );
223  return cscp;
224 }
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define DIRTY_CHARSET
Definition: ntgdihdl.h:149
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
smooth NULL
Definition: ftsmooth.c:416
ULONG ulDirty_
Definition: ntgdihdl.h:298
Definition: polytest.cpp:40
DWORD iCS_CP
Definition: ntgdihdl.h:309
unsigned long DWORD
Definition: ntddk_ex.h:95
static HDC hDC
Definition: 3dtext.c:33
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
INT FASTCALL ftGdiGetTextCharsetInfo(PDC Dc, LPFONTSIGNATURE lpSig, DWORD dwFlags)
Definition: freetype.c:4361
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by GdiGetCodePage().

◆ NtGdiGetRasterizerCaps()

BOOL APIENTRY NtGdiGetRasterizerCaps ( OUT LPRASTERIZER_STATUS  praststat,
IN ULONG  cjBytes 
)

Definition at line 228 of file text.c.

231 {
233  RASTERIZER_STATUS rsSafe;
234 
235  if (praststat && cjBytes)
236  {
237  if ( cjBytes >= sizeof(RASTERIZER_STATUS) ) cjBytes = sizeof(RASTERIZER_STATUS);
238  if ( ftGdiGetRasterizerCaps(&rsSafe))
239  {
240  _SEH2_TRY
241  {
242  ProbeForWrite( praststat,
243  sizeof(RASTERIZER_STATUS),
244  1);
245  RtlCopyMemory(praststat, &rsSafe, cjBytes );
246  }
248  {
250  }
251  _SEH2_END;
252 
253  if (!NT_SUCCESS(Status))
254  {
256  return FALSE;
257  }
258 
259  return TRUE;
260  }
261  }
262  return FALSE;
263 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
struct _RASTERIZER_STATUS RASTERIZER_STATUS
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4226
#define FALSE
Definition: types.h:117
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
BOOL FASTCALL ftGdiGetRasterizerCaps(LPRASTERIZER_STATUS lprs)
Definition: freetype.c:3108
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
_SEH2_END
Definition: create.c:4400
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:3014

◆ NtGdiGetTextCharsetInfo()

INT APIENTRY NtGdiGetTextCharsetInfo ( IN HDC  hdc,
OUT OPTIONAL LPFONTSIGNATURE  lpSig,
IN DWORD  dwFlags 
)

Definition at line 267 of file text.c.

271 {
272  PDC Dc;
273  INT Ret;
274  FONTSIGNATURE fsSafe;
275  PFONTSIGNATURE pfsSafe = &fsSafe;
277 
278  Dc = DC_LockDc(hdc);
279  if (!Dc)
280  {
282  return DEFAULT_CHARSET;
283  }
284 
285  if (!lpSig) pfsSafe = NULL;
286 
287  Ret = HIWORD(ftGdiGetTextCharsetInfo( Dc, pfsSafe, dwFlags));
288 
289  if (lpSig)
290  {
291  if (Ret == DEFAULT_CHARSET)
292  RtlZeroMemory(pfsSafe, sizeof(FONTSIGNATURE));
293 
294  _SEH2_TRY
295  {
296  ProbeForWrite( lpSig,
297  sizeof(FONTSIGNATURE),
298  1);
299  RtlCopyMemory(lpSig, pfsSafe, sizeof(FONTSIGNATURE));
300  }
302  {
304  }
305  _SEH2_END;
306 
307  if (!NT_SUCCESS(Status))
308  {
310  return DEFAULT_CHARSET;
311  }
312  }
313  DC_UnlockDc(Dc);
314  return Ret;
315 }
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:98
LONG NTSTATUS
Definition: precomp.h:26
#define DEFAULT_CHARSET
Definition: wingdi.h:383
int32_t INT
Definition: typedefs.h:58
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4226
#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
Status
Definition: gdiplustypes.h:24
HDC hdc
Definition: main.c:9
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
_SEH2_END
Definition: create.c:4400
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
#define HIWORD(l)
Definition: typedefs.h:247
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:3014
INT FASTCALL ftGdiGetTextCharsetInfo(PDC Dc, LPFONTSIGNATURE lpSig, DWORD dwFlags)
Definition: freetype.c:4361
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by GetTextCharset().

◆ NtGdiGetTextExtent()

BOOL APIENTRY NtGdiGetTextExtent ( HDC  hdc,
LPWSTR  lpwsz,
INT  cwc,
LPSIZE  psize,
UINT  flOpts 
)

Definition at line 492 of file text.c.

497 {
498  return NtGdiGetTextExtentExW(hdc, lpwsz, cwc, 0, NULL, NULL, psize, flOpts);
499 }
_Must_inspect_result_ _Out_ LPSIZE psize
Definition: ntgdi.h:1569
smooth NULL
Definition: ftsmooth.c:416
HDC hdc
Definition: main.c:9
W32KAPI BOOL APIENTRY NtGdiGetTextExtentExW(IN HDC hDC, IN OPTIONAL LPWSTR UnsafeString, IN ULONG Count, IN ULONG MaxExtent, OUT OPTIONAL PULONG UnsafeFit, OUT OPTIONAL PULONG UnsafeDx, OUT LPSIZE UnsafeSize, IN FLONG fl)
Definition: text.c:326

Referenced by GetTextExtentPoint32W(), GetTextExtentPointI(), and GetTextExtentPointW().

◆ NtGdiGetTextExtentExW()

W32KAPI BOOL APIENTRY NtGdiGetTextExtentExW ( IN HDC  hDC,
IN OPTIONAL LPWSTR  UnsafeString,
IN ULONG  Count,
IN ULONG  MaxExtent,
OUT OPTIONAL PULONG  UnsafeFit,
OUT OPTIONAL PULONG  UnsafeDx,
OUT LPSIZE  UnsafeSize,
IN FLONG  fl 
)

Definition at line 326 of file text.c.

336 {
337  PDC dc;
338  PDC_ATTR pdcattr;
339  LPWSTR String;
340  SIZE Size;
342  BOOLEAN Result;
343  INT Fit;
344  LPINT Dx;
345  PTEXTOBJ TextObj;
346 
347  if ((LONG)Count < 0)
348  {
350  return FALSE;
351  }
352 
353  /* FIXME: Handle fl */
354 
355  if (0 == Count)
356  {
357  Size.cx = 0;
358  Size.cy = 0;
359  Status = MmCopyToCaller(UnsafeSize, &Size, sizeof(SIZE));
360  if (! NT_SUCCESS(Status))
361  {
363  return FALSE;
364  }
365  return TRUE;
366  }
367 
369  if (NULL == String)
370  {
372  return FALSE;
373  }
374 
375  if (NULL != UnsafeDx)
376  {
378  if (NULL == Dx)
379  {
382  return FALSE;
383  }
384  }
385  else
386  {
387  Dx = NULL;
388  }
389 
390  Status = MmCopyFromCaller(String, UnsafeString, Count * sizeof(WCHAR));
391  if (! NT_SUCCESS(Status))
392  {
393  if (NULL != Dx)
394  {
396  }
399  return FALSE;
400  }
401 
402  dc = DC_LockDc(hDC);
403  if (NULL == dc)
404  {
405  if (NULL != Dx)
406  {
408  }
411  return FALSE;
412  }
413  pdcattr = dc->pdcattr;
414  TextObj = RealizeFontInit(pdcattr->hlfntNew);
415  if ( TextObj )
416  {
418  TextObj,
419  String,
420  Count,
421  MaxExtent,
422  NULL == UnsafeFit ? NULL : &Fit,
423  Dx,
424  &Size,
425  fl);
426  TEXTOBJ_UnlockText(TextObj);
427  }
428  else
429  Result = FALSE;
430  DC_UnlockDc(dc);
431 
433  if (! Result)
434  {
435  if (NULL != Dx)
436  {
438  }
439  return FALSE;
440  }
441 
442  if (NULL != UnsafeFit)
443  {
444  Status = MmCopyToCaller(UnsafeFit, &Fit, sizeof(INT));
445  if (! NT_SUCCESS(Status))
446  {
447  if (NULL != Dx)
448  {
450  }
452  return FALSE;
453  }
454  }
455 
456  if (NULL != UnsafeDx)
457  {
458  Status = MmCopyToCaller(UnsafeDx, Dx, Count * sizeof(INT));
459  if (! NT_SUCCESS(Status))
460  {
461  if (NULL != Dx)
462  {
464  }
466  return FALSE;
467  }
468  }
469  if (NULL != Dx)
470  {
472  }
473 
474  Status = MmCopyToCaller(UnsafeSize, &Size, sizeof(SIZE));
475  if (! NT_SUCCESS(Status))
476  {
478  return FALSE;
479  }
480 
481  return TRUE;
482 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define TRUE
Definition: types.h:120
FORCEINLINE VOID TEXTOBJ_UnlockText(PLFONT plfnt)
Definition: text.h:96
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
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:1223
#define MmCopyFromCaller
Definition: polytest.cpp:29
#define MmCopyToCaller(x, y, z)
Definition: mmcopy.h:19
static WCHAR String[]
Definition: stringtable.c:55
int32_t INT
Definition: typedefs.h:58
_In_ FLONG fl
Definition: winddi.h:1279
#define FALSE
Definition: types.h:117
Definition: text.h:59
long LONG
Definition: pedump.c:60
HANDLE hlfntNew
Definition: ntgdihdl.h:334
unsigned char BOOLEAN
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: polytest.cpp:40
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Status
Definition: gdiplustypes.h:24
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
static HDC hDC
Definition: 3dtext.c:33
#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 const WCHAR dc[]
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
WCHAR * LPWSTR
Definition: xmlstorage.h:184
BOOL FASTCALL TextIntGetTextExtentPoint(PDC dc, PTEXTOBJ TextObj, LPCWSTR String, INT Count, ULONG MaxExtent, LPINT Fit, LPINT Dx, LPSIZE Size, FLONG fl)
Definition: freetype.c:4218
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
int * LPINT
Definition: windef.h:178

Referenced by GetTextExtentExPointA(), GetTextExtentExPointI(), GetTextExtentExPointW(), GetTextExtentExPointWPri(), and NtGdiGetTextExtent().

◆ NtGdiGetTextFaceW()

W32KAPI INT APIENTRY NtGdiGetTextFaceW ( IN HDC  hDC,
IN INT  Count,
OUT OPTIONAL LPWSTR  FaceName,
IN BOOL  bAliasName 
)

Definition at line 530 of file text.c.

536 {
537  PDC Dc;
538  PDC_ATTR pdcattr;
539  HFONT hFont;
540  PTEXTOBJ TextObj;
542  SIZE_T fLen;
543  INT ret;
544 
545  /* FIXME: Handle bAliasName */
546 
547  Dc = DC_LockDc(hDC);
548  if (Dc == NULL)
549  {
551  return FALSE;
552  }
553  pdcattr = Dc->pdcattr;
554  hFont = pdcattr->hlfntNew;
555  DC_UnlockDc(Dc);
556 
557  TextObj = RealizeFontInit(hFont);
558  ASSERT(TextObj != NULL);
559  fLen = wcslen(TextObj->TextFace) + 1;
560 
561  if (FaceName != NULL)
562  {
563  Count = min(Count, fLen);
564  Status = MmCopyToCaller(FaceName, TextObj->TextFace, Count * sizeof(WCHAR));
565  if (!NT_SUCCESS(Status))
566  {
567  TEXTOBJ_UnlockText(TextObj);
569  return 0;
570  }
571  /* Terminate if we copied only part of the font name */
572  if (Count > 0 && Count < fLen)
573  {
574  FaceName[Count - 1] = '\0';
575  }
576  ret = Count;
577  }
578  else
579  {
580  ret = fLen;
581  }
582 
583  TEXTOBJ_UnlockText(TextObj);
584  return ret;
585 }
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:98
LONG NTSTATUS
Definition: precomp.h:26
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1223
#define MmCopyToCaller(x, y, z)
Definition: mmcopy.h:19
int32_t INT
Definition: typedefs.h:58
HFONT hFont
Definition: main.c:53
#define FALSE
Definition: types.h:117
Definition: text.h:59
HANDLE hlfntNew
Definition: ntgdihdl.h:334
smooth NULL
Definition: ftsmooth.c:416
Definition: polytest.cpp:40
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
int ret
Status
Definition: gdiplustypes.h:24
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
static HDC hDC
Definition: 3dtext.c:33
ULONG_PTR SIZE_T
Definition: typedefs.h:80
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
PTEXTOBJ FASTCALL RealizeFontInit(HFONT hFont)
Definition: font.c:422
WCHAR TextFace[LF_FACESIZE]
Definition: text.h:67
#define min(a, b)
Definition: monoChain.cc:55
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by GetTextFaceAliasW(), and GetTextFaceW().

◆ NtGdiGetTextMetricsW()

W32KAPI BOOL APIENTRY NtGdiGetTextMetricsW ( IN HDC  hDC,
OUT TMW_INTERNAL pUnsafeTmwi,
IN ULONG  cj 
)

Definition at line 590 of file text.c.

594 {
595  TMW_INTERNAL Tmwi;
596 
597  if ( cj <= sizeof(TMW_INTERNAL) )
598  {
599  if (ftGdiGetTextMetricsW(hDC, &Tmwi))
600  {
601  IntTMWFixUp(hDC, &Tmwi);
602  _SEH2_TRY
603  {
604  ProbeForWrite(pUnsafeTmwi, cj, 1);
605  RtlCopyMemory(pUnsafeTmwi, &Tmwi, cj);
606  }
608  {
610  _SEH2_YIELD(return FALSE);
611  }
612  _SEH2_END
613 
614  return TRUE;
615  }
616  }
617  return FALSE;
618 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
_In_ ULONG cj
Definition: winddi.h:3540
#define TRUE
Definition: types.h:120
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4226
#define FALSE
Definition: types.h:117
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
VOID FASTCALL IntTMWFixUp(HDC hDC, TMW_INTERNAL *ptm)
Definition: text.c:30
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
BOOL FASTCALL ftGdiGetTextMetricsW(HDC hDC, PTMW_INTERNAL ptmwi)
Definition: freetype.c:4542
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
static HDC hDC
Definition: 3dtext.c:33
_SEH2_END
Definition: create.c:4400
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12

Referenced by GetTextMetricsA(), and GetTextMetricsW().

◆ NtGdiSetTextJustification()

BOOL APIENTRY NtGdiSetTextJustification ( HDC  hDC,
int  BreakExtra,
int  BreakCount 
)

Definition at line 503 of file text.c.

506 {
507  PDC pDc;
508  PDC_ATTR pdcattr;
509 
510  pDc = DC_LockDc(hDC);
511  if (!pDc)
512  {
514  return FALSE;
515  }
516 
517  pdcattr = pDc->pdcattr;
518 
519  pdcattr->lBreakExtra = BreakExtra;
520  pdcattr->cBreak = BreakCount;
521 
522  DC_UnlockDc(pDc);
523  return TRUE;
524 }
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define TRUE
Definition: types.h:120
LONG lBreakExtra
Definition: ntgdihdl.h:332
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define FALSE
Definition: types.h:117
Definition: polytest.cpp:40
LONG cBreak
Definition: ntgdihdl.h:333
static HDC hDC
Definition: 3dtext.c:33
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27