44// The function types for ScriptItemizeOpenType() and ScriptShapeOpenType().
45// We want to use these functions for OpenType feature support, but we can't
46// call them directly because usp10.dll does not always have them.
47// Instead, we use GetProcAddress() to check whether we can actually use these
48// function. If we can't use these functions, we substitute ScriptItemze() and
49// ScriptShape().
50typedef HRESULT (WINAPI *ScriptItemizeOpenTypeFunc)(const WCHAR*, int, int,
51 const SCRIPT_CONTROL*,
52 const SCRIPT_STATE*,
53 SCRIPT_ITEM*,
54 OPENTYPE_TAG*, int*);
55typedef HRESULT (WINAPI *ScriptShapeOpenTypeFunc)(HDC, SCRIPT_CACHE*,
56 SCRIPT_ANALYSIS*,
57 OPENTYPE_TAG, OPENTYPE_TAG,
58 int*, TEXTRANGE_PROPERTIES**,
59 int, const WCHAR*, int, int,
60 WORD*, SCRIPT_CHARPROP*,
61 WORD*, SCRIPT_GLYPHPROP*,
62 int*);
63
64static ScriptItemizeOpenTypeFunc sScriptItemizeOpenTypeFunc = 0;
65static ScriptShapeOpenTypeFunc sScriptShapeOpenTypeFunc = 0;
66static bool sOpenTypeFunctionsLoaded = false;
67
68static void loadOpenTypeFunctions()
69{
70 HMODULE hModule = GetModuleHandle(L"usp10");
71 if (hModule) {
72 sScriptItemizeOpenTypeFunc = reinterpret_cast<ScriptItemizeOpenTypeFunc>(GetProcAddress(hModule, "ScriptItemizeOpenType"));
73 sScriptShapeOpenTypeFunc = reinterpret_cast<ScriptShapeOpenTypeFunc>(GetProcAddress(hModule, "ScriptShapeOpenType"));
74 }
75 sOpenTypeFunctionsLoaded = true;
76}
77