From 6c4e90a9abf2316e1e3e38fcb6c933dd482bc7ec Mon Sep 17 00:00:00 2001 From: Jason Filby Date: Fri, 23 Jul 2004 20:41:09 +0000 Subject: [PATCH] Port GetCharacterPlacementW from WINE; copy lpString to lpResults->lpGlyphs if it (destination string) is not null svn path=/trunk/; revision=10262 --- reactos/lib/gdi32/misc/stubsw.c | 22 +-------- reactos/lib/gdi32/objects/font.c | 85 +++++++++++++++++++++++++++++++- 2 files changed, 85 insertions(+), 22 deletions(-) diff --git a/reactos/lib/gdi32/misc/stubsw.c b/reactos/lib/gdi32/misc/stubsw.c index 53ecfeb4a03..17177db650c 100644 --- a/reactos/lib/gdi32/misc/stubsw.c +++ b/reactos/lib/gdi32/misc/stubsw.c @@ -1,4 +1,4 @@ -/* $Id: stubsw.c,v 1.29 2004/07/09 20:28:20 navaraf Exp $ +/* $Id: stubsw.c,v 1.30 2004/07/23 20:41:08 jfilby Exp $ * * reactos/lib/gdi32/misc/stubs.c * @@ -241,26 +241,6 @@ GetTextExtentExPointW( } -/* - * @unimplemented - */ -DWORD -STDCALL -GetCharacterPlacementW( - HDC hDc, - LPCWSTR a1, - int a2, - int a3, - LPGCP_RESULTSW a4, - DWORD a5 - ) -{ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - - /* * @implemented */ diff --git a/reactos/lib/gdi32/objects/font.c b/reactos/lib/gdi32/objects/font.c index 1342545aff8..cf391af7638 100644 --- a/reactos/lib/gdi32/objects/font.c +++ b/reactos/lib/gdi32/objects/font.c @@ -1,4 +1,4 @@ -/* $Id: font.c,v 1.6 2004/07/09 20:28:20 navaraf Exp $ +/* $Id: font.c,v 1.7 2004/07/23 20:41:09 jfilby Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -20,6 +20,7 @@ #include #include #include +#include #define NDEBUG #include @@ -421,3 +422,85 @@ GetFontData( { return NtGdiGetFontData(a0, a1, a2, a3, a4); } + + +/* + * @implemented + */ +DWORD +STDCALL +GetCharacterPlacementW( + HDC hdc, + LPCWSTR lpString, + INT uCount, + INT nMaxExtent, + GCP_RESULTSW *lpResults, + DWORD dwFlags + ) +{ + DWORD ret=0; + SIZE size; + UINT i, nSet; + + if(dwFlags&(~GCP_REORDER)) DPRINT("flags 0x%08lx ignored\n", dwFlags); + if(lpResults->lpClass) DPRINT("classes not implemented\n"); + if (lpResults->lpCaretPos && (dwFlags & GCP_REORDER)) + DPRINT("Caret positions for complex scripts not implemented\n"); + + nSet = (UINT)uCount; + if(nSet > lpResults->nGlyphs) + nSet = lpResults->nGlyphs; + + /* return number of initialized fields */ + lpResults->nGlyphs = nSet; + +/*if((dwFlags&GCP_REORDER)==0 || !BidiAvail) + {*/ + /* Treat the case where no special handling was requested in a fastpath way */ + /* copy will do if the GCP_REORDER flag is not set */ + if(lpResults->lpOutString) + strncpyW( lpResults->lpOutString, lpString, nSet ); + + if(lpResults->lpGlyphs) + strncpyW( lpResults->lpGlyphs, lpString, nSet ); + + if(lpResults->lpOrder) + { + for(i = 0; i < nSet; i++) + lpResults->lpOrder[i] = i; + } +/*} else + { + BIDI_Reorder( lpString, uCount, dwFlags, WINE_GCPW_FORCE_LTR, lpResults->lpOutString, + nSet, lpResults->lpOrder ); + }*/ + + /* FIXME: Will use the placement chars */ + if (lpResults->lpDx) + { + int c; + for (i = 0; i < nSet; i++) + { + if (GetCharWidth32W(hdc, lpString[i], lpString[i], &c)) + lpResults->lpDx[i]= c; + } + } + + if (lpResults->lpCaretPos && !(dwFlags & GCP_REORDER)) + { + int pos = 0; + + lpResults->lpCaretPos[0] = 0; + for (i = 1; i < nSet; i++) + if (GetTextExtentPoint32W(hdc, &(lpString[i - 1]), 1, &size)) + lpResults->lpCaretPos[i] = (pos += size.cx); + } + + /*if(lpResults->lpGlyphs) + GetGlyphIndicesW(hdc, lpString, nSet, lpResults->lpGlyphs, 0);*/ + + if (GetTextExtentPoint32W(hdc, lpString, uCount, &size)) + ret = MAKELONG(size.cx, size.cy); + + return ret; +}