Platform SDK: International Features

ScriptXtoCP

The ScriptXtoCP function converts an x offset from the left end (!fLogical) or leading edge (fLogical) of a run to a logical character position and a flag that indicates whether the x position fell in the leading or the trailing half of the character.

HRESULT WINAPI ScriptXtoCP(
  int iX, 
  int cChars, 
  int cGlyphs, 
  const WORD *pwLogClust, 
  const SCRIPT_VISATTR *psva, 
  const int *piAdvance, 
  const SCRIPT_ANALYSIS *psa, 
  int *piCP, 
  int *piTrailing 
);

Parameters

iX
[in] Offset, in logical units, from left of run.
cChars
[in] Count of logical code points in the run.
cGlyphs
[in] Count of glyphs in the run.
pwLogClust
[in] Pointer to an array containing logical clusters.
psva
[in] Pointer to an array of SCRIPT_VISATTR structures containing the glyph's visual attributes.
piAdvance
[in] Pointer to an array of advance widths.
psa
[in] Pointer to a SCRIPT_ANALYSIS structure.
piCP
[out] Pointer to an integer to receive the character position.
piTrailing
[out] Pointer to a flag to receive information about whether the position is the leading or trailing edge of the character.

Return Values

If the function succeeds, the return value is zero.

If the function fails, it returns a nonzero value. And if any other unrecoverable error is encountered, it is also returned as HRESULT. For example, error returns from Win32 API functions are converted to HRESULT using the HRESULT_FROM_WIN32 macro and returned to the client in the HRESULT.

Remarks

For scripts where the caret may conventionally be placed into the middle of clusters (for example, Arabic and Hebrew), the returned character position may be for any code point in the line, and piTrailing will be either zero or one.

For scripts in which the caret is conventionally snapped to the boundaries of a cluster, the returned character position is always the position of the first code point in a cluster (considered logically), and piTrailing is either zero or the number of code points in the cluster.

Thus the appropriate caret position for a mouse hit is always the returned character position plus the value of fTrailing.

If the x position passed is not in the item at all, the resulting position will be the trailing edge of character –1 (for x positions before the item), or the leading edge of character "cChars" (for x positions following the item).

Requirements

  Windows NT/2000: Requires Windows 2000.
  Header: Declared in Usp10.h.
  Library: Use Usp10.lib.

See Also

Uniscribe Overview, Uniscribe Functions, SCRIPT_ANALYSIS, SCRIPT_VISATTR