summaryrefslogtreecommitdiffstats
path: root/src/libnrtype
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-10-16 10:24:04 +0000
committerjabiertxof <jabier.arraiza@marker.es>2015-10-16 10:24:04 +0000
commitc698002c4598209f6c4ccc0a86f89afb54f224a2 (patch)
treecf0c89fdc713f96eba2f760b909c0c648eb075b4 /src/libnrtype
parentworking in dimension to item (diff)
parentupdate to trunk (diff)
downloadinkscape-c698002c4598209f6c4ccc0a86f89afb54f224a2.tar.gz
inkscape-c698002c4598209f6c4ccc0a86f89afb54f224a2.zip
update to current measure code
(bzr r14393.2.1)
Diffstat (limited to 'src/libnrtype')
-rw-r--r--src/libnrtype/Layout-TNG-Compute.cpp28
-rw-r--r--src/libnrtype/Layout-TNG-Input.cpp42
2 files changed, 38 insertions, 32 deletions
diff --git a/src/libnrtype/Layout-TNG-Compute.cpp b/src/libnrtype/Layout-TNG-Compute.cpp
index d81e1b6b4..c4b0a5bee 100644
--- a/src/libnrtype/Layout-TNG-Compute.cpp
+++ b/src/libnrtype/Layout-TNG-Compute.cpp
@@ -24,15 +24,31 @@ namespace Text {
#define TRACE(_args) IFTRACE(g_print _args)
// ******* enum conversion tables
+
+// These enums are probably from the SVG 1.0 era where one could interpret 'writing-mode' as setting direction.
+// SVG 1.1 makes it clear that 'direction' should be used. 'direction' has only two values 'ltr' and 'rtl'.
+// The first two values for the 'writing-mode' enum just happen to match the first two value of 'direction' so the
+// existing code worked when 'writing-mode' was changed to 'direction'.
+// static Layout::EnumConversionItem const enum_convert_spstyle_direction_to_pango_direction[] = {
+// {SP_CSS_WRITING_MODE_LR_TB, PANGO_DIRECTION_LTR},
+// {SP_CSS_WRITING_MODE_RL_TB, PANGO_DIRECTION_RTL},
+// {SP_CSS_WRITING_MODE_TB_LR, PANGO_DIRECTION_LTR}}; // this is correct
+
+// static Layout::EnumConversionItem const enum_convert_spstyle_direction_to_my_direction[] = {
+// {SP_CSS_WRITING_MODE_LR_TB, Layout::LEFT_TO_RIGHT},
+// {SP_CSS_WRITING_MODE_RL_TB, Layout::RIGHT_TO_LEFT},
+// {SP_CSS_WRITING_MODE_TB_LR, Layout::LEFT_TO_RIGHT}}; // this is correct
+
+// Proper 'direction' enums
static Layout::EnumConversionItem const enum_convert_spstyle_direction_to_pango_direction[] = {
- {SP_CSS_WRITING_MODE_LR_TB, PANGO_DIRECTION_LTR},
- {SP_CSS_WRITING_MODE_RL_TB, PANGO_DIRECTION_RTL},
- {SP_CSS_WRITING_MODE_TB_LR, PANGO_DIRECTION_LTR}}; // this is correct
+ {SP_CSS_DIRECTION_LTR, PANGO_DIRECTION_LTR},
+ {SP_CSS_DIRECTION_RTL, PANGO_DIRECTION_RTL}};
static Layout::EnumConversionItem const enum_convert_spstyle_direction_to_my_direction[] = {
- {SP_CSS_WRITING_MODE_LR_TB, Layout::LEFT_TO_RIGHT},
- {SP_CSS_WRITING_MODE_RL_TB, Layout::RIGHT_TO_LEFT},
- {SP_CSS_WRITING_MODE_TB_LR, Layout::LEFT_TO_RIGHT}}; // this is correct
+ {SP_CSS_DIRECTION_LTR, Layout::LEFT_TO_RIGHT},
+ {SP_CSS_DIRECTION_RTL, Layout::RIGHT_TO_LEFT}};
+
+
/** \brief private to Layout. Does the real work of text flowing.
diff --git a/src/libnrtype/Layout-TNG-Input.cpp b/src/libnrtype/Layout-TNG-Input.cpp
index 84f3f260e..77480cebe 100644
--- a/src/libnrtype/Layout-TNG-Input.cpp
+++ b/src/libnrtype/Layout-TNG-Input.cpp
@@ -172,43 +172,33 @@ float Layout::InputStreamTextSource::styleComputeFontSize() const
return medium_font_size * inherit_multiplier;
}
-static const Layout::EnumConversionItem enum_convert_spstyle_block_progression_to_direction[] = {
- {SP_CSS_BLOCK_PROGRESSION_TB, Layout::TOP_TO_BOTTOM},
- {SP_CSS_BLOCK_PROGRESSION_LR, Layout::LEFT_TO_RIGHT},
- {SP_CSS_BLOCK_PROGRESSION_RL, Layout::RIGHT_TO_LEFT}};
-
-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->block_progression.set)
- return (Layout::Direction)_enum_converter(this_style->block_progression.computed, enum_convert_spstyle_block_progression_to_direction, sizeof(enum_convert_spstyle_block_progression_to_direction)/sizeof(enum_convert_spstyle_block_progression_to_direction[0]));
- 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*/)
+static Layout::Alignment text_anchor_to_alignment(unsigned anchor, Layout::Direction para_direction)
{
switch (anchor) {
default:
- case SP_CSS_TEXT_ANCHOR_START: return Layout::LEFT;
+ case SP_CSS_TEXT_ANCHOR_START: return para_direction == Layout::LEFT_TO_RIGHT ? Layout::LEFT : Layout::RIGHT;
case SP_CSS_TEXT_ANCHOR_MIDDLE: return Layout::CENTER;
- case SP_CSS_TEXT_ANCHOR_END: return Layout::RIGHT;
+ case SP_CSS_TEXT_ANCHOR_END: return para_direction == Layout::LEFT_TO_RIGHT ? Layout::RIGHT : Layout::LEFT;
}
}