summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2017-09-06 08:17:56 +0000
committerTavmjong Bah <tavmjong@free.fr>2017-09-06 08:17:56 +0000
commit391c7f6dcd0838f1d621715c31adec33c07c4507 (patch)
tree3bca6958051685352e1052423308832682b352fb
parentReplace reference to non-existant icon to one that exists. (diff)
parentFix vertical RTL text with upright orientation (diff)
downloadinkscape-391c7f6dcd0838f1d621715c31adec33c07c4507.tar.gz
inkscape-391c7f6dcd0838f1d621715c31adec33c07c4507.zip
Merge branch 'khaledhosny/inkscape-glyph-positioning'
Fixes rendering issues for certain languages and fonts.
-rw-r--r--src/libnrtype/Layout-TNG-Compute.cpp15
-rw-r--r--testfiles/rendering_tests/CMakeLists.txt2
-rw-r--r--testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.pngbin0 -> 73451 bytes
-rw-r--r--testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.pngbin0 -> 13746 bytes
-rw-r--r--testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.pngbin0 -> 55017 bytes
-rw-r--r--testfiles/rendering_tests/expected_rendering/test-rtl-vertical.pngbin0 -> 9995 bytes
-rw-r--r--testfiles/rendering_tests/test-glyph-y-pos.svg26
-rw-r--r--testfiles/rendering_tests/test-rtl-vertical.svg26
8 files changed, 61 insertions, 8 deletions
diff --git a/src/libnrtype/Layout-TNG-Compute.cpp b/src/libnrtype/Layout-TNG-Compute.cpp
index 63364ab34..504314046 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 &para,
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 &para,
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;
@@ -818,12 +818,7 @@ void Layout::Calculator::_outputLine(ParagraphInfo const &para,
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;
}
@@ -1751,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/CMakeLists.txt b/testfiles/rendering_tests/CMakeLists.txt
index 3f838628a..8b77927a0 100644
--- a/testfiles/rendering_tests/CMakeLists.txt
+++ b/testfiles/rendering_tests/CMakeLists.txt
@@ -2,6 +2,8 @@
#add your test here (do not put the .svg extension)
set(RENDERING_TESTS
test-empty
+ test-glyph-y-pos
+ test-rtl-vertical
)
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..0720e797c
--- /dev/null
+++ b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos-large.png
Binary files 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..4104e6560
--- /dev/null
+++ b/testfiles/rendering_tests/expected_rendering/test-glyph-y-pos.png
Binary files 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
new file mode 100644
index 000000000..3d8eba4ea
--- /dev/null
+++ b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical-large.png
Binary files 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..44676e4d9
--- /dev/null
+++ b/testfiles/rendering_tests/expected_rendering/test-rtl-vertical.png
Binary files 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 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+
+<svg width="600" height="600"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ version="1.1"
+ viewBox="0 0 600 600">
+ <style type="text/css">
+ text {
+ font-family: DejaVu Sans;
+ font-size: 36px;
+ }
+ .title {
+ text-anchor: middle;
+ }
+ </style>
+
+ <g>
+ <text x="50" y="200">G̃g̃X̃x̃</text>
+ <text x="300" y="200" style="writing-mode:vertical-lr;">G̃g̃X̃x̃</text>
+ <text x="500" y="200" style="writing-mode:vertical-lr;text-orientation:upright">G̃g̃X̃x̃</text>
+ </g>
+
+ <text class="title" x="50%" y="120">Composed Glyphs</text>
+
+</svg>
diff --git a/testfiles/rendering_tests/test-rtl-vertical.svg b/testfiles/rendering_tests/test-rtl-vertical.svg
new file mode 100644
index 000000000..e17b94d39
--- /dev/null
+++ b/testfiles/rendering_tests/test-rtl-vertical.svg
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+
+<svg width="600" height="600"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ version="1.1"
+ viewBox="0 0 600 600">
+ <style type="text/css">
+ text {
+ font-family: DejaVu Sans;
+ font-size: 36px;
+ }
+ .title {
+ text-anchor: middle;
+ }
+ </style>
+
+ <g>
+ <text x="50" y="200">أبجد</text>
+ <text x="300" y="200" style="writing-mode:vertical-lr;">أبجد</text>
+ <text x="500" y="200" style="writing-mode:vertical-lr;text-orientation:upright">أبجد</text>
+ </g>
+
+ <text class="title" x="50%" y="120">RTL text in vertical mode</text>
+
+</svg>