PRB: Embedded Read-Only Fonts in Multiple Application Instances on Windows NT
ID: Q230179
|
The information in this article applies to:
-
Microsoft Windows NT 4.0
-
Microsoft Windows 2000
SYMPTOMS
Microsoft Windows Operating Systems provide a feature called Embedded Read Only fonts that an application can use to temporarily install a TrueType font such that only the application can access and use the font. The behavior of this feature on Windows NT 4.0 may be unexpected. The second and subsequent instances of the application may fail to install the font or may fail to use the font if installation succeeds. This behavior is designed to protect the Embedded Read Only font from misuse by other processes.
CAUSE
The AddFontResource() function will fail to install a hidden font resource file when called by any other process than the process which created the resource file with the CreateScalableFontResource() function.
If a process both creates the hidden font resource file and installs the font resource file, the AddFontResource() function will succeed. However, if the resource file refers to a TrueType font file already in use by another process as a hidden embedded read only font file, the process will be unable to use the font.
RESOLUTION
An application can use embedded read only fonts that are hidden via the CreateScalableFontResource() function in multiple processes ( multiple instances of an application ) by coding each process ( instance of the application ) to use unique copies of both the TrueType font file and the hidden font resource file.
To install unique hidden font resources follow these steps:
- Copy the TrueType font file to a temporary file with a unique filename such as "ttfont01.ttf" that can be owned by the instance of the application.
- Call the CreateScalableFontResource() function to create a uniquely named temporary hidden font resource file that can also be owned by the instance of the application.
- Call the AddFontResource() function to install this uniquely named font resource file for this instance of the application.
- Use the font in the application as desired.
- When the instance of the application terminates or is otherwise finished with the font file, it should uninstall the font resource by calling the RemoveFontResource() function until it fails.
- Lastly, the instance of the application should delete the temporary font resource file and the temporary TrueType font file that it created.
STATUS
This behavior is by design.
This design prevents other processes in the system from using private fonts that a process has installed as hidden to presumably protect the font from unlicensed use outside of the application.
MORE INFORMATION
On Windows NT, when a font resource file is created for a TrueType font file by the CreateScalableFontResource() function and specified to be hidden, the operating system binds this file to the process that created it. When a process attempts to install this font resource file to access the TrueType font, the system fails the AddFontResource() function call if the process is not the one that created it.
Although the AddFontResource() function will succeed if the font resource files are created by each process, subsequent processes will not be allowed to use the font if the font resource file references the same TrueType font file being used by previous processes.
However, if the font resource file that was created as hidden and the TrueType font file it references are distinct files in the file system, then the process can install and use the TrueType font file. This technique succeeds even if the distinct copies of the TrueType font file are internally identical
Steps to Reproduce Behavior
- In an application, install a TrueType font file by creating a hidden font resource with the CreateScalableFontResource() function and install it by calling the AddFontResource() function.
- Try to use the font in the application programmatically ensuring that the CLIP_EMBEDDED flag is used in the LOGFONT structure.
- Regarding the scenarios described in this article, observe that the font variously cannot be either installed or used by any simultaneous instance of the application beyond the first instance that was started.
REFERENCES
For additional information about this issue on Windows 95 and 98, please see the following article in the Microsoft Knowledge Base:
Q230210 - PRB: Embedded Read Only Fonts in Multiple Application Instances on Windows 9x
Additional query words:
licensing embedding bug failure fail font map mapping problem
Keywords : kbFont kbGDI kbNTOS400 kbWinOS2000 kbSDKWin32 kbTTFonts kbGrpGDI
Version : WINDOWS:; winnt:4.0
Platform : WINDOWS winnt
Issue type : kbprb