Commit 0c0ab500 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

usp10: Implement ScriptGetGlyphABCWidth.

Add a test for ScriptGetGlyphABCWidth and ScriptCacheGetHeight.
parent 08484ba4
......@@ -626,6 +626,58 @@ static void test_ScriptString(void)
}
}
void test_ScriptCacheGetHeight(HDC hdc)
{
HRESULT hr;
SCRIPT_CACHE sc = NULL;
LONG height;
hr = ScriptCacheGetHeight(NULL, NULL, NULL);
ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08lx\n", hr);
hr = ScriptCacheGetHeight(NULL, &sc, NULL);
ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08lx\n", hr);
hr = ScriptCacheGetHeight(NULL, &sc, &height);
ok(hr == E_PENDING, "expected E_PENDING, got 0x%08lx\n", hr);
height = 0;
hr = ScriptCacheGetHeight(hdc, &sc, &height);
ok(hr == S_OK, "expected S_OK, got 0x%08lx\n", hr);
ok(height > 0, "expected height > 0\n");
}
void test_ScriptGetGlyphABCWidth(HDC hdc)
{
HRESULT hr;
LOGFONTA lf;
HFONT hfont;
SCRIPT_CACHE sc = NULL;
ABC abc;
memset(&lf, 0, sizeof(lf));
lstrcpyA(lf.lfFaceName, "Symbol");
hfont = CreateFontIndirectA(&lf);
hfont = SelectObject(hdc, hfont);
hr = ScriptGetGlyphABCWidth(NULL, NULL, 'a', NULL);
ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08lx\n", hr);
hr = ScriptGetGlyphABCWidth(NULL, &sc, 'a', NULL);
ok(hr == E_PENDING, "expected E_PENDING, got 0x%08lx\n", hr);
if (0) { /* crashes on WinXP */
hr = ScriptGetGlyphABCWidth(hdc, &sc, 'a', NULL);
ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08lx\n", hr);
}
hr = ScriptGetGlyphABCWidth(hdc, &sc, 'a', &abc);
ok(hr == S_OK, "expected S_OK, got 0x%08lx\n", hr);
}
START_TEST(usp10)
{
HWND hwnd;
......@@ -646,6 +698,8 @@ START_TEST(usp10)
test_ScriptItemIzeShapePlace(hdc,pwOutGlyphs);
test_ScriptGetCMap(hdc, pwOutGlyphs);
test_ScriptCacheGetHeight(hdc);
test_ScriptGetGlyphABCWidth(hdc);
ReleaseDC(hwnd, hdc);
DestroyWindow(hwnd);
......
......@@ -914,3 +914,47 @@ HRESULT WINAPI ScriptCacheGetHeight(HDC hdc, SCRIPT_CACHE *psc, long *height)
*height = metric.tmHeight;
return S_OK;
}
/***********************************************************************
* ScriptGetGlyphABCWidth (USP10.@)
*
* Retrieve the width of a glyph.
*
* PARAMS
* hdc [I] Device context.
* psc [I/O] Opaque pointer to a script cache.
* glyph [I] Glyph to retrieve the width for.
* abc [O] ABC widths of the glyph.
*
* RETURNS
* Success: S_OK
* Failure: Non-zero HRESULT value.
*/
HRESULT WINAPI ScriptGetGlyphABCWidth(HDC hdc, SCRIPT_CACHE *psc, WORD glyph, ABC *abc)
{
HDC phdc;
Scriptcache *pScriptcache;
TRACE("(%p, %p, 0x%04x, %p)\n", hdc, psc, glyph, abc);
if (!psc)
return E_INVALIDARG;
if (!hdc) return E_PENDING;
if (!*psc) {
pScriptcache = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(Scriptcache));
pScriptcache->hdc = hdc;
phdc = hdc;
*psc = pScriptcache;
} else {
pScriptcache = *psc;
phdc = pScriptcache->hdc;
}
/* FIXME: get this from the cache */
if (!GetCharABCWidthsW(phdc, glyph, glyph, abc))
return E_HANDLE;
return S_OK;
}
......@@ -7,7 +7,7 @@
@ stdcall ScriptFreeCache(ptr)
@ stdcall ScriptGetCMap(ptr ptr ptr long long ptr)
@ stdcall ScriptGetFontProperties(long ptr ptr)
@ stub ScriptGetGlyphABCWidth
@ stdcall ScriptGetGlyphABCWidth(ptr ptr long ptr)
@ stub ScriptGetLogicalWidths
@ stdcall ScriptGetProperties(ptr long)
@ stdcall ScriptIsComplex(wstr long long)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment