diff --git a/src/hb-private.hh b/src/hb-private.hh index 0cb049e8d..ea8caf5e6 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -464,7 +464,17 @@ struct hb_lockable_set_t static inline uint16_t hb_be_uint16 (const uint16_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. diff --git a/src/hb-uniscribe.cc b/src/hb-uniscribe.cc index 2edc17835..5013e9f6f 100644 --- a/src/hb-uniscribe.cc +++ b/src/hb-uniscribe.cc @@ -331,7 +331,7 @@ retry: /* 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_ot_tags_from_script (buffer->props.script, &buffer_script_tags[0], @@ -347,10 +347,10 @@ retry: OPENTYPE_TAG script_tag; /* We ignore what script tag Uniscribe chose, except to differentiate * between old/new tags. Not sure if this picks DFLT up correctly... */ - if (script_tags[i] == buffer_script_tags[1]) - script_tag = buffer_script_tags[1]; + if (script_tags[i] == hb_uint32_swap (buffer_script_tags[1])) + script_tag = hb_uint32_swap (buffer_script_tags[1]); else - script_tag = buffer_script_tags[0]; + script_tag = hb_uint32_swap (buffer_script_tags[0]); hr = ScriptShapeOpenType (font_data->hdc, &font_data->script_cache,