X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Flibnrtype%2FLayout-TNG-Input.cpp;h=dcf76b3bddc17d171339fbe8a7ffa1f62e531ef1;hb=c87b166f1c3ba0af0656b0b634d1a444e6a316ff;hp=c8dc41e953234d8a5e13d44856e7d02af593edce;hpb=4ffc73d2f7ced0101455af195be98c7f45d9efb2;p=inkscape.git diff --git a/src/libnrtype/Layout-TNG-Input.cpp b/src/libnrtype/Layout-TNG-Input.cpp index c8dc41e95..dcf76b3bd 100755 --- a/src/libnrtype/Layout-TNG-Input.cpp +++ b/src/libnrtype/Layout-TNG-Input.cpp @@ -8,6 +8,8 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ + +#include #include "Layout-TNG.h" #include "style.h" #include "svg/svg-length.h" @@ -138,7 +140,7 @@ float Layout::InputStreamTextSource::styleComputeFontSize() const } } } - 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; } @@ -167,7 +169,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; } @@ -175,13 +177,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; } } @@ -211,7 +213,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; } @@ -229,7 +231,11 @@ static const Layout::EnumConversionItem enum_convert_spstyle_weight_to_pango_wei {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_700, PANGO_WEIGHT_BOLD}, @@ -284,14 +290,18 @@ PangoFontDescription *Layout::InputStreamTextSource::styleGetFontDescription() c pango_font_description_set_family(descr,family.c_str()); pango_font_description_set_weight(descr,(PangoWeight)_enum_converter(style->font_weight.computed, enum_convert_spstyle_weight_to_pango_weight, sizeof(enum_convert_spstyle_weight_to_pango_weight)/sizeof(enum_convert_spstyle_weight_to_pango_weight[0]))); - pango_font_description_set_stretch(descr,(PangoStretch)_enum_converter(style->font_stretch.computed, enum_convert_spstyle_stretch_to_pango_stretch, sizeof(enum_convert_spstyle_stretch_to_pango_stretch)/sizeof(enum_convert_spstyle_stretch_to_pango_stretch[0]))); pango_font_description_set_style(descr,(PangoStyle)_enum_converter(style->font_style.computed, enum_convert_spstyle_style_to_pango_style, sizeof(enum_convert_spstyle_style_to_pango_style)/sizeof(enum_convert_spstyle_style_to_pango_style[0]))); pango_font_description_set_variant(descr,(PangoVariant)_enum_converter(style->font_variant.computed, enum_convert_spstyle_variant_to_pango_variant, sizeof(enum_convert_spstyle_variant_to_pango_variant)/sizeof(enum_convert_spstyle_variant_to_pango_variant[0]))); #ifdef USE_PANGO_WIN32 // damn Pango fudges the size, so we need to unfudge. See source of pango_win32_font_map_init() pango_font_description_set_size(descr, (int) ((font_factory::Default())->fontSize*PANGO_SCALE*72/GetDeviceCaps(pango_win32_get_dc(),LOGPIXELSY))); // mandatory huge size (hinting workaround) + // we don't set stretch on Win32, because pango-win32 has no concept of it + // (Windows doesn't really provide any useful field it could use). + // If we did set stretch, then any text with a font-stretch attribute would + // end up falling back to Arial. #else pango_font_description_set_size(descr, (int) ((font_factory::Default())->fontSize*PANGO_SCALE)); // mandatory huge size (hinting workaround) + pango_font_description_set_stretch(descr,(PangoStretch)_enum_converter(style->font_stretch.computed, enum_convert_spstyle_stretch_to_pango_stretch, sizeof(enum_convert_spstyle_stretch_to_pango_stretch)/sizeof(enum_convert_spstyle_stretch_to_pango_stretch[0]))); #endif return descr; }