ReactOS 0.4.16-dev-1163-gec5b142
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 */
17BOOL
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 */
64BOOL
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, lpString, cchString, NULL);
74}
75
76
77/*
78 * @unimplemented
79 */
80BOOL
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 */
109BOOL
110WINAPI
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 */
138DWORD
139WINAPI
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 */
163INT
164WINAPI
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 */
185INT
186WINAPI
188 _In_ HDC hdc)
189{
190 /* MSDN docs say this is equivalent */
192}
193
194
195/*
196 * @implemented
197 */
198BOOL
199WINAPI
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 */
219BOOL
220WINAPI
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 */
240BOOL
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 /* FIXME: lpString can be non-NUL-terminated */
253 RtlInitAnsiString(&StringA, lpString);
254 RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
255
256 ret = GetTextExtentPointW(hdc, StringU.Buffer, cchString, lpsz);
257
258 RtlFreeUnicodeString(&StringU);
259
260 return ret;
261}
262
263
264/*
265 * @implemented
266 */
267BOOL
270 _In_ HDC hdc,
271 _In_reads_(cchString) LPCWSTR lpString,
272 _In_ INT cchString,
273 _Out_ LPSIZE lpsz)
274{
275 return NtGdiGetTextExtent(hdc, lpString, cchString, lpsz, 0);
276}
277
278
279/*
280 * @implemented
281 */
282BOOL
283WINAPI
285 _In_ HDC hdc,
286 _In_reads_(cchString) LPCWSTR lpszString,
287 _In_ INT cchString,
288 _In_ INT nMaxExtent,
289 _Out_opt_ LPINT lpnFit,
290 _Out_writes_to_opt_(cchString, *lpnFit) LPINT lpnDx,
291 _Out_ LPSIZE lpSize)
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(hdc, lpszString, cchString, nMaxExtent, (PULONG)lpnFit, (PULONG)lpnDx, lpSize, 0);
303}
304
305
306/*
307 * @implemented
308 */
309BOOL
310WINAPI
312 _In_ HDC hdc,
313 _In_reads_(cwc) PCWCH lpwsz,
314 _In_ INT cwc,
315 _In_ INT dxMax,
316 _Out_opt_ LPINT pcCh,
317 _Out_writes_to_opt_(cwc, *pcCh) LPINT pdxOut,
319{
320 return NtGdiGetTextExtentExW(hdc, lpwsz, cwc, dxMax, (PULONG)pcCh, (PULONG)pdxOut, psize, 0);
321}
322
323/*
324 * @implemented
325 */
326BOOL
327WINAPI
329 _In_ HDC hdc,
330 _In_reads_(cchString) LPCSTR lpszStr,
331 _In_ INT cchString,
332 _In_ INT nMaxExtent,
333 _Out_opt_ LPINT lpnFit,
334 _Out_writes_to_opt_ (cchString, *lpnFit) LPINT lpnDx,
335 _Out_ LPSIZE lpSize)
336{
338 LPWSTR lpszStrW;
339 BOOL bResult = FALSE;
340
341 if (nMaxExtent < -1)
342 {
344 return FALSE;
345 }
346
347 Status = HEAP_strdupA2W(&lpszStrW, lpszStr);
348 if (!NT_SUCCESS (Status))
349 {
351 return FALSE;
352 }
353
354 bResult = NtGdiGetTextExtentExW(hdc,
355 lpszStrW,
356 cchString,
357 nMaxExtent,
358 (PULONG)lpnFit,
359 (PULONG)lpnDx,
360 lpSize,
361 0);
362
363 HEAP_free(lpszStrW);
364
365 return bResult;
366}
367
368
369/*
370 * @implemented
371 */
372BOOL
373WINAPI
375 _In_ HDC hdc,
376 _In_reads_(cchString) LPCSTR lpString,
377 _In_ INT cchString,
378 _Out_ LPSIZE lpSize)
379{
380 ANSI_STRING StringA;
381 UNICODE_STRING StringU;
382 BOOL ret;
383
384 StringA.Buffer = (LPSTR)lpString;
385 StringA.Length = cchString;
386 RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
387
388 ret = GetTextExtentPoint32W(hdc, StringU.Buffer, cchString, lpSize);
389
390 RtlFreeUnicodeString(&StringU);
391
392 return ret;
393}
394
395
396/*
397 * @implemented
398 */
399BOOL
400WINAPI
402 _In_ HDC hdc,
403 _In_reads_(cchString) LPCWSTR lpString,
404 _In_ int cchString,
405 _Out_ LPSIZE lpSize)
406{
407 return NtGdiGetTextExtent(hdc, lpString, cchString, lpSize, 0);
408}
409
410/*
411 * @implemented
412 */
413BOOL
414WINAPI
416 _In_ HDC hdc,
417 _In_reads_(cgi) LPWORD pgiIn,
418 _In_ INT cgi,
419 _In_ INT nMaxExtent,
420 _Out_opt_ LPINT lpnFit,
421 _Out_writes_to_opt_(cwchString, *lpnFit) LPINT lpnDx,
422 _Out_ LPSIZE lpSize)
423{
425 pgiIn,
426 cgi,
427 nMaxExtent,
428 (PULONG)lpnFit,
429 (PULONG)lpnDx,
430 lpSize,
432}
433
434/*
435 * @implemented
436 */
437BOOL
438WINAPI
440 _In_ HDC hdc,
441 _In_reads_(cgi) LPWORD pgiIn,
442 _In_ int cgi,
443 _Out_ LPSIZE lpSize)
444{
445 return NtGdiGetTextExtent(hdc, pgiIn, cgi, lpSize, GTEF_INDICES);
446}
447
448/*
449 * @implemented
450 */
451BOOL
452WINAPI
454 _In_ HDC hdc,
455 _In_ INT x,
456 _In_ INT y,
457 _In_ UINT fuOptions,
458 _In_opt_ const RECT *lprc,
459 _In_reads_opt_(cch) LPCSTR lpString,
460 _In_ UINT cch,
461 _In_reads_opt_(cch) const INT *lpDx)
462{
463 ANSI_STRING StringA;
464 UNICODE_STRING StringU;
465 BOOL ret;
466
467 if (fuOptions & ETO_GLYPH_INDEX)
468 return ExtTextOutW(hdc, x, y, fuOptions, lprc, (LPCWSTR)lpString, cch, lpDx);
469
470 StringA.Buffer = (PCHAR)lpString;
471 StringA.Length = StringA.MaximumLength = cch;
472 RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
473
474 if (StringU.Length != StringA.Length * sizeof(WCHAR))
475 DPRINT1("ERROR: Should convert lpDx properly!\n");
476
477 ret = ExtTextOutW(hdc, x, y, fuOptions, lprc, StringU.Buffer, cch, lpDx);
478
479 RtlFreeUnicodeString(&StringU);
480
481 return ret;
482}
483
485
486/*
487 * @implemented
488 */
489BOOL
490WINAPI
492 _In_ HDC hdc,
493 _In_ INT x,
494 _In_ INT y,
495 _In_ UINT fuOptions,
496 _In_opt_ const RECT *lprc,
497 _In_reads_opt_(cwc) LPCWSTR lpString,
498 _In_ UINT cwc,
499 _In_reads_opt_(cwc) const INT *lpDx)
500{
501 PDC_ATTR pdcattr;
502
503 // Need both, should return a parameter error? No they don't!
504 if ( !lpDx && fuOptions & ETO_PDY )
505 return FALSE;
506
507 // Now sorting out rectangle.
508
509 // Here again, need both.
510 if ( lprc && !(fuOptions & (ETO_CLIPPED|ETO_OPAQUE)) )
511 {
512 lprc = NULL; // No flags, no rectangle.
513 }
514 else if (!lprc) // No rectangle, force clear flags if set and continue.
515 {
516 fuOptions &= ~(ETO_CLIPPED|ETO_OPAQUE);
517 }
518
519 if ( !bBypassETOWMF )
520 {
523 FALSE,
524 hdc,
525 x,
526 y,
527 fuOptions,
528 lprc,
529 lpString,
530 cwc,
531 lpDx);
532 }
533
534 if ( GdiConvertAndCheckDC(hdc) == NULL ) return FALSE;
535
536 if (!(fuOptions & (ETO_GLYPH_INDEX | ETO_IGNORELANGUAGE)))
537 {
539
540 if (LoadLPK(LPK_ETO))
541 return LpkExtTextOut(hdc, x, y, fuOptions, lprc, lpString, cwc , lpDx, 0);
542 }
543 else
544 {
546 }
547
548 /* Get the DC attribute */
549 pdcattr = GdiGetDcAttr(hdc);
550 if ( pdcattr &&
551 !(pdcattr->ulDirty_ & DC_DIBSECTION) &&
552 !(pdcattr->lTextAlign & TA_UPDATECP))
553 {
554 if ( lprc && !cwc )
555 {
556 if ( fuOptions & ETO_OPAQUE )
557 {
559
561 if (pgO)
562 {
563 pdcattr->ulDirty_ |= DC_MODE_DIRTY;
564 pgO->Count = cwc;
565 pgO->Rect = *lprc;
566 pgO->Options = fuOptions;
567 /* Snapshot attribute */
568 pgO->ulBackgroundClr = pdcattr->ulBackgroundClr;
569 pgO->ptlViewportOrg = pdcattr->ptlViewportOrg;
570 return TRUE;
571 }
572 }
573 else // Do nothing, old explorer pops this off.
574 {
575 DPRINT("GdiBCExtTextOut nothing\n");
576 return TRUE;
577 }
578 } // Max 580 wchars, if offset 0
579 else if ( cwc <= ((GDIBATCHBUFSIZE - sizeof(GDIBSTEXTOUT)) / sizeof(WCHAR)) )
580 {
581 PGDIBSTEXTOUT pgO;
582 PTEB pTeb = NtCurrentTeb();
583
585 if (pgO)
586 {
587 USHORT cjSize = 0;
588 ULONG DxSize = 0;
589
590 if (cwc > 2) cjSize = (cwc * sizeof(WCHAR)) - sizeof(pgO->String);
591
592 /* Calculate buffer size for string and Dx values */
593 if (lpDx)
594 {
595 /* If ETO_PDY is specified, we have pairs of INTs */
596 DxSize = (cwc * sizeof(INT)) * (fuOptions & ETO_PDY ? 2 : 1);
597 cjSize += DxSize;
598 // The structure buffer holds 4 bytes. Store Dx data then string.
599 // Result one wchar -> Buf[ Dx ]Str[wC], [4][2][X] one extra unused wchar
600 // to assure alignment of 4.
601 }
602
603 if ((pTeb->GdiTebBatch.Offset + cjSize ) <= GDIBATCHBUFSIZE)
604 {
606 pgO->cbCount = cwc;
607 pgO->x = x;
608 pgO->y = y;
609 pgO->Options = fuOptions;
610 pgO->iCS_CP = 0;
611
612 if (lprc) pgO->Rect = *lprc;
613 else
614 {
615 pgO->Options |= GDIBS_NORECT; // Tell the other side lprc is nill.
616 }
617
618 /* Snapshot attributes */
619 pgO->crForegroundClr = pdcattr->crForegroundClr;
620 pgO->crBackgroundClr = pdcattr->crBackgroundClr;
621 pgO->ulForegroundClr = pdcattr->ulForegroundClr;
622 pgO->ulBackgroundClr = pdcattr->ulBackgroundClr;
623 pgO->lBkMode = pdcattr->lBkMode == OPAQUE ? OPAQUE : TRANSPARENT;
624 pgO->hlfntNew = pdcattr->hlfntNew;
625 pgO->flTextAlign = pdcattr->flTextAlign;
626 pgO->ptlViewportOrg = pdcattr->ptlViewportOrg;
627
628 pgO->Size = DxSize; // of lpDx then string after.
629 /* Put the Dx before the String to assure alignment of 4 */
630 if (lpDx) RtlCopyMemory( &pgO->Buffer, lpDx, DxSize);
631
632 if (cwc) RtlCopyMemory( &pgO->String[DxSize/sizeof(WCHAR)], lpString, cwc * sizeof(WCHAR));
633
634 // Recompute offset and return size
635 pTeb->GdiTebBatch.Offset += cjSize;
636 ((PGDIBATCHHDR)pgO)->Size += cjSize;
637 return TRUE;
638 }
639 // Reset offset and count then fall through
640 pTeb->GdiTebBatch.Offset -= sizeof(GDIBSTEXTOUT);
641 pTeb->GdiBatchCount--;
642 }
643 }
644 }
645 return NtGdiExtTextOutW(hdc,
646 x,
647 y,
648 fuOptions,
649 lprc,
650 lpString,
651 cwc,
652 lpDx,
653 0);
654}
655
656
657/*
658 * @implemented
659 */
660INT
661WINAPI
663 _In_ HDC hdc,
664 _In_ INT cwcMax,
665 _Out_writes_to_opt_(cwcMax, return) LPWSTR pFaceName)
666{
667 /* Validate parameters */
668 if (pFaceName && cwcMax <= 0)
669 {
670 /* Set last error and return failure */
672 return 0;
673 }
674
675 /* Forward to kernel */
676 return NtGdiGetTextFaceW(hdc, cwcMax, pFaceName, FALSE);
677}
678
679
680/*
681 * @implemented
682 */
683INT
684WINAPI
686 _In_ HDC hdc,
689{
690 INT res;
692
693 /* Validate parameters */
694 if (lpName && cchMax <= 0)
695 {
696 /* Set last error and return failure */
698 return 0;
699 }
700
701 res = GetTextFaceW(hdc, 0, NULL);
702 nameW = HeapAlloc( GetProcessHeap(), 0, res * 2 );
703 if (nameW == NULL)
704 {
705 return 0;
706 }
707
709
710 if (lpName)
711 {
713 lpName[cchMax-1] = 0;
714 res = strlen(lpName);
715 }
716 else
717 {
718 res = WideCharToMultiByte( CP_ACP, 0, nameW, -1, NULL, 0, NULL, NULL);
719 }
720
722 return res;
723}
724
725
726/*
727 * @implemented
728 */
729INT
730WINAPI
732 _In_ HDC hdc,
733 _In_ INT cwcMax,
734 _Out_writes_to_opt_(cwcMax, return) LPWSTR pszOut)
735{
736 if (pszOut && !cwcMax)
737 {
739 return 0;
740 }
741
742 return NtGdiGetTextFaceW(hdc, cwcMax, pszOut, TRUE);
743}
744
745
746BOOL
747WINAPI
750 _Inout_ DWORD *pdwBufSize,
751 _Out_writes_to_opt_(*pdwBufSize, 1) PVOID lpBuffer,
752 _In_ DWORD dwType)
753{
754 BOOL bRet;
755 UNICODE_STRING NtFileName;
756
757 DPRINT("GetFontResourceInfoW: dwType = %lu\n", dwType);
758
759 if (!lpFileName || !pdwBufSize)
760 {
762 return FALSE;
763 }
764
766 &NtFileName,
767 NULL,
768 NULL))
769 {
771 return FALSE;
772 }
773
775 NtFileName.Buffer,
776 (NtFileName.Length / sizeof(WCHAR)) + 1,
777 1,
778 *pdwBufSize,
779 pdwBufSize,
780 lpBuffer,
781 dwType);
782
783 RtlFreeHeap(RtlGetProcessHeap(), 0, NtFileName.Buffer);
784
785 return bRet;
786}
787
788
789/*
790 * @unimplemented
791 */
792INT
793WINAPI
795 _In_ HDC hdc,
796 _In_ INT nCharExtra)
797{
798 PDC_ATTR pdcattr;
799 INT nOldCharExtra;
800
801 if (nCharExtra == 0x80000000)
802 {
804 return 0x80000000;
805 }
806
807 HANDLE_METADC16(INT, SetTextCharacterExtra, 0x80000000, hdc, nCharExtra);
808
809 /* Get the DC attribute */
810 pdcattr = GdiGetDcAttr(hdc);
811 if (pdcattr == NULL)
812 {
814 return 0x8000000;
815 }
816
817 if (NtCurrentTeb()->GdiTebBatch.HDC == hdc)
818 {
819 if (pdcattr->ulDirty_ & DC_FONTTEXT_DIRTY)
820 {
821 NtGdiFlush(); // Sync up pdcattr from Kernel space.
823 }
824 }
825
826 nOldCharExtra = pdcattr->lTextExtra;
827 pdcattr->lTextExtra = nCharExtra;
828 return nOldCharExtra;
829}
830
831/*
832 * @implemented
833 *
834 */
835UINT
836WINAPI
838 _In_ HDC hdc)
839{
840 PDC_ATTR pdcattr;
841
842 /* Get the DC attribute */
843 pdcattr = GdiGetDcAttr(hdc);
844 if (pdcattr == NULL)
845 {
846 /* Do not set LastError here! */
847 return GDI_ERROR;
848 }
849
850 return pdcattr->lTextAlign;
851}
852
853
854/*
855 * @implemented
856 *
857 */
859WINAPI
861 _In_ HDC hdc)
862{
863 PDC_ATTR pdcattr;
864
865 /* Get the DC attribute */
866 pdcattr = GdiGetDcAttr(hdc);
867 if (pdcattr == NULL)
868 {
869 /* Do not set LastError here! */
870 return CLR_INVALID;
871 }
872
873 return pdcattr->ulForegroundClr;
874}
875
876
877/*
878 * @unimplemented
879 */
880UINT
881WINAPI
883 _In_ HDC hdc,
884 _In_ UINT fMode)
885{
886 PDC_ATTR pdcattr;
887 UINT fOldMode;
888
890
891 /* Get the DC attribute */
892 pdcattr = GdiGetDcAttr(hdc);
893 if (pdcattr == NULL)
894 {
896 return GDI_ERROR;
897 }
898
899
900 fOldMode = pdcattr->lTextAlign;
901 pdcattr->lTextAlign = fMode; // Raw
902 if (pdcattr->dwLayout & LAYOUT_RTL)
903 {
904 if ((fMode & TA_CENTER) != TA_CENTER) fMode ^= TA_RIGHT;
905 }
906
907 pdcattr->flTextAlign = fMode & TA_MASK;
908 return fOldMode;
909}
910
911
912/*
913 * @implemented
914 */
916WINAPI
918 _In_ HDC hdc,
919 _In_ COLORREF crColor)
920{
921 PDC_ATTR pdcattr;
922 COLORREF crOldColor;
923
925
926 pdcattr = GdiGetDcAttr(hdc);
927 if (pdcattr == NULL)
928 {
930 return CLR_INVALID;
931 }
932
933 crOldColor = (COLORREF) pdcattr->ulForegroundClr;
934 pdcattr->ulForegroundClr = (ULONG)crColor;
935
936 if (pdcattr->crForegroundClr != crColor)
937 {
939 pdcattr->crForegroundClr = crColor;
940 }
941
942 return crOldColor;
943}
944
945/*
946 * @implemented
947 */
948BOOL
949WINAPI
951 _In_ HDC hdc,
952 _In_ INT nBreakExtra,
953 _In_ INT nBreakCount)
954{
955 PDC_ATTR pdcattr;
956
957 HANDLE_METADC16(BOOL, SetTextJustification, FALSE, hdc, nBreakExtra, nBreakCount);
958
959 /* Get the DC attribute */
960 pdcattr = GdiGetDcAttr(hdc);
961 if (pdcattr == NULL)
962 {
963 /* Do not set LastError here! */
964 return GDI_ERROR;
965 }
966
967
968 if (NtCurrentTeb()->GdiTebBatch.HDC == hdc)
969 {
970 if (pdcattr->ulDirty_ & DC_FONTTEXT_DIRTY)
971 {
972 NtGdiFlush(); // Sync up pdcattr from Kernel space.
974 }
975 }
976
977 pdcattr->cBreak = nBreakCount;
978 pdcattr->lBreakExtra = nBreakExtra;
979 return TRUE;
980}
981
982/*
983 * @implemented
984 */
985UINT
986WINAPI
988 _In_ HDC hdc,
989 _In_ LPSTR psz,
990 _In_ BOOL bDoCall,
991 _In_ UINT cj,
992 _Out_writes_(cj) BYTE *lpSB)
993{
994
996 PWSTR pwsz;
997 UINT uResult = 0;
998
999 if (!bDoCall)
1000 {
1001 return 0;
1002 }
1003
1004 Status = HEAP_strdupA2W(&pwsz, psz);
1005 if (!NT_SUCCESS(Status))
1006 {
1008 }
1009 else
1010 {
1011 uResult = NtGdiGetStringBitmapW(hdc, pwsz, 1, lpSB, cj);
1012 HEAP_free(pwsz);
1013 }
1014
1015 return uResult;
1016
1017}
1018
1019/*
1020 * @implemented
1021 */
1022UINT
1023WINAPI
1025 _In_ HDC hdc,
1026 _In_ LPWSTR pwsz,
1027 _In_ BOOL bDoCall,
1028 _In_ UINT cj,
1029 _Out_writes_(cj) BYTE *lpSB)
1030{
1031 if (!bDoCall)
1032 {
1033 return 0;
1034 }
1035
1036 return NtGdiGetStringBitmapW(hdc, pwsz, 1, lpSB, cj);
1037
1038}
1039
1040/*
1041 * @implemented
1042 */
1043BOOL
1044WINAPI
1046 _In_ HDC hdc,
1047 _Out_ EXTTEXTMETRIC *petm)
1048{
1049 BOOL bResult;
1050
1051 bResult = NtGdiGetETM(hdc, petm);
1052
1053 if (bResult && petm)
1054 {
1055 petm->emKernPairs = (WORD)GetKerningPairsA(hdc, 0, 0);
1056 }
1057
1058 return bResult;
1059}
UINT cchMax
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
LONG NTSTATUS
Definition: precomp.h:26
static const WCHAR nameW[]
Definition: main.c:49
#define DPRINT1
Definition: precomp.h:8
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:634
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define APIENTRY
Definition: api.h:79
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:109
#define SetLastError(x)
Definition: compat.h:752
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define WideCharToMultiByte
Definition: compat.h:111
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
HDC WINAPI GdiConvertAndCheckDC(HDC hdc)
Definition: dc.c:403
FORCEINLINE PVOID GdiAllocBatchCommand(HDC hdc, USHORT Cmd)
Definition: gdi32p.h:407
#define HANDLE_METADC16(_RetType, _Func, dwError, hdc,...)
Definition: gdi32p.h:639
#define HANDLE_METADC(_RetType, _Func, dwError, hdc,...)
Definition: gdi32p.h:615
#define LPK_ETO
Definition: gdi32p.h:82
VOID FASTCALL FONT_TextMetricWToA(const TEXTMETRICW *ptmW, LPTEXTMETRICA ptmA)
Definition: font.c:81
BOOL WINAPI LoadLPK(INT LpkFunctionID)
Definition: utils.c:423
LPKETO LpkExtTextOut
Definition: utils.c:5
static VOID FASTCALL HEAP_free(_In_ __drv_freesMem(Mem) PVOID memory)
Definition: gdi32p.h:226
#define LPK_GTEP
Definition: gdi32p.h:84
VOID WINAPI GdiSetLastError(DWORD dwErrCode)
Definition: misc.c:873
LPKGTEP LpkGetTextExtentExPoint
Definition: utils.c:7
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:477
NTSTATUS FASTCALL HEAP_strdupA2W(_Outptr_ PWSTR *ppszW, _In_ PCSTR lpszA)
Definition: heap.c:34
Status
Definition: gdiplustypes.h:25
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint res
Definition: glext.h:9613
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
#define NtCurrentTeb
#define PCHAR
Definition: match.c:90
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
static LPTEXTMETRICW lptm
Definition: font.c:42
unsigned int UINT
Definition: ndis.h:50
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)
#define _Out_writes_to_opt_(s, c)
Definition: no_sal2.h:238
#define _In_reads_(s)
Definition: no_sal2.h:168
#define _Out_opt_
Definition: no_sal2.h:214
#define _Inout_
Definition: no_sal2.h:162
#define _In_z_
Definition: no_sal2.h:164
#define _Out_writes_(s)
Definition: no_sal2.h:176
#define _Out_
Definition: no_sal2.h:160
#define _In_reads_opt_(s)
Definition: no_sal2.h:222
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
CONST WCHAR * PCWCH
Definition: ntbasedef.h:423
__kernel_entry W32KAPI DWORD APIENTRY NtGdiGetCharSet(_In_ HDC hdc)
Definition: text.c:204
__kernel_entry W32KAPI NTSTATUS APIENTRY NtGdiFlush(VOID)
Definition: gdibatch.c:471
__kernel_entry W32KAPI UINT APIENTRY NtGdiGetStringBitmapW(_In_ HDC hdc, _In_ LPWSTR pwsz, _In_ UINT cwc, _Out_writes_bytes_(cj) BYTE *lpSB, _In_ UINT cj)
__kernel_entry W32KAPI INT APIENTRY NtGdiGetTextCharsetInfo(_In_ HDC hdc, _Out_opt_ LPFONTSIGNATURE lpSig, _In_ DWORD dwFlags)
Definition: text.c:265
__kernel_entry W32KAPI INT APIENTRY NtGdiGetTextFaceW(_In_ HDC hDC, _In_ INT Count, _Out_writes_to_opt_(Count, return) PWSTR FaceName, _In_ BOOL bAliasName)
Definition: text.c:529
__kernel_entry W32KAPI BOOL APIENTRY NtGdiGetFontResourceInfoInternalW(_In_reads_z_(cwc) PCWCH pwszFiles, _In_ ULONG cwc, _In_ ULONG cFiles, _In_ UINT cjBuf, _Out_ LPDWORD pdwBytes, _Out_writes_bytes_(cjBuf) LPVOID pvBuf, _In_ DWORD iType)
_Must_inspect_result_ _Out_ LPSIZE psize
Definition: ntgdi.h:1569
__kernel_entry W32KAPI BOOL APIENTRY NtGdiGetTextExtent(_In_ HDC hdc, _In_reads_(cwc) PCWCH lpwsz, _In_ INT cwc, _Out_ PSIZE psize, _In_ UINT flOpts)
Definition: text.c:489
__kernel_entry W32KAPI BOOL APIENTRY NtGdiExtTextOutW(_In_ HDC hdc, _In_ INT x, _In_ INT y, _In_ UINT flOpts, _In_opt_ LPCRECT prcl, _In_reads_opt_(cwc) PCWCH pwsz, _In_range_(0, 0xffff) UINT cwc, _In_reads_opt_(_Inexpressible_(cwc)) const INT *pdx, _In_ DWORD dwCodePage)
__kernel_entry W32KAPI BOOL APIENTRY NtGdiGetTextExtentExW(_In_ HDC hdc, _In_reads_opt_(cwc) PCWCH pwsz, _In_ ULONG cwc, _In_ ULONG dxMax, _Out_opt_ PULONG pcCh, _Out_writes_to_opt_(cwc, *pcCh) PULONG pdxOut, _Out_ PSIZE psize, _In_ FLONG fl)
__kernel_entry W32KAPI BOOL APIENTRY NtGdiGetETM(_In_ HDC hdc, _Out_opt_ EXTTEXTMETRIC *petm)
#define DC_FONTTEXT_DIRTY
Definition: ntgdihdl.h:145
#define DC_DIBSECTION
Definition: ntgdihdl.h:137
#define DIRTY_FILL
Definition: ntgdihdl.h:123
#define DC_MODE_DIRTY
Definition: ntgdihdl.h:144
#define DIRTY_TEXT
Definition: ntgdihdl.h:125
#define DIRTY_LINE
Definition: ntgdihdl.h:124
#define DIRTY_CHARSET
Definition: ntgdihdl.h:127
#define GTEF_INDICES
Definition: ntgdityp.h:213
struct _GDIBSTEXTOUT GDIBSTEXTOUT
#define GDIBATCHBUFSIZE
Definition: ntgdityp.h:200
struct _GDIBATCHHDR * PGDIBATCHHDR
@ GdiBCTextOut
Definition: ntgdityp.h:88
@ GdiBCExtTextOut
Definition: ntgdityp.h:89
#define GDIBS_NORECT
Definition: ntgdityp.h:507
#define LOWORD(l)
Definition: pedump.c:82
unsigned short USHORT
Definition: pedump.c:61
#define INT
Definition: polytest.cpp:20
#define DPRINT
Definition: sndvol32.h:73
USHORT MaximumLength
Definition: env_spec_w32.h:377
LONG lBreakExtra
Definition: ntgdihdl.h:328
DWORD iCS_CP
Definition: ntgdihdl.h:305
LONG lBkMode
Definition: ntgdihdl.h:313
LONG cBreak
Definition: ntgdihdl.h:329
ULONG ulBackgroundClr
Definition: ntgdihdl.h:298
DWORD dwLayout
Definition: ntgdihdl.h:339
LONG lTextAlign
Definition: ntgdihdl.h:325
POINTL ptlViewportOrg
Definition: ntgdihdl.h:343
ULONG ulForegroundClr
Definition: ntgdihdl.h:300
LONG lTextExtra
Definition: ntgdihdl.h:326
COLORREF crForegroundClr
Definition: ntgdihdl.h:299
HANDLE hlfntNew
Definition: ntgdihdl.h:330
COLORREF crBackgroundClr
Definition: ntgdihdl.h:297
ULONG ulDirty_
Definition: ntgdihdl.h:294
FLONG flTextAlign
Definition: ntgdihdl.h:324
POINTL ptlViewportOrg
Definition: ntgdityp.h:539
ULONG ulBackgroundClr
Definition: ntgdityp.h:540
ULONG Buffer[1]
Definition: ntgdityp.h:529
POINTL ptlViewportOrg
Definition: ntgdityp.h:526
UINT cbCount
Definition: ntgdityp.h:522
UINT Options
Definition: ntgdityp.h:519
HANDLE hlfntNew
Definition: ntgdityp.h:524
WCHAR String[2]
Definition: ntgdityp.h:528
LONG lBkMode
Definition: ntgdityp.h:514
COLORREF crForegroundClr
Definition: ntgdityp.h:512
ULONG ulForegroundClr
Definition: ntgdityp.h:515
FLONG flTextAlign
Definition: ntgdityp.h:525
COLORREF crBackgroundClr
Definition: ntgdityp.h:513
ULONG ulBackgroundClr
Definition: ntgdityp.h:516
DWORD iCS_CP
Definition: ntgdityp.h:521
ULONG Offset
Definition: compat.h:831
Definition: compat.h:836
GDI_TEB_BATCH GdiTebBatch
Definition: compat.h:857
ULONG GdiBatchCount
Definition: compat.h:887
TEXTMETRICW TextMetric
Definition: ntgdityp.h:370
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t * PULONG
Definition: typedefs.h:59
uint16_t * LPWORD
Definition: typedefs.h:56
int32_t INT
Definition: typedefs.h:58
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define MAXUSHORT
Definition: typedefs.h:83
uint32_t ULONG
Definition: typedefs.h:59
int ret
BOOL WINAPI GetTextExtentPointI(_In_ HDC hdc, _In_reads_(cgi) LPWORD pgiIn, _In_ int cgi, _Out_ LPSIZE lpSize)
Definition: text.c:439
UINT WINAPI GetTextAlign(_In_ HDC hdc)
Definition: text.c:837
UINT WINAPI GetStringBitmapA(_In_ HDC hdc, _In_ LPSTR psz, _In_ BOOL bDoCall, _In_ UINT cj, _Out_writes_(cj) BYTE *lpSB)
Definition: text.c:987
COLORREF WINAPI SetTextColor(_In_ HDC hdc, _In_ COLORREF crColor)
Definition: text.c:917
BOOL WINAPI SetTextJustification(_In_ HDC hdc, _In_ INT nBreakExtra, _In_ INT nBreakCount)
Definition: text.c:950
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:415
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:491
UINT WINAPI GetStringBitmapW(_In_ HDC hdc, _In_ LPWSTR pwsz, _In_ BOOL bDoCall, _In_ UINT cj, _Out_writes_(cj) BYTE *lpSB)
Definition: text.c:1024
BOOL WINAPI TextOutW(_In_ HDC hdc, _In_ INT nXStart, _In_ INT nYStart, _In_reads_(cchString) LPCWSTR lpString, _In_ INT cchString)
Definition: text.c:66
BOOL WINAPI GetTextMetricsW(_In_ HDC hdc, _Out_ LPTEXTMETRICW lptm)
Definition: text.c:221
BOOL APIENTRY GetTextExtentPointA(_In_ HDC hdc, _In_reads_(cchString) LPCSTR lpString, _In_ INT cchString, _Out_ LPSIZE lpsz)
Definition: text.c:242
INT WINAPI GetTextFaceA(_In_ HDC hdc, _In_ INT cchMax, _Out_writes_to_opt_(cchMax, return) LPSTR lpName)
Definition: text.c:685
BOOL WINAPI PolyTextOutA(_In_ HDC hdc, _In_reads_(cStrings) const POLYTEXTA *pptxt, _In_ INT cStrings)
Definition: text.c:82
BOOL WINAPI GetTextExtentPoint32A(_In_ HDC hdc, _In_reads_(cchString) LPCSTR lpString, _In_ INT cchString, _Out_ LPSIZE lpSize)
Definition: text.c:374
BOOL WINAPI TextOutA(_In_ HDC hdc, _In_ INT nXStart, _In_ INT nYStart, _In_reads_(cchString) LPCSTR lpString, _In_ INT cchString)
Definition: text.c:19
BOOL APIENTRY GetTextExtentPointW(_In_ HDC hdc, _In_reads_(cchString) LPCWSTR lpString, _In_ INT cchString, _Out_ LPSIZE lpsz)
Definition: text.c:269
UINT WINAPI SetTextAlign(_In_ HDC hdc, _In_ UINT fMode)
Definition: text.c:882
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:284
INT WINAPI SetTextCharacterExtra(_In_ HDC hdc, _In_ INT nCharExtra)
Definition: text.c:794
BOOL WINAPI GetTextExtentPoint32W(_In_ HDC hdc, _In_reads_(cchString) LPCWSTR lpString, _In_ int cchString, _Out_ LPSIZE lpSize)
Definition: text.c:401
COLORREF WINAPI GetTextColor(_In_ HDC hdc)
Definition: text.c:860
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:453
DWORD WINAPI GdiGetCodePage(_In_ HDC hdc)
Definition: text.c:140
BOOL WINAPI GetTextExtentExPointWPri(_In_ HDC hdc, _In_reads_(cwc) PCWCH 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:311
static BOOL bBypassETOWMF
Definition: text.c:484
BOOL WINAPI PolyTextOutW(_In_ HDC hdc, _In_reads_(cStrings) const POLYTEXTW *pptxt, _In_ INT cStrings)
Definition: text.c:111
INT WINAPI GetTextFaceAliasW(_In_ HDC hdc, _In_ INT cwcMax, _Out_writes_to_opt_(cwcMax, return) LPWSTR pszOut)
Definition: text.c:731
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:328
BOOL WINAPI GetFontResourceInfoW(_In_z_ LPCWSTR lpFileName, _Inout_ DWORD *pdwBufSize, _Out_writes_to_opt_(*pdwBufSize, 1) PVOID lpBuffer, _In_ DWORD dwType)
Definition: text.c:748
INT WINAPI GetTextCharset(_In_ HDC hdc)
Definition: text.c:187
INT WINAPI GetTextCharacterExtra(_In_ HDC hdc)
Definition: text.c:165
INT WINAPI GetTextFaceW(_In_ HDC hdc, _In_ INT cwcMax, _Out_writes_to_opt_(cwcMax, return) LPWSTR pFaceName)
Definition: text.c:662
BOOL WINAPI GetETM(_In_ HDC hdc, _Out_ EXTTEXTMETRIC *petm)
Definition: text.c:1045
W32KAPI BOOL APIENTRY NtGdiGetTextMetricsW(_In_ HDC hDC, _Out_ PTMW_INTERNAL pUnsafeTmwi, _In_ ULONG cj)
Definition: text.c:588
_In_ LPCSTR lpFileName
Definition: winbase.h:3103
_In_ LPCSTR lpName
Definition: winbase.h:2821
_In_ ULONG cj
Definition: winddi.h:3540
_In_ ULONG cjSize
Definition: winddi.h:3634
int * LPINT
Definition: windef.h:178
DWORD COLORREF
Definition: windef.h:300
#define WINAPI
Definition: msvc.h:6
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
#define TA_UPDATECP
Definition: wingdi.h:936
#define TA_RIGHT
Definition: wingdi.h:933
#define TRANSPARENT
Definition: wingdi.h:950
#define CLR_INVALID
Definition: wingdi.h:883
#define LAYOUT_RTL
Definition: wingdi.h:1371
#define TA_MASK
Definition: wingdi.h:937
DWORD WINAPI GetKerningPairsA(_In_ HDC hdc, _In_ DWORD nPairs, _Out_writes_to_opt_(nPairs, return) LPKERNINGPAIR lpKernPair)
#define ETO_CLIPPED
Definition: wingdi.h:648
#define ExtTextOut
Definition: wingdi.h:4454
#define ETO_OPAQUE
Definition: wingdi.h:647
#define OPAQUE
Definition: wingdi.h:949
#define GDI_ERROR
Definition: wingdi.h:1309
#define ETO_PDY
Definition: wingdi.h:657
BOOL WINAPI GetTextMetricsA(_In_ HDC, _Out_ LPTEXTMETRICA)
Definition: text.c:200
#define TA_CENTER
Definition: wingdi.h:931
_In_ int _Inout_ LPRECT lprc
Definition: winuser.h:4477
const char * LPCSTR
Definition: xmlstorage.h:183
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
unsigned char BYTE
Definition: xxhash.c:193