CTFramesetter.pas 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. {
  2. * CTFramesetter.h
  3. * CoreText
  4. *
  5. * Copyright (c) 2003-2008 Apple Inc. All rights reserved.
  6. *
  7. }
  8. { Initial Pascal Translation: Jonas Maebe, <[email protected]>, October 2009 }
  9. {
  10. Modified for use with Free Pascal
  11. Version 308
  12. Please report any bugs to <[email protected]>
  13. }
  14. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  15. {$mode macpas}
  16. {$packenum 1}
  17. {$macro on}
  18. {$inline on}
  19. {$calling mwpascal}
  20. unit CTFramesetter;
  21. interface
  22. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  23. {$setc GAP_INTERFACES_VERSION := $0308}
  24. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  25. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  26. {$endc}
  27. {$ifc defined CPUPOWERPC and defined CPUI386}
  28. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  29. {$endc}
  30. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  31. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  32. {$endc}
  33. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  34. {$setc __ppc__ := 1}
  35. {$elsec}
  36. {$setc __ppc__ := 0}
  37. {$endc}
  38. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  39. {$setc __ppc64__ := 1}
  40. {$elsec}
  41. {$setc __ppc64__ := 0}
  42. {$endc}
  43. {$ifc not defined __i386__ and defined CPUI386}
  44. {$setc __i386__ := 1}
  45. {$elsec}
  46. {$setc __i386__ := 0}
  47. {$endc}
  48. {$ifc not defined __x86_64__ and defined CPUX86_64}
  49. {$setc __x86_64__ := 1}
  50. {$elsec}
  51. {$setc __x86_64__ := 0}
  52. {$endc}
  53. {$ifc not defined __arm__ and defined CPUARM}
  54. {$setc __arm__ := 1}
  55. {$elsec}
  56. {$setc __arm__ := 0}
  57. {$endc}
  58. {$ifc defined cpu64}
  59. {$setc __LP64__ := 1}
  60. {$elsec}
  61. {$setc __LP64__ := 0}
  62. {$endc}
  63. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  64. {$error Conflicting definitions for __ppc__ and __i386__}
  65. {$endc}
  66. {$ifc defined __ppc__ and __ppc__}
  67. {$setc TARGET_CPU_PPC := TRUE}
  68. {$setc TARGET_CPU_PPC64 := FALSE}
  69. {$setc TARGET_CPU_X86 := FALSE}
  70. {$setc TARGET_CPU_X86_64 := FALSE}
  71. {$setc TARGET_CPU_ARM := FALSE}
  72. {$setc TARGET_OS_MAC := TRUE}
  73. {$setc TARGET_OS_IPHONE := FALSE}
  74. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  75. {$elifc defined __ppc64__ and __ppc64__}
  76. {$setc TARGET_CPU_PPC := FALSE}
  77. {$setc TARGET_CPU_PPC64 := TRUE}
  78. {$setc TARGET_CPU_X86 := FALSE}
  79. {$setc TARGET_CPU_X86_64 := FALSE}
  80. {$setc TARGET_CPU_ARM := FALSE}
  81. {$setc TARGET_OS_MAC := TRUE}
  82. {$setc TARGET_OS_IPHONE := FALSE}
  83. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  84. {$elifc defined __i386__ and __i386__}
  85. {$setc TARGET_CPU_PPC := FALSE}
  86. {$setc TARGET_CPU_PPC64 := FALSE}
  87. {$setc TARGET_CPU_X86 := TRUE}
  88. {$setc TARGET_CPU_X86_64 := FALSE}
  89. {$setc TARGET_CPU_ARM := FALSE}
  90. {$ifc defined(iphonesim)}
  91. {$setc TARGET_OS_MAC := FALSE}
  92. {$setc TARGET_OS_IPHONE := TRUE}
  93. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  94. {$elsec}
  95. {$setc TARGET_OS_MAC := TRUE}
  96. {$setc TARGET_OS_IPHONE := FALSE}
  97. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  98. {$endc}
  99. {$elifc defined __x86_64__ and __x86_64__}
  100. {$setc TARGET_CPU_PPC := FALSE}
  101. {$setc TARGET_CPU_PPC64 := FALSE}
  102. {$setc TARGET_CPU_X86 := FALSE}
  103. {$setc TARGET_CPU_X86_64 := TRUE}
  104. {$setc TARGET_CPU_ARM := FALSE}
  105. {$setc TARGET_OS_MAC := TRUE}
  106. {$setc TARGET_OS_IPHONE := FALSE}
  107. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  108. {$elifc defined __arm__ and __arm__}
  109. {$setc TARGET_CPU_PPC := FALSE}
  110. {$setc TARGET_CPU_PPC64 := FALSE}
  111. {$setc TARGET_CPU_X86 := FALSE}
  112. {$setc TARGET_CPU_X86_64 := FALSE}
  113. {$setc TARGET_CPU_ARM := TRUE}
  114. { will require compiler define when/if other Apple devices with ARM cpus ship }
  115. {$setc TARGET_OS_MAC := FALSE}
  116. {$setc TARGET_OS_IPHONE := TRUE}
  117. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  118. {$elsec}
  119. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ is defined.}
  120. {$endc}
  121. {$ifc defined __LP64__ and __LP64__ }
  122. {$setc TARGET_CPU_64 := TRUE}
  123. {$elsec}
  124. {$setc TARGET_CPU_64 := FALSE}
  125. {$endc}
  126. {$ifc defined FPC_BIG_ENDIAN}
  127. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  128. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  129. {$elifc defined FPC_LITTLE_ENDIAN}
  130. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  131. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  132. {$elsec}
  133. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  134. {$endc}
  135. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  136. {$setc CALL_NOT_IN_CARBON := FALSE}
  137. {$setc OLDROUTINENAMES := FALSE}
  138. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  139. {$setc OPAQUE_UPP_TYPES := TRUE}
  140. {$setc OTCARBONAPPLICATION := TRUE}
  141. {$setc OTKERNEL := FALSE}
  142. {$setc PM_USE_SESSION_APIS := TRUE}
  143. {$setc TARGET_API_MAC_CARBON := TRUE}
  144. {$setc TARGET_API_MAC_OS8 := FALSE}
  145. {$setc TARGET_API_MAC_OSX := TRUE}
  146. {$setc TARGET_CARBON := TRUE}
  147. {$setc TARGET_CPU_68K := FALSE}
  148. {$setc TARGET_CPU_MIPS := FALSE}
  149. {$setc TARGET_CPU_SPARC := FALSE}
  150. {$setc TARGET_OS_UNIX := FALSE}
  151. {$setc TARGET_OS_WIN32 := FALSE}
  152. {$setc TARGET_RT_MAC_68881 := FALSE}
  153. {$setc TARGET_RT_MAC_CFM := FALSE}
  154. {$setc TARGET_RT_MAC_MACHO := TRUE}
  155. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  156. {$setc TYPE_BOOL := FALSE}
  157. {$setc TYPE_EXTENDED := FALSE}
  158. {$setc TYPE_LONGLONG := TRUE}
  159. uses MacTypes,CTFrame,CTTypesetter,CFBase,CFDictionary,CFAttributedString,CGGeometry,CGPath;
  160. {$endc} {not MACOSALLINCLUDE}
  161. {$ifc TARGET_OS_MAC}
  162. {$ALIGN POWER}
  163. {!
  164. @header
  165. Thread Safety Information
  166. All functions in this header are thread safe unless otherwise specified.
  167. }
  168. { --------------------------------------------------------------------------- }
  169. { Framesetter Types }
  170. { --------------------------------------------------------------------------- }
  171. type
  172. CTFramesetterRef = ^SInt32; { an opaque type }
  173. CTFramesetterRefPtr = ^CTFramesetterRef;
  174. {!
  175. @function CTFramesetterGetTypeID
  176. @abstract Returns the CFType of the framesetter object
  177. }
  178. function CTFramesetterGetTypeID: CFTypeID; external name '_CTFramesetterGetTypeID';
  179. (* AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER *)
  180. { --------------------------------------------------------------------------- }
  181. { Framesetter Creation }
  182. { --------------------------------------------------------------------------- }
  183. {!
  184. @function CTFramesetterCreateWithAttributedString
  185. @abstract Creates an immutable framesetter object from an attributed
  186. string.
  187. @discussion The resultant framesetter object can be used to create and
  188. fill text frames with the CTFramesetterCreateFrame call.
  189. @param string
  190. The run with which you want to construct the framesetter
  191. object with.
  192. @result This function will return a reference to a CTFramesetter if
  193. the call was successful. Otherwise, it will return NULL.
  194. }
  195. function CTFramesetterCreateWithAttributedString( strng: CFAttributedStringRef ): CTFramesetterRef; external name '_CTFramesetterCreateWithAttributedString';
  196. (* AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER *)
  197. { --------------------------------------------------------------------------- }
  198. { Frame Creation }
  199. { --------------------------------------------------------------------------- }
  200. {!
  201. @function CTFramesetterCreateFrame
  202. @abstract Creates an immutable frame from a framesetter.
  203. @discussion This call will create a frame full of glyphs in the shape of
  204. the path provided by the "path" parameter. The framesetter
  205. will continue to fill the frame until it either runs out of
  206. text or it finds that text no longer fits.
  207. @param framesetter
  208. The framesetter that will be used to create the frame.
  209. @param stringRange
  210. The string range which the new frame will be based on. The
  211. string range is a range over the string that was used to
  212. create the framesetter. If the length portion of the range
  213. is set to 0, then the framesetter will continue to add lines
  214. until it runs out of text or space.
  215. @param path
  216. A CGPath object that specifies the shape which the frame will
  217. take on. Currently accepts only rectangles.
  218. @param frameAttributes
  219. Additional attributes that control the frame filling process
  220. can be specified here, or NULL if there are no such attributes.
  221. See CTFrame.h for available attributes.
  222. @result This function will return a reference to a new CTFrame object
  223. if the call was successful. Otherwise, it will return NULL.
  224. }
  225. function CTFramesetterCreateFrame( framesetter: CTFramesetterRef; stringRange: CFRange; path: CGPathRef; frameAttributes: CFDictionaryRef ): CTFrameRef; external name '_CTFramesetterCreateFrame';
  226. (* AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER *)
  227. {!
  228. @function CTFramesetterGetTypesetter
  229. @abstract Returns the typesetter object being used by the framesetter.
  230. @discussion Each framesetter uses a typesetter internally to perform
  231. line breaking and other contextual analysis based on the
  232. characters in a string; this function returns the typesetter
  233. being used by a particular framesetter if the caller would
  234. like to perform other operations on that typesetter.
  235. @param framesetter
  236. The framesetter from which a typesetter is being requested.
  237. @result This function will return a reference to a CTTypesetter
  238. object if the call was successful. Otherwise, it will return
  239. NULL. The framesetter maintains a reference to the returned
  240. object, which should not be disposed by the caller.
  241. }
  242. function CTFramesetterGetTypesetter( framesetter: CTFramesetterRef ): CTTypesetterRef; external name '_CTFramesetterGetTypesetter';
  243. (* AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER *)
  244. { --------------------------------------------------------------------------- }
  245. { Frame Sizing }
  246. { --------------------------------------------------------------------------- }
  247. {!
  248. @function CTFramesetterSuggestFrameSizeWithConstraints
  249. @abstract Determines the frame size needed for a string range.
  250. @discussion This function may be used to determine how much space is needed
  251. to display a string, optionally by constraining the space along
  252. either dimension.
  253. @param framesetter
  254. The framesetter that will be used for measuring the frame size.
  255. @param stringRange
  256. The string range to which the frame size will apply. The
  257. string range is a range over the string that was used to
  258. create the framesetter. If the length portion of the range
  259. is set to 0, then the framesetter will continue to add lines
  260. until it runs out of text or space.
  261. @param frameAttributes
  262. Additional attributes that control the frame filling process
  263. can be specified here, or NULL if there are no such attributes.
  264. @param constraints
  265. The width and height to which the frame size will be constrained,
  266. A value of CGFLOAT_MAX for either dimension indicates that it
  267. should be treated as unconstrained.
  268. @param fitRange
  269. The range of the string that actually fit in the constrained size.
  270. @result The actual dimensions for the given string range and constraints.
  271. }
  272. function CTFramesetterSuggestFrameSizeWithConstraints( framesetter: CTFramesetterRef; stringRange: CFRange; frameAttributes: CFDictionaryRef; constraints: CGSize; var fitRange: CFRange ): CGSize; external name '_CTFramesetterSuggestFrameSizeWithConstraints';
  273. (* AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER *)
  274. {$endc} {TARGET_OS_MAC}
  275. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  276. end.
  277. {$endc} {not MACOSALLINCLUDE}