From 092edd81e653b2be20e65f5d2af8458ec7b01701 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Sat, 23 Dec 2006 11:07:55 +0100 Subject: [PATCH] usp10: Implement ScriptString_pSize. --- dlls/usp10/tests/usp10.c | 2 +- dlls/usp10/usp10.c | 50 +++++++++++++++++++++++++++++++++++++++- dlls/usp10/usp10.spec | 2 +- include/usp10.h | 2 +- 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/dlls/usp10/tests/usp10.c b/dlls/usp10/tests/usp10.c index b291301e2d5..d637aeba9dc 100644 --- a/dlls/usp10/tests/usp10.c +++ b/dlls/usp10/tests/usp10.c @@ -897,7 +897,7 @@ static void test_ScriptCacheGetHeight(HDC hdc) { HRESULT hr; SCRIPT_CACHE sc = NULL; - long height; + LONG height; hr = ScriptCacheGetHeight(NULL, NULL, NULL); ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr); diff --git a/dlls/usp10/usp10.c b/dlls/usp10/usp10.c index 448153f4be1..85fc82d7b7b 100644 --- a/dlls/usp10/usp10.c +++ b/dlls/usp10/usp10.c @@ -703,6 +703,7 @@ HRESULT WINAPI ScriptStringFree(SCRIPT_STRING_ANALYSIS *pssa) HeapFree(GetProcessHeap(), 0, analysis->glyphs); HeapFree(GetProcessHeap(), 0, analysis->pItem); + HeapFree(GetProcessHeap(), 0, analysis->sz); HeapFree(GetProcessHeap(), 0, analysis); if(invalid) @@ -1248,7 +1249,7 @@ HRESULT WINAPI ScriptTextOut(const HDC hdc, SCRIPT_CACHE *psc, int x, int y, UIN * Success: S_OK * Failure: Non-zero HRESULT value. */ -HRESULT WINAPI ScriptCacheGetHeight(HDC hdc, SCRIPT_CACHE *psc, long *height) +HRESULT WINAPI ScriptCacheGetHeight(HDC hdc, SCRIPT_CACHE *psc, LONG *height) { HDC phdc; Scriptcache *pScriptcache; @@ -1388,3 +1389,50 @@ HRESULT WINAPI ScriptStringValidate(SCRIPT_STRING_ANALYSIS ssa) FIXME("(%p): stub\n", ssa); return S_OK; } + +/*********************************************************************** + * ScriptString_pSize (USP10.@) + * + * Retrieve width and height of an analysed string. + * + * PARAMS + * ssa [I] string analysis. + * + * RETURNS + * Success: Pointer to a SIZE structure. + * Failure: NULL + */ +const SIZE * WINAPI ScriptString_pSize(SCRIPT_STRING_ANALYSIS ssa) +{ + unsigned int i, j; + StringAnalysis *analysis = ssa; + TEXTMETRICW metric; + + TRACE("(%p)\n", ssa); + + if (!analysis) return NULL; + + if (!analysis->sz) + { + if (!(analysis->sz = HeapAlloc(GetProcessHeap(), 0, sizeof(SIZE)))) + return NULL; + + /* FIXME: These values should be calculated at a more + * appropriate place so that we can just pass cached + * values here. + */ + if (!GetTextMetricsW(analysis->hdc, &metric)) + { + HeapFree(GetProcessHeap(), 0, analysis->sz); + analysis->sz = NULL; + return NULL; + } + analysis->sz->cy = metric.tmHeight; + + analysis->sz->cx = 0; + for (i = 0; i < analysis->numItems; i++) + for (j = 0; j < analysis->glyphs[i].numGlyphs; j++) + analysis->sz->cx += analysis->glyphs[i].piAdvance[j]; + } + return analysis->sz; +} diff --git a/dlls/usp10/usp10.spec b/dlls/usp10/usp10.spec index 56fd85b5de1..73ea44771ac 100644 --- a/dlls/usp10/usp10.spec +++ b/dlls/usp10/usp10.spec @@ -26,7 +26,7 @@ @ stdcall ScriptStringValidate(ptr) @ stdcall ScriptStringXtoCP(ptr long ptr ptr) @ stub ScriptString_pLogAttr -@ stub ScriptString_pSize +@ stdcall ScriptString_pSize(ptr) @ stub ScriptString_pcOutChars @ stdcall ScriptTextOut(ptr ptr long long long ptr ptr ptr long ptr long ptr ptr ptr) @ stdcall ScriptXtoCP(long long long ptr ptr ptr ptr ptr ptr) diff --git a/include/usp10.h b/include/usp10.h index 9b997c4baf9..6dc7584d7f3 100644 --- a/include/usp10.h +++ b/include/usp10.h @@ -245,7 +245,7 @@ HRESULT WINAPI ScriptShape(HDC hdc, SCRIPT_CACHE *psc, const WCHAR *pwcChars, in HRESULT WINAPI ScriptPlace(HDC hdc, SCRIPT_CACHE *psc, const WORD *pwGlyphs, int cGlyphs, const SCRIPT_VISATTR *psva, SCRIPT_ANALYSIS *psa, int *piAdvance, GOFFSET *pGoffset, ABC *pABC ); HRESULT WINAPI ScriptBreak(const WCHAR *pwcChars, int cChars, const SCRIPT_ANALYSIS *psa, SCRIPT_LOGATTR *psla); -HRESULT WINAPI ScriptCacheGetHeight(HDC hdc, SCRIPT_CACHE *psc, long *tmHeight); +HRESULT WINAPI ScriptCacheGetHeight(HDC hdc, SCRIPT_CACHE *psc, LONG *tmHeight); HRESULT WINAPI ScriptCPtoX(int iCP, BOOL fTrailing, int cChars, int cGlyphs, const WORD *pwLogClust, const SCRIPT_VISATTR *psva, const int *piAdvance, const SCRIPT_ANALYSIS *psa, int *piX); HRESULT WINAPI ScriptXtoCP(int iX, int cChars, int cGlyphs, const WORD *pwLogClust, const SCRIPT_VISATTR *psva,