00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __LOENGINE_H
00009 #define __LOENGINE_H
00010
00011 #include "unicode/utypes.h"
00012 #include "unicode/uscript.h"
00013 #include "unicode/unistr.h"
00014
00015 #include "layout/LETypes.h"
00016 #include "layout/LayoutEngine.h"
00017
00018 U_NAMESPACE_BEGIN
00019
00048 class U_LAYOUT_API ICULayoutEngine
00049 {
00050 private:
00055 LayoutEngine *fLayoutEngine;
00056
00063 ICULayoutEngine();
00064
00074 ICULayoutEngine(LayoutEngine *layoutEngine);
00075
00076 public:
00077
00086 virtual ~ICULayoutEngine();
00087
00106 int32_t layoutChars(const UChar chars[],
00107 UTextOffset startOffset,
00108 UTextOffset endOffset,
00109 UTextOffset maxOffset,
00110 UBool rightToLeft,
00111 float x, float y,
00112 UErrorCode &success);
00113
00114
00132 int32_t layoutString(const UnicodeString &str,
00133 UTextOffset startOffset,
00134 UTextOffset endOffset,
00135 UBool rightToLeft,
00136 float x, float y,
00137 UErrorCode &success);
00138
00146 int32_t countGlyphs() const;
00147
00156 void getGlyphs(uint16_t glyphs[], UErrorCode &success);
00157
00166 void getCharIndices(int32_t charIndices[], UErrorCode &success);
00167
00177 void getCharIndices(int32_t charIndices[], int32_t indexBase, UErrorCode &success);
00178
00188 void getGlyphPositions(float positions[], UErrorCode &success);
00189
00203 void getGlyphPosition(int32_t glyphIndex, float &x, float &y, UErrorCode &success);
00204
00220 static ICULayoutEngine *createInstance(const LEFontInstance *fontInstance,
00221 UScriptCode script, Locale &locale,
00222 UErrorCode &success);
00223 };
00224
00225 inline ICULayoutEngine::ICULayoutEngine()
00226 {
00227
00228 }
00229
00230 inline ICULayoutEngine::ICULayoutEngine(LayoutEngine *layoutEngine)
00231 : fLayoutEngine(layoutEngine)
00232 {
00233
00234 }
00235
00236 inline ICULayoutEngine::~ICULayoutEngine()
00237 {
00238 delete fLayoutEngine;
00239 fLayoutEngine = 0;
00240 }
00241
00242 inline int32_t ICULayoutEngine::layoutChars(const UChar chars[],
00243 UTextOffset startOffset,
00244 UTextOffset endOffset,
00245 UTextOffset maxOffset,
00246 UBool rightToLeft,
00247 float x, float y,
00248 UErrorCode &success)
00249 {
00250
00251 fLayoutEngine->reset();
00252 return fLayoutEngine->layoutChars(chars,
00253 startOffset,
00254 endOffset - startOffset,
00255 maxOffset,
00256 rightToLeft,
00257 x, y,
00258 (LEErrorCode &) success);
00259 }
00260
00261 inline int32_t ICULayoutEngine::layoutString(const UnicodeString &str,
00262 UTextOffset startOffset,
00263 UTextOffset endOffset,
00264 UBool rightToLeft,
00265 float x, float y,
00266 UErrorCode &success)
00267 {
00268 int32_t glyphCount = 0;
00269 int32_t max = str.length();
00270 UChar *chars = new UChar[max];
00271
00272 str.extract(0, max, chars);
00273
00274
00275 fLayoutEngine->reset();
00276 glyphCount = fLayoutEngine->layoutChars(chars,
00277 startOffset,
00278 endOffset - startOffset,
00279 max,
00280 rightToLeft,
00281 x, y,
00282 (LEErrorCode &) success);
00283
00284 delete[] chars;
00285
00286 return glyphCount;
00287 }
00288
00289 inline int32_t ICULayoutEngine::countGlyphs() const
00290 {
00291 return fLayoutEngine->getGlyphCount();
00292 }
00293
00294 inline void ICULayoutEngine::getGlyphs(uint16_t glyphs[], UErrorCode &success)
00295 {
00296 fLayoutEngine->getGlyphs(glyphs, (LEErrorCode &) success);
00297 }
00298
00299 inline void ICULayoutEngine::getCharIndices(int32_t charIndices[], UErrorCode &success)
00300 {
00301 fLayoutEngine->getCharIndices(charIndices, (LEErrorCode &) success);
00302 }
00303
00304 inline void ICULayoutEngine::getCharIndices(int32_t charIndices[], int32_t indexBase, UErrorCode &success)
00305 {
00306 fLayoutEngine->getCharIndices(charIndices, indexBase, (LEErrorCode &) success);
00307 }
00308
00309 inline void ICULayoutEngine::getGlyphPositions(float positions[], UErrorCode &success)
00310 {
00311 fLayoutEngine->getGlyphPositions(positions, (LEErrorCode &) success);
00312 }
00313
00314 inline void ICULayoutEngine::getGlyphPosition(int32_t glyphIndex, float &x, float &y, UErrorCode &success)
00315 {
00316 fLayoutEngine->getGlyphPosition(glyphIndex, x, y, (LEErrorCode &) success);
00317 }
00318
00319 inline ICULayoutEngine *ICULayoutEngine::createInstance(const LEFontInstance *fontInstance,
00320 UScriptCode script,
00321 Locale &locale, UErrorCode &success)
00322 {
00323 LayoutEngine *engine = LayoutEngine::layoutEngineFactory(fontInstance,
00324 (le_int32) script,
00325 0,
00326 (LEErrorCode &) success);
00327
00328 return new ICULayoutEngine(engine);
00329 }
00330
00331 U_NAMESPACE_END
00332 #endif