I just wanted if anyone have ever used this function:
to let me know how to use it
I tried to use it with ExtTextOut() to generate BIDIrectional text editor
I need to know how to use the GCP_RESULTS structure
Posted on 2002-10-13 15:12:56 by hosam_shahin
I have used this function already (for handling arabic text).
Please give a more detailled question or a description of what
you would like to do.

The GCP_RESULTS structure is well described at microsoft
so I dont know where to start to tell you :)
Posted on 2002-10-15 11:47:41 by beaster
I am trying to build a text editor to handle Arabic/Hebrew text...
I am not sure I am using the function or initializing the structure GCP very well
What I can understand from documentation is that I can use this function to get
the Arabic glyphs and BiDi reordering

I used this code for initialization:

WORD szOut[40];
int dx[13];
int caretPos;
UINT order[13];

gcp.lStructSize = sizeof(GCP_RESULTS);
gcp.lpOutString = szOut;
gcp.lpDx = dx;
gcp.lpCaretPos = &caretPos;
gcp.lpOrder = ℴ
gcp.nGlyphs = NO_G;

1-There is no enough information on lpClass....
2-How Can I reorder text and use with ExtTextOut?
3-is the Initialization code suffecient for BiDi?

If you could give me a piece of example to see how GetCharacterPlacement
generates the Bidi Reordering.

Posted on 2002-10-15 22:34:35 by hosam_shahin
I have no directly fitting code snipp, so I will try to explain:

the ExtTextOut function can work directly with glyph indizes (that are the offsets inside the truetype font
to the corresponding glyph shapes). The call will look like this:

ExtTextOut (hDC, dwX, dwY, ETO_GLYPH_INDEX, lprcDim, lpwArray, dwCount, lpKerning)

where lpwArray are glyph indizes instead of chars.
So you need to get the indizes before with GetCharacterPlacement.

The function will
- process ligates (GCP_LIGATE)
- reorder right-left (GCP_REORDER)
- measure kerning (GCP_USEKERNING)
- find glyph shapes (GCP_GLYPHSHAPE)

GetCharacterPlacement (hDC, lpSourceText, dwSrcLen, dwMaxExtent, lpxResult, flags <like above> )

the GCP struct:

gcp.lStructSize = sizeof(GCP_RESULTS);
gcp.lpOutString = szOut; -> can be NULL
gcp.lpDx = dx; -> receive kerning information, can be used for ExtTextOut (otherwise you get the TTFs default kerning)
gcp.lpCaretPos = &caretPos; -> can be NULL, useful for positioning the caret in an editor application
gcp.lpClass -> receives the type of each caracter -> useful for determining in which direction the caret should move
gcp.lpGlyphs -> receive the glyhp index array for ExtTextOut
gcp.lpOrder = &order;
gcp.nGlyhps -> can be different than length of source string in chars!
gcp.nMaxFit -> maximum array size

please ask me further if you have trouble with this...
Posted on 2002-10-18 06:27:22 by beaster
Thank you indeed Beaster, that much made things move..
I wrote a simple test code for that:

After CreateFont,SelectObject..

GetCharacterPlacement (hdc, szOutput, col, 0, &gcp, GCP_LIGATE|GCP_REORDER|GCP_USEKERNING|GCP_GLYPHSHAPE);

ExtTextOut (hdc, rect.right-10, (row*20), ETO_GLYPH_INDEX, &rect, (TCHAR*)gcp.lpGlyphs, col,0);

but still have some problems:

1-Using gcp.lpDx yeilds the following:

ab c d e f g...

kerning is steadily increasing...

2-English Characters insertion is not correct:

(Some Arabic Text) English

it should display "English" to the left of the arabic text as I wrote the arabic text before "English"

English (Some Arabic Text)

Thank you very much for your help
Posted on 2002-10-19 01:07:38 by hosam_shahin