summaryrefslogtreecommitdiffstats
path: root/src/libnrtype
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2015-10-15 12:14:01 +0000
committertavmjong-free <tavmjong@free.fr>2015-10-15 12:14:01 +0000
commitd929999b79640a8b1425a999483d782883035d3b (patch)
tree189f81846ca267597a1f9fe708612828fc5ac55c /src/libnrtype
parentAdd new 'writing-mode' values, remove 'block-progression', fix a few typos. (diff)
downloadinkscape-d929999b79640a8b1425a999483d782883035d3b.tar.gz
inkscape-d929999b79640a8b1425a999483d782883035d3b.zip
Simplify code after removal of 'block-progression'.
(bzr r14417)
Diffstat (limited to 'src/libnrtype')
-rw-r--r--src/libnrtype/Layout-TNG-Input.cpp29
1 files changed, 13 insertions, 16 deletions
diff --git a/src/libnrtype/Layout-TNG-Input.cpp b/src/libnrtype/Layout-TNG-Input.cpp
index 9c2fc5c11..77480cebe 100644
--- a/src/libnrtype/Layout-TNG-Input.cpp
+++ b/src/libnrtype/Layout-TNG-Input.cpp
@@ -172,27 +172,24 @@ float Layout::InputStreamTextSource::styleComputeFontSize() const
return medium_font_size * inherit_multiplier;
}
-static const Layout::EnumConversionItem enum_convert_spstyle_writing_mode_to_direction[] = {
- {SP_CSS_WRITING_MODE_LR_TB, Layout::TOP_TO_BOTTOM},
- {SP_CSS_WRITING_MODE_RL_TB, Layout::TOP_TO_BOTTOM},
- {SP_CSS_WRITING_MODE_TB_RL, Layout::RIGHT_TO_LEFT},
- {SP_CSS_WRITING_MODE_TB_LR, Layout::LEFT_TO_RIGHT}};
-
Layout::Direction Layout::InputStreamTextSource::styleGetBlockProgression() const
{
- // this function shouldn't be necessary, but since style.cpp doesn't support
- // shorthand properties yet, it is.
- SPStyle const *this_style = style;
+ switch( style->writing_mode.computed ) {
- for ( ; ; ) {
- if (this_style->writing_mode.set)
- return (Layout::Direction)_enum_converter(this_style->writing_mode.computed, enum_convert_spstyle_writing_mode_to_direction, sizeof(enum_convert_spstyle_writing_mode_to_direction)/sizeof(enum_convert_spstyle_writing_mode_to_direction[0]));
- if (this_style->object == NULL || this_style->object->parent == NULL) break;
- this_style = this_style->object->parent->style;
- if (this_style == NULL) break;
- }
+ case SP_CSS_WRITING_MODE_LR_TB:
+ case SP_CSS_WRITING_MODE_RL_TB:
return TOP_TO_BOTTOM;
+
+ case SP_CSS_WRITING_MODE_TB_RL:
+ return RIGHT_TO_LEFT;
+
+ case SP_CSS_WRITING_MODE_TB_LR:
+ return LEFT_TO_RIGHT;
+ default:
+ std::cerr << "Layout::InputTextStream::styleGetBlockProgression: invalid writing mode." << std::endl;
+ }
+ return TOP_TO_BOTTOM;
}
static Layout::Alignment text_anchor_to_alignment(unsigned anchor, Layout::Direction para_direction)