Hans Leidekker : usp10: Implement ScriptGetGlyphABCWidth.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Aug 4 14:57:27 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 0c0ab500b9e7b71034e26c55dda47f778bf42aac
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=0c0ab500b9e7b71034e26c55dda47f778bf42aac

Author: Hans Leidekker <hans at it.vu.nl>
Date:   Fri Aug  4 14:55:30 2006 +0200

usp10: Implement ScriptGetGlyphABCWidth. 

Add a test for ScriptGetGlyphABCWidth and ScriptCacheGetHeight.

---

 dlls/usp10/tests/usp10.c |   54 ++++++++++++++++++++++++++++++++++++++++++++++
 dlls/usp10/usp10.c       |   44 +++++++++++++++++++++++++++++++++++++
 dlls/usp10/usp10.spec    |    2 +-
 3 files changed, 99 insertions(+), 1 deletions(-)

diff --git a/dlls/usp10/tests/usp10.c b/dlls/usp10/tests/usp10.c
index 6a8f0bb..85546b1 100644
--- a/dlls/usp10/tests/usp10.c
+++ b/dlls/usp10/tests/usp10.c
@@ -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);
diff --git a/dlls/usp10/usp10.c b/dlls/usp10/usp10.c
index 7a13acd..7d76a81 100644
--- a/dlls/usp10/usp10.c
+++ b/dlls/usp10/usp10.c
@@ -914,3 +914,47 @@ HRESULT WINAPI ScriptCacheGetHeight(HDC 
     *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;
+}
diff --git a/dlls/usp10/usp10.spec b/dlls/usp10/usp10.spec
index 3d0e1ce..0c9ab51 100644
--- a/dlls/usp10/usp10.spec
+++ b/dlls/usp10/usp10.spec
@@ -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)




More information about the wine-cvs mailing list