CTLine.pas 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. {
  2. * CTLine.h
  3. * CoreText
  4. *
  5. * Copyright (c) 2003-2012 Apple Inc. All rights reserved.
  6. *
  7. }
  8. { Initial Pascal Translation: Jonas Maebe, <[email protected]>, October 2009 }
  9. { Pascal Translation Updated: Jonas Maebe, <[email protected]>, October 2012 }
  10. {
  11. Modified for use with Free Pascal
  12. Version 308
  13. Please report any bugs to <[email protected]>
  14. }
  15. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  16. {$mode macpas}
  17. {$packenum 1}
  18. {$macro on}
  19. {$inline on}
  20. {$calling mwpascal}
  21. unit CTLine;
  22. interface
  23. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  24. {$setc GAP_INTERFACES_VERSION := $0308}
  25. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  26. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  27. {$endc}
  28. {$ifc defined CPUPOWERPC and defined CPUI386}
  29. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  30. {$endc}
  31. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  32. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  33. {$endc}
  34. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  35. {$setc __ppc__ := 1}
  36. {$elsec}
  37. {$setc __ppc__ := 0}
  38. {$endc}
  39. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  40. {$setc __ppc64__ := 1}
  41. {$elsec}
  42. {$setc __ppc64__ := 0}
  43. {$endc}
  44. {$ifc not defined __i386__ and defined CPUI386}
  45. {$setc __i386__ := 1}
  46. {$elsec}
  47. {$setc __i386__ := 0}
  48. {$endc}
  49. {$ifc not defined __x86_64__ and defined CPUX86_64}
  50. {$setc __x86_64__ := 1}
  51. {$elsec}
  52. {$setc __x86_64__ := 0}
  53. {$endc}
  54. {$ifc not defined __arm__ and defined CPUARM}
  55. {$setc __arm__ := 1}
  56. {$elsec}
  57. {$setc __arm__ := 0}
  58. {$endc}
  59. {$ifc defined cpu64}
  60. {$setc __LP64__ := 1}
  61. {$elsec}
  62. {$setc __LP64__ := 0}
  63. {$endc}
  64. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  65. {$error Conflicting definitions for __ppc__ and __i386__}
  66. {$endc}
  67. {$ifc defined __ppc__ and __ppc__}
  68. {$setc TARGET_CPU_PPC := TRUE}
  69. {$setc TARGET_CPU_PPC64 := FALSE}
  70. {$setc TARGET_CPU_X86 := FALSE}
  71. {$setc TARGET_CPU_X86_64 := FALSE}
  72. {$setc TARGET_CPU_ARM := FALSE}
  73. {$setc TARGET_OS_MAC := TRUE}
  74. {$setc TARGET_OS_IPHONE := FALSE}
  75. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  76. {$setc TARGET_OS_EMBEDDED := FALSE}
  77. {$elifc defined __ppc64__ and __ppc64__}
  78. {$setc TARGET_CPU_PPC := FALSE}
  79. {$setc TARGET_CPU_PPC64 := TRUE}
  80. {$setc TARGET_CPU_X86 := FALSE}
  81. {$setc TARGET_CPU_X86_64 := FALSE}
  82. {$setc TARGET_CPU_ARM := FALSE}
  83. {$setc TARGET_OS_MAC := TRUE}
  84. {$setc TARGET_OS_IPHONE := FALSE}
  85. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  86. {$setc TARGET_OS_EMBEDDED := FALSE}
  87. {$elifc defined __i386__ and __i386__}
  88. {$setc TARGET_CPU_PPC := FALSE}
  89. {$setc TARGET_CPU_PPC64 := FALSE}
  90. {$setc TARGET_CPU_X86 := TRUE}
  91. {$setc TARGET_CPU_X86_64 := FALSE}
  92. {$setc TARGET_CPU_ARM := FALSE}
  93. {$ifc defined(iphonesim)}
  94. {$setc TARGET_OS_MAC := FALSE}
  95. {$setc TARGET_OS_IPHONE := TRUE}
  96. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  97. {$elsec}
  98. {$setc TARGET_OS_MAC := TRUE}
  99. {$setc TARGET_OS_IPHONE := FALSE}
  100. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  101. {$endc}
  102. {$setc TARGET_OS_EMBEDDED := FALSE}
  103. {$elifc defined __x86_64__ and __x86_64__}
  104. {$setc TARGET_CPU_PPC := FALSE}
  105. {$setc TARGET_CPU_PPC64 := FALSE}
  106. {$setc TARGET_CPU_X86 := FALSE}
  107. {$setc TARGET_CPU_X86_64 := TRUE}
  108. {$setc TARGET_CPU_ARM := FALSE}
  109. {$setc TARGET_OS_MAC := TRUE}
  110. {$setc TARGET_OS_IPHONE := FALSE}
  111. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  112. {$setc TARGET_OS_EMBEDDED := FALSE}
  113. {$elifc defined __arm__ and __arm__}
  114. {$setc TARGET_CPU_PPC := FALSE}
  115. {$setc TARGET_CPU_PPC64 := FALSE}
  116. {$setc TARGET_CPU_X86 := FALSE}
  117. {$setc TARGET_CPU_X86_64 := FALSE}
  118. {$setc TARGET_CPU_ARM := TRUE}
  119. { will require compiler define when/if other Apple devices with ARM cpus ship }
  120. {$setc TARGET_OS_MAC := FALSE}
  121. {$setc TARGET_OS_IPHONE := TRUE}
  122. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  123. {$setc TARGET_OS_EMBEDDED := TRUE}
  124. {$elsec}
  125. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ is defined.}
  126. {$endc}
  127. {$ifc defined __LP64__ and __LP64__ }
  128. {$setc TARGET_CPU_64 := TRUE}
  129. {$elsec}
  130. {$setc TARGET_CPU_64 := FALSE}
  131. {$endc}
  132. {$ifc defined FPC_BIG_ENDIAN}
  133. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  134. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  135. {$elifc defined FPC_LITTLE_ENDIAN}
  136. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  137. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  138. {$elsec}
  139. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  140. {$endc}
  141. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  142. {$setc CALL_NOT_IN_CARBON := FALSE}
  143. {$setc OLDROUTINENAMES := FALSE}
  144. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  145. {$setc OPAQUE_UPP_TYPES := TRUE}
  146. {$setc OTCARBONAPPLICATION := TRUE}
  147. {$setc OTKERNEL := FALSE}
  148. {$setc PM_USE_SESSION_APIS := TRUE}
  149. {$setc TARGET_API_MAC_CARBON := TRUE}
  150. {$setc TARGET_API_MAC_OS8 := FALSE}
  151. {$setc TARGET_API_MAC_OSX := TRUE}
  152. {$setc TARGET_CARBON := TRUE}
  153. {$setc TARGET_CPU_68K := FALSE}
  154. {$setc TARGET_CPU_MIPS := FALSE}
  155. {$setc TARGET_CPU_SPARC := FALSE}
  156. {$setc TARGET_OS_UNIX := FALSE}
  157. {$setc TARGET_OS_WIN32 := FALSE}
  158. {$setc TARGET_RT_MAC_68881 := FALSE}
  159. {$setc TARGET_RT_MAC_CFM := FALSE}
  160. {$setc TARGET_RT_MAC_MACHO := TRUE}
  161. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  162. {$setc TYPE_BOOL := FALSE}
  163. {$setc TYPE_EXTENDED := FALSE}
  164. {$setc TYPE_LONGLONG := TRUE}
  165. uses MacTypes,CFBase,CFArray,CFAttributedString,CGBase,CGContext,CGGeometry;
  166. {$endc} {not MACOSALLINCLUDE}
  167. {$ALIGN POWER}
  168. {!
  169. @header
  170. Thread Safety Information
  171. All functions in this header are thread safe unless otherwise specified.
  172. }
  173. { --------------------------------------------------------------------------- }
  174. { Line Types }
  175. { --------------------------------------------------------------------------- }
  176. type
  177. CTLineRef = ^__CTLine; { an opaque type }
  178. __CTLine = record end;
  179. CTLineRefPtr = ^CTLineRef;
  180. {!
  181. @enum CTLineBoundsOptions
  182. @abstract Options for CTLineGetBoundsWithOptions.
  183. @constant kCTLineBoundsExcludeTypographicLeading
  184. Pass this option to exclude typographic leading.
  185. @constant kCTLineBoundsExcludeTypographicShifts
  186. Pass this option to ignore cross-stream shifts due to
  187. positioning (such as kerning or baseline alignment).
  188. @constant kCTLineBoundsUseHangingPunctuation
  189. Normally line bounds include all glyphs; pass this option to
  190. treat standard punctuation hanging off either end of the line
  191. as fully hanging.
  192. @constant kCTLineBoundsUseGlyphPathBounds
  193. Pass this option to use glyph path bounds rather than the
  194. default typographic bounds.
  195. @constant kCTLineBoundsUseOpticalBounds
  196. Pass this option to use optical bounds. This option overrides
  197. kCTLineBoundsUseGlyphPathBounds.
  198. }
  199. const
  200. kCTLineBoundsExcludeTypographicLeading = 1 shl 0;
  201. kCTLineBoundsExcludeTypographicShifts = 1 shl 1;
  202. kCTLineBoundsUseHangingPunctuation = 1 shl 2;
  203. kCTLineBoundsUseGlyphPathBounds = 1 shl 3;
  204. kCTLineBoundsUseOpticalBounds = 1 shl 4;
  205. type
  206. CTLineBoundsOptions = CFOptionFlags;
  207. {!
  208. @enum CTLineTruncationType
  209. @abstract Truncation types required by CTLineCreateTruncatedLine. These
  210. will tell truncation engine which type of truncation is being
  211. requested.
  212. @constant kCTLineTruncationStart
  213. Truncate at the beginning of the line, leaving the end portion
  214. visible.
  215. @constant kCTLineTruncationEnd
  216. Truncate at the end of the line, leaving the start portion
  217. visible.
  218. @constant kCTLineTruncationMiddle
  219. Truncate in the middle of the line, leaving both the start
  220. and the end portions visible.
  221. }
  222. const
  223. kCTLineTruncationStart = 0;
  224. kCTLineTruncationEnd = 1;
  225. kCTLineTruncationMiddle = 2;
  226. type
  227. CTLineTruncationType = UInt32;
  228. {!
  229. @function CTLineGetTypeID
  230. @abstract Returns the CFType of the line object
  231. }
  232. function CTLineGetTypeID: CFTypeID; external name '_CTLineGetTypeID';
  233. (* CT_AVAILABLE_STARTING( __MAC_10_5, __IPHONE_3_2) *)
  234. { --------------------------------------------------------------------------- }
  235. { Line Creation }
  236. { --------------------------------------------------------------------------- }
  237. {!
  238. @function CTLineCreateWithAttributedString
  239. @abstract Creates a single immutable line object directly from an
  240. attributed string.
  241. @discussion This will allow clients who need very simple line generation to
  242. create a line without needing to create a typesetter object. The
  243. typesetting will be done under the hood. Without a typesetter
  244. object, the line cannot be properly broken. However, for simple
  245. things like text labels and other things, this is not an issue.
  246. @param string
  247. The string which the line will be created for.
  248. @result This function will return a reference to a CTLine object if the
  249. call was successful. Otherwise, it will return NULL.
  250. }
  251. function CTLineCreateWithAttributedString( strng: CFAttributedStringRef ): CTLineRef; external name '_CTLineCreateWithAttributedString';
  252. (* CT_AVAILABLE_STARTING( __MAC_10_5, __IPHONE_3_2) *)
  253. {!
  254. @function CTLineCreateTruncatedLine
  255. @abstract Creates a truncated line from an existing line.
  256. @param line
  257. The line that you want to create a truncated line for.
  258. @param width
  259. The width at which truncation will begin. The line will be
  260. truncated if its width is greater than the width passed in this.
  261. @param truncationType
  262. The type of truncation to perform if needed.
  263. @param truncationToken
  264. This token will be added to the point where truncation took place
  265. to indicate that the line was truncated. Usually, the truncation
  266. token is the ellipsis character (U+2026). If this parameter is
  267. set to NULL, then no truncation token is used, and the line is
  268. simply cut off. The line specified in truncationToken should have
  269. a width less than the width specified by the width parameter. If
  270. the width of the line specified in truncationToken is greater,
  271. this function will return NULL if truncation is needed.
  272. @result This function will return a reference to a truncated CTLine
  273. object if the call was successful. Otherwise, it will return
  274. NULL.
  275. }
  276. function CTLineCreateTruncatedLine( line: CTLineRef; width: Float64; truncationType: CTLineTruncationType; truncationToken: CTLineRef ): CTLineRef; external name '_CTLineCreateTruncatedLine';
  277. (* CT_AVAILABLE_STARTING( __MAC_10_5, __IPHONE_3_2) *)
  278. {!
  279. @function CTLineCreateJustifiedLine
  280. @abstract Creates a justified line from an existing line.
  281. @param line
  282. The line that you want to create a justified line for.
  283. @param justificationFactor
  284. Allows for full or partial justification. When set to 1.0 or
  285. greater indicates, full justification will be performed. If less
  286. than 1.0, varying degrees of partial justification will be
  287. performed. If set to 0 or less, then no justification will be
  288. performed.
  289. @param justificationWidth
  290. The width to which the resultant line will be justified. If
  291. justificationWidth is less than the actual width of the line,
  292. then negative justification will be performed ("text squishing").
  293. @result This function will return a reference to a justified CTLine
  294. object if the call was successful. Otherwise, it will return
  295. NULL.
  296. }
  297. function CTLineCreateJustifiedLine( line: CTLineRef; justificationFactor: CGFloat; justificationWidth: Float64 ): CTLineRef; external name '_CTLineCreateJustifiedLine';
  298. (* CT_AVAILABLE_STARTING( __MAC_10_5, __IPHONE_3_2) *)
  299. { --------------------------------------------------------------------------- }
  300. { Line Access }
  301. { --------------------------------------------------------------------------- }
  302. {!
  303. @function CTLineGetGlyphCount
  304. @abstract Returns the total glyph count for the line object.
  305. @discussion The total glyph count is equal to the sum of all of the glyphs in
  306. the glyph runs forming the line.
  307. @param line
  308. The line that you want to obtain the glyph count for.
  309. @result The total glyph count for the line passed in.
  310. }
  311. function CTLineGetGlyphCount( line: CTLineRef ): CFIndex; external name '_CTLineGetGlyphCount';
  312. (* CT_AVAILABLE_STARTING( __MAC_10_5, __IPHONE_3_2) *)
  313. {!
  314. @function CTLineGetGlyphRuns
  315. @abstract Returns the array of glyph runs that make up the line object.
  316. @param line
  317. The line that you want to obtain the glyph run array for.
  318. @result A CFArrayRef containing the CTRun objects that make up the line.
  319. }
  320. function CTLineGetGlyphRuns( line: CTLineRef ): CFArrayRef; external name '_CTLineGetGlyphRuns';
  321. (* CT_AVAILABLE_STARTING( __MAC_10_5, __IPHONE_3_2) *)
  322. {!
  323. @function CTLineGetStringRange
  324. @abstract Gets the range of characters that originally spawned the glyphs
  325. in the line.
  326. @param line
  327. The line that you want to obtain the string range from.
  328. @result A CFRange that contains the range over the backing store string
  329. that spawned the glyphs. If the function fails for any reason, an
  330. empty range will be returned.
  331. }
  332. function CTLineGetStringRange( line: CTLineRef ): CFRange; external name '_CTLineGetStringRange';
  333. (* CT_AVAILABLE_STARTING( __MAC_10_5, __IPHONE_3_2) *)
  334. {!
  335. @function CTLineGetPenOffsetForFlush
  336. @abstract Gets the pen offset required to draw flush text.
  337. @param line
  338. The line that you want to obtain a flush position from.
  339. @param flushFactor
  340. Specifies what kind of flushness you want. A flushFactor of 0 or
  341. less indicates left flush. A flushFactor of 1.0 or more indicates
  342. right flush. Flush factors between 0 and 1.0 indicate varying
  343. degrees of center flush, with a value of 0.5 being totally center
  344. flush.
  345. @param flushWidth
  346. Specifies the width that the flushness operation should apply to.
  347. @result A value which can be used to offset the current pen position for
  348. the flush operation.
  349. }
  350. function CTLineGetPenOffsetForFlush( line: CTLineRef; flushFactor: CGFloat; flushWidth: Float64 ): Float64; external name '_CTLineGetPenOffsetForFlush';
  351. (* CT_AVAILABLE_STARTING( __MAC_10_5, __IPHONE_3_2) *)
  352. {!
  353. @function CTLineDraw
  354. @abstract Draws a line.
  355. @discussion This is a convenience call, since the line could be drawn
  356. run-by-run by getting the glyph runs and accessing the glyphs out
  357. of them. Note that this call may leave the graphics context in
  358. any state and does not flush the context after the draw
  359. operation.
  360. @param line
  361. The line that you want to draw.
  362. @param context
  363. The context to which the line will be drawn.
  364. }
  365. procedure CTLineDraw( line: CTLineRef; context: CGContextRef ); external name '_CTLineDraw';
  366. (* CT_AVAILABLE_STARTING( __MAC_10_5, __IPHONE_3_2) *)
  367. { --------------------------------------------------------------------------- }
  368. { Line Measurement }
  369. { --------------------------------------------------------------------------- }
  370. {!
  371. @function CTLineGetTypographicBounds
  372. @abstract Calculates the typographic bounds for a line.
  373. @discussion A line's typographic width is the distance to the rightmost
  374. glyph advance width edge. Note that this distance includes
  375. trailing whitespace glyphs.
  376. @param line
  377. The line that you want to calculate the typographic bounds for.
  378. @param ascent
  379. Upon return, this parameter will contain the ascent of the line.
  380. This may be set to NULL if not needed.
  381. @param descent
  382. Upon return, this parameter will contain the descent of the line.
  383. This may be set to NULL if not needed.
  384. @param leading
  385. Upon return, this parameter will contain the leading of the line.
  386. This may be set to NULL if not needed.
  387. @result The typographic width of the line. If line is invalid, this
  388. function will always return zero.
  389. @seealso CTLineGetTrailingWhitespaceWidth
  390. }
  391. function CTLineGetTypographicBounds( line: CTLineRef; ascent: CGFloatPtr {can be null}; descent: CGFloatPtr {can be null} ; leading: CGFloatPtr {can be null} ): Float64; external name '_CTLineGetTypographicBounds';
  392. (* CT_AVAILABLE_STARTING( __MAC_10_5, __IPHONE_3_2) *)
  393. {!
  394. @function CTLineGetBoundsWithOptions
  395. @abstract Calculates the bounds for a line.
  396. @param line
  397. The line that you want to calculate the bounds for.
  398. @param options
  399. Desired options or 0 if none.
  400. @result The bounds of the line as specified by the type and options,
  401. such that the coordinate origin is coincident with the line
  402. origin and the rect origin is at the bottom left. If the line
  403. is invalid this function will return CGRectNull.
  404. }
  405. function CTLineGetBoundsWithOptions( line: CTLineRef; options: CTLineBoundsOptions ): CGRect; external name '_CTLineGetBoundsWithOptions';
  406. (* CT_AVAILABLE_STARTING( __MAC_10_8, __IPHONE_6_0) *)
  407. {!
  408. @function CTLineGetTrailingWhitespaceWidth
  409. @abstract Calculates the trailing whitespace width for a line.
  410. @param line
  411. The line that you want to calculate the trailing whitespace width
  412. for. Creating a line for a width can result in a line that is
  413. actually longer than the desired width due to trailing
  414. whitespace. Normally this is not an issue due to whitespace being
  415. invisible, but this function may be used to determine what amount
  416. of a line's width is due to trailing whitespace.
  417. @result The width of the line's trailing whitespace. If line is invalid,
  418. this function will always return zero.
  419. }
  420. function CTLineGetTrailingWhitespaceWidth( line: CTLineRef ): Float64; external name '_CTLineGetTrailingWhitespaceWidth';
  421. (* CT_AVAILABLE_STARTING( __MAC_10_5, __IPHONE_3_2) *)
  422. {!
  423. @function CTLineGetImageBounds
  424. @abstract Calculates the image bounds for a line.
  425. @discussion The image bounds for a line is the union of all non-empty glyph
  426. bounding rects, each positioned as it would be if drawn using
  427. CTLineDraw using the current context. Note that the result is
  428. ideal and does not account for raster coverage due to rendering.
  429. This function is purely a convenience for using glyphs as an
  430. image and should not be used for typographic purposes.
  431. @param line
  432. The line that you want to calculate the image bounds for.
  433. @param context
  434. The context which the image bounds will be calculated for. This
  435. is required because the context could have settings in it that
  436. can cause changes in the image bounds.
  437. @result A rectangle that tightly encloses the paths of the line's glyphs,
  438. which will be translated by the supplied context's text position.
  439. If the line or context is invalid, CGRectNull will be returned.
  440. @seealso CTLineGetTypographicBounds
  441. @seealso CTLineGetBoundsWithOptions
  442. @seealso CTLineGetPenOffsetForFlush
  443. }
  444. function CTLineGetImageBounds( line: CTLineRef; context: CGContextRef ): CGRect; external name '_CTLineGetImageBounds';
  445. (* CT_AVAILABLE_STARTING( __MAC_10_5, __IPHONE_3_2) *)
  446. { --------------------------------------------------------------------------- }
  447. { Line Caret Positioning and Highlighting }
  448. { --------------------------------------------------------------------------- }
  449. {!
  450. @function CTLineGetStringIndexForPosition
  451. @abstract Performs hit testing.
  452. @discussion This function can be used to determine the string index for a
  453. mouse click or other event. This string index corresponds to the
  454. character before which the next character should be inserted.
  455. This determination is made by analyzing the string from which a
  456. typesetter was created and the corresponding glyphs as embodied
  457. by a particular line.
  458. @param line
  459. The line being examined.
  460. @param position
  461. The location of the mouse click relative to the line's origin.
  462. @result The string index for the position. Relative to the line's string
  463. range, this value will be no less than the first string index and
  464. no greater than one plus the last string index. In the event of
  465. failure, this function will return kCFNotFound.
  466. }
  467. function CTLineGetStringIndexForPosition( line: CTLineRef; position: CGPoint ): CFIndex; external name '_CTLineGetStringIndexForPosition';
  468. (* CT_AVAILABLE_STARTING( __MAC_10_5, __IPHONE_3_2) *)
  469. {!
  470. @function CTLineGetOffsetForStringIndex
  471. @abstract Determines the graphical offset(s) for a string index.
  472. @discussion This function returns the graphical offset(s) corresponding to
  473. a string index, suitable for movement between adjacent lines or
  474. for drawing a custom caret. For the former, the primary offset
  475. may be adjusted for any relative indentation of the two lines;
  476. a CGPoint constructed with the adjusted offset for its x value
  477. and 0.0 for its y value is suitable for passing to
  478. CTLineGetStringIndexForPosition. In either case, the primary
  479. offset corresponds to the portion of the caret that represents
  480. the visual insertion location for a character whose direction
  481. matches the line's writing direction.
  482. @param line
  483. The line from which the offset is requested.
  484. @param charIndex
  485. The string index corresponding to the desired position.
  486. @param secondaryOffset
  487. An output parameter that will be set to the secondary offset
  488. along the baseline for charIndex. When a single caret is
  489. sufficient for a string index, this value will be the same as
  490. the primary offset, which is the return value of this function.
  491. This parameter may be NULL.
  492. @result The primary offset along the baseline for charIndex, or 0.0 in
  493. the event of failure.
  494. }
  495. function CTLineGetOffsetForStringIndex( line: CTLineRef; charIndex: CFIndex; secondaryOffset: CGFloatPtr {can be null} ): CGFloat; external name '_CTLineGetOffsetForStringIndex';
  496. (* CT_AVAILABLE_STARTING( __MAC_10_5, __IPHONE_3_2) *)
  497. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  498. end.
  499. {$endc} {not MACOSALLINCLUDE}