Hi there,
We know the font Ariel Unicode MS support Unicode U+5929 and Ariel not. Can any one tell:
1. How do we determine if the font Ariel Unicode MS is installed?
2. How can we determine if a font support Unicode U+5929?
I appreciate any help,
This is a discussion on How to determine if a font support a Unicode? within the Windows Programming forums, part of the Platform Specific Boards category; Hi there, We know the font Ariel Unicode MS support Unicode U+5929 and Ariel not. Can any one tell: 1. ...
Hi there,
We know the font Ariel Unicode MS support Unicode U+5929 and Ariel not. Can any one tell:
1. How do we determine if the font Ariel Unicode MS is installed?
2. How can we determine if a font support Unicode U+5929?
I appreciate any help,
I made a couple of functions:
Code:#define _WIN32_WINNT 0x0500 /* GetGlyphIndices requires Windows 2000 or later. */ #include <windows.h> #include <stdio.h> static int CALLBACK EnumFontFamProc( CONST ENUMLOGFONT *lpelf, // logical-font data CONST NEWTEXTMETRIC *lpntm, // physical-font data DWORD FontType, // type of font LPARAM lParam // application-defined data ) { *((BOOL*)lParam) = TRUE; return 0; } /* * Checks if a font is installed. * Based on OpenOffice code from: * http://sourceforge.krugle.com/examples/p-CsDwK3y6Lb7A3V1s/winos.cxx */ BOOL IsFontInstalled( LPCTSTR szFontName ) { BOOL bIsInstalled = FALSE; HDC hDC = GetDC( NULL ); EnumFontFamilies( hDC, szFontName, (FONTENUMPROC) EnumFontFamProc, (LPARAM) &bIsInstalled ); ReleaseDC( NULL, hDC ); return bIsInstalled; } /* * Checks if a character glyph is available for the currently selected font * in the given HDC. * Note: Does not support unicode surrogates. */ BOOL IsCharacterAvailableInHDC( HDC hdc, WORD character ) { WORD indice; return (GetGlyphIndicesW( hdc, &character, 1, &indice, GGI_MARK_NONEXISTING_GLYPHS ) != GDI_ERROR && indice != 0xffff); } /* * Checks if a character glyph is available in a given font. * Note: Does not support unicode surrogates. */ BOOL IsCharacterAvailableInFont( LPCTSTR szFontName, WORD character ) { HDC hdc; HFONT hFontOld; HFONT hFontNew; BOOL bResult; /* Create the given font with default parameters. */ hFontNew = CreateFont( 0, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, szFontName ); if (hFontNew == NULL) return FALSE; /* Create a screen compatible DC and select our new font. */ hdc = GetDC( NULL ); hFontOld = (HFONT) SelectObject( hdc, hFontNew ); /* Check if the character is available. */ bResult = IsCharacterAvailableInHDC( hdc, character ); /* Cleanup. */ SelectObject( hdc, hFontOld); DeleteObject( hFontNew ); ReleaseDC( NULL, hdc ); return bResult; } int main(void) { if (IsFontInstalled( TEXT("Arial") ) ) { printf("Arial is installed!\n"); } if (IsFontInstalled( TEXT("Arial Unicode MS") )) { printf("Arial Unicode MS is installed!\n"); } if (IsCharacterAvailableInFont( TEXT("Arial"), 0x01FD )) { printf("Character is available!\n"); } getchar(); return 0; }