summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2015-11-03 10:46:37 +0000
committertavmjong-free <tavmjong@free.fr>2015-11-03 10:46:37 +0000
commitead60e7c6226f24be5d11b550cea287fe2ddee11 (patch)
tree1fd8b93311ad369dd42da6f27ae3166232c133c0 /src
parentImplement 'text-orientation' with user interface. Update 'writing-mode', addi... (diff)
downloadinkscape-ead60e7c6226f24be5d11b550cea287fe2ddee11.tar.gz
inkscape-ead60e7c6226f24be5d11b550cea287fe2ddee11.zip
Vertical baseline depends on block 'text-orientation' value.
(bzr r14430.1.2)
Diffstat (limited to 'src')
-rw-r--r--src/libnrtype/Layout-TNG-Compute.cpp37
-rw-r--r--src/libnrtype/Layout-TNG-Input.cpp5
-rw-r--r--src/libnrtype/Layout-TNG.h9
3 files changed, 43 insertions, 8 deletions
diff --git a/src/libnrtype/Layout-TNG-Compute.cpp b/src/libnrtype/Layout-TNG-Compute.cpp
index 4201d052c..1fb0e2d8d 100644
--- a/src/libnrtype/Layout-TNG-Compute.cpp
+++ b/src/libnrtype/Layout-TNG-Compute.cpp
@@ -700,10 +700,20 @@ static void dumpUnbrokenSpans(ParagraphInfo *para){
new_glyph.x = current_x + unbroken_span_glyph_info->geometry.x_offset * font_size_multiplier;
- new_glyph.y =_y_offset +
- unbroken_span.baseline_shift +
- (unbroken_span_glyph_info->geometry.y_offset * font_size_multiplier)
- + 0.5 * (new_span.line_height.descent - new_span.line_height.ascent);
+ // Baseline is determined by overall block (i.e. <text>) 'text-orientation' value.
+ // (It's actually a bit more complicated but this should handle most cases.)
+ if( _flow._blockTextOrientation() == SP_CSS_TEXT_ORIENTATION_SIDEWAYS ) {
+ // Baseline is alphabetic
+ new_glyph.y =_y_offset +
+ unbroken_span.baseline_shift +
+ (unbroken_span_glyph_info->geometry.y_offset * font_size_multiplier);
+ } else {
+ // Baseline is center
+ new_glyph.y =_y_offset +
+ unbroken_span.baseline_shift +
+ (unbroken_span_glyph_info->geometry.y_offset * font_size_multiplier) +
+ 0.5 * (new_span.line_height.descent - new_span.line_height.ascent);
+ }
new_glyph.width = new_span.font_size * para.pango_items[unbroken_span.pango_item_index].font->Advance(unbroken_span_glyph_info->glyph, false);
@@ -713,10 +723,21 @@ static void dumpUnbrokenSpans(ParagraphInfo *para){
new_glyph.x = current_x + unbroken_span_glyph_info->geometry.x_offset * font_size_multiplier +
new_span.line_height.ascent;
- new_glyph.y = _y_offset + // Does baseline shift have any meaning here?
- unbroken_span.baseline_shift +
- (unbroken_span_glyph_info->geometry.y_offset -
- unbroken_span_glyph_info->geometry.width * 0.5) * font_size_multiplier;
+ // Baseline is determined by overall block (i.e. <text>) 'text-orientation' value.
+ // (It's actually a bit more complicated but this should handle most cases.)
+ if( _flow._blockTextOrientation() == SP_CSS_TEXT_ORIENTATION_SIDEWAYS ) {
+ // Baseline is alphabetic .. sideways
+ new_glyph.y =_y_offset +
+ unbroken_span.baseline_shift +
+ (unbroken_span_glyph_info->geometry.y_offset * font_size_multiplier) -
+ new_span.line_height.descent;
+ } else {
+ // Baseline is center
+ new_glyph.y = _y_offset + // Does baseline shift have any meaning here?
+ unbroken_span.baseline_shift +
+ (unbroken_span_glyph_info->geometry.y_offset -
+ unbroken_span_glyph_info->geometry.width * 0.5) * font_size_multiplier;
+ }
new_glyph.width = new_span.font_size * para.pango_items[unbroken_span.pango_item_index].font->Advance(unbroken_span_glyph_info->glyph, true);
if( new_glyph.width == 0 ) {
diff --git a/src/libnrtype/Layout-TNG-Input.cpp b/src/libnrtype/Layout-TNG-Input.cpp
index 77480cebe..d99433adf 100644
--- a/src/libnrtype/Layout-TNG-Input.cpp
+++ b/src/libnrtype/Layout-TNG-Input.cpp
@@ -192,6 +192,11 @@ Layout::Direction Layout::InputStreamTextSource::styleGetBlockProgression() cons
return TOP_TO_BOTTOM;
}
+SPCSSTextOrientation Layout::InputStreamTextSource::styleGetTextOrientation() const
+{
+ return ((SPCSSTextOrientation)style->text_orientation.computed);
+}
+
static Layout::Alignment text_anchor_to_alignment(unsigned anchor, Layout::Direction para_direction)
{
switch (anchor) {
diff --git a/src/libnrtype/Layout-TNG.h b/src/libnrtype/Layout-TNG.h
index 66cc96d3f..6875fa14a 100644
--- a/src/libnrtype/Layout-TNG.h
+++ b/src/libnrtype/Layout-TNG.h
@@ -700,6 +700,7 @@ private:
PangoFontDescription *styleGetFontDescription() const;
font_instance *styleGetFontInstance() const;
Direction styleGetBlockProgression() const;
+ SPCSSTextOrientation styleGetTextOrientation() const;
Alignment styleGetAlignment(Direction para_direction, bool try_text_align) const;
};
@@ -738,6 +739,14 @@ private:
return TOP_TO_BOTTOM;
}
+ /** The overall text-orientation of the whole flow. */
+ inline SPCSSTextOrientation _blockTextOrientation() const
+ {
+ if(!_input_stream.empty())
+ return static_cast<InputStreamTextSource*>(_input_stream.front())->styleGetTextOrientation();
+ return SP_CSS_TEXT_ORIENTATION_MIXED;
+ }
+
/** so that LEFT_TO_RIGHT == RIGHT_TO_LEFT but != TOP_TO_BOTTOM */
static bool _directions_are_orthogonal(Direction d1, Direction d2);