diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index dc0639f4f..f7a0495b3 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -687,6 +687,8 @@ hb_buffer_t::guess_segment_properties (void) /* If direction is set to INVALID, guess from script */ if (props.direction == HB_DIRECTION_INVALID) { props.direction = hb_script_get_horizontal_direction (props.script); + if (props.direction == HB_DIRECTION_INVALID) + props.direction = HB_DIRECTION_LTR; } /* If language is not set, use default language from locale */ @@ -1489,6 +1491,8 @@ hb_buffer_reverse_clusters (hb_buffer_t *buffer) * Next, if buffer direction is not set (ie. is %HB_DIRECTION_INVALID), * it will be set to the natural horizontal direction of the * buffer script as returned by hb_script_get_horizontal_direction(). + * If hb_script_get_horizontal_direction() returns %HB_DIRECTION_INVALID, + * then %HB_DIRECTION_LTR is used. * * Finally, if buffer language is not set (ie. is %HB_LANGUAGE_INVALID), * it will be set to the process's default language as returned by diff --git a/src/hb-common.cc b/src/hb-common.cc index f38ebb043..956855c4d 100644 --- a/src/hb-common.cc +++ b/src/hb-common.cc @@ -536,6 +536,12 @@ hb_script_get_horizontal_direction (hb_script_t script) case HB_SCRIPT_ADLAM: return HB_DIRECTION_RTL; + + + /* https://github.com/harfbuzz/harfbuzz/issues/1000 */ + case HB_SCRIPT_OLD_ITALIC: + + return HB_DIRECTION_INVALID; } return HB_DIRECTION_LTR; diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index dd10e346e..5dc578421 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -306,13 +306,16 @@ static void hb_ensure_native_direction (hb_buffer_t *buffer) { hb_direction_t direction = buffer->props.direction; + hb_direction_t horiz_dir = hb_script_get_horizontal_direction (buffer->props.script); /* TODO vertical: * The only BTT vertical script is Ogham, but it's not clear to me whether OpenType * Ogham fonts are supposed to be implemented BTT or not. Need to research that * first. */ - if ((HB_DIRECTION_IS_HORIZONTAL (direction) && direction != hb_script_get_horizontal_direction (buffer->props.script)) || - (HB_DIRECTION_IS_VERTICAL (direction) && direction != HB_DIRECTION_TTB)) + if ((HB_DIRECTION_IS_HORIZONTAL (direction) && + direction != horiz_dir && horiz_dir != HB_DIRECTION_INVALID) || + (HB_DIRECTION_IS_VERTICAL (direction) && + direction != HB_DIRECTION_TTB)) { /* Same loop as hb_form_clusters(). * Since form_clusters() merged clusters already, we don't merge. */ diff --git a/test/api/test-common.c b/test/api/test-common.c index 74b50be96..f6f0d4851 100644 --- a/test/api/test-common.c +++ b/test/api/test-common.c @@ -173,6 +173,7 @@ test_types_script (void) g_assert_cmpint (hb_script_get_horizontal_direction (HB_SCRIPT_LATIN), ==, HB_DIRECTION_LTR); g_assert_cmpint (hb_script_get_horizontal_direction (HB_SCRIPT_ARABIC), ==, HB_DIRECTION_RTL); + g_assert_cmpint (hb_script_get_horizontal_direction (HB_SCRIPT_OLD_ITALIC), ==, HB_DIRECTION_INVALID); g_assert_cmpint (hb_script_get_horizontal_direction (hb_script_from_iso15924_tag (wWyZ)), ==, HB_DIRECTION_LTR); } diff --git a/test/shaping/data/in-house/Makefile.sources b/test/shaping/data/in-house/Makefile.sources index 9a1434ec6..bf4df2018 100644 --- a/test/shaping/data/in-house/Makefile.sources +++ b/test/shaping/data/in-house/Makefile.sources @@ -31,6 +31,7 @@ TESTS = \ tests/mark-filtering-sets.tests \ tests/mongolian-variation-selector.tests \ tests/myanmar-syllable.tests \ + tests/none-directional.tests \ tests/spaces.tests \ tests/simple.tests \ tests/tibetan-contractions-1.tests \ diff --git a/test/shaping/data/in-house/fonts/73e84dac2fc6a2d1bc9250d1414353661088937d.ttf b/test/shaping/data/in-house/fonts/73e84dac2fc6a2d1bc9250d1414353661088937d.ttf new file mode 100644 index 000000000..46e7c1dac Binary files /dev/null and b/test/shaping/data/in-house/fonts/73e84dac2fc6a2d1bc9250d1414353661088937d.ttf differ diff --git a/test/shaping/data/in-house/tests/none-directional.tests b/test/shaping/data/in-house/tests/none-directional.tests new file mode 100644 index 000000000..e59946d1a --- /dev/null +++ b/test/shaping/data/in-house/tests/none-directional.tests @@ -0,0 +1,3 @@ +../fonts/73e84dac2fc6a2d1bc9250d1414353661088937d.ttf::U+10300,U+10301:[u10300=0+1470|u10301=1+1284] +../fonts/73e84dac2fc6a2d1bc9250d1414353661088937d.ttf:--direction=ltr:U+10300,U+10301:[u10300=0+1470|u10301=1+1284] +../fonts/73e84dac2fc6a2d1bc9250d1414353661088937d.ttf:--direction=rtl:U+10300,U+10301:[u10301_r=1+1284|u10300_r=0+1470]