views:

113

answers:

1

How can I use ScriptGetProperties API from Uniscribe Dll (usp10.dll) in Delphi

I found an example in C++, but I don't know how to translate it, because I'm not good on C.

const SCRIPT_PROPERTIES **g_ppScriptProperties;
int g_iMaxScript;

WCHAR *pwcInChars = L"Unicode string to itemize";
int cInChars = wcslen(pwcInChars);
const int cMaxItems = 20;
SCRIPT_ITEM si[cMaxItems + 1];
SCRIPT_ITEM *pItems = si;
int cItems;

ScriptGetProperties(&g_ppScriptProperties,
                    &g_iMaxScript);

HRESULT hResult = ScriptItemize(pwcInChars,
                                cInChars,
                                cMaxItems,
                                NULL,
                                NULL,
                                pItems,
                                &cItems);
if (hResult == 0) {
    for (int i=0; i<cItems; i++) {
        if (g_ppScriptProperties[pItems[i].a.eScript]->fComplex) {

            // Item [i] is complex script text
            // requiring glyph shaping.

        } else {

            // The text may be rendered legibly without using Uniscribe. 
            // However, Uniscribe may still be used as a means of accessing 
            // font typographic features. 
        }
    }
} else {
    // Handle the error.
}

The Delphi code should be complied with Turbo Delphi 2006 or above.

+1  A: 

Before you start working with the library you will need to translate it's header file to a .pas file. See Dr. Bob's header converter for a starting point. The header being converted should only have structs, functions, enum, simple types, etc. If there are class declarations, global variables, macros, etc you will most likely need to have an intermediate .h that you translate to Delphi.

Good luck.

Adam Markowitz