MLang implements a service called font linking to assist developers who must output strings that contain characters from a variety of character sets. This service creates a custom font that inherits from a specified source font. The IMLangFontLink interface contains the methods a client uses to perform font linking.
To use the font-linking functionality of MLang:
Before you can use any of the functionality provided by MLang, you must first initialize the Component Object Library through a call to CoInitialize. Every call to CoInitialize must be accompanied by a call to CoUninitialize when the application terminates. CoUninitialize ensures that the application does not quit until it has received all of its pending messages.
The IMLangFontLink interface is part of the MultiLanguage Object. If no such object exists, you must create one and obtain a pointer to the corresponding IMultiLanguage interface through a call to CoCreateInstance. Once this has been accomplished, call QueryInterface through IMultiLanguage for a pointer to an IMLangFontLink interface.
Try to use a font that will display as many of the characters in the string as possible. This helps limit the number of times a custom font must be created.
Using the IMLangCodePages::GetCharCodePages, IMLangCodePages::GetStrCodePages, and IMLangFontLink::GetFontCodePages methods, you can determine if a custom font is needed to output the given string (or character). The following code sample demonstrates how to determine if a character (ch) can be output by a given font.
// IMLangFontLink* pMLangFontLink; DWORD dwFontCodePages; DWORD dwCharCodePages; pMLangFontLink->GetFontCodePages(hDC, hFont, &dwFontCodePages); pMLangFontLink->GetCharCodePages(ch, &dwCharCodePages); if(dwCharCodePages & dwFontCodePages) { // Character ch can be output with hFont on hDC. } else { // Create a custom font to output the characters from // dwCharCodePages. }
IMLangFontLink implements a font cache to store the custom fonts that are created. When a custom font is no longer being used, it must be released from the font cache through the IMLangFontLink::ReleaseFont method. This allows the font object to be deleted if the cache becomes full.
The following link provides further information about the operations described in this article: