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