From 8551a8f3fb61cdd56cb6f24b068474979c4ebc9f Mon Sep 17 00:00:00 2001 From: Shachar Shemesh Date: Wed, 4 Sep 2002 18:49:36 +0000 Subject: [PATCH] - Return old code for handling parameters to GetCharacterPlacement (+ fix heap overrun in it). New code did not correctly match the Windows behaviour. - Amend the BiDi algorithm so that many strings will now produce quite readable output. --- objects/font.c | 49 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/objects/font.c b/objects/font.c index 2146fb18135..55bc4f21f57 100644 --- a/objects/font.c +++ b/objects/font.c @@ -1924,24 +1924,18 @@ GetCharacterPlacementA(HDC hdc, LPCSTR lpString, INT uCount, memcpy(&resultsW, lpResults, sizeof(resultsW)); lpStringW = FONT_mbtowc(hdc, lpString, uCount, &uCountW, &font_cp); - if( dwFlags&GCP_REORDER ) - { - /* If the REORDER flag is not set, this field is ignored anyways */ - if(lpResults->lpOutString) - resultsW.lpOutString = HeapAlloc(GetProcessHeap(), 0, uCountW); - else - resultsW.lpOutString = NULL; - } + if(lpResults->lpOutString) + resultsW.lpOutString = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*uCountW); ret = GetCharacterPlacementW(hdc, lpStringW, uCountW, nMaxExtent, &resultsW, dwFlags); if(lpResults->lpOutString) { if(font_cp != CP_SYMBOL) - WideCharToMultiByte(font_cp, 0, resultsW.lpOutString, uCountW, - lpResults->lpOutString, uCount, NULL, NULL ); - else - for(i = 0; i < uCount; i++) - lpResults->lpOutString[i] = (CHAR)resultsW.lpOutString[i]; + WideCharToMultiByte(font_cp, 0, resultsW.lpOutString, uCountW, + lpResults->lpOutString, uCount, NULL, NULL ); + else + for(i = 0; i < uCount; i++) + lpResults->lpOutString[i] = (CHAR)resultsW.lpOutString[i]; } HeapFree(GetProcessHeap(), 0, lpStringW); @@ -2002,9 +1996,23 @@ GetCharacterPlacementW( /* return number of initialized fields */ lpResults->nGlyphs = nSet; + if(dwFlags==0) + { + /* 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) + for(i=0; ilpOutString[i]=lpString[i]; + + if(lpResults->lpOrder) + { + for(i = 0; i < nSet; i++) + lpResults->lpOrder[i] = i; + } + } + if((dwFlags&GCP_REORDER)!=0) { - /* MSDN says lpOutString and lpOrder are ignored if GCP_REORDER not set */ WORD *pwCharType; int run_end; /* Keep a static table that translates the C2 types to something meaningful */ @@ -2027,7 +2035,10 @@ GetCharacterPlacementW( /* The complete and correct (at least according to MS) BiDi algorythm is not * yet implemented here. Instead, we just make sure that consecutive runs of - * the same direction (or neutral) are ordered correctly + * the same direction (or neutral) are ordered correctly. We also assign Neutrals + * that are between runs of opposing directions the base (ok, always LTR) dir. + * While this is a LONG way from a BiDi algorithm, it does produce more or less + * readable results. */ for( i=0; ilpOutString) { int j;