Tip: Detect if a Language Font is Installed (Such as East Asian)

There are times when your application might need to display Japanese fonts or some other East Asian languages, like Chinese or Korean—which are collectively know as CJK in acronym. On a Japanese Windows XP, this is not a problem. On a non-Japanese Windows XP, there is a problem, because the Japanese characters will appear as squared boxes, so (non-Japanese) users may wonder what the actual language and its content are. A way is needed to detect when the application is running on non-Japanese Windows XP without the East Asian Language Pack installed, and it needs to be able to notify the users that the East Asian Language Pack needs to be installed in order to display Japanese text.

Upon seeing the prompt, the user may choose the install the East Asian Language Pack if they can understand Japanese or they can ignore it ( or not run the application), if they don't understand Japanese anyway. Please note this is not a problem on Windows Vista and Windows 7 as these two operating systems have all of the common languages installed.

I have searched for the solution on how to detect if an East Asian Language is installed on Windows XP, however I can find none. Instead, I find many useless replies taht say this is a non-issue: because only a Japanese user will run a Japanese application and they will have all the necessary fonts installed. While this is true in most cases, it is not true in all cases. For example, if I have an English OpenGL game demo that happens to display Japanese text in one of the signboards in the scene because it is depicting a busy street in a Japanese City, then I need a way to detect if Japanese language is installed so that I can generate the text glyphs for that scene. If Japanese language is not installed, I can choose to display English text instead.

I found out that there is a API, EnumSystemLanguageGroups function, which can do this. This is the function signature below.

BOOL EnumSystemLanguageGroups(
  __in  LANGUAGEGROUP_ENUMPROC lpLanguageGroupEnumProc,
  __in  DWORD dwFlags,
  __in  LONG_PTR lParam

The first parameter, lpLanguageGroupEnumProc, is a callback function, of EnumLanguageGroupsProc type, which is called during system language enumeration. The second parameter, dwFlags, is a flag that can be passed in LGRPID_INSTALLED or LGRPID_SUPPORTED, depending which is the minimum support you want to detect. The third parameter, lParam, is an address of a variable that will be passed into the callback function. You can set the language enumeration result into this variable inside the callback function. Below is a code sample on how to detect if Japanese is installed.

#include <string>
#include <iostream>
#include <Windows.h>
#include <Winnls.h>

BOOL CALLBACK JapaneseEnumLanguageGroupsProc(
    LGRPID LanguageGroup,             // language-group identifier
    LPTSTR lpLanguageGroupString,     // language-group identifier string
    LPTSTR lpLanguageGroupNameString, // language-group name string 
    DWORD dwFlags,                    // options
    LONG_PTR  lParam                  // callback parameter
    LONG* plLang = (LONG*)(lParam);
    std::wstring strLang=lpLanguageGroupNameString;
        *plLang = 1;
        return FALSE; // Do not enumerate anymore

    return TRUE;

bool IsJapaneseLangInstalled()
    LONG lLang=0;
        JapaneseEnumLanguageGroupsProc, // callback function
        LGRPID_SUPPORTED,               // language groups
        (LONG_PTR)&lLang          // callback parameter

        return true;

    return false;

int _tmain(int argc, _TCHAR* argv[])
	std::wstring strAns = IsJapaneseLangInstalled() ? L"Yes" : L"No" ;
	std::wcout<<L"Japanese Language Installed : " <<  strAns  << std::endl;
	return 0;

Note: For Chinese language, you have to choose whether you want to detect if Traditional Chinese, Simplified Chinese, or both are installed. The sample code to detect CJK is included as a source code download of this article.

About the Author

Wong Shao Voon

I guess I'll write here what I does in my free time, than to write an accolade of skills which I currently possess. I believe the things I does in my free time, say more about me.

When I am not working, I like to watch Japanese anime. I am also writing some movie script, hoping to see my own movie on the big screen one day.

I like to jog because it makes me feel good, having done something meaningful in the morning before the day starts.

I also writes articles for CodeGuru; I have a few ideas to write about but never get around writing because of hectic schedule.



  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • The advent of compute accelerators, special purpose coprocessors that significantly improve the performance of traditional host-based central processing unit (CPU) computations, represents a major transition in the tools available to achieve supercomputing power. This white paper presents Dell solution offerings and shows how they push the envelope of available solutions that bring immediate added value to HPC users in terms of integration, flexibility, and efficiency of hybrid compute solutions.

  • Live Event Date: February 25, 2015 @ 2:00 p.m. ET / 11:00 a.m. PT Secure Shell (SSH) keys provide unmitigated access for privileged users and applications. However, managing and securing these critical privileged credentials poses a real challenge for organizations, putting sensitive data at risk. In fact, more than 50% of organizations report experiencing an SSH Key related compromise. Check out this upcoming eSeminar and join Adam Bosnian, EVP of Global Business Development at CyberArk, as he discusses the …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date