On Thursday, June 26, 2003 2:26 PM, Philippe Verdy <[EMAIL PROTECTED]> wrote:

I forgot also the probably better function from the Uniscribe library, which processes 
strings through a language-dependant shaping algorithm, and can determine appropriate 
glyph substitution, or use custom composite fonts to process character clusters into 
grapheme clusters with 1-to-1, 1-to-N, N-to-1, or N-to-M substitutions, using either 
the "cmap" table of classic TrueType fonts (which do not support characters out of the 
BMP), or the new tables added in OpenType fonts.

-- Philippe.

source: Microsoft MSDN:

*ScriptGetCMap*

The *ScriptGetCMap* function takes a string and returns the glyph indices of the 
Unicode characters according to the TrueType cmap table or the standard cmap table 
implemented for old style fonts.

HRESULT WINAPI ScriptGetCMap(
  HDC hdc, 
  SCRIPT_CACHE *psc, 
  const WCHAR *pwcInChars, 
  int cChars, 
  DWORD dwFlags, 
  WORD *pwOutGlyphs 
);

*Parameters*

/hdc/ [in] Handle to the device context. This parameter is optional.

/psc/ [in/out] Pointer to a SCRIPT_CACHE structure.

/pwcInChars/ [in] Pointer to a string of Unicode characters. 

/cChars/ [in] Number of Unicode characters in pwcInChars.

/dwFlags/ [in] Flag that specifies any special handling of the glyphs. By default, the 
glyphs of the buffer are given in logical order with no special handling. This 
parameter can be the following value.

- Value - Meaning
- SGCM_RTL - Indicates the glyph array pwOutGlyps should contain mirrored glyphs for 
those glyphs that have a mirrored equivalent.

/pwOutGlyphs/ [out] Pointer to an array that receives the glyph indexes. 

*Return Values*

If all Unicode code points are present in the font, the return value is S_OK.
If the function fails, it may return one of the following nonzero values.

- Return value - Meaning
- E_HANDLE - The font or the system does not support glyph indices.
- S_FALSE - Some of the Unicode code points were mapped to the default glyph.

If any other unrecoverable error is encountered, it is returned as an HRESULT. 

*Remarks*

ScriptGetCMap may be used to determine which characters in a run are supported by the 
selected font. The caller may scan the returned glyph buffer looking for the default 
glyph to determine which characters are not available. The default glyph index for the 
selected font should be determined by calling ScriptGetFontProperties.

The return value indicates the presence of any missing glyphs.

Note that some code points can be rendered by a combination of glyphs as well as by a 
single glyph -- for example, 00C9; LATIN CAPITAL LETTER E WITH ACUTE. In this case, if 
the font supports the capital E glyph and the acute glyph but not a single glyph for 
00C9, ScriptGetCMap will show 00C9 is unsupported. To determine the font support for a 
string that contains these kinds of code points, call ScriptShape. If it returns S_OK, 
check the output for missing glyphs.

*Requirements*

- Windows NT/2000/XP: Included in Windows 2000 and later.
- Redistributable: Requires Internet Explorer 5 or later on Windows 95/98/Me.
- Header: Declared in Usp10.h.
- Library: Use Usp10.lib.

*See Also*

Uniscribe Overview, Uniscribe Functions, ScriptGetFontProperties, ScriptShape, 
SCRIPT_CACHE


Reply via email to