Click to See Complete Forum and Search --> : uniscribe help


g3RC4n
October 7th, 2008, 01:35 PM
i'm trying to use uniscribe but i've found litte help from anywhere

so far i've managed to get the first glyph of the only run (i think) to be drawn, what am i doing wrong?


void f(HDC hdc)
{
std::wstring wstr = L"hello world";

const int mem_size = 128;

int item_count = 0;

SCRIPT_ITEM* items = new SCRIPT_ITEM[128];

HRESULT r = ScriptItemize(wstr.c_str(),wstr.size(),128-1,0,0,items,&item_count);

if(!SUCCEEDED(r))
return;


int* vis_log = new int[128];
int* log_vis = new int[128];
BYTE* dirs = new BYTE[128];
for(int i=0;i<100;++i)
dirs[i] = 0;

r = ScriptLayout(item_count,dirs,vis_log,log_vis);

if(!SUCCEEDED(r))
return;

WORD* aaa = new WORD[128];
WORD* bbb = new WORD[128];
SCRIPT_VISATTR* ccc = new SCRIPT_VISATTR[128];

int num = 0;
SCRIPT_CACHE scache = 0;
r = ScriptShape(hdc,&scache,wstr.c_str(),item_count,128-1,&items[0].a,aaa,bbb,ccc,&num);


if(!SUCCEEDED(r))
return;

GOFFSET* go = new GOFFSET[128];
ABC* abc = new ABC[128];
int* adv = new int[128];

r = ScriptPlace(hdc,&scache,aaa,num,ccc,&items[0].a,adv,go,abc);

if(!SUCCEEDED(r))
return;

::ScriptTextOut(hdc,
&scache,
0,
0,
0,

0,
&items[0].a,
0,
0,
aaa,

num,
&adv[0],
0,
go);

delete[]items;
delete[]vis_log;
delete[]log_vis;
delete[]dirs;
delete[]aaa;
delete[]bbb;
delete[]ccc;
delete[]go;
delete[]abc;
delete[]adv;
}

g3RC4n
October 7th, 2008, 05:12 PM
nevermind got it

Marc G
October 8th, 2008, 05:36 AM
It might help others having the same problem if you could post what exactly the problem was.

g3RC4n
October 11th, 2008, 12:54 PM
It might help others having the same problem if you could post what exactly the problem was.

k well you could say that i never got the original code to work, there are what i understand two methods to use uniscribe, and easy method (one which i got to work), and the more complicated method which i tryed (which apparently is the proper way to do it).

ScriptStringAnalyse is a wrapper for all the other functions and allocates the buffers instead of me


bool f(HDC hdc)
{
std::wstring wstr = L"hello world";

SCRIPT_CONTROL srpt_ctrl;
SCRIPT_STATE srpt_st;
SCRIPT_STRING_ANALYSIS srpt_sa;

HRESULT r = ::ScriptStringAnalyse(hdc, // hdc
wstr.c_str(), // string
wstr.size(), // string size
static_cast<int>(1.5*wstr.size()+16), // buffer size as recomened by msdn
-1, // unicode string flag
SSA_GLYPHS|SSA_FALLBACK,
0,
&srpt_ctrl,
&srpt_st,
0,
0,
0,
&srpt_sa);
if(!SUCCEEDED(r))
{
false;
}

r = ::ScriptStringOut(srpt_sa, //analysis
0, // x pos
0, // y pos
0,
0, //
0, // for text processing
0, // for text processing
FALSE);

::ScriptStringFree(&srpt_sa);

if(!SUCCEEDED(r))
{
false;
}

return true;
}


it should be noted theres very little documentaton on uniscribe and no examples on msdn and very few online