Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

327 lines
14 KiB

  1. /*
  2. * Adobe Universal Font Library
  3. *
  4. * Copyright (c) 1996 Adobe Systems Inc.
  5. * All Rights Reserved
  6. *
  7. * UFLClient -- Universal Font Library Client Callback APIs
  8. *
  9. *
  10. * $Header:
  11. */
  12. #ifndef _H_UFLClient
  13. #define _H_UFLClient
  14. /*===============================================================================*
  15. * Include files used by this interface *
  16. *===============================================================================*/
  17. #include "UFLTypes.h"
  18. /*===============================================================================*
  19. * Theory of Operation *
  20. *===============================================================================*/
  21. /*
  22. This file specifies the font callback functions that a client needs to provided in order for it to use UFL.
  23. */
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /*===============================================================================*
  28. * Constants *
  29. *===============================================================================*/
  30. /* Type 1 outline constants */
  31. /* returns from NextOutlineSegment */
  32. enum {
  33. kUFLOutlineIterDone,
  34. kUFLOutlineIterBeginGlyph,
  35. kUFLOutlineIterMoveTo,
  36. kUFLOutlineIterLineTo,
  37. kUFLOutlineIterCurveTo,
  38. kUFLOutlineIterClose,
  39. kUFLOutlineIterEndGlyph,
  40. kUFLOutlineIterErr
  41. };
  42. //
  43. // Extra information for support of vertical propoertional font
  44. // Fix #287084, #309104, and #309482
  45. //
  46. #define kUFLVPFPlatformID9x 0
  47. #define kUFLVPFPlatformIDNT 1
  48. #define kUFLVPFPlatformID2K 2
  49. #define kUFLVPFSkewElement2 2
  50. #define kUFLVPFSkewElement3 3
  51. #define kUFLVPFTangent12 ".21255656"
  52. #define kUFLVPFTangent18 ".3249197"
  53. #define kUFLVPFTangent20 ".36397023"
  54. /*===========================================================================
  55. GetGlyphBmp -- Retrieves a bitmap for the glyph specified by the given
  56. character and font. The given font is specified within UFL's
  57. client private data handle.
  58. handle (in) -- Handle of client private data.
  59. glyphID (in) -- Specifies the character value of the glyph to retrieve.
  60. bmp (out) -- Points to buffer pointer that has the bitmap for the glyph.
  61. xWidth, yWidth (out) -- Points to the buffer that receives the character width.
  62. bbox (out) -- Points to 4 UFLFixed that received the glyph bbox.
  63. If the function succeeds, it returns 1, otherwise, it return 0.
  64. ==============================================================================*/
  65. typedef char (UFLCALLBACK *UFLGetGlyphBmp)(
  66. UFLHANDLE handle,
  67. UFLGlyphID glyphID,
  68. UFLGlyphMap **bmp,
  69. UFLFixed *xWidth,
  70. UFLFixed *yWidth,
  71. UFLFixed *bbox
  72. );
  73. /*===========================================================================
  74. DeleteGlyphBmp -- Delete the glyph bitmap data space.
  75. handle (in) -- Handle of client private data.
  76. ==============================================================================*/
  77. typedef void (UFLCALLBACK *UFLDeleteGlyphBmp)(
  78. UFLHANDLE handle
  79. );
  80. /*==============================================================================
  81. CreateGlyphOutlineIter -- Create an OutlineIter for the glyph specified by the given
  82. character and font. The given font is specified within UFL's
  83. client private data handle. To get an outline of a glyph, UFL first creates
  84. an OutlineIter with CreateOutlineIter. If this succeeds (return != 0) UFL
  85. then proceed to call NextOutlineSegment. This will step through the
  86. line and curve segments in the character outlines for the given strike
  87. array in the given font. See more info in CoolType.h.
  88. handle (in) -- Handle of client private data.
  89. glyphID (in) -- Specifies the character value of the glyph to retrieve.
  90. xWidth, yWidth, xSB, ySB (out) -- sbw values
  91. If the function succeeds, it returns 1, otherwise, it returns 0.
  92. ==============================================================================*/
  93. typedef char (UFLCALLBACK *UFLCreateGlyphOutlineIter)(
  94. UFLHANDLE handle,
  95. UFLGlyphID glyphID,
  96. UFLFixed *xWidth,
  97. UFLFixed *yWidth,
  98. UFLFixed *xSB,
  99. UFLFixed *ySB,
  100. UFLBool *bYAxisNegative //added to allow client to specify glyph orientation
  101. );
  102. /*==============================================================================
  103. NextOutlineSegment -- Retrieve the next outline segment
  104. handle (in) -- Handle of client private data.
  105. p0, p1, p2 (out) - Points of the outline segment.
  106. return -- Outline constant defined above.
  107. ==============================================================================*/
  108. typedef long (UFLCALLBACK *UFLNextOutlineSegment)(
  109. UFLHANDLE handle,
  110. UFLFixedPoint *p0,
  111. UFLFixedPoint *p1,
  112. UFLFixedPoint *p2
  113. );
  114. /*==============================================================================
  115. DeleteGlyphOutlineIter -- Terminate the glyph OutlineIter process.
  116. handle (in) -- Handle of client private data.
  117. ==============================================================================*/
  118. typedef void (UFLCALLBACK* UFLDeleteGlyphOutlineIter)(
  119. UFLHANDLE handle
  120. );
  121. /*===========================================================================
  122. GetTTFontData -- Get the SFNT table of a TT font.
  123. handle (in) -- Handle of client private data.
  124. ulTable (in) -- Specifies the name of a font metric table from which the
  125. font data is to be retrieved. This parameter can identify
  126. one of the metric tables documented in the TrueType. If
  127. this parameter is NULL, the information is retrieved
  128. starting at the beginning of the font file.
  129. cbOffset (in) -- Specifies the offset from the beginning of the font metric
  130. table to the location where the function should begin
  131. retrieving information. If this parameter is zero, the
  132. information is retrieved starting at the beginning of the
  133. table specified by the table parameter. If this value is
  134. greater than or equal to the size of the table, an error
  135. occurs.
  136. pvBuffer (in/out) -- Points to a buffer to receive the font information. If
  137. this parameter is NULL, the function returns the size of
  138. the buffer required for the font data.
  139. cbData (in) -- Specifies the length, in bytes, of the information to be
  140. retrieved. If this parameter is zero, the function returns
  141. the size of the data specified in the table parameter.
  142. index (in) -- The FontIndex number for a TTC file. This index is ignored
  143. when ulTable is 0 (reading from start of file, not font)
  144. returns -- If pvBuffer is NULL, the function returns the size of
  145. the buffer required for the font data. If the table does
  146. not exist, the function returns 0.
  147. ==============================================================================*/
  148. typedef unsigned long (UFLCALLBACK *UFLGetTTFontData)(
  149. UFLHANDLE handle, /* Handle of client's private data */
  150. unsigned long ulTable, /* metric table to query */
  151. unsigned long cbOffset, /* offset into table being queried */
  152. void *pvBuffer, /* address of buffer for returned data */
  153. unsigned long cbData, /* length of data to query */
  154. unsigned short index /* Font Index in a TTC file */
  155. );
  156. /*===========================================================================
  157. UFLGetCIDMap -- Get the CIDMap for building a CIDFont with non-ientity CIDMap
  158. handle (in) -- Handle of client private data.
  159. pCIDMap (in/out) -- Points to a buffer to receive the CIDMap data - It must be a
  160. well formatted PostScript string in ASCII format
  161. (e.g., "200 string", (12345), <01020a0b>,..)
  162. If this parameter is NULL, the function returns the size of
  163. the buffer required .
  164. cbData (in) -- Specifies the length, in bytes, of the information to be
  165. retrieved. If this parameter is zero, the function returns
  166. the size of the CIDMap
  167. returns -- If pCIDMap is NULL, the function returns the size of
  168. the buffer required for CIDMap data. If the client has no
  169. CIDMap, the function returns 0.
  170. ==============================================================================*/
  171. typedef unsigned long (UFLCALLBACK *UFLGetCIDMap)(
  172. UFLHANDLE handle, /* Handle of client's private data */
  173. char *pCIDMap, /* address of buffer for returned data */
  174. unsigned long cbData /* length of buffer pCIDMap in bytes */
  175. );
  176. /*===========================================================================
  177. UFLGetGlyphID -- Get the GlyphID from local-code or unicode infomation.
  178. handle (in) -- Handle of client private (font) data.
  179. unicode (in) -- Unicode to look for
  180. localcode (in) -- code point in the current font's language
  181. returns -- If the Glyph Index in this font
  182. ==============================================================================*/
  183. typedef unsigned long (UFLCALLBACK *UFLGetGlyphID)(
  184. UFLHANDLE handle, /* Handle of client's private data */
  185. unsigned short unicode, /* unicode value */
  186. unsigned short localcode /* code value in current font's language */
  187. );
  188. /*==============================================================================
  189. UFLGetRotatedGIDs -- Get the rotated GlyphIDs
  190. handle (in) -- Handle of client private (font) data.
  191. pGIDs (in/out) -- Points to a buffer to receive the rotated (or
  192. unrotated, if bFlag is nil) glyph IDs.
  193. If null, returns the number of rotated glyph IDs only.
  194. nCount (in) -- Number of GIDs stored to the array pointed to by
  195. pGIDs (thus, valid only when pGIDs is valid).
  196. bFlag (in) -- nil if unrotated (in TrueType definition) glyph IDs
  197. are expected.
  198. returns -- Number of rotated glyph IDs. -1 if failed.
  199. ================================================================================*/
  200. typedef long (UFLCALLBACK *UFLGetRotatedGIDs)(
  201. UFLHANDLE handle, /* Handle of client's private data */
  202. unsigned long *pGIDs, /* address of buffer for returned data */
  203. long nCount, /* number of GIDs stored to pGIDs */
  204. UFLBool bFlag /* nil or non-nil */
  205. );
  206. /*==============================================================================
  207. UFLGetRotatedGSUBs -- Get the rotated GlyphID's substitutions
  208. handle (in) -- Handle of client private (font) data.
  209. pGIDs (in/out) -- Pointer to a buffer to recieve the substitution glyph IDs.
  210. Horizotal glyph IDs are already stored and its number is
  211. nCount. It's the caller's responsibility to guarantee that
  212. the buffer is big enough to store both H and V glyphs.
  213. nCount (in) -- Number of horizontal GIDs stored from the beginning of the
  214. buffer pointed to by pGIDs.
  215. returns -- Number of the substitution GIDs found.
  216. ================================================================================*/
  217. typedef long (UFLCALLBACK *UFLGetRotatedGSUBs)(
  218. UFLHANDLE handle, /* Handle of client's private data */
  219. unsigned long *pGIDs, /* address of buffer for returned data */
  220. long nCount /* number of GIDs stored to pGIDs */
  221. );
  222. /*==============================================================================
  223. UFLAddFontInfo -- Adds more key/value pairs to FontInfo dict
  224. handle (in) -- Handle of client private (font) data.
  225. returns -- A pointer to a PS string composed of key/value pairs
  226. which will be added to the FontInfo dictionary.
  227. ================================================================================*/
  228. typedef unsigned long * (UFLCALLBACK *UFLAddFontInfo)(
  229. UFLHANDLE handle, /* Handle of client's private data */
  230. char *buffer,
  231. int bufLen
  232. );
  233. /*==============================================================================
  234. UFLHostFontHandler -- HostFont request hander
  235. ================================================================================*/
  236. typedef char (UFLCALLBACK *UFLHostFontHandler)(
  237. unsigned int req, /* HostFont request number */
  238. UFLHANDLE hHostFont, /* hostfontdata handle */
  239. void* pvObj, /* pointer to an object */
  240. unsigned long* pvObjSize, /* size of object */
  241. UFLHANDLE hClientData, /* Client's private data handle */
  242. DWORD dwHint /* a hint value */
  243. );
  244. /******************************************
  245. Structure To Hold Callback Functions
  246. *******************************************/
  247. /* UFLFontProcs - contains all the client font information callback functions */
  248. typedef struct _t_UFLFontProcs {
  249. /* TrueType font downloades as T3 support functions */
  250. UFLGetGlyphBmp pfGetGlyphBmp;
  251. UFLDeleteGlyphBmp pfDeleteGlyphBmp;
  252. /* TrueType font downloaded as T1 support functions */
  253. UFLCreateGlyphOutlineIter pfCreateGlyphOutlineIter;
  254. UFLNextOutlineSegment pfNextOutlineSegment;
  255. UFLDeleteGlyphOutlineIter pfDeleteGlyphOutlineIter;
  256. /* TrueType font downloaded as T42 support function */
  257. UFLGetTTFontData pfGetTTFontData;
  258. UFLGetCIDMap pfGetCIDMap;
  259. UFLGetGlyphID pfGetGlyphID;
  260. UFLGetRotatedGIDs pfGetRotatedGIDs;
  261. UFLGetRotatedGSUBs pfGetRotatedGSUBs;
  262. UFLAddFontInfo pfAddFontInfo;
  263. /* HostFont support */
  264. UFLHostFontHandler pfHostFontUFLHandler;
  265. } UFLFontProcs;
  266. #ifdef __cplusplus
  267. }
  268. #endif
  269. #endif