home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s076 / 2.img / TXT / EMBEDDIN.TXT next >
Encoding:
Text File  |  1992-05-01  |  7.7 KB  |  157 lines

  1.  
  2.  
  3.   Technical Information for ISVs Implementing TrueType Font Embedding 
  4.            under Microsoft Windows 3.1 and Windows NT
  5.  
  6. Any application written for Microsoft Windows 3.1 or Windows NT can 
  7. store, or embed, the appropriately licensed TrueType fonts used in that 
  8. application's document. The document can then be transported to another 
  9. machine to be displayed or printed. Since TrueType fonts work on any 
  10. display and print to any printer under Windows, the user can be assured 
  11. of WYSIWYG between different platforms.  Font embedding consists of 
  12. two parts: the inclusion of the fonts in the document on the current 
  13. machine and the installation of the fonts on the target machine. 
  14. Specific information on the format of the APIs can be found in the 
  15. Windows 3.1 SDK.
  16.  
  17.  
  18. Embedding the fonts
  19. ===================
  20.  
  21. Applications can use the GetFontData() function to save TrueType 
  22. scalable fonts with their documents. The application reads the 
  23. entire font file using this function with the DWORD table set to 
  24. zero. The application must check the font's license bit otmfstype 
  25. bits 1 and 2 to ensure that embedding is permitted. 
  26.  
  27. To determine that a font can be embedded first call the 
  28. GetOutlineTextMetrics() function and check the otmfsType field, 
  29. bits 1 and 2. The values and their assigned meanings are:
  30.  
  31. Bit #
  32. 1    2    Meaning
  33. -----------------------
  34. 0    0    Read-write and read-only embedding permitted
  35. 0    1    Only read-only embedding permitted
  36. 1    x    Embedding is not permitted
  37.  
  38. Embedding any fonts for which embedding is not permitted (that is, 
  39. if bit 1 = 1) or not following the guidelines below may violate 
  40. the font vendor's proprietary rights and/or the end-user's licensing 
  41. agreement. 
  42.  
  43. After you determine which fonts can be embedded, you can read in 
  44. the complete font using the GetFontData() function (set the dwTable 
  45. and dwOffset arguments to 0L to ensure that you read the entire 
  46. font file, starting at the beginning of the font). The font data 
  47. stream is stored with the document that uses the font; use the 
  48. format that best suits your application.  We suggest that you build 
  49. a font directory in the document, noting which fonts are bundled 
  50. (you should use at least the otmpStyleName, otmpFamilyName, 
  51. otmTextMetrics.tmWeight, otmTextMetrics.tmItalic, and otmfsType 
  52. fields that the GetOutlineTextMetrics() function returns) and which 
  53. are read-write or read-only embedded fonts.
  54.  
  55. If the read-only embedding bit is set for a font (that is, if 
  56. otmfsType&6 is TRUE), you must apply a form of simple encryption to 
  57. the font data before storing it with the document. Although you can 
  58. do so any way that you prefer, XORing the font data with a specific 
  59. byte value that you choose and use consistently suffices (this 
  60. method is also fairly fast).  Since the actual embedding is
  61. completely under the control of the application, ISVs who are
  62. worried about file size can choose to do compression of the
  63. included TrueType font.
  64.  
  65. When all fonts are bundled with the document, embedding is complete.
  66.  
  67.  
  68. Installation of fonts
  69. =====================
  70.  
  71. When an application encounters a document that contains embedded 
  72. fonts, it must separate and install them for Windows to use them.
  73. Precisely how an application does this depends on how the fonts 
  74. were bundled, but in general the steps are as follows.
  75.  
  76. 1. Resolve name conflicts before installing the fonts. For example,
  77.    using each family name, call the EnumFontFamilies() function to 
  78.    see if any style names are duplicated; the application must avoid 
  79.    duplication. If duplicate fonts are installed, Windows typically,
  80.    though not necessarily, selects the first font installed. 
  81.  
  82.    The directory containing family name, style name, weight, italic 
  83.    flag, and fsType information suffices for the pupose of checking 
  84.    for duplicates. 
  85.  
  86. 2. For all fonts to be installed, access the bundled font and write 
  87.    all the data to a file, decoding any fonts that are read-only 
  88.    embedded. Read-write embedded fonts should use the TTF file 
  89.    extension. Read-only embedded fonts cannot use TTF and should 
  90.    avoid FOT and FON; these fonts should have an entirely different 
  91.    file extenstion, for example, TTR.
  92.  
  93.    You need not place the font files in any specific directory. We 
  94.    suggest, however, that you place read-write embedded fonts in a 
  95.    the Windows or appliction directory and that you place read-only 
  96.    embedded fonts in a temporary file directory.
  97.  
  98. 3. Use the CreateScalableFontResource function to create font resource 
  99.    files for each TrueType font unbundled. Use the extension FOT for 
  100.    read-write embedded fonts, and ensure that the first parameter is 0.
  101.    Use a different extension for read-only embedded fonts, for example,
  102.    FOR; the first parameter must be 1. Use the AddFontResource() 
  103.    function to install each font resource file. Place the FOT and 
  104.    FOR files in the same directory as the font itself.
  105.  
  106. Because Windows resources are normally available to all Windows 
  107. processes, all fonts that are installed with the AddFontResource()
  108. function are typically available to all other applications that are 
  109. active at the time. To prevent a read-only embedded font from being 
  110. used in other documents, Windows suppresses the enumeration and 
  111. availability of these fonts. As noted above, this is controlled by 
  112. parameter #1 of CreateScalableFontResource(). If this parameter is 
  113. set to 0, the font is considered "normal." If it is set to 1, the 
  114. font is considered "read-only embedded" and will not be enumerated 
  115. under any circumstances. Further, the font can only be selected if 
  116. the CLIP_EMBEDDED flag is or'd into the lfClipPrecision field of the 
  117. LOGFONT. This should prevent other active applications from making 
  118. use of your application's read-only embedded fonts.
  119.  
  120. Because users can use read-write embedded fonts on an ongoing basis,
  121. offer them the option of installing read-write embedded fonts 
  122. permanently. To install a font permanently, concatenate the family 
  123. and style names into one string, and insert this string with the FOT 
  124. file name in the WIN.INI [Fonts] section. (See the documentation on 
  125. WIN.INI for details on the format of the [Fonts] section.)
  126.  
  127. You must never install read-only embedded fonts permanently. You 
  128. must remove them from the system and from the hard disk when the 
  129. document in which they are bundled is closed.
  130.  
  131. The fonts are now ready to be used with the document in which they 
  132. were bundled. If a document contains one or more read-only embedded 
  133. fonts, however, the user must not be permitted to edit the document.
  134. The user can only view the document on the screen or print it. Before 
  135. any editing can occur, the application must strip away and delete 
  136. the read-only embedded fonts. To delete the fonts, the application must:
  137.  
  138.    1. Call the DeleteFontResource function for each font to be deleted.
  139.    2. Delete the font resource file for each font.
  140.    3. Delete each TrueType font file for each font.
  141.  
  142. Documents with read-only embedded fonts are themselves read-only and 
  143. print-only. The document cannot be edited until every read-only embedded 
  144. font has been removed. This option should be provided to the user.
  145.  
  146. When the document is closed, read-write embedded fonts can be installed 
  147. on the user's machine. The user can delete the fonts through Control 
  148. Panel, however, if the above installation process was followed. 
  149.  
  150. If, for some reason, you are unable to delete one or more FOR files, 
  151. don't worry; all you waste is disk space. If, however, you are unable 
  152. to delete one or more TTR files, the application should make every 
  153. effort to delete these files later (for example, when the application 
  154. itself exits, when the application starts up again, or after an 
  155. elapsed period of time). 
  156.  
  157.