Re: Question about Unicode Ranges in TrueType fonts

From: Philippe Verdy (verdy_p@wanadoo.fr)
Date: Thu Jun 26 2003 - 08:26:13 EDT

  • Next message: Philippe Verdy: "Re: Question about Unicode Ranges in TrueType fonts"

    On Thursday, June 26, 2003 11:50 AM, Andrew C. West <andrewcwest@alumni.princeton.edu> wrote:

    > On Wed, 25 Jun 2003 21:58:28 -0700, "Elisha Berns" wrote:
    >
    > > Some weeks back there were a number of postings about software for
    > > viewing Unicode Ranges in TrueType fonts and I had a few questions
    > > about that. Most viewers listed seemed to only check the Unicode
    > > Range bits of the fonts which can be misleading in certain cases.
    >
    > Now the caveat. The USB sets a Surrogates bit to indicate that the
    > font contains at least one codepoint beyond the Basic Multilingual
    > Plane (BMP). Unfortunately the "ranges" array of the GLYPHSET
    > structure only lists contiguous clumps of Unicode codepoints within
    > the BMP (wcLow is a 16 bit value), and does not list surrogate
    > coverage. Therefore you cannot determine supra-BMP codepoint coverage
    > from the GLYPHSET structure. If anyone does know an easy way to do
    > this under Windows, please let me know.

    Isn't there a work-around with the following function (quote from Microsoft MSDN):
    (with the caveat that you first need to allocate and fill a Unicode string for the
    codepoints you want to test, and this can be lengthy if one wants to retreive the
    full list of supported codepoints).
    However, this is still the best function to use to know if a string can effectively
    be rendered before drawing it...

    -- Philippe.

    _*GetGlyphIndices*_

    The *GetGlyphIndices* function translates a string into an array of glyph indices. The function can be used to determine whether a glyph exists in a font.

    DWORD GetGlyphIndices(
      HDC hdc, // handle to DC
      LPCTSTR lpstr, // string to convert
      int c, // number of characters in string
      LPWORD pgi, // array of glyph indices
      DWORD fl // glyph options
    );

    _Parameters_

    /hdc / [in] Handle to the device context.

    /lpstr/ [in] Pointer to the string to be converted.

    /c/ [in] Length of the string in pgi. For the ANSI function it is a BYTE count and for the Unicode function it is a WORD count. Note that for the ANSI function, characters in SBCS code pages take one byte each, while most characters in DBCS code pages take two bytes; for the Unicode function, most currently defined Unicode characters (those in the Basic Multilingual Plane (BMP)) are one WORD while Unicode surrogates are two WORDs.

    /pgi/ [out] Array of glyph indices corresponding to the characters in the string.

    /fl/ [in] Specifies how glyphs should be handled if they are not supported. This parameter can be the following value.

    Value - Meaning
    GGI_MARK_NONEXISTING_GLYPHS - Marks unsupported glyphs with the hexadecimal value 0xffff.

    _Return Values_

    If the function succeeds, it returns the number of bytes (for the ANSI function) or WORDs (for the Unicode function) converted.
    If the function fails, the return value is GDI_ERROR.

    *Windows NT/2000/XP*: To get extended error information, call *GetLastError*.

    _Requirements_

    - Windows NT/2000/XP: Included in Windows 2000 and later.
    - Windows 95/98/Me: Unsupported.
    - Header: Declared in Wingdi.h; include Windows.h.
    - Library: Use Gdi32.lib.
    - Unicode: Implemented as Unicode and ANSI versions.



    This archive was generated by hypermail 2.1.5 : Thu Jun 26 2003 - 09:20:19 EDT