From: buliabyak Date: Thu, 28 Aug 2008 18:35:16 +0000 (+0000) Subject: null check fixes patch from bug 261475 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8eb2b6772a9db58582162899b9d525211efbc11c;p=inkscape.git null check fixes patch from bug 261475 --- diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 760ee87b6..f2d3be60a 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -821,7 +821,8 @@ font_instance *font_factory::Face(PangoFontDescription *descr, bool canFail) res->Ref(); AddInCache(res); } - res->InitTheFace(); + if(res) + res->InitTheFace(); return res; } diff --git a/src/libnrtype/Layout-TNG-Compute.cpp b/src/libnrtype/Layout-TNG-Compute.cpp index c1897e066..96ea2be7c 100644 --- a/src/libnrtype/Layout-TNG-Compute.cpp +++ b/src/libnrtype/Layout-TNG-Compute.cpp @@ -475,9 +475,9 @@ class Layout::Calculator new_span.in_input_stream_item = unbroken_span.input_index; new_span.baseline_shift = _y_offset; new_span.block_progression = _block_progression; - if (_flow._input_stream[unbroken_span.input_index]->Type() == TEXT_SOURCE) { - new_span.font = para.pango_items[unbroken_span.pango_item_index].font; - new_span.font->Ref(); + if ((_flow._input_stream[unbroken_span.input_index]->Type() == TEXT_SOURCE) && (new_span.font = para.pango_items[unbroken_span.pango_item_index].font)) + { + new_span.font->Ref(); new_span.font_size = unbroken_span.font_size; new_span.direction = para.pango_items[unbroken_span.pango_item_index].item->analysis.level & 1 ? RIGHT_TO_LEFT : LEFT_TO_RIGHT; new_span.input_stream_first_character = Glib::ustring::const_iterator(unbroken_span.input_stream_first_character.base() + it_span->start.char_byte); @@ -562,7 +562,7 @@ class Layout::Calculator new_glyph.x = x + unbroken_span.glyph_string->glyphs[glyph_index].geometry.x_offset * font_size_multiplier; new_glyph.y = _y_offset + unbroken_span.glyph_string->glyphs[glyph_index].geometry.y_offset * font_size_multiplier; new_glyph.width = unbroken_span.glyph_string->glyphs[glyph_index].geometry.width * font_size_multiplier; - if (new_glyph.width == 0) + if ((new_glyph.width == 0) && (para.pango_items[unbroken_span.pango_item_index].font)) new_glyph.width = new_span.font_size * para.pango_items[unbroken_span.pango_item_index].font->Advance(unbroken_span.glyph_string->glyphs[glyph_index].glyph, false); // for some reason pango returns zero width for invalid glyph characters (those empty boxes), so go to freetype for the info } @@ -903,7 +903,8 @@ void Layout::Calculator::_computeFontLineHeight(font_instance *font, double font line_height->setZero(); *line_height_multiplier = 1.0; } - font->FontMetrics(line_height->ascent, line_height->descent, line_height->leading); + else + font->FontMetrics(line_height->ascent, line_height->descent, line_height->leading); *line_height *= font_size; // yet another borked SPStyle member that we're going to have to fix ourselves diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index aa3875048..a3857b476 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -116,22 +116,24 @@ void Layout::getBoundingBox(NRRect *bounding_box, NR::Matrix const &transform, i _getGlyphTransformMatrix(glyph_index, &glyph_matrix); NR::Matrix total_transform = glyph_matrix; total_transform *= transform; - boost::optional glyph_rect = _glyphs[glyph_index].span(this).font->BBox(_glyphs[glyph_index].glyph); - if (glyph_rect) { - NR::Point bmi = glyph_rect->min(), bma = glyph_rect->max(); - NR::Point tlp(bmi[0],bmi[1]), trp(bma[0],bmi[1]), blp(bmi[0],bma[1]), brp(bma[0],bma[1]); - tlp *= total_transform; - trp *= total_transform; - blp *= total_transform; - brp *= total_transform; - *glyph_rect = NR::Rect(tlp,trp); - glyph_rect->expandTo(blp); - glyph_rect->expandTo(brp); - if ( (glyph_rect->min())[0] < bounding_box->x0 ) bounding_box->x0=(glyph_rect->min())[0]; - if ( (glyph_rect->max())[0] > bounding_box->x1 ) bounding_box->x1=(glyph_rect->max())[0]; - if ( (glyph_rect->min())[1] < bounding_box->y0 ) bounding_box->y0=(glyph_rect->min())[1]; - if ( (glyph_rect->max())[1] > bounding_box->y1 ) bounding_box->y1=(glyph_rect->max())[1]; - } + if(_glyphs[glyph_index].span(this).font) { + boost::optional glyph_rect = _glyphs[glyph_index].span(this).font->BBox(_glyphs[glyph_index].glyph); + if (glyph_rect) { + NR::Point bmi = glyph_rect->min(), bma = glyph_rect->max(); + NR::Point tlp(bmi[0],bmi[1]), trp(bma[0],bmi[1]), blp(bmi[0],bma[1]), brp(bma[0],bma[1]); + tlp *= total_transform; + trp *= total_transform; + blp *= total_transform; + brp *= total_transform; + *glyph_rect = NR::Rect(tlp,trp); + glyph_rect->expandTo(blp); + glyph_rect->expandTo(brp); + if ( (glyph_rect->min())[0] < bounding_box->x0 ) bounding_box->x0=(glyph_rect->min())[0]; + if ( (glyph_rect->max())[0] > bounding_box->x1 ) bounding_box->x1=(glyph_rect->max())[0]; + if ( (glyph_rect->min())[1] < bounding_box->y0 ) bounding_box->y0=(glyph_rect->min())[1]; + if ( (glyph_rect->max())[1] > bounding_box->y1 ) bounding_box->y1=(glyph_rect->max())[1]; + } + } } }