如何象"金山詞霸"那樣,把自己創建的字體放在自己的程序目錄下面,而不是把字體安裝到系統.在程序需要的時候可以調用自己的字體呢?

解决方案 »

  1.   

    Platform SDK: Windows GDI 
    Font Installation and DeletionTo temporarily install a font, call AddFontResource or AddFontResourceEx. These functions load a font that is stored in a font-resource file. However, this is a temporary installation because after a reboot the font will not be present. 
    In the case of TrueType and OpenType fonts, an additional step is sometimes necessary before the font can be installed in the font table. Some font manufacturers ship only the TrueType or OpenType font-data files (identified by the .ttf extension). Before The system can load these fonts, it requires a corresponding header file (identified by the .fot extension). To create this header file, an application must call the CreateScalableFontResource function and pass the name of the font-data file as the third parameter. When this header file is created, an application can install the font by calling the AddFontResource or AddFontResourceEx function and passing the name of the new header file. For an application that installs TrueType fonts, see the Font Installation SDK at http://fontweb/tools/install/.When an application finishes using an installed font, it must remove that font by calling the RemoveFontResource function. Whenever an application calls the functions that add and delete font resources, it should also call the SendMessage function and send a WM_FONTCHANGE message to all top-level windows in the system. This message notifies other applications that the internal font table has been altered by an application that added or removed a font. 
      

  2.   

    謝謝jiangsheng(蒋晟.MSMVP2004Jan) !好詳細!
      

  3.   

    jiangsheng 已经说出原理了,在
    <<delphi深度历险>>也有详细的例子可用
      

  4.   

    使用没有注册的字体资源:procedure TForm1.FormCreate(Sender: TObject);beginAddFontResource(PChar(ExtractFilePath(ParamStr(0) + 'YourFont.TTF')));SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);end; procedure TForm1.FormDestroy(Sender: TObject);beginRemoveFontResource(PChar(ExtractFilePath(ParamStr(0) + 'YourFont.TTF')));SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);end;