]> git.saurik.com Git - apple/icu.git/blame - icuSources/layoutex/playout.cpp
ICU-551.51.4.tar.gz
[apple/icu.git] / icuSources / layoutex / playout.cpp
CommitLineData
46f4442e
A
1/*
2 *
3 * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved
4 *
5 */
6
7/*
8 * paragraphLayout doesn't make much sense without
9 * BreakIterator...
10 */
11#include "layout/LETypes.h"
12#include "layout/loengine.h"
13#include "layout/plruns.h"
14#include "layout/playout.h"
15
16#include "unicode/locid.h"
17
18#include "layout/LayoutEngine.h"
19#include "layout/ParagraphLayout.h"
20
21#if ! UCONFIG_NO_BREAK_ITERATION
22
23U_NAMESPACE_USE
24
25U_CAPI pl_paragraph * U_EXPORT2
26pl_create(const LEUnicode chars[],
27 le_int32 count,
28 const pl_fontRuns *fontRuns,
29 const pl_valueRuns *levelRuns,
30 const pl_valueRuns *scriptRuns,
31 const pl_localeRuns *localeRuns,
32 UBiDiLevel paragraphLevel,
33 le_bool vertical,
34 LEErrorCode *status)
35{
36 ParagraphLayout *pl = new ParagraphLayout(chars, count, (const FontRuns *) fontRuns,
37 (const ValueRuns *) levelRuns, (const ValueRuns *) scriptRuns, (const LocaleRuns *) localeRuns,
38 paragraphLevel, vertical, *status);
39
40 return (pl_paragraph *) pl;
41}
42
43U_CAPI void U_EXPORT2
44pl_close(pl_paragraph *paragraph)
45{
46 ParagraphLayout *pl = (ParagraphLayout *) paragraph;
47
48 delete pl;
49}
50
51U_CAPI le_bool U_EXPORT2
52pl_isComplex(const LEUnicode chars[],
53 le_int32 count)
54{
55 return ParagraphLayout::isComplex(chars, count);
56}
57
58U_CAPI UBiDiLevel U_EXPORT2
59pl_getParagraphLevel(pl_paragraph *paragraph)
60{
61 ParagraphLayout *pl = (ParagraphLayout *) paragraph;
62
63 if (pl == NULL) {
64 return 0;
65 }
66
67 return pl->getParagraphLevel();
68}
69
70U_CAPI UBiDiDirection U_EXPORT2
71pl_getTextDirection(pl_paragraph *paragraph)
72{
73 ParagraphLayout *pl = (ParagraphLayout *) paragraph;
74
75 if (pl == NULL) {
76 return UBIDI_LTR;
77 }
78
79 return pl->getTextDirection();
80}
81
82U_CAPI le_int32 U_EXPORT2
83pl_getAscent(const pl_paragraph *paragraph)
84{
85 ParagraphLayout *pl = (ParagraphLayout *) paragraph;
86
87 if (pl == NULL) {
88 return 0;
89 }
90
91 return pl->getAscent();
92}
93
94U_CAPI le_int32 U_EXPORT2
95pl_getDescent(const pl_paragraph *paragraph)
96{
97 ParagraphLayout *pl = (ParagraphLayout *) paragraph;
98
99 if (pl == NULL) {
100 return 0;
101 }
102
103 return pl->getDescent();
104}
105
106U_CAPI le_int32 U_EXPORT2
107pl_getLeading(const pl_paragraph *paragraph)
108{
109 ParagraphLayout *pl = (ParagraphLayout *) paragraph;
110
111 if (pl == NULL) {
112 return 0;
113 }
114
115 return pl->getLeading();
116}
117
118U_CAPI void U_EXPORT2
119pl_reflow(pl_paragraph *paragraph)
120{
121 ParagraphLayout *pl = (ParagraphLayout *) paragraph;
122
123 if (pl == NULL) {
124 return;
125 }
126
127 return pl->reflow();
128}
129
130U_CAPI pl_line * U_EXPORT2
131pl_nextLine(pl_paragraph *paragraph, float width)
132{
133 ParagraphLayout *pl = (ParagraphLayout *) paragraph;
134
135 if (pl == NULL) {
136 return NULL;
137 }
138
139 return (pl_line *) pl->nextLine(width);
140}
141
142U_CAPI void U_EXPORT2
143pl_closeLine(pl_line *line)
144{
145 ParagraphLayout::Line *ll = (ParagraphLayout::Line *) line;
146
147 delete ll;
148}
149
150U_CAPI le_int32 U_EXPORT2
151pl_countLineRuns(const pl_line *line)
152{
153 ParagraphLayout::Line *ll = (ParagraphLayout::Line *) line;
154
155 if (ll == NULL) {
156 return 0;
157 }
158
159 return ll->countRuns();
160}
161
162U_CAPI le_int32 U_EXPORT2
163pl_getLineAscent(const pl_line *line)
164{
165 ParagraphLayout::Line *ll = (ParagraphLayout::Line *) line;
166
167 if (ll == NULL) {
168 return 0;
169 }
170
171 return ll->getAscent();
172}
173
174U_CAPI le_int32 U_EXPORT2
175pl_getLineDescent(const pl_line *line)
176{
177 ParagraphLayout::Line *ll = (ParagraphLayout::Line *) line;
178
179 if (ll == NULL) {
180 return 0;
181 }
182
183 return ll->getDescent();
184}
185
186U_CAPI le_int32 U_EXPORT2
187pl_getLineLeading(const pl_line *line)
188{
189 ParagraphLayout::Line *ll = (ParagraphLayout::Line *) line;
190
191 if (ll == NULL) {
192 return 0;
193 }
194
195 return ll->getLeading();
196}
197
198U_CAPI le_int32 U_EXPORT2
199pl_getLineWidth(const pl_line *line)
200{
201 ParagraphLayout::Line *ll = (ParagraphLayout::Line *) line;
202
203 if (ll == NULL) {
204 return 0;
205 }
206
207 return ll->getWidth();
208}
209
210U_CAPI const pl_visualRun * U_EXPORT2
211pl_getLineVisualRun(const pl_line *line, le_int32 runIndex)
212{
213 ParagraphLayout::Line *ll = (ParagraphLayout::Line *) line;
214
215 if (ll == NULL) {
216 return 0;
217 }
218
219 return (pl_visualRun *) ll->getVisualRun(runIndex);
220}
221
222U_CAPI const le_font * U_EXPORT2
223pl_getVisualRunFont(const pl_visualRun *run)
224{
225 ParagraphLayout::VisualRun *vr = (ParagraphLayout::VisualRun *) run;
226
227 if (vr == NULL) {
228 return NULL;
229 }
230
231 return (const le_font *) vr->getFont();
232}
233
234U_CAPI UBiDiDirection U_EXPORT2
235pl_getVisualRunDirection(const pl_visualRun *run)
236{
237 ParagraphLayout::VisualRun *vr = (ParagraphLayout::VisualRun *) run;
238
239 if (vr == NULL) {
240 return UBIDI_LTR;
241 }
242
243 return vr->getDirection();
244}
245
246U_CAPI le_int32 U_EXPORT2
247pl_getVisualRunGlyphCount(const pl_visualRun *run)
248{
249 ParagraphLayout::VisualRun *vr = (ParagraphLayout::VisualRun *) run;
250
251 if (vr == NULL) {
252 return -1;
253 }
254
255 return vr->getGlyphCount();
256}
257
258U_CAPI const LEGlyphID * U_EXPORT2
259pl_getVisualRunGlyphs(const pl_visualRun *run)
260{
261 ParagraphLayout::VisualRun *vr = (ParagraphLayout::VisualRun *) run;
262
263 if (vr == NULL) {
264 return NULL;
265 }
266
267 return vr->getGlyphs();
268}
269
270U_CAPI const float * U_EXPORT2
271pl_getVisualRunPositions(const pl_visualRun *run)
272{
273 ParagraphLayout::VisualRun *vr = (ParagraphLayout::VisualRun *) run;
274
275 if (vr == NULL) {
276 return NULL;
277 }
278
279 return vr->getPositions();
280}
281
282U_CAPI const le_int32 * U_EXPORT2
283pl_getVisualRunGlyphToCharMap(const pl_visualRun *run)
284{
285 ParagraphLayout::VisualRun *vr = (ParagraphLayout::VisualRun *) run;
286
287 if (vr == NULL) {
288 return NULL;
289 }
290
291 return vr->getGlyphToCharMap();
292}
293
294U_CAPI le_int32 U_EXPORT2
295pl_getVisualRunAscent(const pl_visualRun *run)
296{
297 ParagraphLayout::VisualRun *vr = (ParagraphLayout::VisualRun *) run;
298
299 if (vr == NULL) {
300 return 0;
301 }
302
303 return vr->getAscent();
304}
305
306U_CAPI le_int32 U_EXPORT2
307pl_getVisualRunDescent(const pl_visualRun *run)
308{
309 ParagraphLayout::VisualRun *vr = (ParagraphLayout::VisualRun *) run;
310
311 if (vr == NULL) {
312 return 0;
313 }
314
315 return vr->getDescent();
316}
317
318U_CAPI le_int32 U_EXPORT2
319pl_getVisualRunLeading(const pl_visualRun *run)
320{
321 ParagraphLayout::VisualRun *vr = (ParagraphLayout::VisualRun *) run;
322
323 if (vr == NULL) {
324 return 0;
325 }
326
327 return vr->getLeading();
328}
329
330#endif