* Released under GNU GPL, read the file 'COPYING' for more information
*/
+#define PANGO_ENABLE_ENGINE
+
#include <gtk/gtkversion.h>
#include "Layout-TNG.h"
#include "style.h"
#include "svg/svg-length.h"
#include "sp-object.h"
+#include "sp-string.h"
#include "FontFactory.h"
+#if !PANGO_VERSION_CHECK(1,24,0)
+#define PANGO_WEIGHT_THIN static_cast<PangoWeight>(100)
+#define PANGO_WEIGHT_BOOK static_cast<PangoWeight>(380)
+#define PANGO_WEIGHT_MEDIUM static_cast<PangoWeight>(500)
+#define PANGO_WEIGHT_ULTRAHEAVY static_cast<PangoWeight>(1000)
+#endif
+
namespace Inkscape {
namespace Text {
_copyInputVector(optional_attributes->dx, optional_attributes_offset, &new_source->dx, new_source->text_length);
_copyInputVector(optional_attributes->dy, optional_attributes_offset, &new_source->dy, new_source->text_length);
_copyInputVector(optional_attributes->rotate, optional_attributes_offset, &new_source->rotate, new_source->text_length);
+ if (!optional_attributes->rotate.empty() && optional_attributes_offset >= optional_attributes->rotate.size()) {
+ SVGLength last_rotate;
+ last_rotate = 0.f;
+ for (std::vector<SVGLength>::const_iterator it = optional_attributes->rotate.begin() ; it != optional_attributes->rotate.end() ; ++it)
+ if (it->_set)
+ last_rotate = *it;
+ new_source->rotate.resize(1, last_rotate);
+ }
}
_input_stream.push_back(new_source);
}
}
}
- if (this_style->object->parent == NULL) break;
+ if (this_style->object == NULL || this_style->object->parent == NULL) break;
this_style = this_style->object->parent->style;
if (this_style == NULL) break;
}
@@ -169,7 +187,7 @@ Layout::Direction Layout::InputStreamTextSource::styleGetBlockProgression() cons
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->parent == NULL) break;
+ if (this_style->object == NULL || this_style->object->parent == NULL) break;
this_style = this_style->object->parent->style;
if (this_style == NULL) break;
}
@@ -177,13 +195,13 @@ Layout::Direction Layout::InputStreamTextSource::styleGetBlockProgression() cons
}
-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 para_direction == Layout::LEFT_TO_RIGHT ? Layout::LEFT : Layout::RIGHT;
+ case SP_CSS_TEXT_ANCHOR_START: return Layout::LEFT;
case SP_CSS_TEXT_ANCHOR_MIDDLE: return Layout::CENTER;
- case SP_CSS_TEXT_ANCHOR_END: return para_direction == Layout::LEFT_TO_RIGHT ? Layout::RIGHT : Layout::LEFT;
+ case SP_CSS_TEXT_ANCHOR_END: return Layout::RIGHT;
}
}
@@ -213,7 +231,7 @@ Layout::Alignment Layout::InputStreamTextSource::styleGetAlignment(Layout::Direc
}
if (this_style->text_anchor.set)
return text_anchor_to_alignment(this_style->text_anchor.computed, para_direction);
- if (this_style->object->parent == NULL) break;
+ if (this_style->object == NULL || this_style->object->parent == NULL) break;
this_style = this_style->object->parent->style;
if (this_style == NULL) break;
}
@@ -226,18 +244,16 @@ static const Layout::EnumConversionItem enum_convert_spstyle_style_to_pango_styl
{SP_CSS_FONT_STYLE_OBLIQUE, PANGO_STYLE_OBLIQUE}};
static const Layout::EnumConversionItem enum_convert_spstyle_weight_to_pango_weight[] = {
+ // NB: The Pango web page calls 500 "the normal font" but both CSS2 and the Pango
+ // enumeration define 400 as normal.
{SP_CSS_FONT_WEIGHT_NORMAL, PANGO_WEIGHT_NORMAL},
- {SP_CSS_FONT_WEIGHT_100, PANGO_WEIGHT_ULTRALIGHT},
+ {SP_CSS_FONT_WEIGHT_BOLD,PANGO_WEIGHT_BOLD},
+ {SP_CSS_FONT_WEIGHT_100, PANGO_WEIGHT_THIN},
{SP_CSS_FONT_WEIGHT_200, PANGO_WEIGHT_ULTRALIGHT},
{SP_CSS_FONT_WEIGHT_300, PANGO_WEIGHT_LIGHT},
{SP_CSS_FONT_WEIGHT_400, PANGO_WEIGHT_NORMAL},
-#if GTK_CHECK_VERSION(2,6,0)
- {SP_CSS_FONT_WEIGHT_500, PANGO_WEIGHT_SEMIBOLD},
-#else
- {SP_CSS_FONT_WEIGHT_500, PANGO_WEIGHT_NORMAL},
-#endif
- {SP_CSS_FONT_WEIGHT_600, PANGO_WEIGHT_BOLD},
- {SP_CSS_FONT_WEIGHT_BOLD,PANGO_WEIGHT_BOLD},
+ {SP_CSS_FONT_WEIGHT_500, PANGO_WEIGHT_MEDIUM},
+ {SP_CSS_FONT_WEIGHT_600, PANGO_WEIGHT_SEMIBOLD},
{SP_CSS_FONT_WEIGHT_700, PANGO_WEIGHT_BOLD},
{SP_CSS_FONT_WEIGHT_800, PANGO_WEIGHT_ULTRABOLD},
{SP_CSS_FONT_WEIGHT_900, PANGO_WEIGHT_HEAVY}};