Easy way to tell if unicode character is supported in current font?

后端 未结 2 738
忘了有多久
忘了有多久 2020-12-30 14:08

I\'m using Borland C++ Builder 2009 and I display the right and left pointing arrows like so:

Button2->Hint = L\"Ctrl+\\u2190\" ;
Button3->Hint = L\"Ct         


        
2条回答
  •  误落风尘
    2020-12-30 14:39

    Just for reference and the Google Gods:

    bool UnicodeCharSupported(HWND Handle, wchar_t Char)
    {
    if (Handle)
        {
        DWORD dwSize = GetFontUnicodeRanges(Handle, NULL);
        if (dwSize)
            {
            bool Supported = false ;
            BYTE* bBuffer = new BYTE[dwSize];
            GLYPHSET* pGlyphSet = reinterpret_cast(bBuffer);
            if (GetFontUnicodeRanges(Handle, pGlyphSet))
                {
                for (DWORD x = 0 ; x < pGlyphSet->cRanges && !Supported ; x++)
                    {
                    Supported = (Char >= pGlyphSet->ranges[x].wcLow &&
                                 Char < (pGlyphSet->ranges[x].wcLow + pGlyphSet->ranges[x].cGlyphs)) ;
                    }
                }
            delete[] bBuffer;
            return Supported ;
            }
        }
    return false ;
    }
    

    Example, relating to my Question:

    if (!UnicodeCharSupported(Canvas->Handle, 0x2190))
        { /* Character not supported in current Font, use different character */ }
    

提交回复
热议问题