Re: [PATCH v2 0/4] MR11035: gdi32/uniscribe: Eagerly cache cmap tables for a font.
On Mon Jun 1 10:41:38 2026 +0000, समीरसिंह Sameer Singh wrote:
I don't think that is the case. I tried running this program on windows, where I make two calls to `ScriptShapeOpenType` and in between the first and second call I delete the `dc` . If windows cached the HDC then the second called would have failed, but that is not the case the shaping was done successfully. ```c #include <windows.h> #include <usp10.h> #include <stdio.h> #define MAKE_OPENTYPE_TAG(a,b,c,d) \ ((OPENTYPE_TAG)(a) | ((OPENTYPE_TAG)(b) << 8) | \ ((OPENTYPE_TAG)(c) << 16) | ((OPENTYPE_TAG)(d) << 24)) int main(void) { static const WCHAR test1[] = {'O','n','e',0}; static const WCHAR test2[] = {'T','w','o',0}; HDC hdc = CreateCompatibleDC(NULL); HFONT font = CreateFontA(20, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma"); HFONT orig_font = SelectObject(hdc, font); WORD glyphs[4], logclust[4]; SCRIPT_CHARPROP charProp[4]; SCRIPT_GLYPHPROP glyphProp[4]; int pcGlyphs = 0; SCRIPT_CACHE sc = NULL; SCRIPT_ANALYSIS sa = {0}; sa.eScript = 1; OPENTYPE_TAG scriptTag = MAKE_OPENTYPE_TAG('l', 'a', 't', 'n'); HRESULT hr = ScriptShapeOpenType(hdc, &sc, &sa, scriptTag, 0, NULL, NULL, 0, test1, 3, 3, logclust, charProp, glyphs, glyphProp, &pcGlyphs); if (FAILED(hr)) { printf("Shaping failed for the first run. hr=%08lx\n", hr); return -1; } DeleteDC(hdc); DeleteObject(font); hr = ScriptShapeOpenType(NULL, &sc, &sa, scriptTag, 0, NULL, NULL, 0, test2, 3, 3, logclust, charProp, glyphs, glyphProp, &pcGlyphs); if (FAILED(hr)) { printf("Shaping failed for the second run. hr=%08lx\n", hr); return -1; } printf("Shaping successful for the second run. hr=%08lx\n", hr); ScriptFreeCache(&sc); return 0; } ``` Output: ``` Shaping successful for the second run. hr=00000000 ``` Then referenced font objects could also be kept around, after GDI handles are released. The point is that keeping just cmap is clearly not enough for shaping to work. And duplicating all of the font data for every cache instance also would be a strange solution.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/11035#note_141853
participants (1)
-
Nikolay Sivov (@nsivov)