提交 71ee1f24 编写于 作者: B Behdad Esfahbod

Port to ICU LayoutEngine C API

Incidentally, this makes it not crash with icu-le-hb anymore...
I'm not smart / stupid enough to spend two more days debugging C++
linking issues, and this is ABI-stable at least.
上级 0144f05e
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include "hb-icu-le/PortableFontInstance.h" #include "hb-icu-le/PortableFontInstance.h"
#include "layout/LayoutEngine.h" #include "layout/loengine.h"
#include "unicode/unistr.h" #include "unicode/unistr.h"
#include "hb-icu.h" #include "hb-icu.h"
...@@ -117,13 +117,13 @@ _hb_icu_le_shape (hb_shape_plan_t *shape_plan, ...@@ -117,13 +117,13 @@ _hb_icu_le_shape (hb_shape_plan_t *shape_plan,
le_int32 language_code = -1 /* TODO */; le_int32 language_code = -1 /* TODO */;
le_int32 typography_flags = 3; // essential for ligatures and kerning le_int32 typography_flags = 3; // essential for ligatures and kerning
LEErrorCode status = LE_NO_ERROR; LEErrorCode status = LE_NO_ERROR;
LayoutEngine *le = LayoutEngine::layoutEngineFactory (font_instance, le_engine *le = le_create ((const le_font *) font_instance,
script_code, script_code,
language_code, language_code,
typography_flags, typography_flags,
status); &status);
if (status != LE_NO_ERROR) if (status != LE_NO_ERROR)
{ delete (le); return false; } { le_close (le); return false; }
retry: retry:
...@@ -143,15 +143,16 @@ retry: ...@@ -143,15 +143,16 @@ retry:
clusters[i] = buffer->info[i].cluster; clusters[i] = buffer->info[i].cluster;
} }
unsigned int glyph_count = le->layoutChars(chars, unsigned int glyph_count = le_layoutChars (le,
chars,
0, 0,
buffer->len, buffer->len,
buffer->len, buffer->len,
HB_DIRECTION_IS_BACKWARD (buffer->props.direction), HB_DIRECTION_IS_BACKWARD (buffer->props.direction),
0., 0., 0., 0.,
status); &status);
if (status != LE_NO_ERROR) if (status != LE_NO_ERROR)
{ delete (le); return false; } { le_close (le); return false; }
unsigned int num_glyphs = scratch_size / (sizeof (LEGlyphID) + unsigned int num_glyphs = scratch_size / (sizeof (LEGlyphID) +
sizeof (le_int32) + sizeof (le_int32) +
...@@ -160,7 +161,7 @@ retry: ...@@ -160,7 +161,7 @@ retry:
if (unlikely (glyph_count >= num_glyphs || glyph_count > buffer->allocated)) { if (unlikely (glyph_count >= num_glyphs || glyph_count > buffer->allocated)) {
buffer->ensure (buffer->allocated * 2); buffer->ensure (buffer->allocated * 2);
if (buffer->in_error) if (buffer->in_error)
{ delete (le); return false; } { le_close (le); return false; }
goto retry; goto retry;
} }
...@@ -168,9 +169,9 @@ retry: ...@@ -168,9 +169,9 @@ retry:
ALLOCATE_ARRAY (le_int32, indices, glyph_count); ALLOCATE_ARRAY (le_int32, indices, glyph_count);
ALLOCATE_ARRAY (float, positions, glyph_count * 2 + 2); ALLOCATE_ARRAY (float, positions, glyph_count * 2 + 2);
le->getGlyphs(glyphs, status); le_getGlyphs (le, glyphs, &status);
le->getCharIndices(indices, status); le_getCharIndices (le, indices, &status);
le->getGlyphPositions(positions, status); le_getGlyphPositions (le, positions, &status);
#undef ALLOCATE_ARRAY #undef ALLOCATE_ARRAY
...@@ -208,6 +209,6 @@ retry: ...@@ -208,6 +209,6 @@ retry:
pos->y_offset = info->var2.u32; pos->y_offset = info->var2.u32;
} }
delete (le); le_close (le);
return true; return true;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册