[uniscribe] Ask Uniscribe to return shaping results in logical order

See discussion on the list in the thread "Arabic presentation forms
and the uniscribe backend".

Based on patch from Jonathan Kew.
This commit is contained in:
Behdad Esfahbod 2013-08-21 17:22:21 -04:00
parent 1d05fdd09f
commit 3409fb1c76
1 changed files with 12 additions and 12 deletions

View File

@ -832,9 +832,8 @@ retry:
unsigned int glyphs_offset = 0;
unsigned int glyphs_len;
bool backward = HB_DIRECTION_IS_BACKWARD (buffer->props.direction);
for (unsigned int j = 0; j < item_count; j++)
for (unsigned int i = 0; i < item_count; i++)
{
unsigned int i = backward ? item_count - 1 - j : j;
unsigned int chars_offset = items[i].iCharPos;
unsigned int item_chars_len = items[i + 1].iCharPos - chars_offset;
@ -875,6 +874,10 @@ retry:
}
}
/* Asking for glyphs in logical order circumvents at least
* one bug in Uniscribe. */
items[i].a.fLogicalOrder = true;
retry_shape:
hr = funcs->ScriptShapeOpenType (font_data->hdc,
&font_data->script_cache,
@ -962,15 +965,9 @@ retry:
uint32_t *p = &vis_clusters[log_clusters[buffer->info[i].utf16_index()]];
*p = MIN (*p, buffer->info[i].cluster);
}
if (!backward) {
for (unsigned int i = 1; i < glyphs_len; i++)
if (vis_clusters[i] == -1)
vis_clusters[i] = vis_clusters[i - 1];
} else {
for (int i = glyphs_len - 2; i >= 0; i--)
if (vis_clusters[i] == -1)
vis_clusters[i] = vis_clusters[i + 1];
}
for (unsigned int i = 1; i < glyphs_len; i++)
if (vis_clusters[i] == -1)
vis_clusters[i] = vis_clusters[i - 1];
#undef utf16_index
@ -1004,10 +1001,13 @@ retry:
/* TODO vertical */
pos->x_advance = info->mask;
pos->x_offset = info->var1.u32;
pos->x_offset = backward ? -info->var1.u32 : info->var1.u32;
pos->y_offset = info->var2.u32;
}
if (backward)
hb_buffer_reverse (buffer);
/* Wow, done! */
return true;
}