Unbreak Uniscribe

Oops.  hb_tag_t and OPENTYPE_TAG have different endianness.  Perhaps
something to add API for in hb-uniscribe.h
This commit is contained in:
Behdad Esfahbod 2012-06-08 09:59:43 -04:00
parent 29eac8f591
commit fcd6f53261
2 changed files with 15 additions and 5 deletions

View File

@ -464,7 +464,17 @@ struct hb_lockable_set_t
static inline uint16_t hb_be_uint16 (const uint16_t v) static inline uint16_t hb_be_uint16 (const uint16_t v)
{ {
const uint8_t *V = (const uint8_t *) &v; const uint8_t *V = (const uint8_t *) &v;
return (uint16_t) (V[0] << 8) + V[1]; return (V[0] << 8) | V[1];
}
static inline uint16_t hb_uint16_swap (const uint16_t v)
{
return (v >> 8) | (v << 8);
}
static inline uint32_t hb_uint32_swap (const uint32_t v)
{
return (hb_uint16_swap (v) << 16) | hb_uint16_swap (v >> 16);
} }
/* Note, of the following macros, uint16_get is the one called many many times. /* Note, of the following macros, uint16_get is the one called many many times.

View File

@ -331,7 +331,7 @@ retry:
/* TODO setup ranges */ /* TODO setup ranges */
} }
OPENTYPE_TAG language_tag = hb_ot_tag_from_language (buffer->props.language); OPENTYPE_TAG language_tag = hb_uint32_swap (hb_ot_tag_from_language (buffer->props.language));
hb_tag_t buffer_script_tags[2]; hb_tag_t buffer_script_tags[2];
hb_ot_tags_from_script (buffer->props.script, hb_ot_tags_from_script (buffer->props.script,
&buffer_script_tags[0], &buffer_script_tags[0],
@ -347,10 +347,10 @@ retry:
OPENTYPE_TAG script_tag; OPENTYPE_TAG script_tag;
/* We ignore what script tag Uniscribe chose, except to differentiate /* We ignore what script tag Uniscribe chose, except to differentiate
* between old/new tags. Not sure if this picks DFLT up correctly... */ * between old/new tags. Not sure if this picks DFLT up correctly... */
if (script_tags[i] == buffer_script_tags[1]) if (script_tags[i] == hb_uint32_swap (buffer_script_tags[1]))
script_tag = buffer_script_tags[1]; script_tag = hb_uint32_swap (buffer_script_tags[1]);
else else
script_tag = buffer_script_tags[0]; script_tag = hb_uint32_swap (buffer_script_tags[0]);
hr = ScriptShapeOpenType (font_data->hdc, hr = ScriptShapeOpenType (font_data->hdc,
&font_data->script_cache, &font_data->script_cache,