[uniscribe] Various improvements

This commit is contained in:
Behdad Esfahbod 2011-09-19 14:53:26 -04:00
parent 11e51993ab
commit 5c29934311
1 changed files with 19 additions and 11 deletions

View File

@ -300,17 +300,22 @@ retry:
#define MAX_ITEMS 10 #define MAX_ITEMS 10
SCRIPT_ITEM items[MAX_ITEMS + 1]; SCRIPT_ITEM items[MAX_ITEMS + 1];
SCRIPT_CONTROL bidi_control = {0};
SCRIPT_STATE bidi_state = {0}; SCRIPT_STATE bidi_state = {0};
WIN_ULONG script_tags[MAX_ITEMS]; WIN_ULONG script_tags[MAX_ITEMS];
int item_count; int item_count;
/* MinGW32 doesn't define fMergeNeutralItems, so we bruteforce */
//bidi_control.fMergeNeutralItems = TRUE;
*(uint32_t*)&bidi_control |= 1<<24;
bidi_state.uBidiLevel = HB_DIRECTION_IS_FORWARD (buffer->props.direction) ? 0 : 1; bidi_state.uBidiLevel = HB_DIRECTION_IS_FORWARD (buffer->props.direction) ? 0 : 1;
bidi_state.fOverrideDirection = 1; // bidi_state.fOverrideDirection = 1;
hr = ScriptItemizeOpenType (wchars, hr = ScriptItemizeOpenType (wchars,
chars_len, chars_len,
MAX_ITEMS, MAX_ITEMS,
NULL, &bidi_control,
&bidi_state, &bidi_state,
items, items,
script_tags, script_tags,
@ -324,7 +329,7 @@ retry:
TEXTRANGE_PROPERTIES **range_properties = NULL; TEXTRANGE_PROPERTIES **range_properties = NULL;
int range_count = 0; int range_count = 0;
if (num_features) { if (num_features) {
/* XXX setup ranges */ /* TODO setup ranges */
} }
OPENTYPE_TAG language_tag = hb_ot_tag_from_language (buffer->props.language); OPENTYPE_TAG language_tag = hb_ot_tag_from_language (buffer->props.language);
@ -399,15 +404,21 @@ retry:
* very, *very*, carefully! */ * very, *very*, carefully! */
/* Calculate visual-clusters. That's what we ship. */ /* Calculate visual-clusters. That's what we ship. */
for (unsigned int i = 0; i < buffer->len; i++) for (unsigned int i = 0; i < glyphs_len; i++)
vis_clusters[i] = 0; vis_clusters[i] = -1;
for (unsigned int i = 0; i < buffer->len; i++) { for (unsigned int i = 0; i < buffer->len; i++) {
uint32_t *p = &vis_clusters[log_clusters[buffer->info[i].utf16_index()]]; uint32_t *p = &vis_clusters[log_clusters[buffer->info[i].utf16_index()]];
*p = MIN (*p, buffer->info[i].cluster); *p = MIN (*p, buffer->info[i].cluster);
} }
if (HB_DIRECTION_IS_FORWARD (buffer->props.direction)) {
for (unsigned int i = 1; i < glyphs_len; i++) for (unsigned int i = 1; i < glyphs_len; i++)
if (!glyph_props[i].sva.fClusterStart) if (!glyph_props[i].sva.fClusterStart)
vis_clusters[i] = vis_clusters[i - 1]; vis_clusters[i] = vis_clusters[i - 1];
} else {
for (int i = glyphs_len - 2; i >= 0; i--)
if (!glyph_props[i].sva.fClusterStart)
vis_clusters[i] = vis_clusters[i + 1];
}
#undef utf16_index #undef utf16_index
@ -421,9 +432,6 @@ retry:
buffer->len = 0; buffer->len = 0;
for (unsigned int i = 0; i < glyphs_len; i++) for (unsigned int i = 0; i < glyphs_len; i++)
{ {
if (glyph_props[i].sva.fZeroWidth)
continue;
hb_glyph_info_t *info = &buffer->info[buffer->len++]; hb_glyph_info_t *info = &buffer->info[buffer->len++];
info->codepoint = glyphs[i]; info->codepoint = glyphs[i];