diff options
| author | Liam P. White <inkscapebrony@gmail.com> | 2014-11-24 03:07:36 +0000 |
|---|---|---|
| committer | Liam P. White <inkscapebrony@gmail.com> | 2014-11-24 03:07:36 +0000 |
| commit | f12a73dd77175bd6126319f3a698eb16193e7b68 (patch) | |
| tree | b5a59803e5bd212f0e355faa029295aa79d47a0e /src/libnrtype | |
| parent | Update to trunk r13690 (diff) | |
| parent | Extensions: try to calculate the SVG unit (diff) | |
| download | inkscape-f12a73dd77175bd6126319f3a698eb16193e7b68.tar.gz inkscape-f12a73dd77175bd6126319f3a698eb16193e7b68.zip | |
Update to trunk r13750
(bzr r13341.5.23)
Diffstat (limited to 'src/libnrtype')
| -rw-r--r-- | src/libnrtype/Layout-TNG-Compute.cpp | 53 | ||||
| -rw-r--r-- | src/libnrtype/Layout-TNG.h | 1 |
2 files changed, 35 insertions, 19 deletions
diff --git a/src/libnrtype/Layout-TNG-Compute.cpp b/src/libnrtype/Layout-TNG-Compute.cpp index 7eb53446f..bd1acbe46 100644 --- a/src/libnrtype/Layout-TNG-Compute.cpp +++ b/src/libnrtype/Layout-TNG-Compute.cpp @@ -704,6 +704,7 @@ static void dumpUnbrokenSpans(ParagraphInfo *para){ // create the Layout::Character(s) double advance_width = new_glyph.width; if (newcluster){ + newcluster = 0; // find where the text ends for this log_cluster end_byte = it_span->start.iter_span->text_bytes; // Upper limit for(int next_glyph_index = glyph_index+1; next_glyph_index < unbroken_span.glyph_string->num_glyphs; next_glyph_index++){ @@ -751,18 +752,15 @@ static void dumpUnbrokenSpans(ParagraphInfo *para){ log_cluster_size_chars--; } - if (newcluster){ - advance_width *= direction_sign; - if (new_span.direction != para.direction) { - counter_directional_width_remaining -= advance_width; - x -= advance_width; - x_in_span_last -= advance_width; - } else { - x += advance_width; - x_in_span_last += advance_width; - } + advance_width *= direction_sign; + if (new_span.direction != para.direction) { + counter_directional_width_remaining -= advance_width; + x -= advance_width; + x_in_span_last -= advance_width; + } else { + x += advance_width; + x_in_span_last += advance_width; } - newcluster = 0; } } else if (_flow._input_stream[unbroken_span.input_index]->Type() == CONTROL_CODE) { x += static_cast<InputStreamControlCode const *>(_flow._input_stream[unbroken_span.input_index])->width; @@ -1080,7 +1078,9 @@ void Layout::Calculator::_computeFontLineHeight(font_instance *font, double font bool compareGlyphWidth(const PangoGlyphInfo &a, const PangoGlyphInfo &b) { - return (a.geometry.width > b.geometry.width); + bool retval = false; + if ( b.geometry.width == 0 && (a.geometry.width > 0))retval = true; + return (retval); } @@ -1227,13 +1227,27 @@ unsigned Layout::Calculator::_buildSpansForPara(ParagraphInfo *para) const /* CAREFUL, within a log_cluster the order of glyphs may not map 1:1, or even in the same order, to the original unicode characters!!! Among - other things, diacritical mark glyphs can end up in front of the base - character. That makes determining kerning, even approximately, difficult - later on. To resolve this somewhat sort the glyphs with the same - log_cluster into descending order by width. In theory there should be 1 - that is nonzero, and N that are zero. The order of the zero width ones - does not matter. Sort the glyphs before copying. If ligatures other than with - Mark, nonspacing are ever implemented in Pango this will screw up, for instance + other things, diacritical mark glyphs can end up sequentially in front of the base + character glyph. That makes determining kerning, even approximately, difficult + later on. + + To resolve this to the extent possible sort the glyphs within the same + log_cluster into descending order by width in a special manner before copying. Diacritical marks + and similar have zero width and the glyph they modify has nonzero width. The order + of the zero width ones does not matter. A logical cluster is sorted into sequential order + [base] [zw_modifier1] [zw_modifier2] + where all the modifiers have zero width and the base does not. This works for languages like Hebrew. + + Pango also creates log clusters for languages like Telugu having many glyphs with nonzero widths. + Since these are nonzero, their order is not modified. + + If some language mixes these modes, having a log cluster having something like + [base1] [zw_modifier1] [base2] [zw_modifier2] + the result will be incorrect: + base1] [base2] [zw_modifier1] [zw_modifier2] + + + If ligatures other than with Mark, nonspacing are ever implemented in Pango this will screw up, for instance changing "fi" to "if". */ if(j - i){ @@ -1258,6 +1272,7 @@ unsigned Layout::Calculator::_buildSpansForPara(ParagraphInfo *para) const while( (j < nglyphs-1) && (new_span.glyph_string->log_clusters[j+1] == new_span.glyph_string->log_clusters[i]) )j++; + /* see note in preceding section */ if(j - i){ std::sort(&(new_span.glyph_string->glyphs[i]), &(new_span.glyph_string->glyphs[j+1]), compareGlyphWidth); } diff --git a/src/libnrtype/Layout-TNG.h b/src/libnrtype/Layout-TNG.h index efb5ebc24..fd5bbfaef 100644 --- a/src/libnrtype/Layout-TNG.h +++ b/src/libnrtype/Layout-TNG.h @@ -481,6 +481,7 @@ public: from a call to appendText() then the optional \a text_iterator parameter is set to point to the actual character, otherwise \a text_iterator is unaltered. */ + // TODO FIXME a void* cookie is a very unsafe design, and C++ makes it unnecessary. void getSourceOfCharacter(iterator const &it, void **source_cookie, Glib::ustring::iterator *text_iterator = NULL) const; /** For latin text, the left side of the character, on the baseline */ |
