ReactOS  0.4.13-dev-551-gf37fb1f
text.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS GDI32
3  * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE: Text drawing API.
5  * COPYRIGHT: Copyright 2014 Timo Kreuzer
6  * Copyright 2017 Katayama Hirofumi MZ
7  */
8 
9 #include <precomp.h>
10 
11 #define NDEBUG
12 #include <debug.h>
13 
14 /*
15  * @implemented
16  */
17 BOOL
18 WINAPI
20  _In_ HDC hdc,
21  _In_ INT nXStart,
22  _In_ INT nYStart,
23  _In_reads_(cchString) LPCSTR lpString,
24  _In_ INT cchString)
25 {
26  ANSI_STRING StringA;
27  UNICODE_STRING StringU;
28  BOOL bResult;
30 
31  if (lpString != NULL && cchString > 0)
32  {
33  if (cchString > MAXUSHORT)
34  cchString = MAXUSHORT;
35 
36  StringA.Length = (USHORT)cchString;
37  StringA.MaximumLength = (USHORT)cchString;
38  StringA.Buffer = (PCHAR)lpString;
39 
40  Status = RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
41  if (!NT_SUCCESS(Status))
42  {
43  StringU.Buffer = NULL;
44  StringU.Length = 0;
45  }
46  }
47  else
48  {
49  StringU.Buffer = NULL;
50  StringU.Length = 0;
51  }
52 
53  bResult = TextOutW(hdc, nXStart, nYStart,
54  StringU.Buffer, StringU.Length / sizeof(WCHAR));
55 
56  RtlFreeUnicodeString(&StringU);
57  return bResult;
58 }
59 
60 
61 /*
62  * @implemented
63  */
64 BOOL
65 WINAPI
67  _In_ HDC hdc,
68  _In_ INT nXStart,
69  _In_ INT nYStart,
70  _In_reads_(cchString) LPCWSTR lpString,
71  _In_ INT cchString)
72 {
73  return ExtTextOutW(hdc, nXStart, nYStart, 0, NULL, (LPWSTR)lpString, cchString, NULL);
74 }
75 
76 
77 /*
78  * @unimplemented
79  */
80 BOOL
81 WINAPI
83  _In_ HDC hdc,
84  _In_reads_(cStrings) const POLYTEXTA *pptxt,
85  _In_ INT cStrings)
86 {
87  for (; cStrings>0; cStrings--, pptxt++)
88  {
89  if (!ExtTextOutA(hdc,
90  pptxt->x,
91  pptxt->y,
92  pptxt->uiFlags,
93  &pptxt->rcl,
94  pptxt->lpstr,
95  pptxt->n,
96  pptxt->pdx))
97  {
98  return FALSE;
99  }
100  }
101 
102  return TRUE;
103 }
104 
105 
106 /*
107  * @unimplemented
108  */
109 BOOL
110 WINAPI
112  _In_ HDC hdc,
113  _In_reads_(cStrings) const POLYTEXTW *pptxt,
114  _In_ INT cStrings)
115 {
116  for (; cStrings>0; cStrings--, pptxt++)
117  {
118  if (!ExtTextOutW(hdc,
119  pptxt->x,
120  pptxt->y,
121  pptxt->uiFlags,
122  &pptxt->rcl,
123  pptxt->lpstr,
124  pptxt->n,
125  pptxt->pdx))
126  {
127  return FALSE;
128  }
129  }
130 
131  return TRUE;
132 }
133 
134 
135 /*
136  * @implemented
137  */
138 DWORD
139 WINAPI
141  _In_ HDC hdc)
142 {
143  PDC_ATTR pdcattr;
144 
145  /* Get the DC attribute */
146  pdcattr = GdiGetDcAttr(hdc);
147  if (pdcattr == NULL)
148  {
150  return 0;
151  }
152 
153  if (pdcattr->ulDirty_ & DIRTY_CHARSET)
154  return LOWORD(NtGdiGetCharSet(hdc));
155 
156  return LOWORD(pdcattr->iCS_CP);
157 }
158 
159 
160 /*
161  * @unimplemented
162  */
163 INT
164 WINAPI
166  _In_ HDC hdc)
167 {
168  PDC_ATTR pdcattr;
169 
170  /* Get the DC attribute */
171  pdcattr = GdiGetDcAttr(hdc);
172  if (pdcattr == NULL)
173  {
174  /* Do not set LastError here! */
175  return 0x8000000;
176  }
177 
178  return pdcattr->lTextExtra;
179 }
180 
181 
182 /*
183  * @implemented
184  */
185 INT
186 WINAPI
188  _In_ HDC hdc)
189 {
190  /* MSDN docs say this is equivalent */
191  return NtGdiGetTextCharsetInfo(hdc,NULL,0);
192 }
193 
194 
195 /*
196  * @implemented
197  */
198 BOOL
199 WINAPI
201  _In_ HDC hdc,
203 {
204  TMW_INTERNAL tmwi;
205 
206  if (!NtGdiGetTextMetricsW(hdc, &tmwi, sizeof(TMW_INTERNAL)))
207  {
208  return FALSE;
209  }
210 
212  return TRUE;
213 }
214 
215 
216 /*
217  * @implemented
218  */
219 BOOL
220 WINAPI
222  _In_ HDC hdc,
224 {
225  TMW_INTERNAL tmwi;
226 
227  if (!NtGdiGetTextMetricsW(hdc, &tmwi, sizeof(TMW_INTERNAL)))
228  {
229  return FALSE;
230  }
231 
232  *lptm = tmwi.TextMetric;
233  return TRUE;
234 }
235 
236 
237 /*
238  * @implemented
239  */
240 BOOL
241 APIENTRY
243  _In_ HDC hdc,
244  _In_reads_(cchString) LPCSTR lpString,
245  _In_ INT cchString,
246  _Out_ LPSIZE lpsz)
247 {
248  ANSI_STRING StringA;
249  UNICODE_STRING StringU;
250  BOOL ret;
251 
252  RtlInitAnsiString(&StringA, (LPSTR)lpString);
253  RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
254 
255  ret = GetTextExtentPointW(hdc, StringU.Buffer, cchString, lpsz);
256 
257  RtlFreeUnicodeString(&StringU);
258 
259  return ret;
260 }
261 
262 
263 /*
264  * @implemented
265  */
266 BOOL
267 APIENTRY
269  _In_ HDC hdc,
270  _In_reads_(cchString) LPCWSTR lpString,
271  _In_ INT cchString,
272  _Out_ LPSIZE lpsz)
273 {
274  return NtGdiGetTextExtent(hdc, (LPWSTR)lpString, cchString, lpsz, 0);
275 }
276 
277 
278 /*
279  * @implemented
280  */
281 BOOL
282 WINAPI
284  _In_ HDC hdc,
285  _In_reads_(cchString) LPCWSTR lpszString,
286  _In_ INT cchString,
287  _In_ INT nMaxExtent,
288  _Out_opt_ LPINT lpnFit,
289  _Out_writes_to_opt_(cchString, *lpnFit) LPINT lpnDx,
290  _Out_ LPSIZE lpSize)
291 {
292 
293  /* Windows doesn't check nMaxExtent validity in unicode version */
294  if (nMaxExtent < -1)
295  {
296  DPRINT("nMaxExtent is invalid: %d\n", nMaxExtent);
297  }
298 
299  if (LoadLPK(LPK_GTEP))
300  return LpkGetTextExtentExPoint(hdc, lpszString, cchString, nMaxExtent, lpnFit, lpnDx, lpSize, 0, 0);
301 
302  return NtGdiGetTextExtentExW (
303  hdc, (LPWSTR)lpszString, cchString, nMaxExtent, (PULONG)lpnFit, (PULONG)lpnDx, lpSize, 0 );
304 }
305 
306 
307 /*
308  * @implemented
309  */
310 BOOL
311 WINAPI
313  _In_ HDC hdc,
314  _In_reads_(cwc) LPCWSTR lpwsz,
315  _In_ INT cwc,
316  _In_ INT dxMax,
317  _Out_opt_ LPINT pcCh,
318  _Out_writes_to_opt_(cwc, *pcCh) LPINT pdxOut,
319  _In_ LPSIZE psize)
320 {
321  return NtGdiGetTextExtentExW(hdc, (LPWSTR)lpwsz, cwc, dxMax, (PULONG)pcCh, (PULONG)pdxOut, psize, 0);
322 }
323 
324 /*
325  * @implemented
326  */
327 BOOL
328 WINAPI
330  _In_ HDC hdc,
331  _In_reads_(cchString) LPCSTR lpszStr,
332  _In_ INT cchString,
333  _In_ INT nMaxExtent,
334  _Out_opt_ LPINT lpnFit,
335  _Out_writes_to_opt_ (cchString, *lpnFit) LPINT lpnDx,
336  _Out_ LPSIZE lpSize)
337 {
339  LPWSTR lpszStrW;
340  BOOL bResult = FALSE;
341 
342  if (nMaxExtent < -1)
343  {
345  return FALSE;
346  }
347 
348  Status = HEAP_strdupA2W(&lpszStrW, lpszStr);
349  if (!NT_SUCCESS (Status))
350  {
352  return FALSE;
353  }
354 
355  bResult = NtGdiGetTextExtentExW(hdc,
356  lpszStrW,
357  cchString,
358  nMaxExtent,
359  (PULONG)lpnFit,
360  (PULONG)lpnDx,
361  lpSize,
362  0);
363 
364  HEAP_free(lpszStrW);
365 
366  return bResult;
367 }
368 
369 
370 /*
371  * @implemented
372  */
373 BOOL
374 WINAPI
376  _In_ HDC hdc,
377  _In_reads_(cchString) LPCSTR lpString,
378  _In_ INT cchString,
379  _Out_ LPSIZE lpSize)
380 {
381  ANSI_STRING StringA;
382  UNICODE_STRING StringU;
383  BOOL ret;
384 
385  StringA.Buffer = (LPSTR)lpString;
386  StringA.Length = cchString;
387  RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
388 
389  ret = GetTextExtentPoint32W(hdc, StringU.Buffer, cchString, lpSize);
390 
391  RtlFreeUnicodeString(&StringU);
392 
393  return ret;
394 }
395 
396 
397 /*
398  * @implemented
399  */
400 BOOL
401 WINAPI
403  _In_ HDC hdc,
404  _In_reads_(cchString) LPCWSTR lpString,
405  _In_ int cchString,
406  _Out_ LPSIZE lpSize)
407 {
408  return NtGdiGetTextExtent(hdc, (LPWSTR)lpString, cchString, lpSize, 0);
409 }
410 
411 /*
412  * @implemented
413  */
414 BOOL
415 WINAPI
417  _In_ HDC hdc,
418  _In_reads_(cgi) LPWORD pgiIn,
419  _In_ INT cgi,
420  _In_ INT nMaxExtent,
421  _Out_opt_ LPINT lpnFit,
422  _Out_writes_to_opt_(cwchString, *lpnFit) LPINT lpnDx,
423  _Out_ LPSIZE lpSize)
424 {
425  return NtGdiGetTextExtentExW(hdc,
426  pgiIn,
427  cgi,
428  nMaxExtent,
429  (PULONG)lpnFit,
430  (PULONG)lpnDx,
431  lpSize,
432  GTEF_INDICES);
433 }
434 
435 /*
436  * @implemented
437  */
438 BOOL
439 WINAPI
441  _In_ HDC hdc,
442  _In_reads_(cgi) LPWORD pgiIn,
443  _In_ int cgi,
444  _Out_ LPSIZE lpSize)
445 {
446  return NtGdiGetTextExtent(hdc, pgiIn, cgi, lpSize, GTEF_INDICES);
447 }
448 
449 /*
450  * @implemented
451  */
452 BOOL
453 WINAPI
455  _In_ HDC hdc,
456  _In_ INT x,
457  _In_ INT y,
458  _In_ UINT fuOptions,
459  _In_opt_ const RECT *lprc,
460  _In_reads_opt_(cch) LPCSTR lpString,
461  _In_ UINT cch,
462  _In_reads_opt_(cch) const INT *lpDx)
463 {
464  ANSI_STRING StringA;
465  UNICODE_STRING StringU;
466  BOOL ret;
467 
468  RtlInitAnsiString(&StringA, (LPSTR)lpString);
469  RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
470 
471  ret = ExtTextOutW(hdc, x, y, fuOptions, lprc, StringU.Buffer, cch, lpDx);
472 
473  RtlFreeUnicodeString(&StringU);
474 
475  return ret;
476 }
477 
478 
479 /*
480  * @implemented
481  */
482 BOOL
483 WINAPI
485  _In_ HDC hdc,
486  _In_ INT x,
487  _In_ INT y,
488  _In_ UINT fuOptions,
489  _In_opt_ const RECT *lprc,
490  _In_reads_opt_(cwc) LPCWSTR lpString,
491  _In_ UINT cwc,
492  _In_reads_opt_(cwc) const INT *lpDx)
493 {
494  PDC_ATTR pdcattr;
495 
497  ExtTextOut,
498  FALSE,
499  hdc,
500  x,
501  y,
502  fuOptions,
503  lprc,
504  lpString,
505  cwc,
506  lpDx);
507 
508  if (!(fuOptions & (ETO_GLYPH_INDEX | ETO_IGNORELANGUAGE)))
509  {
510  if (LoadLPK(LPK_ETO))
511  return LpkExtTextOut(hdc, x, y, fuOptions, lprc, lpString, cwc , lpDx, 0);
512  }
513 
514  /* Get the DC attribute */
515  pdcattr = GdiGetDcAttr(hdc);
516  if ( pdcattr &&
517  !(pdcattr->ulDirty_ & DC_DIBSECTION) &&
518  !(pdcattr->lTextAlign & TA_UPDATECP))
519  {
520  if ( lprc && !cwc )
521  {
522  if ( fuOptions & ETO_OPAQUE )
523  {
524  PGDIBSEXTTEXTOUT pgO;
525 
527  if (pgO)
528  {
529  pdcattr->ulDirty_ |= DC_MODE_DIRTY;
530  pgO->Count = cwc;
531  pgO->Rect = *lprc;
532  pgO->Options = fuOptions;
533  /* Snapshot attribute */
534  pgO->ulBackgroundClr = pdcattr->ulBackgroundClr;
535  pgO->ptlViewportOrg = pdcattr->ptlViewportOrg;
536  return TRUE;
537  }
538  }
539  else // Do nothing, old explorer pops this off.
540  {
541  DPRINT1("GdiBCExtTextOut nothing\n");
542  return TRUE;
543  }
544  } // Max 580 wchars, if offset 0
545  else if ( cwc <= ((GDIBATCHBUFSIZE - sizeof(GDIBSTEXTOUT)) / sizeof(WCHAR)) )
546  {
547  PGDIBSTEXTOUT pgO;
548  PTEB pTeb = NtCurrentTeb();
549 
551  if (pgO)
552  {
553  USHORT cjSize = 0;
554  ULONG DxSize = 0;
555 
556  if (cwc > 2) cjSize = (cwc * sizeof(WCHAR)) - sizeof(pgO->String);
557 
558  /* Calculate buffer size for string and Dx values */
559  if (lpDx)
560  {
561  /* If ETO_PDY is specified, we have pairs of INTs */
562  DxSize = (cwc * sizeof(INT)) * (fuOptions & ETO_PDY ? 2 : 1);
563  cjSize += DxSize;
564  // The structure buffer holds 4 bytes. Store Dx data then string.
565  // Result one wchar -> Buf[ Dx ]Str[wC], [4][2][X] one extra unused wchar
566  // to assure alignment of 4.
567  }
568 
569  if ((pTeb->GdiTebBatch.Offset + cjSize ) <= GDIBATCHBUFSIZE)
570  {
572  pgO->cbCount = cwc;
573  pgO->x = x;
574  pgO->y = y;
575  pgO->Options = fuOptions;
576  pgO->iCS_CP = 0;
577 
578  if (lprc) pgO->Rect = *lprc;
579  else
580  {
581  pgO->Options |= GDIBS_NORECT; // Tell the other side lprc is nill.
582  }
583 
584  /* Snapshot attributes */
585  pgO->crForegroundClr = pdcattr->crForegroundClr;
586  pgO->crBackgroundClr = pdcattr->crBackgroundClr;
587  pgO->ulForegroundClr = pdcattr->ulForegroundClr;
588  pgO->ulBackgroundClr = pdcattr->ulBackgroundClr;
589  pgO->lBkMode = pdcattr->lBkMode == OPAQUE ? OPAQUE : TRANSPARENT;
590  pgO->hlfntNew = pdcattr->hlfntNew;
591  pgO->flTextAlign = pdcattr->flTextAlign;
592  pgO->ptlViewportOrg = pdcattr->ptlViewportOrg;
593 
594  pgO->Size = DxSize; // of lpDx then string after.
595  /* Put the Dx before the String to assure alignment of 4 */
596  if (lpDx) RtlCopyMemory( &pgO->Buffer, lpDx, DxSize);
597 
598  if (cwc) RtlCopyMemory( &pgO->String[DxSize/sizeof(WCHAR)], lpString, cwc * sizeof(WCHAR));
599 
600  // Recompute offset and return size
601  pTeb->GdiTebBatch.Offset += cjSize;
602  ((PGDIBATCHHDR)pgO)->Size += cjSize;
603  return TRUE;
604  }
605  // Reset offset and count then fall through
606  pTeb->GdiTebBatch.Offset -= sizeof(GDIBSTEXTOUT);
607  pTeb->GdiBatchCount--;
608  }
609  }
610  }
611  return NtGdiExtTextOutW(hdc,
612  x,
613  y,
614  fuOptions,
615  (LPRECT)lprc,
616  (LPWSTR)lpString,
617  cwc,
618  (LPINT)lpDx,
619  0);
620 }
621 
622 
623 /*
624  * @implemented
625  */
626 INT
627 WINAPI
629  _In_ HDC hdc,
630  _In_ INT cwcMax,
631  _Out_writes_to_opt_(cwcMax, return) LPWSTR pFaceName)
632 {
633  /* Validate parameters */
634  if (pFaceName && cwcMax <= 0)
635  {
636  /* Set last error and return failure */
638  return 0;
639  }
640 
641  /* Forward to kernel */
642  return NtGdiGetTextFaceW(hdc, cwcMax, pFaceName, FALSE);
643 }
644 
645 
646 /*
647  * @implemented
648  */
649 INT
650 WINAPI
652  _In_ HDC hdc,
653  _In_ INT cchMax,
655 {
656  INT res;
657  LPWSTR nameW;
658 
659  /* Validate parameters */
660  if (lpName && cchMax <= 0)
661  {
662  /* Set last error and return failure */
664  return 0;
665  }
666 
667  res = GetTextFaceW(hdc, 0, NULL);
668  nameW = HeapAlloc( GetProcessHeap(), 0, res * 2 );
669  if (nameW == NULL)
670  {
671  return 0;
672  }
673 
674  GetTextFaceW( hdc, res, nameW );
675 
676  if (lpName)
677  {
679  lpName[cchMax-1] = 0;
680  res = strlen(lpName);
681  }
682  else
683  {
684  res = WideCharToMultiByte( CP_ACP, 0, nameW, -1, NULL, 0, NULL, NULL);
685  }
686 
687  HeapFree( GetProcessHeap(), 0, nameW );
688  return res;
689 }
690 
691 
692 /*
693  * @implemented
694  */
695 INT
696 WINAPI
698  _In_ HDC hdc,
699  _In_ INT cwcMax,
700  _Out_writes_to_opt_(cwcMax, return) LPWSTR pszOut)
701 {
702  if (pszOut && !cwcMax)
703  {
705  return 0;
706  }
707 
708  return NtGdiGetTextFaceW(hdc, cwcMax, pszOut, TRUE);
709 }
710 
711 
712 BOOL
713 WINAPI
716  _Inout_ DWORD *pdwBufSize,
717  _Out_writes_to_opt_(*pdwBufSize, 1) PVOID lpBuffer,
718  _In_ DWORD dwType)
719 {
720  BOOL bRet;
721  UNICODE_STRING NtFileName;
722 
723  DPRINT("GetFontResourceInfoW: dwType = %lu\n", dwType);
724 
725  if (!lpFileName || !pdwBufSize)
726  {
728  return FALSE;
729  }
730 
732  &NtFileName,
733  NULL,
734  NULL))
735  {
737  return FALSE;
738  }
739 
741  NtFileName.Buffer,
742  (NtFileName.Length / sizeof(WCHAR)) + 1,
743  1,
744  *pdwBufSize,
745  pdwBufSize,
746  lpBuffer,
747  dwType);
748 
749  RtlFreeHeap(RtlGetProcessHeap(), 0, NtFileName.Buffer);
750 
751  return bRet;
752 }
753 
754 
755 /*
756  * @unimplemented
757  */
758 INT
759 WINAPI
761  _In_ HDC hdc,
762  _In_ INT nCharExtra)
763 {
764  PDC_ATTR pdcattr;
765  INT nOldCharExtra;
766 
767  if (nCharExtra == 0x80000000)
768  {
770  return 0x80000000;
771  }
772 
774  {
775  HANDLE_METADC(INT, SetTextCharacterExtra, 0x80000000, hdc, nCharExtra);
776  }
777 
778  /* Get the DC attribute */
779  pdcattr = GdiGetDcAttr(hdc);
780  if (pdcattr == NULL)
781  {
783  return 0x8000000;
784  }
785 
786  if (NtCurrentTeb()->GdiTebBatch.HDC == hdc)
787  {
788  if (pdcattr->ulDirty_ & DC_FONTTEXT_DIRTY)
789  {
790  NtGdiFlush(); // Sync up pdcattr from Kernel space.
792  }
793  }
794 
795  nOldCharExtra = pdcattr->lTextExtra;
796  pdcattr->lTextExtra = nCharExtra;
797  return nOldCharExtra;
798 }
799 
800 /*
801  * @implemented
802  *
803  */
804 UINT
805 WINAPI
807  _In_ HDC hdc)
808 {
809  PDC_ATTR pdcattr;
810 
811  /* Get the DC attribute */
812  pdcattr = GdiGetDcAttr(hdc);
813  if (pdcattr == NULL)
814  {
815  /* Do not set LastError here! */
816  return GDI_ERROR;
817  }
818 
819  return pdcattr->lTextAlign;
820 }
821 
822 
823 /*
824  * @implemented
825  *
826  */
827 COLORREF
828 WINAPI
830  _In_ HDC hdc)
831 {
832  PDC_ATTR pdcattr;
833 
834  /* Get the DC attribute */
835  pdcattr = GdiGetDcAttr(hdc);
836  if (pdcattr == NULL)
837  {
838  /* Do not set LastError here! */
839  return CLR_INVALID;
840  }
841 
842  return pdcattr->ulForegroundClr;
843 }
844 
845 
846 /*
847  * @unimplemented
848  */
849 UINT
850 WINAPI
852  _In_ HDC hdc,
853  _In_ UINT fMode)
854 {
855  PDC_ATTR pdcattr;
856  UINT fOldMode;
857 
859 
860  /* Get the DC attribute */
861  pdcattr = GdiGetDcAttr(hdc);
862  if (pdcattr == NULL)
863  {
865  return GDI_ERROR;
866  }
867 
868 
869  fOldMode = pdcattr->lTextAlign;
870  pdcattr->lTextAlign = fMode; // Raw
871  if (pdcattr->dwLayout & LAYOUT_RTL)
872  {
873  if ((fMode & TA_CENTER) != TA_CENTER) fMode ^= TA_RIGHT;
874  }
875 
876  pdcattr->flTextAlign = fMode & TA_MASK;
877  return fOldMode;
878 }
879 
880 
881 /*
882  * @implemented
883  */
884 COLORREF
885 WINAPI
887  _In_ HDC hdc,
888  _In_ COLORREF crColor)
889 {
890  PDC_ATTR pdcattr;
891  COLORREF crOldColor;
892 
894 
895  pdcattr = GdiGetDcAttr(hdc);
896  if (pdcattr == NULL)
897  {
899  return CLR_INVALID;
900  }
901 
902  crOldColor = (COLORREF) pdcattr->ulForegroundClr;
903  pdcattr->ulForegroundClr = (ULONG)crColor;
904 
905  if (pdcattr->crForegroundClr != crColor)
906  {
908  pdcattr->crForegroundClr = crColor;
909  }
910 
911  return crOldColor;
912 }
913 
914 /*
915  * @implemented
916  */
917 BOOL
918 WINAPI
920  _In_ HDC hdc,
921  _In_ INT nBreakExtra,
922  _In_ INT nBreakCount)
923 {
924  PDC_ATTR pdcattr;
925 
927  {
928  HANDLE_METADC(BOOL, SetTextJustification, FALSE, hdc, nBreakExtra, nBreakCount);
929  }
930 
931  /* Get the DC attribute */
932  pdcattr = GdiGetDcAttr(hdc);
933  if (pdcattr == NULL)
934  {
935  /* Do not set LastError here! */
936  return GDI_ERROR;
937  }
938 
939 
940  if (NtCurrentTeb()->GdiTebBatch.HDC == hdc)
941  {
942  if (pdcattr->ulDirty_ & DC_FONTTEXT_DIRTY)
943  {
944  NtGdiFlush(); // Sync up pdcattr from Kernel space.
946  }
947  }
948 
949  pdcattr->cBreak = nBreakCount;
950  pdcattr->lBreakExtra = nBreakExtra;
951  return TRUE;
952 }
953 
954 /*
955  * @implemented
956  */
957 UINT
958 WINAPI
960  _In_ HDC hdc,
961  _In_ LPSTR psz,
962  _In_ BOOL bDoCall,
963  _In_ UINT cj,
964  _Out_writes_(cj) BYTE *lpSB)
965 {
966 
968  PWSTR pwsz;
969  UINT uResult = 0;
970 
971  if (!bDoCall)
972  {
973  return 0;
974  }
975 
976  Status = HEAP_strdupA2W(&pwsz, psz);
977  if (!NT_SUCCESS(Status))
978  {
980  }
981  else
982  {
983  uResult = NtGdiGetStringBitmapW(hdc, pwsz, 1, lpSB, cj);
984  HEAP_free(pwsz);
985  }
986 
987  return uResult;
988 
989 }
990 
991 /*
992  * @implemented
993  */
994 UINT
995 WINAPI
997  _In_ HDC hdc,
998  _In_ LPWSTR pwsz,
999  _In_ BOOL bDoCall,
1000  _In_ UINT cj,
1001  _Out_writes_(cj) BYTE *lpSB)
1002 {
1003  if (!bDoCall)
1004  {
1005  return 0;
1006  }
1007 
1008  return NtGdiGetStringBitmapW(hdc, pwsz, 1, lpSB, cj);
1009 
1010 }
1011 
1012 /*
1013  * @implemented
1014  */
1015 BOOL
1016 WINAPI
1018  _In_ HDC hdc,
1019  _Out_ EXTTEXTMETRIC *petm)
1020 {
1021  BOOL bResult;
1022 
1023  bResult = NtGdiGetETM(hdc, petm);
1024 
1025  if (bResult && petm)
1026  {
1027  petm->emKernPairs = (WORD)GetKerningPairsA(hdc, 0, 0);
1028  }
1029 
1030  return bResult;
1031 }
ULONG Buffer[1]
Definition: ntgdityp.h:528
TEXTMETRICW TextMetric
Definition: ntgdityp.h:369
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
BOOL WINAPI GetTextExtentExPointI(_In_ HDC hdc, _In_reads_(cgi) LPWORD pgiIn, _In_ INT cgi, _In_ INT nMaxExtent, _Out_opt_ LPINT lpnFit, _Out_writes_to_opt_(cwchString, *lpnFit) LPINT lpnDx, _Out_ LPSIZE lpSize)
Definition: text.c:416
VOID HEAP_free(LPVOID memory)
Definition: heap.c:63
POINTL ptlViewportOrg
Definition: ntgdihdl.h:340
ULONG ulBackgroundClr
Definition: ntgdityp.h:539
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
_In_ ULONG cj
Definition: winddi.h:3540
INT WINAPI SetTextCharacterExtra(_In_ HDC hdc, _In_ INT nCharExtra)
Definition: text.c:760
_Must_inspect_result_ _Out_ LPSIZE psize
Definition: ntgdi.h:1569
_In_ int _Inout_ LPRECT lprc
Definition: winuser.h:4334
BOOL WINAPI GetETM(_In_ HDC hdc, _Out_ EXTTEXTMETRIC *petm)
Definition: text.c:1017
BOOL WINAPI GetTextExtentPointI(_In_ HDC hdc, _In_reads_(cgi) LPWORD pgiIn, _In_ int cgi, _Out_ LPSIZE lpSize)
Definition: text.c:440
#define LAYOUT_RTL
Definition: wingdi.h:1353
BOOL WINAPI TextOutW(_In_ HDC hdc, _In_ INT nXStart, _In_ INT nYStart, _In_reads_(cchString) LPCWSTR lpString, _In_ INT cchString)
Definition: text.c:66
#define WideCharToMultiByte
Definition: compat.h:101
BOOL APIENTRY GetTextExtentPointA(_In_ HDC hdc, _In_reads_(cchString) LPCSTR lpString, _In_ INT cchString, _Out_ LPSIZE lpsz)
Definition: text.c:242
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
LONG lBreakExtra
Definition: ntgdihdl.h:325
uint16_t * PWSTR
Definition: typedefs.h:54
__kernel_entry W32KAPI BOOL APIENTRY NtGdiExtTextOutW(_In_ HDC hdc, _In_ INT x, _In_ INT y, _In_ UINT flOpts, _In_opt_ LPRECT prcl, _In_reads_opt_(cwc) LPWSTR pwsz, _In_range_(0, 0xffff) INT cwc, _In_reads_opt_(_Inexpressible_(cwc)) LPINT pdx, _In_ DWORD dwCodePage)
#define CP_ACP
Definition: compat.h:99
#define DIRTY_CHARSET
Definition: ntgdihdl.h:149
BOOL WINAPI GetTextExtentExPointWPri(_In_ HDC hdc, _In_reads_(cwc) LPCWSTR lpwsz, _In_ INT cwc, _In_ INT dxMax, _Out_opt_ LPINT pcCh, _Out_writes_to_opt_(cwc, *pcCh) LPINT pdxOut, _In_ LPSIZE psize)
Definition: text.c:312
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
#define _In_reads_(size)
Definition: no_sal2.h:228
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
#define INT
Definition: polytest.cpp:20
static HDC
Definition: imagelist.c:92
_In_ LPCSTR lpName
Definition: winbase.h:2729
#define CLR_INVALID
Definition: wingdi.h:882
#define DC_DIBSECTION
Definition: ntgdihdl.h:159
struct _GDIBATCHHDR * PGDIBATCHHDR
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
LONG lTextExtra
Definition: ntgdihdl.h:323
VOID FASTCALL FONT_TextMetricWToA(const TEXTMETRICW *ptmW, LPTEXTMETRICA ptmA)
Definition: font.c:79
char * LPSTR
Definition: xmlstorage.h:182
int32_t INT
Definition: typedefs.h:56
#define HANDLE_METADC(_RetType, _Func, dwError, hdc,...)
Definition: gdi32p.h:616
#define _In_opt_
Definition: no_sal2.h:213
LONG lBkMode
Definition: ntgdityp.h:513
ULONG ulBackgroundClr
Definition: ntgdihdl.h:295
INT WINAPI GetTextCharacterExtra(_In_ HDC hdc)
Definition: text.c:165
FLONG flTextAlign
Definition: ntgdityp.h:524
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
#define _Out_writes_(size)
Definition: no_sal2.h:367
DWORD WINAPI GetKerningPairsA(_In_ HDC hdc, _In_ DWORD nPairs, _Out_writes_to_opt_(nPairs, return) LPKERNINGPAIR lpKernPair)
BOOL WINAPI LoadLPK(INT LpkFunctionID)
Definition: utils.c:423
#define ETO_OPAQUE
Definition: wingdi.h:646
unsigned int BOOL
Definition: ntddk_ex.h:94
HANDLE hlfntNew
Definition: ntgdihdl.h:327
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
BOOL WINAPI PolyTextOutW(_In_ HDC hdc, _In_reads_(cStrings) const POLYTEXTW *pptxt, _In_ INT cStrings)
Definition: text.c:111
BOOL WINAPI ExtTextOutW(_In_ HDC hdc, _In_ INT x, _In_ INT y, _In_ UINT fuOptions, _In_opt_ const RECT *lprc, _In_reads_opt_(cwc) LPCWSTR lpString, _In_ UINT cwc, _In_reads_opt_(cwc) const INT *lpDx)
Definition: text.c:484
#define TRANSPARENT
Definition: wingdi.h:949
#define GDIBATCHBUFSIZE
Definition: ntgdityp.h:199
COLORREF crBackgroundClr
Definition: ntgdityp.h:512
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:201
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS HEAP_strdupA2W(LPWSTR *ppszW, LPCSTR lpszA)
Definition: heap.c:43
#define _Out_
Definition: no_sal2.h:323
void DPRINT(...)
Definition: polytest.cpp:61
const char * LPCSTR
Definition: xmlstorage.h:183
UINT Options
Definition: ntgdityp.h:518
INT WINAPI GetTextFaceAliasW(_In_ HDC hdc, _In_ INT cwcMax, _Out_writes_to_opt_(cwcMax, return) LPWSTR pszOut)
Definition: text.c:697
#define TA_UPDATECP
Definition: wingdi.h:935
ULONG ulDirty_
Definition: ntgdihdl.h:291
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
#define PCHAR
Definition: match.c:90
static const WCHAR nameW[]
Definition: main.c:46
__kernel_entry W32KAPI NTSTATUS APIENTRY NtGdiFlush(VOID)
Definition: gdibatch.c:471
#define TA_RIGHT
Definition: wingdi.h:932
USHORT MaximumLength
Definition: env_spec_w32.h:377
#define _Out_opt_
Definition: no_sal2.h:339
ULONG ulBackgroundClr
Definition: ntgdityp.h:515
BOOL WINAPI SetTextJustification(_In_ HDC hdc, _In_ INT nBreakExtra, _In_ INT nBreakCount)
Definition: text.c:919
INT WINAPI GetTextFaceA(_In_ HDC hdc, _In_ INT cchMax, _Out_writes_to_opt_(cchMax, return) LPSTR lpName)
Definition: text.c:651
COLORREF crBackgroundClr
Definition: ntgdihdl.h:294
#define GetProcessHeap()
Definition: compat.h:395
__kernel_entry W32KAPI BOOL APIENTRY NtGdiGetFontResourceInfoInternalW(_In_reads_z_(cwc) LPWSTR pwszFiles, _In_ ULONG cwc, _In_ ULONG cFiles, _In_ UINT cjBuf, _Out_ LPDWORD pdwBytes, _Out_writes_bytes_(cjBuf) LPVOID pvBuf, _In_ DWORD iType)
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
COLORREF crForegroundClr
Definition: ntgdityp.h:511
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
INT WINAPI GetTextFaceW(_In_ HDC hdc, _In_ INT cwcMax, _Out_writes_to_opt_(cwcMax, return) LPWSTR pFaceName)
Definition: text.c:628
DWORD COLORREF
Definition: windef.h:285
struct _GDIBSTEXTOUT GDIBSTEXTOUT
W32KAPI BOOL APIENTRY NtGdiGetTextMetricsW(IN HDC hDC, OUT TMW_INTERNAL *pUnsafeTmwi, IN ULONG cj)
Definition: text.c:547
#define WINAPI
Definition: msvc.h:8
unsigned short WORD
Definition: ntddk_ex.h:93
#define LPK_GTEP
Definition: gdi32p.h:84
DWORD iCS_CP
Definition: ntgdihdl.h:302
unsigned long DWORD
Definition: ntddk_ex.h:95
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
LONG cBreak
Definition: ntgdihdl.h:326
#define GDIBS_NORECT
Definition: ntgdityp.h:506
#define SetLastError(x)
Definition: compat.h:409
#define _Inout_
Definition: no_sal2.h:244
POINTL ptlViewportOrg
Definition: ntgdityp.h:538
UINT cchMax
#define DIRTY_TEXT
Definition: ntgdihdl.h:147
#define ExtTextOut
Definition: wingdi.h:4432
GDI_TEB_BATCH GdiTebBatch
Definition: compat.h:506
int ret
#define DIRTY_FILL
Definition: ntgdihdl.h:145
ULONG GdiBatchCount
Definition: compat.h:536
UINT WINAPI GetStringBitmapW(_In_ HDC hdc, _In_ LPWSTR pwsz, _In_ BOOL bDoCall, _In_ UINT cj, _Out_writes_(cj) BYTE *lpSB)
Definition: text.c:996
#define OPAQUE
Definition: wingdi.h:948
BOOL WINAPI GetTextMetricsW(_In_ HDC hdc, _Out_ LPTEXTMETRICW lptm)
Definition: text.c:221
HDC hdc
Definition: main.c:9
HANDLE hlfntNew
Definition: ntgdityp.h:523
#define DC_MODE_DIRTY
Definition: ntgdihdl.h:166
BOOL WINAPI GetTextExtentPoint32A(_In_ HDC hdc, _In_reads_(cchString) LPCSTR lpString, _In_ INT cchString, _Out_ LPSIZE lpSize)
Definition: text.c:375
BOOL APIENTRY GetTextExtentPointW(_In_ HDC hdc, _In_reads_(cchString) LPCWSTR lpString, _In_ INT cchString, _Out_ LPSIZE lpsz)
Definition: text.c:268
BOOL WINAPI GetTextExtentPoint32W(_In_ HDC hdc, _In_reads_(cchString) LPCWSTR lpString, _In_ int cchString, _Out_ LPSIZE lpSize)
Definition: text.c:402
unsigned char BYTE
Definition: mem.h:68
#define DC_FONTTEXT_DIRTY
Definition: ntgdihdl.h:167
#define TA_MASK
Definition: wingdi.h:936
UINT WINAPI GetTextAlign(_In_ HDC hdc)
Definition: text.c:806
BOOL APIENTRY NtGdiGetTextExtent(HDC hdc, LPWSTR lpwsz, INT cwc, LPSIZE psize, UINT flOpts)
Definition: text.c:449
WCHAR String[2]
Definition: ntgdityp.h:527
POINTL ptlViewportOrg
Definition: ntgdityp.h:525
Status
Definition: gdiplustypes.h:24
uint16_t * LPWORD
Definition: typedefs.h:54
COLORREF WINAPI GetTextColor(_In_ HDC hdc)
Definition: text.c:829
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
#define _In_
Definition: no_sal2.h:204
DWORD iCS_CP
Definition: ntgdityp.h:520
#define LPK_ETO
Definition: gdi32p.h:82
VOID WINAPI GdiSetLastError(DWORD dwErrCode)
Definition: misc.c:873
Definition: compat.h:484
ULONG Offset
Definition: compat.h:480
BOOL WINAPI GetTextExtentExPointA(_In_ HDC hdc, _In_reads_(cchString) LPCSTR lpszStr, _In_ INT cchString, _In_ INT nMaxExtent, _Out_opt_ LPINT lpnFit, _Out_writes_to_opt_(cchString, *lpnFit) LPINT lpnDx, _Out_ LPSIZE lpSize)
Definition: text.c:329
BOOL WINAPI ExtTextOutA(_In_ HDC hdc, _In_ INT x, _In_ INT y, _In_ UINT fuOptions, _In_opt_ const RECT *lprc, _In_reads_opt_(cch) LPCSTR lpString, _In_ UINT cch, _In_reads_opt_(cch) const INT *lpDx)
Definition: text.c:454
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
unsigned short USHORT
Definition: pedump.c:61
ULONG ulForegroundClr
Definition: ntgdihdl.h:297
#define _In_z_
Definition: no_sal2.h:239
#define _Out_writes_to_opt_(size, count)
Definition: no_sal2.h:379
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
unsigned int * PULONG
Definition: retypes.h:1
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI GetFontResourceInfoW(_In_z_ LPCWSTR lpFileName, _Inout_ DWORD *pdwBufSize, _Out_writes_to_opt_(*pdwBufSize, 1) PVOID lpBuffer, _In_ DWORD dwType)
Definition: text.c:714
W32KAPI INT APIENTRY NtGdiGetTextFaceW(IN HDC hDC, IN INT Count, OUT OPTIONAL LPWSTR FaceName, IN BOOL bAliasName)
Definition: text.c:487
DWORD APIENTRY NtGdiGetCharSet(HDC hDC)
Definition: text.c:163
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:283
DWORD WINAPI GdiGetCodePage(_In_ HDC hdc)
Definition: text.c:140
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define MAXUSHORT
Definition: typedefs.h:81
#define ETO_PDY
Definition: wingdi.h:656
FLONG flTextAlign
Definition: ntgdihdl.h:321
#define DPRINT1
Definition: precomp.h:8
LONG lBkMode
Definition: ntgdihdl.h:310
BOOL WINAPI PolyTextOutA(_In_ HDC hdc, _In_reads_(cStrings) const POLYTEXTA *pptxt, _In_ INT cStrings)
Definition: text.c:82
COLORREF crForegroundClr
Definition: ntgdihdl.h:296
#define _In_reads_opt_(size)
Definition: no_sal2.h:231
BOOL WINAPI GetTextExtentExPointW(_In_ HDC hdc, _In_reads_(cchString) LPCWSTR lpszString, _In_ INT cchString, _In_ INT nMaxExtent, _Out_opt_ LPINT lpnFit, _Out_writes_to_opt_(cchString, *lpnFit) LPINT lpnDx, _Out_ LPSIZE lpSize)
Definition: text.c:283
INT WINAPI GetTextCharset(_In_ HDC hdc)
Definition: text.c:187
BOOL WINAPI TextOutA(_In_ HDC hdc, _In_ INT nXStart, _In_ INT nYStart, _In_reads_(cchString) LPCSTR lpString, _In_ INT cchString)
Definition: text.c:19
GLuint res
Definition: glext.h:9613
unsigned int ULONG
Definition: retypes.h:1
_In_ ULONG cjSize
Definition: winddi.h:3634
UINT cbCount
Definition: ntgdityp.h:521
#define DIRTY_LINE
Definition: ntgdihdl.h:146
DWORD dwLayout
Definition: ntgdihdl.h:336
INT APIENTRY NtGdiGetTextCharsetInfo(IN HDC hdc, OUT OPTIONAL LPFONTSIGNATURE lpSig, IN DWORD dwFlags)
Definition: text.c:224
COLORREF WINAPI SetTextColor(_In_ HDC hdc, _In_ COLORREF crColor)
Definition: text.c:886
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
#define TA_CENTER
Definition: wingdi.h:930
ULONG ulForegroundClr
Definition: ntgdityp.h:514
FORCEINLINE PVOID GdiAllocBatchCommand(HDC hdc, USHORT Cmd)
Definition: gdi32p.h:381
BOOL WINAPI GetTextMetricsA(_In_ HDC hdc, _Out_ LPTEXTMETRICA lptm)
Definition: text.c:200
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LPKETO LpkExtTextOut
Definition: utils.c:5
#define GDI_ERROR
Definition: wingdi.h:1291
#define LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:394
#define GTEF_INDICES
Definition: ntgdityp.h:212
static LPTEXTMETRICW lptm
Definition: font.c:42
#define APIENTRY
Definition: api.h:79
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToNtPathName_U(_In_opt_z_ PCWSTR DosPathName, _Out_ PUNICODE_STRING NtPathName, _Out_opt_ PCWSTR *NtFileNamePart, _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo)
_In_ LPCSTR lpFileName
Definition: winbase.h:3011
LONG lTextAlign
Definition: ntgdihdl.h:322
__kernel_entry W32KAPI BOOL APIENTRY NtGdiGetETM(_In_ HDC hdc, _Out_opt_ EXTTEXTMETRIC *petm)
UINT WINAPI GetStringBitmapA(_In_ HDC hdc, _In_ LPSTR psz, _In_ BOOL bDoCall, _In_ UINT cj, _Out_writes_(cj) BYTE *lpSB)
Definition: text.c:959
__kernel_entry W32KAPI UINT APIENTRY NtGdiGetStringBitmapW(_In_ HDC hdc, _In_ LPWSTR pwsz, _In_ UINT cwc, _Out_writes_bytes_(cj) BYTE *lpSB, _In_ UINT cj)
LPKGTEP LpkGetTextExtentExPoint
Definition: utils.c:7
int * LPINT
Definition: windef.h:178
UINT WINAPI SetTextAlign(_In_ HDC hdc, _In_ UINT fMode)
Definition: text.c:851