[coretext] Simplify cluster mapping

This commit is contained in:
Behdad Esfahbod 2014-08-11 02:04:38 -04:00
parent 49f7fb6376
commit 9ce067c775
1 changed files with 17 additions and 24 deletions

View File

@ -819,33 +819,26 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
* This does *not* mean we'll form the same clusters as Uniscribe * This does *not* mean we'll form the same clusters as Uniscribe
* or the native OT backend, only that the cluster indices will be * or the native OT backend, only that the cluster indices will be
* monotonic in the output buffer. */ * monotonic in the output buffer. */
if (HB_DIRECTION_IS_FORWARD (buffer->props.direction)) { if (count > 1)
unsigned int prev_cluster = 0; {
for (unsigned int i = 0; i < count; i++) { hb_glyph_info_t *info = buffer->info;
unsigned int curr_cluster = buffer->info[i].cluster; if (HB_DIRECTION_IS_FORWARD (buffer->props.direction))
if (curr_cluster < prev_cluster) { {
for (unsigned int j = i; j > 0; j--) { unsigned int cluster = info[count - 1].cluster;
if (buffer->info[j - 1].cluster > curr_cluster) for (unsigned int i = count - 1; i > 0; i--)
buffer->info[j - 1].cluster = curr_cluster; {
else cluster = MIN (cluster, info[i - 1].cluster);
break; info[i - 1].cluster = cluster;
}
} }
prev_cluster = curr_cluster;
} }
} else { else
unsigned int prev_cluster = (unsigned int)-1; {
for (unsigned int i = 0; i < count; i++) { unsigned int cluster = info[0].cluster;
unsigned int curr_cluster = buffer->info[i].cluster; for (unsigned int i = 1; i < count; i++)
if (curr_cluster > prev_cluster) { {
for (unsigned int j = i; j > 0; j--) { cluster = MIN (cluster, info[i].cluster);
if (buffer->info[j - 1].cluster < curr_cluster) info[i].cluster = cluster;
buffer->info[j - 1].cluster = curr_cluster;
else
break;
}
} }
prev_cluster = curr_cluster;
} }
} }