Microsoft HomeproductssearchsupportshopWrite Us   Microsoft Home
Magazine
 |  Community
 |  Workshop
 |  Tools & Samples
 |  Training
 |  Site Info

Workshop

How to Use Font Linking


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:

  1. Make sure the Component Object Library has been initialized.

    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.

  2. Obtain a pointer to an IMLangFontLink interface.

    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.

  3. Obtain handles to the default font you want to use to output the string and to the device context through which it will be displayed.

    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.

  4. Use the IMLangCodePages and IMLangFontLink methods to determine if a custom font is needed for the string you want to output.

    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.
    }
    
  5. If a custom font is needed, call IMLangFontLink::MapFont to create a font.

    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.

  6. Remember to release the interfaces and uninitialize the Component Object Library before your program terminates.

The following link provides further information about the operations described in this article:


Does this content meet your programming needs? Write us!

Back to topBack to top

© 1998 Microsoft Corporation. All rights reserved. Terms of use.

 

Magazine Home
Ask Jane
DHTML Dude
Extreme XML
For Starters
More or Hess
Servin' It Up
Site Lights
Web Men Talking
Member Community Home
Benefits: Freebies & Discounts
Benefits: Promote Your Site
Benefits: Connect with Your Peers
Benefits at a Glance
Online Special-Interest Groups
Your Membership
SBN Stores
Join Now
Workshop Home
Essentials
Content & Component Delivery
Component Development
Data Access & Databases
Design
DHTML, HTML & CSS
Extensible Markup Language (XML)
Languages & Development Tools
Messaging & Collaboration
Networking, Protocols & Data Formats
Reusing Browser Technology
Security & Cryptography
Server Technologies
Streaming & Interactive Media
Web Content Management
Workshop Index
Tools & Samples Home
Tools
Samples, Headers, Libs
Images
Sounds
Style Sheets
Web Fonts
Training Home
SBN Live Seminars
SBN Live Chats
Courses
Peer Support
CD-ROM Training
Books & Training Kits
Certification
SBN Home
New to SBN?
What's New on SBN
Site Map
Site Search
Glossary
Write Us
About This Site