15 _In_reads_(cchString
) LPCSTR lpString
,
19 UNICODE_STRING StringU
;
24 RtlInitAnsiString(&StringA
, (LPSTR
)lpString
);
25 RtlAnsiStringToUnicodeString(&StringU
, &StringA
, TRUE
);
29 StringU
.Buffer
= NULL
;
32 bResult
= TextOutW(hdc
, nXStart
, nYStart
, StringU
.Buffer
, cchString
);
34 RtlFreeUnicodeString(&StringU
);
48 _In_reads_(cchString
) LPCWSTR lpString
,
51 return ExtTextOutW(hdc
, nXStart
, nYStart
, 0, NULL
, (LPWSTR
)lpString
, cchString
, NULL
);
62 _In_reads_(cStrings
) const POLYTEXTA
*pptxt
,
65 for (; cStrings
>0; cStrings
--, pptxt
++)
91 _In_reads_(cStrings
) const POLYTEXTW
*pptxt
,
94 for (; cStrings
>0; cStrings
--, pptxt
++)
123 /* Get the DC attribute */
124 pdcattr
= GdiGetDcAttr(hdc
);
127 SetLastError(ERROR_INVALID_PARAMETER
);
131 if (pdcattr
->ulDirty_
& DIRTY_CHARSET
)
132 return LOWORD(NtGdiGetCharSet(hdc
));
134 return LOWORD(pdcattr
->iCS_CP
);
143 GetTextCharacterExtra(
148 /* Get the DC attribute */
149 pdcattr
= GdiGetDcAttr(hdc
);
152 /* Do not set LastError here! */
156 return pdcattr
->lTextExtra
;
168 /* MSDN docs say this is equivalent */
169 return NtGdiGetTextCharsetInfo(hdc
,NULL
,0);
180 _Out_ LPTEXTMETRICA lptm
)
184 if (!NtGdiGetTextMetricsW(hdc
, &tmwi
, sizeof(TMW_INTERNAL
)))
189 FONT_TextMetricWToA(&tmwi
.TextMetric
, lptm
);
201 _Out_ LPTEXTMETRICW lptm
)
205 if (!NtGdiGetTextMetricsW(hdc
, &tmwi
, sizeof(TMW_INTERNAL
)))
210 *lptm
= tmwi
.TextMetric
;
222 _In_reads_(cchString
) LPCSTR lpString
,
227 UNICODE_STRING StringU
;
230 RtlInitAnsiString(&StringA
, (LPSTR
)lpString
);
231 RtlAnsiStringToUnicodeString(&StringU
, &StringA
, TRUE
);
233 ret
= GetTextExtentPointW(hdc
, StringU
.Buffer
, cchString
, lpsz
);
235 RtlFreeUnicodeString(&StringU
);
248 _In_reads_(cchString
) LPCWSTR lpString
,
252 return NtGdiGetTextExtent(hdc
, (LPWSTR
)lpString
, cchString
, lpsz
, 0);
261 GetTextExtentExPointW(
263 _In_reads_(cchString
) LPCWSTR lpszString
,
266 _Out_opt_ LPINT lpnFit
,
267 _Out_writes_to_opt_(cchString
, *lpnFit
) LPINT lpnDx
,
271 /* Windows doesn't check nMaxExtent validity in unicode version */
274 DPRINT("nMaxExtent is invalid: %d\n", nMaxExtent
);
277 return NtGdiGetTextExtentExW (
278 hdc
, (LPWSTR
)lpszString
, cchString
, nMaxExtent
, (PULONG
)lpnFit
, (PULONG
)lpnDx
, lpSize
, 0 );
287 GetTextExtentExPointWPri(
289 _In_reads_(cwc
) LPWSTR lpwsz
,
292 _Out_opt_ ULONG
*pcCh
,
293 _Out_writes_to_opt_(cwc
, *pcCh
) PULONG pdxOut
,
296 return NtGdiGetTextExtentExW(hdc
, lpwsz
, cwc
, dxMax
, pcCh
, pdxOut
, psize
, 0);
304 GetTextExtentExPointA(
306 _In_reads_(cchString
) LPCSTR lpszStr
,
309 _Out_opt_ LPINT lpnFit
,
310 _Out_writes_to_opt_ (cchString
, *lpnFit
) LPINT lpnDx
,
315 BOOL bResult
= FALSE
;
319 SetLastError(ERROR_INVALID_PARAMETER
);
323 Status
= HEAP_strdupA2W(&lpszStrW
, lpszStr
);
324 if (!NT_SUCCESS (Status
))
326 SetLastError(RtlNtStatusToDosError(Status
));
330 bResult
= NtGdiGetTextExtentExW(hdc
,
350 GetTextExtentPoint32A(
352 _In_reads_(cchString
) LPCSTR lpString
,
357 UNICODE_STRING StringU
;
360 StringA
.Buffer
= (LPSTR
)lpString
;
361 StringA
.Length
= cchString
;
362 RtlAnsiStringToUnicodeString(&StringU
, &StringA
, TRUE
);
364 ret
= GetTextExtentPoint32W(hdc
, StringU
.Buffer
, cchString
, lpSize
);
366 RtlFreeUnicodeString(&StringU
);
377 GetTextExtentPoint32W(
379 _In_reads_(cchString
) LPCWSTR lpString
,
383 return NtGdiGetTextExtent(hdc
, (LPWSTR
)lpString
, cchString
, lpSize
, 0);
391 GetTextExtentExPointI(
393 _In_reads_(cgi
) LPWORD pgiIn
,
396 _Out_opt_ LPINT lpnFit
,
397 _Out_writes_to_opt_(cwchString
, *lpnFit
) LPINT lpnDx
,
400 return NtGdiGetTextExtentExW(hdc
,
417 _In_reads_(cgi
) LPWORD pgiIn
,
421 return NtGdiGetTextExtent(hdc
, pgiIn
, cgi
, lpSize
, GTEF_INDICES
);
434 _In_opt_
const RECT
*lprc
,
435 _In_reads_opt_(cch
) LPCSTR lpString
,
437 _In_reads_opt_(cch
) const INT
*lpDx
)
440 UNICODE_STRING StringU
;
443 RtlInitAnsiString(&StringA
, (LPSTR
)lpString
);
444 RtlAnsiStringToUnicodeString(&StringU
, &StringA
, TRUE
);
446 ret
= ExtTextOutW(hdc
, x
, y
, fuOptions
, lprc
, StringU
.Buffer
, cch
, lpDx
);
448 RtlFreeUnicodeString(&StringU
);
464 _In_opt_
const RECT
*lprc
,
465 _In_reads_opt_(cwc
) LPCWSTR lpString
,
467 _In_reads_opt_(cwc
) const INT
*lpDx
)
481 return NtGdiExtTextOutW(hdc
,
501 _Out_writes_to_opt_(cwcMax
, return) LPWSTR pFaceName
)
503 /* Validate parameters */
504 if (pFaceName
&& cwcMax
<= 0)
506 /* Set last error and return failure */
507 GdiSetLastError(ERROR_INVALID_PARAMETER
);
511 /* Forward to kernel */
512 return NtGdiGetTextFaceW(hdc
, cwcMax
, pFaceName
, FALSE
);
524 _Out_writes_to_opt_(cchMax
, return) LPSTR lpName
)
529 /* Validate parameters */
530 if (lpName
&& cchMax
<= 0)
532 /* Set last error and return failure */
533 GdiSetLastError(ERROR_INVALID_PARAMETER
);
537 res
= GetTextFaceW(hdc
, 0, NULL
);
538 nameW
= HeapAlloc( GetProcessHeap(), 0, res
* 2 );
544 GetTextFaceW( hdc
, res
, nameW
);
548 if (cchMax
&& !WideCharToMultiByte( CP_ACP
, 0, nameW
, -1, lpName
, cchMax
, NULL
, NULL
))
549 lpName
[cchMax
-1] = 0;
550 res
= strlen(lpName
);
554 res
= WideCharToMultiByte( CP_ACP
, 0, nameW
, -1, NULL
, 0, NULL
, NULL
);
557 HeapFree( GetProcessHeap(), 0, nameW
);
570 _Out_writes_to_opt_(cwcMax
, return) LPWSTR pszOut
)
572 if (pszOut
&& !cwcMax
)
574 GdiSetLastError(ERROR_INVALID_PARAMETER
);
578 return NtGdiGetTextFaceW(hdc
, cwcMax
, pszOut
, TRUE
);
584 GetFontResourceInfoW(
585 _In_z_ LPCWSTR lpFileName
,
586 _Inout_ DWORD
*pdwBufSize
,
587 _Out_writes_to_(*pdwBufSize
, *pdwBufSize
) PVOID lpBuffer
,
591 UNICODE_STRING NtFileName
;
593 if (!lpFileName
|| !pdwBufSize
|| !lpBuffer
)
595 SetLastError(ERROR_INVALID_PARAMETER
);
599 if (!RtlDosPathNameToNtPathName_U(lpFileName
,
604 SetLastError(ERROR_PATH_NOT_FOUND
);
608 bRet
= NtGdiGetFontResourceInfoInternalW(
610 (NtFileName
.Length
/ sizeof(WCHAR
)) + 1,
617 RtlFreeHeap(RtlGetProcessHeap(), 0, NtFileName
.Buffer
);
628 SetTextCharacterExtra(
635 if (nCharExtra
== 0x80000000)
637 SetLastError(ERROR_INVALID_PARAMETER
);
641 if (GDI_HANDLE_GET_TYPE(hdc
) == GDILoObjType_LO_METADC16_TYPE
)
643 HANDLE_METADC(INT
, SetTextCharacterExtra
, 0x80000000, hdc
, nCharExtra
);
646 /* Get the DC attribute */
647 pdcattr
= GdiGetDcAttr(hdc
);
650 SetLastError(ERROR_INVALID_PARAMETER
);
654 if (NtCurrentTeb()->GdiTebBatch
.HDC
== hdc
)
656 if (pdcattr
->ulDirty_
& DC_FONTTEXT_DIRTY
)
658 NtGdiFlush(); // Sync up pdcattr from Kernel space.
659 pdcattr
->ulDirty_
&= ~(DC_MODE_DIRTY
|DC_FONTTEXT_DIRTY
);
663 nOldCharExtra
= pdcattr
->lTextExtra
;
664 pdcattr
->lTextExtra
= nCharExtra
;
665 return nOldCharExtra
;
679 /* Get the DC attribute */
680 pdcattr
= GdiGetDcAttr(hdc
);
683 /* Do not set LastError here! */
687 return pdcattr
->lTextAlign
;
702 /* Get the DC attribute */
703 pdcattr
= GdiGetDcAttr(hdc
);
706 /* Do not set LastError here! */
710 return pdcattr
->ulForegroundClr
;
726 HANDLE_METADC(BOOL
, SetTextAlign
, GDI_ERROR
, hdc
, fMode
);
728 /* Get the DC attribute */
729 pdcattr
= GdiGetDcAttr(hdc
);
732 SetLastError(ERROR_INVALID_PARAMETER
);
737 fOldMode
= pdcattr
->lTextAlign
;
738 pdcattr
->lTextAlign
= fMode
; // Raw
739 if (pdcattr
->dwLayout
& LAYOUT_RTL
)
741 if ((fMode
& TA_CENTER
) != TA_CENTER
) fMode
^= TA_RIGHT
;
744 pdcattr
->flTextAlign
= fMode
& TA_MASK
;
756 _In_ COLORREF crColor
)
761 HANDLE_METADC(COLORREF
, SetTextColor
, CLR_INVALID
, hdc
, crColor
);
763 pdcattr
= GdiGetDcAttr(hdc
);
766 SetLastError(ERROR_INVALID_PARAMETER
);
770 crOldColor
= (COLORREF
) pdcattr
->ulForegroundClr
;
771 pdcattr
->ulForegroundClr
= (ULONG
)crColor
;
773 if (pdcattr
->crForegroundClr
!= crColor
)
775 pdcattr
->ulDirty_
|= (DIRTY_TEXT
|DIRTY_LINE
|DIRTY_FILL
);
776 pdcattr
->crForegroundClr
= crColor
;
787 SetTextJustification(
789 _In_ INT nBreakExtra
,
790 _In_ INT nBreakCount
)
794 if (GDI_HANDLE_GET_TYPE(hdc
) == GDILoObjType_LO_METADC16_TYPE
)
796 HANDLE_METADC(BOOL
, SetTextJustification
, FALSE
, hdc
, nBreakExtra
, nBreakCount
);
799 /* Get the DC attribute */
800 pdcattr
= GdiGetDcAttr(hdc
);
803 /* Do not set LastError here! */
808 if (NtCurrentTeb()->GdiTebBatch
.HDC
== hdc
)
810 if (pdcattr
->ulDirty_
& DC_FONTTEXT_DIRTY
)
812 NtGdiFlush(); // Sync up pdcattr from Kernel space.
813 pdcattr
->ulDirty_
&= ~(DC_MODE_DIRTY
|DC_FONTTEXT_DIRTY
);
817 pdcattr
->cBreak
= nBreakCount
;
818 pdcattr
->lBreakExtra
= nBreakExtra
;
832 _Out_writes_(cj
) BYTE
*lpSB
)
844 Status
= HEAP_strdupA2W(&pwsz
, psz
);
845 if (!NT_SUCCESS(Status
))
847 SetLastError (RtlNtStatusToDosError(Status
));
851 uResult
= NtGdiGetStringBitmapW(hdc
, pwsz
, 1, lpSB
, cj
);
869 _Out_writes_(cj
) BYTE
*lpSB
)
876 return NtGdiGetStringBitmapW(hdc
, pwsz
, 1, lpSB
, cj
);
887 _Out_ EXTTEXTMETRIC
*petm
)
891 bResult
= NtGdiGetETM(hdc
, petm
);
895 petm
->emKernPairs
= (WORD
)GetKerningPairsA(hdc
, 0, 0);