playout.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. /*
  2. *
  3. * (C) Copyright IBM Corp. 1998-2011 - All Rights Reserved
  4. *
  5. */
  6. #ifndef __PLAYOUT_H
  7. #define __PLAYOUT_H
  8. /*
  9. * ParagraphLayout doesn't make much sense without
  10. * BreakIterator...
  11. */
  12. #include "unicode/ubidi.h"
  13. #if ! UCONFIG_NO_BREAK_ITERATION
  14. #ifndef U_HIDE_INTERNAL_API
  15. #include "layout/LETypes.h"
  16. #include "plruns.h"
  17. /**
  18. * \file
  19. * \brief C API for paragraph layout.
  20. *
  21. * This is a technology preview. The API may
  22. * change significantly.
  23. *
  24. */
  25. /**
  26. * The opaque type for a paragraph layout.
  27. *
  28. * @internal
  29. */
  30. typedef void pl_paragraph;
  31. /**
  32. * The opaque type for a line in a paragraph layout.
  33. *
  34. * @internal
  35. */
  36. typedef void pl_line;
  37. /**
  38. * The opaque type for a visual run in a line.
  39. *
  40. * @internal
  41. */
  42. typedef void pl_visualRun;
  43. /**
  44. * Construct a <code>ParagraphLayout</code> object for a styled paragraph. The paragraph is specified
  45. * as runs of text all in the same font. An <code>LEFontInstance</code> object and a limit offset
  46. * are specified for each font run. The limit offset is the offset of the character immediately
  47. * after the font run.
  48. *
  49. * Clients can optionally specify directional runs and / or script runs. If these aren't specified
  50. * they will be computed.
  51. *
  52. * If any errors are encountered during construction, <code>status</code> will be set, and the object
  53. * will be set to be empty.
  54. *
  55. * @param chars is an array of the characters in the paragraph
  56. *
  57. * @param count is the number of characters in the paragraph.
  58. *
  59. * @param fontRuns a pointer to a <code>pl_fontRuns</code> object representing the font runs.
  60. *
  61. * @param levelRuns is a pointer to a <code>pl_valueRuns</code> object representing the directional levels.
  62. * If this pointer in <code>NULL</code> the levels will be determined by running the Unicde
  63. * Bidi algorithm.
  64. *
  65. * @param scriptRuns is a pointer to a <code>pl_valueRuns</code> object representing script runs.
  66. * If this pointer in <code>NULL</code> the script runs will be determined using the
  67. * Unicode code points.
  68. *
  69. * @param localeRuns is a pointer to a <code>pl_localeRuns</code> object representing locale runs.
  70. * The <code>Locale</code> objects are used to determind the language of the text. If this
  71. * pointer is <code>NULL</code> the default locale will be used for all of the text.
  72. *
  73. * @param paragraphLevel is the directionality of the paragraph, as in the UBiDi object.
  74. *
  75. * @param vertical is <code>TRUE</code> if the paragraph should be set vertically.
  76. *
  77. * @param status will be set to any error code encountered during construction.
  78. *
  79. * @return a pointer to the newly created <code>pl_paragraph</code> object. The object
  80. * will remain valid until <code>pl_close</code> is called.
  81. *
  82. * @see ubidi.h
  83. * @see longine.h
  84. * @see plruns.h
  85. *
  86. * @internal
  87. */
  88. U_INTERNAL pl_paragraph * U_EXPORT2
  89. pl_create(const LEUnicode chars[],
  90. le_int32 count,
  91. const pl_fontRuns *fontRuns,
  92. const pl_valueRuns *levelRuns,
  93. const pl_valueRuns *scriptRuns,
  94. const pl_localeRuns *localeRuns,
  95. UBiDiLevel paragraphLevel,
  96. le_bool vertical,
  97. LEErrorCode *status);
  98. /**
  99. * Close the given paragraph layout object.
  100. *
  101. * @param paragraph the <code>pl_paragraph</code> object to be
  102. * closed. Once this routine returns the object
  103. * can no longer be referenced
  104. *
  105. * @internal
  106. */
  107. U_INTERNAL void U_EXPORT2
  108. pl_close(pl_paragraph *paragraph);
  109. /**
  110. * Examine the given text and determine if it contains characters in any
  111. * script which requires complex processing to be rendered correctly.
  112. *
  113. * @param chars is an array of the characters in the paragraph
  114. *
  115. * @param count is the number of characters in the paragraph.
  116. *
  117. * @return <code>TRUE</code> if any of the text requires complex processing.
  118. *
  119. * @internal
  120. */
  121. U_INTERNAL le_bool U_EXPORT2
  122. pl_isComplex(const LEUnicode chars[],
  123. le_int32 count);
  124. /**
  125. * Return the resolved paragraph level. This is useful for those cases
  126. * where the bidi analysis has determined the level based on the first
  127. * strong character in the paragraph.
  128. *
  129. * @param paragraph the <code>pl_paragraph</code>
  130. *
  131. * @return the resolved paragraph level.
  132. *
  133. * @internal
  134. */
  135. U_INTERNAL UBiDiLevel U_EXPORT2
  136. pl_getParagraphLevel(pl_paragraph *paragraph);
  137. /**
  138. * Return the directionality of the text in the paragraph.
  139. *
  140. * @param paragraph the <code>pl_paragraph</code>
  141. *
  142. * @return <code>UBIDI_LTR</code> if the text is all left to right,
  143. * <code>UBIDI_RTL</code> if the text is all right to left,
  144. * or <code>UBIDI_MIXED</code> if the text has mixed direction.
  145. *
  146. * @internal
  147. */
  148. U_INTERNAL UBiDiDirection U_EXPORT2
  149. pl_getTextDirection(pl_paragraph *paragraph);
  150. /**
  151. * Get the max ascent value for all the fonts
  152. * in the paragraph.
  153. *
  154. * @param paragraph the <code>pl_paragraph</code>
  155. *
  156. * Return the max ascent value for all the fonts
  157. * in the paragraph.
  158. *
  159. * @param paragraph the <code>pl_paragraph</code>
  160. *
  161. * @return the ascent value.
  162. *
  163. * @internal
  164. */
  165. U_INTERNAL le_int32 U_EXPORT2
  166. pl_getAscent(const pl_paragraph *paragraph);
  167. /**
  168. * Return the max descent value for all the fonts
  169. * in the paragraph.
  170. *
  171. * @param paragraph the <code>pl_paragraph</code>
  172. *
  173. * @return the decent value.
  174. *
  175. * @internal
  176. */
  177. U_INTERNAL le_int32 U_EXPORT2
  178. pl_getDescent(const pl_paragraph *paragraph);
  179. /**
  180. * Return the max leading value for all the fonts
  181. * in the paragraph.
  182. *
  183. * @param paragraph the <code>pl_paragraph</code>
  184. *
  185. * @return the leading value.
  186. *
  187. * @internal
  188. */
  189. U_INTERNAL le_int32 U_EXPORT2
  190. pl_getLeading(const pl_paragraph *paragraph);
  191. /**
  192. * Reset line breaking to start from the beginning of the paragraph.
  193. *
  194. * @param paragraph the <code>pl_paragraph</code>
  195. *
  196. * @internal
  197. */
  198. U_INTERNAL void U_EXPORT2
  199. pl_reflow(pl_paragraph *paragraph);
  200. /**
  201. * Return a <code>pl_line</code> object which represents next line
  202. * in the paragraph. The width of the line is specified each time so that it can
  203. * be varied to support arbitrary paragraph shapes.
  204. *
  205. * @param paragraph the <code>pl_paragraph</code>
  206. * @param width is the width of the line. If <code>width</code> is less than or equal
  207. * to zero, a <code>ParagraphLayout::Line</code> object representing the
  208. * rest of the paragraph will be returned.
  209. *
  210. * @return a <code>ParagraphLayout::Line</code> object which represents the line. The caller
  211. * is responsible for deleting the object. Returns <code>NULL</code> if there are no
  212. * more lines in the paragraph.
  213. *
  214. * @see pl_line
  215. *
  216. * @internal
  217. */
  218. U_INTERNAL pl_line * U_EXPORT2
  219. pl_nextLine(pl_paragraph *paragraph, float width);
  220. /**
  221. * Close the given line object. Line objects are created
  222. * by <code>pl_nextLine</code> but it is the client's responsibility
  223. * to close them by calling this routine.
  224. *
  225. * @param line the <code>pl_line</code> object to close.
  226. *
  227. * @internal
  228. */
  229. U_INTERNAL void U_EXPORT2
  230. pl_closeLine(pl_line *line);
  231. /**
  232. * Count the number of visual runs in the line.
  233. *
  234. * @param line the <code>pl_line</code> object.
  235. *
  236. * @return the number of visual runs.
  237. *
  238. * @internal
  239. */
  240. U_INTERNAL le_int32 U_EXPORT2
  241. pl_countLineRuns(const pl_line *line);
  242. /**
  243. * Get the ascent of the line. This is the maximum ascent
  244. * of all the fonts on the line.
  245. *
  246. * @param line the <code>pl_line</code> object.
  247. *
  248. * @return the ascent of the line.
  249. *
  250. * @internal
  251. */
  252. U_INTERNAL le_int32 U_EXPORT2
  253. pl_getLineAscent(const pl_line *line);
  254. /**
  255. * Get the descent of the line. This is the maximum descent
  256. * of all the fonts on the line.
  257. *
  258. * @param line the <code>pl_line</code> object.
  259. *
  260. * @return the descent of the line.
  261. *
  262. * @internal
  263. */
  264. U_INTERNAL le_int32 U_EXPORT2
  265. pl_getLineDescent(const pl_line *line);
  266. /**
  267. * Get the leading of the line. This is the maximum leading
  268. * of all the fonts on the line.
  269. *
  270. * @param line the <code>pl_line</code> object.
  271. *
  272. * @return the leading of the line.
  273. *
  274. * @internal
  275. */
  276. U_INTERNAL le_int32 U_EXPORT2
  277. pl_getLineLeading(const pl_line *line);
  278. /**
  279. * Get the width of the line. This is a convenience method
  280. * which returns the last X position of the last visual run
  281. * in the line.
  282. *
  283. * @param line the <code>pl_line</code> object.
  284. *
  285. * @return the width of the line.
  286. *
  287. * @internal
  288. */
  289. U_INTERNAL le_int32 U_EXPORT2
  290. pl_getLineWidth(const pl_line *line);
  291. /**
  292. * Get a <code>ParagraphLayout::VisualRun</code> object for a given
  293. * visual run in the line.
  294. *
  295. * @param line the <code>pl_line</code> object.
  296. * @param runIndex is the index of the run, in visual order.
  297. *
  298. * @return the <code>pl_visualRun</code> object representing the
  299. * visual run. This object is owned by the <code>pl_line</code> object which
  300. * created it, and will remain valid for as long as the <code>pl_line</code>
  301. * object is valid.
  302. *
  303. * @see pl_visualRun
  304. *
  305. * @internal
  306. */
  307. U_INTERNAL const pl_visualRun * U_EXPORT2
  308. pl_getLineVisualRun(const pl_line *line, le_int32 runIndex);
  309. /**
  310. * Get the <code>le_font</code> object which
  311. * represents the font of the visual run. This will always
  312. * be a non-composite font.
  313. *
  314. * @param run the <code>pl_visualRun</code> object.
  315. *
  316. * @return the <code>le_font</code> object which represents the
  317. * font of the visual run.
  318. *
  319. * @see le_font
  320. *
  321. * @internal
  322. */
  323. U_INTERNAL const le_font * U_EXPORT2
  324. pl_getVisualRunFont(const pl_visualRun *run);
  325. /**
  326. * Get the direction of the visual run.
  327. *
  328. * @param run the <code>pl_visualRun</code> object.
  329. *
  330. * @return the direction of the run. This will be <code>UBIDI_LTR</code> if the
  331. * run is left-to-right and <code>UBIDI_RTL</code> if the line is right-to-left.
  332. *
  333. * @internal
  334. */
  335. U_INTERNAL UBiDiDirection U_EXPORT2
  336. pl_getVisualRunDirection(const pl_visualRun *run);
  337. /**
  338. * Get the number of glyphs in the visual run.
  339. *
  340. * @param run the <code>pl_visualRun</code> object.
  341. *
  342. * @return the number of glyphs.
  343. *
  344. * @internal
  345. */
  346. U_INTERNAL le_int32 U_EXPORT2
  347. pl_getVisualRunGlyphCount(const pl_visualRun *run);
  348. /**
  349. * Get the glyphs in the visual run. Glyphs with the values <code>0xFFFE</code> and
  350. * <code>0xFFFF</code> should be ignored.
  351. *
  352. * @param run the <code>pl_visualRun</code> object.
  353. *
  354. * @return the address of the array of glyphs for this visual run. The storage
  355. * is owned by the <code>pl_visualRun</code> object and must not be deleted.
  356. * It will remain valid as long as the <code>pl_visualRun</code> object is valid.
  357. *
  358. * @internal
  359. */
  360. U_INTERNAL const LEGlyphID * U_EXPORT2
  361. pl_getVisualRunGlyphs(const pl_visualRun *run);
  362. /**
  363. * Get the (x, y) positions of the glyphs in the visual run. To simplify storage
  364. * management, the x and y positions are stored in a single array with the x positions
  365. * at even offsets in the array and the corresponding y position in the following odd offset.
  366. * There is an extra (x, y) pair at the end of the array which represents the advance of
  367. * the final glyph in the run.
  368. *
  369. * @param run the <code>pl_visualRun</code> object.
  370. *
  371. * @return the address of the array of glyph positions for this visual run. The storage
  372. * is owned by the <code>pl_visualRun</code> object and must not be deleted.
  373. * It will remain valid as long as the <code>pl_visualRun</code> object is valid.
  374. *
  375. * @internal
  376. */
  377. U_INTERNAL const float * U_EXPORT2
  378. pl_getVisualRunPositions(const pl_visualRun *run);
  379. /**
  380. * Get the glyph-to-character map for this visual run. This maps the indices into
  381. * the glyph array to indices into the character array used to create the paragraph.
  382. *
  383. * @param run the <code>pl_visualRun</code> object.
  384. *
  385. * @return the address of the character-to-glyph map for this visual run. The storage
  386. * is owned by the <code>pl_visualRun</code> object and must not be deleted.
  387. * It will remain valid as long as the <code>pl_visualRun</code> object is valid.
  388. *
  389. * @internal
  390. */
  391. U_INTERNAL const le_int32 * U_EXPORT2
  392. pl_getVisualRunGlyphToCharMap(const pl_visualRun *run);
  393. /**
  394. * A convenience method which returns the ascent value for the font
  395. * associated with this run.
  396. *
  397. * @param run the <code>pl_visualRun</code> object.
  398. *
  399. * @return the ascent value of this run's font.
  400. *
  401. * @internal
  402. */
  403. U_INTERNAL le_int32 U_EXPORT2
  404. pl_getVisualRunAscent(const pl_visualRun *run);
  405. /**
  406. * A convenience method which returns the descent value for the font
  407. * associated with this run.
  408. *
  409. * @param run the <code>pl_visualRun</code> object.
  410. *
  411. * @return the descent value of this run's font.
  412. *
  413. * @internal
  414. */
  415. U_INTERNAL le_int32 U_EXPORT2
  416. pl_getVisualRunDescent(const pl_visualRun *run);
  417. /**
  418. * A convenience method which returns the leading value for the font
  419. * associated with this run.
  420. *
  421. * @param run the <code>pl_visualRun</code> object.
  422. *
  423. * @return the leading value of this run's font.
  424. *
  425. * @internal
  426. */
  427. U_INTERNAL le_int32 U_EXPORT2
  428. pl_getVisualRunLeading(const pl_visualRun *run);
  429. #endif /* U_HIDE_INTERNAL_API */
  430. #endif
  431. #endif