From 2abe0bb681044d972e171189395a2afdbc39bf28 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Tue, 15 Aug 2017 22:39:32 +0200 Subject: Fix inverted y sign for glyph positioning This is causing vertical glyph positioning to move in the wrong direction e.g. marks go below base glyph instead of above. Seems to be a regression introduced in: commit 83dac189ff21c59be9b4f912e0d0e9690e710a4d Author: Tavmjong Bah Date: Tue Nov 3 13:19:36 2015 +0100 Rearrange code to make handling of baseline clearer. (bzr r14430.1.3) --- src/libnrtype/Layout-TNG-Compute.cpp | 4 ++-- testfiles/rendering_tests/CMakeLists.txt | 1 + .../expected_rendering/test-glyph-y-pos-large.png | Bin 0 -> 73316 bytes .../expected_rendering/test-glyph-y-pos.png | Bin 0 -> 13723 bytes testfiles/rendering_tests/test-glyph-y-pos.svg | 26 +++++++++++++++++++++ 5 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png create mode 100644 testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png create mode 100644 testfiles/rendering_tests/test-glyph-y-pos.svg diff --git a/src/libnrtype/Layout-TNG-Compute.cpp b/src/libnrtype/Layout-TNG-Compute.cpp index 63364ab34..5d0c5c3ce 100644 --- a/src/libnrtype/Layout-TNG-Compute.cpp +++ b/src/libnrtype/Layout-TNG-Compute.cpp @@ -767,7 +767,7 @@ void Layout::Calculator::_outputLine(ParagraphInfo const ¶, if( dominant_baseline == SP_CSS_BASELINE_AUTO ) dominant_baseline = SP_CSS_BASELINE_ALPHABETIC; } - new_glyph.y += delta_y; + new_glyph.y -= delta_y; // TODO: Should also check 'glyph_orientation_vertical' if 'text-orientation' is unset... if( new_span.text_orientation == SP_CSS_TEXT_ORIENTATION_SIDEWAYS || @@ -801,7 +801,7 @@ void Layout::Calculator::_outputLine(ParagraphInfo const ¶, if( dominant_baseline == SP_CSS_BASELINE_AUTO ) dominant_baseline = SP_CSS_BASELINE_ALPHABETIC; - new_glyph.y -= delta_y; + new_glyph.y += delta_y; new_glyph.y += new_span.font_size * para.pango_items[unbroken_span.pango_item_index].font->GetBaselines()[ dominant_baseline ]; new_glyph.width = unbroken_span_glyph_info->geometry.width * font_size_multiplier; diff --git a/testfiles/rendering_tests/CMakeLists.txt b/testfiles/rendering_tests/CMakeLists.txt index 3f838628a..739f9789d 100644 --- a/testfiles/rendering_tests/CMakeLists.txt +++ b/testfiles/rendering_tests/CMakeLists.txt @@ -2,6 +2,7 @@ #add your test here (do not put the .svg extension) set(RENDERING_TESTS test-empty + test-glyph-y-pos ) diff --git a/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png new file mode 100644 index 000000000..0bd76e68e Binary files /dev/null and b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png differ diff --git a/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png new file mode 100644 index 000000000..27833a1bb Binary files /dev/null and b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png differ diff --git a/testfiles/rendering_tests/test-glyph-y-pos.svg b/testfiles/rendering_tests/test-glyph-y-pos.svg new file mode 100644 index 000000000..28200c79b --- /dev/null +++ b/testfiles/rendering_tests/test-glyph-y-pos.svg @@ -0,0 +1,26 @@ + + + + + + + G̃g̃X̃x̃ + G̃g̃X̃x̃ + G̃g̃X̃x̃ + + + Composed Glyphs + + -- cgit v1.2.3 From f7e6b3725686becd2b8d034cc572417e5a272cba Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Tue, 15 Aug 2017 22:41:53 +0200 Subject: Fix RTL glyph widths in vertical orientation The vertical branch seems to be broken, removing it makes RTL text in vertical orientation work again. --- src/libnrtype/Layout-TNG-Compute.cpp | 7 +----- testfiles/rendering_tests/CMakeLists.txt | 1 + .../expected_rendering/test-rtl-vertical-large.png | Bin 0 -> 50034 bytes .../expected_rendering/test-rtl-vertical.png | Bin 0 -> 8677 bytes testfiles/rendering_tests/test-rtl-vertical.svg | 25 +++++++++++++++++++++ 5 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.png create mode 100644 testfiles/rendering_tests/expected_rendering/test-rtl-vertical.png create mode 100644 testfiles/rendering_tests/test-rtl-vertical.svg diff --git a/src/libnrtype/Layout-TNG-Compute.cpp b/src/libnrtype/Layout-TNG-Compute.cpp index 5d0c5c3ce..f812f0c41 100644 --- a/src/libnrtype/Layout-TNG-Compute.cpp +++ b/src/libnrtype/Layout-TNG-Compute.cpp @@ -818,12 +818,7 @@ void Layout::Calculator::_outputLine(ParagraphInfo const ¶, for (unsigned rtl_index = glyph_index; rtl_index < it_span->end_glyph_index ; rtl_index++) { if (unbroken_span.glyph_string->glyphs[rtl_index].attr.is_cluster_start && rtl_index != glyph_index) break; - if (_block_progression == LEFT_TO_RIGHT || _block_progression == RIGHT_TO_LEFT) - // Vertical text - cluster_width += new_span.font_size * para.pango_items[unbroken_span.pango_item_index].font->Advance(unbroken_span.glyph_string->glyphs[rtl_index].glyph, true); - else - // Horizontal text - cluster_width += font_size_multiplier * unbroken_span.glyph_string->glyphs[rtl_index].geometry.width; + cluster_width += font_size_multiplier * unbroken_span.glyph_string->glyphs[rtl_index].geometry.width; } new_glyph.x -= cluster_width; } diff --git a/testfiles/rendering_tests/CMakeLists.txt b/testfiles/rendering_tests/CMakeLists.txt index 739f9789d..8b77927a0 100644 --- a/testfiles/rendering_tests/CMakeLists.txt +++ b/testfiles/rendering_tests/CMakeLists.txt @@ -3,6 +3,7 @@ set(RENDERING_TESTS test-empty test-glyph-y-pos + test-rtl-vertical ) diff --git a/testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.png b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.png new file mode 100644 index 000000000..a96c2bfdb Binary files /dev/null and b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.png differ diff --git a/testfiles/rendering_tests/expected_rendering/test-rtl-vertical.png b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical.png new file mode 100644 index 000000000..3dccfca78 Binary files /dev/null and b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical.png differ diff --git a/testfiles/rendering_tests/test-rtl-vertical.svg b/testfiles/rendering_tests/test-rtl-vertical.svg new file mode 100644 index 000000000..feb454ed6 --- /dev/null +++ b/testfiles/rendering_tests/test-rtl-vertical.svg @@ -0,0 +1,25 @@ + + + + + + + أبجد + أبجد + + + RTL text in vertical mode + + -- cgit v1.2.3 From b0e00d7b7fd82a4c4abcd28b467fd83ed6ee6164 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Fri, 18 Aug 2017 00:45:37 +0200 Subject: Fix vertical RTL text with upright orientation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When orientation is upright we don’t want Pango to use the natural gravity of the text (that would be the mixed orientation). This also changes the positioning of combining marks in such case. It is still wrong, however, but it matches Pango output now. --- src/libnrtype/Layout-TNG-Compute.cpp | 4 ++++ .../expected_rendering/test-glyph-y-pos-large.png | Bin 73316 -> 73451 bytes .../expected_rendering/test-glyph-y-pos.png | Bin 13723 -> 13746 bytes .../expected_rendering/test-rtl-vertical-large.png | Bin 50034 -> 55017 bytes .../expected_rendering/test-rtl-vertical.png | Bin 8677 -> 9995 bytes testfiles/rendering_tests/test-rtl-vertical.svg | 1 + 6 files changed, 5 insertions(+) diff --git a/src/libnrtype/Layout-TNG-Compute.cpp b/src/libnrtype/Layout-TNG-Compute.cpp index f812f0c41..504314046 100644 --- a/src/libnrtype/Layout-TNG-Compute.cpp +++ b/src/libnrtype/Layout-TNG-Compute.cpp @@ -1746,6 +1746,10 @@ bool Layout::Calculator::calculate() if( _block_progression == RIGHT_TO_LEFT || _block_progression == LEFT_TO_RIGHT ) { // Vertical text, CJK pango_context_set_base_gravity(_pango_context, PANGO_GRAVITY_EAST); + + if( _flow._blockTextOrientation() != SP_CSS_TEXT_ORIENTATION_MIXED ) { + pango_context_set_gravity_hint(_pango_context, PANGO_GRAVITY_HINT_STRONG); + } } else { // Horizontal text pango_context_set_base_gravity(_pango_context, PANGO_GRAVITY_AUTO); diff --git a/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png index 0bd76e68e..0720e797c 100644 Binary files a/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png and b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png differ diff --git a/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png index 27833a1bb..4104e6560 100644 Binary files a/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png and b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png differ diff --git a/testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.png b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.png index a96c2bfdb..3d8eba4ea 100644 Binary files a/testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.png and b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.png differ diff --git a/testfiles/rendering_tests/expected_rendering/test-rtl-vertical.png b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical.png index 3dccfca78..44676e4d9 100644 Binary files a/testfiles/rendering_tests/expected_rendering/test-rtl-vertical.png and b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical.png differ diff --git a/testfiles/rendering_tests/test-rtl-vertical.svg b/testfiles/rendering_tests/test-rtl-vertical.svg index feb454ed6..e17b94d39 100644 --- a/testfiles/rendering_tests/test-rtl-vertical.svg +++ b/testfiles/rendering_tests/test-rtl-vertical.svg @@ -18,6 +18,7 @@ أبجد أبجد + أبجد RTL text in vertical mode -- cgit v1.2.3