1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
## 03-chinese-inkscape.dpatch by Wolfram Quester <wolfi@sigxcpu.org>
4
## All lines beginning with `## DP:' are a description of the patch.
5
## DP: This is a patch by Luca Bruno to fix a segfault which
6
## DP: occurs in file handling wit locales like zh_CN.
7
## DP: (closes: #487623)
11
Index: src/libnrtype/FontFactory.cpp
12
===================================================================
13
--- src/libnrtype/FontFactory.cpp (revisione 19753)
14
+++ ./src/libnrtype/FontFactory.cpp (copia locale)
25
Index: src/libnrtype/Layout-TNG-Output.cpp
26
===================================================================
27
--- src/libnrtype/Layout-TNG-Output.cpp (revisione 19753)
28
+++ ./src/libnrtype/Layout-TNG-Output.cpp (copia locale)
30
_getGlyphTransformMatrix(glyph_index, &glyph_matrix);
31
NR::Matrix total_transform = glyph_matrix;
32
total_transform *= transform;
33
- NR::Maybe<NR::Rect> glyph_rect = _glyphs[glyph_index].span(this).font->BBox(_glyphs[glyph_index].glyph);
35
- NR::Point bmi = glyph_rect->min(), bma = glyph_rect->max();
36
- NR::Point tlp(bmi[0],bmi[1]), trp(bma[0],bmi[1]), blp(bmi[0],bma[1]), brp(bma[0],bma[1]);
37
- tlp *= total_transform;
38
- trp *= total_transform;
39
- blp *= total_transform;
40
- brp *= total_transform;
41
- *glyph_rect = NR::Rect(tlp,trp);
42
- glyph_rect->expandTo(blp);
43
- glyph_rect->expandTo(brp);
44
- if ( (glyph_rect->min())[0] < bounding_box->x0 ) bounding_box->x0=(glyph_rect->min())[0];
45
- if ( (glyph_rect->max())[0] > bounding_box->x1 ) bounding_box->x1=(glyph_rect->max())[0];
46
- if ( (glyph_rect->min())[1] < bounding_box->y0 ) bounding_box->y0=(glyph_rect->min())[1];
47
- if ( (glyph_rect->max())[1] > bounding_box->y1 ) bounding_box->y1=(glyph_rect->max())[1];
49
+ if(_glyphs[glyph_index].span(this).font) {
50
+ NR::Maybe<NR::Rect> glyph_rect = _glyphs[glyph_index].span(this).font->BBox(_glyphs[glyph_index].glyph);
52
+ NR::Point bmi = glyph_rect->min(), bma = glyph_rect->max();
53
+ NR::Point tlp(bmi[0],bmi[1]), trp(bma[0],bmi[1]), blp(bmi[0],bma[1]), brp(bma[0],bma[1]);
54
+ tlp *= total_transform;
55
+ trp *= total_transform;
56
+ blp *= total_transform;
57
+ brp *= total_transform;
58
+ *glyph_rect = NR::Rect(tlp,trp);
59
+ glyph_rect->expandTo(blp);
60
+ glyph_rect->expandTo(brp);
61
+ if ( (glyph_rect->min())[0] < bounding_box->x0 ) bounding_box->x0=(glyph_rect->min())[0];
62
+ if ( (glyph_rect->max())[0] > bounding_box->x1 ) bounding_box->x1=(glyph_rect->max())[0];
63
+ if ( (glyph_rect->min())[1] < bounding_box->y0 ) bounding_box->y0=(glyph_rect->min())[1];
64
+ if ( (glyph_rect->max())[1] > bounding_box->y1 ) bounding_box->y1=(glyph_rect->max())[1];
70
Index: src/libnrtype/Layout-TNG-Compute.cpp
71
===================================================================
72
--- src/libnrtype/Layout-TNG-Compute.cpp (revisione 19753)
73
+++ ./src/libnrtype/Layout-TNG-Compute.cpp (copia locale)
75
new_span.in_input_stream_item = unbroken_span.input_index;
76
new_span.baseline_shift = _y_offset;
77
new_span.block_progression = _block_progression;
78
- if (_flow._input_stream[unbroken_span.input_index]->Type() == TEXT_SOURCE) {
79
- new_span.font = para.pango_items[unbroken_span.pango_item_index].font;
80
- new_span.font->Ref();
81
+ if ((_flow._input_stream[unbroken_span.input_index]->Type() == TEXT_SOURCE) && (new_span.font = para.pango_items[unbroken_span.pango_item_index].font))
83
+ new_span.font->Ref();
84
new_span.font_size = unbroken_span.font_size;
85
new_span.direction = para.pango_items[unbroken_span.pango_item_index].item->analysis.level & 1 ? RIGHT_TO_LEFT : LEFT_TO_RIGHT;
86
new_span.input_stream_first_character = Glib::ustring::const_iterator(unbroken_span.input_stream_first_character.base() + it_span->start.char_byte);
88
new_glyph.x = x + unbroken_span.glyph_string->glyphs[glyph_index].geometry.x_offset * font_size_multiplier;
89
new_glyph.y = _y_offset + unbroken_span.glyph_string->glyphs[glyph_index].geometry.y_offset * font_size_multiplier;
90
new_glyph.width = unbroken_span.glyph_string->glyphs[glyph_index].geometry.width * font_size_multiplier;
91
- if (new_glyph.width == 0)
92
+ if ((new_glyph.width == 0) && (para.pango_items[unbroken_span.pango_item_index].font))
93
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);
94
// for some reason pango returns zero width for invalid glyph characters (those empty boxes), so go to freetype for the info
97
line_height->setZero();
98
*line_height_multiplier = 1.0;
100
- font->FontMetrics(line_height->ascent, line_height->descent, line_height->leading);
102
+ font->FontMetrics(line_height->ascent, line_height->descent, line_height->leading);
103
*line_height *= font_size;
105
// yet another borked SPStyle member that we're going to have to fix ourselves