1/*
2 *
3 * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved
4 *
5 */
6
7#include "LETypes.h"
8#include "loengine.h"
9#include "LayoutEngine.h"
10
11/**
12 * \file
13 * \brief C API for complex text layout.
14 */
15
16U_NAMESPACE_USE
17
18U_CAPI le_engine * U_EXPORT2
19le_create(const le_font *font,
20		  le_int32 scriptCode,
21		  le_int32 languageCode,
22		  le_int32 typo_flags,
23		  LEErrorCode *success)
24{
25	LEFontInstance *fontInstance = (LEFontInstance *) font;
26
27	return (le_engine *) LayoutEngine::layoutEngineFactory(fontInstance, scriptCode, languageCode, typo_flags, *success);
28}
29
30U_CAPI void U_EXPORT2
31le_close(le_engine *engine)
32{
33	LayoutEngine *le = (LayoutEngine *) engine;
34
35	delete le;
36}
37
38U_CAPI le_int32 U_EXPORT2
39le_layoutChars(le_engine *engine,
40			   const LEUnicode chars[],
41			   le_int32 offset,
42			   le_int32 count,
43			   le_int32 max,
44			   le_bool rightToLeft,
45			   float x,
46			   float y,
47			   LEErrorCode *success)
48{
49	LayoutEngine *le = (LayoutEngine *) engine;
50
51	if (le == NULL) {
52		*success = LE_ILLEGAL_ARGUMENT_ERROR;
53		return -1;
54	}
55
56	return le->layoutChars(chars, offset, count, max, rightToLeft, x, y, *success);
57}
58
59U_CAPI le_int32 U_EXPORT2
60le_getGlyphCount(le_engine *engine,
61				 LEErrorCode *success)
62{
63	LayoutEngine *le = (LayoutEngine *) engine;
64
65	if (le == NULL) {
66		*success = LE_ILLEGAL_ARGUMENT_ERROR;
67		return -1;
68	}
69
70	return le->getGlyphCount();
71}
72
73U_CAPI void U_EXPORT2
74le_getGlyphs(le_engine *engine,
75			 LEGlyphID glyphs[],
76			 LEErrorCode *success)
77{
78	LayoutEngine *le = (LayoutEngine *) engine;
79
80	if (le == NULL) {
81		*success = LE_ILLEGAL_ARGUMENT_ERROR;
82		return;
83	}
84
85	le->getGlyphs(glyphs, *success);
86}
87
88U_CAPI void U_EXPORT2
89le_getCharIndices(le_engine *engine,
90				  le_int32 charIndices[],
91				  LEErrorCode *success)
92{
93	LayoutEngine *le = (LayoutEngine *) engine;
94
95	if (le == NULL) {
96		*success = LE_ILLEGAL_ARGUMENT_ERROR;
97		return;
98	}
99
100	le->getCharIndices(charIndices, *success);
101}
102
103U_CAPI void U_EXPORT2
104le_getCharIndicesWithBase(le_engine *engine,
105				          le_int32 charIndices[],
106				          le_int32 indexBase,
107				          LEErrorCode *success)
108{
109	LayoutEngine *le = (LayoutEngine *) engine;
110
111	if (le == NULL) {
112		*success = LE_ILLEGAL_ARGUMENT_ERROR;
113		return;
114	}
115
116	le->getCharIndices(charIndices, indexBase, *success);
117}
118
119U_CAPI void U_EXPORT2
120le_getGlyphPositions(le_engine *engine,
121					 float positions[],
122					 LEErrorCode *success)
123{
124	LayoutEngine *le = (LayoutEngine *) engine;
125
126	if (le == NULL) {
127		*success = LE_ILLEGAL_ARGUMENT_ERROR;
128		return;
129	}
130
131	le->getGlyphPositions(positions, *success);
132}
133
134U_CAPI void U_EXPORT2
135le_getGlyphPosition(le_engine *engine,
136					le_int32 glyphIndex,
137					float *x,
138					float *y,
139					LEErrorCode *success)
140{
141	LayoutEngine *le = (LayoutEngine *) engine;
142
143	if (le == NULL) {
144		*success = LE_ILLEGAL_ARGUMENT_ERROR;
145		return;
146	}
147
148	le->getGlyphPosition(glyphIndex, *x, *y, *success);
149}
150
151U_CAPI void U_EXPORT2
152le_reset(le_engine *engine,
153		 LEErrorCode *success)
154{
155	LayoutEngine *le = (LayoutEngine *) engine;
156
157	if (le == NULL) {
158		*success = LE_ILLEGAL_ARGUMENT_ERROR;
159		return;
160	}
161
162	le->reset();
163}
164