summaryrefslogtreecommitdiffstats
path: root/src/libnrtype
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2016-12-24 15:41:34 +0000
committertavmjong-free <tavmjong@free.fr>2016-12-24 15:41:34 +0000
commitd19b21f387be9c5516d020679e97d077d8df8242 (patch)
tree4280956d3a5f682c5d59da9f7db3e6ff14cc6850 /src/libnrtype
parenti18n. Flood autogap list not correctly translated at runtime. (diff)
downloadinkscape-d19b21f387be9c5516d020679e97d077d8df8242.tar.gz
inkscape-d19b21f387be9c5516d020679e97d077d8df8242.zip
Line space properly blank lines that have their own styling (i.e. empty tspan).
(bzr r15352)
Diffstat (limited to 'src/libnrtype')
-rw-r--r--src/libnrtype/Layout-TNG-Compute.cpp30
-rw-r--r--src/libnrtype/Layout-TNG-Output.cpp17
-rw-r--r--src/libnrtype/Layout-TNG.h8
3 files changed, 50 insertions, 5 deletions
diff --git a/src/libnrtype/Layout-TNG-Compute.cpp b/src/libnrtype/Layout-TNG-Compute.cpp
index 6b1aba53f..e6da9ba63 100644
--- a/src/libnrtype/Layout-TNG-Compute.cpp
+++ b/src/libnrtype/Layout-TNG-Compute.cpp
@@ -1182,10 +1182,34 @@ unsigned Layout::Calculator::_buildSpansForPara(ParagraphInfo *para) const
for(input_index = para->first_input_index ; input_index < _flow._input_stream.size() ; input_index++) {
if (_flow._input_stream[input_index]->Type() == CONTROL_CODE) {
Layout::InputStreamControlCode const *control_code = static_cast<Layout::InputStreamControlCode const *>(_flow._input_stream[input_index]);
+
if ( control_code->code == SHAPE_BREAK
- || control_code->code == PARAGRAPH_BREAK)
+ || control_code->code == PARAGRAPH_BREAK) {
+
+ // Add span to be used to calculate line spacing of blank lines.
+ UnbrokenSpan new_span;
+ new_span.pango_item_index = -1;
+ new_span.input_index = input_index;
+
+ // No pango object, so find font and line height ourselves.
+ SPObject * object = static_cast<SPObject *>(control_code->source_cookie);
+ if (object) {
+ SPStyle * style = object->style;
+ if (style) {
+ new_span.font_size = style->font_size.computed * _flow.getTextLengthMultiplierDue();
+ font_factory * factory = font_factory::Default();
+ font_instance * font = factory->FaceFromStyle( style );
+ new_span.line_height_multiplier = _computeFontLineHeight( object->style );
+ new_span.line_height.set( font );
+ new_span.line_height *= new_span.font_size;
+ }
+ }
+ new_span.text_bytes = 0;
+ new_span.char_index_in_para = char_index_in_para;
+ para->unbroken_spans.push_back(new_span);
+ TRACE(("add empty span for break %lu\n", para->unbroken_spans.size() - 1));
break; // stop at the end of the paragraph
- else if (control_code->code == ARBITRARY_GAP) {
+ } else if (control_code->code == ARBITRARY_GAP) {
UnbrokenSpan new_span;
new_span.pango_item_index = -1;
new_span.input_index = input_index;
@@ -1619,8 +1643,8 @@ bool Layout::Calculator::_buildChunksInScanRun(ParagraphInfo const &para,
*line_height = *strut_height;
for (std::vector<ChunkInfo>::const_iterator it_chunk = chunk_info->begin() ; it_chunk != chunk_info->end() ; it_chunk++) {
for (std::vector<BrokenSpan>::const_iterator it_span = it_chunk->broken_spans.begin() ; it_span != it_chunk->broken_spans.end() ; it_span++) {
- TRACE((" brokenspan line_height: %f\n", it_span->start.iter_span->line_height.emSize() ));
FontMetrics span_height = it_span->start.iter_span->line_height;
+ TRACE((" brokenspan line_height: %f\n", span_height.emSize() ));
span_height.computeEffective( it_span->start.iter_span->line_height_multiplier );
line_height->max( span_height );
}
diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp
index df7adf5b4..a1a19f2b3 100644
--- a/src/libnrtype/Layout-TNG-Output.cpp
+++ b/src/libnrtype/Layout-TNG-Output.cpp
@@ -867,6 +867,23 @@ double Layout::getActualLength() const
}//namespace Text
}//namespace Inkscape
+std::ostream &operator<<(std::ostream &out, const Inkscape::Text::Layout::FontMetrics &f) {
+ out << " emSize: " << f.emSize()
+ << " ascent: " << f.ascent
+ << " descent: " << f.descent
+ << " xheight: " << f.xheight;
+ return out;
+}
+
+std::ostream &operator<<(std::ostream &out, const Inkscape::Text::Layout::FontMetrics *f) {
+ out << " emSize: " << f->emSize()
+ << " ascent: " << f->ascent
+ << " descent: " << f->descent
+ << " xheight: " << f->xheight;
+ return out;
+}
+
+
/*
Local Variables:
diff --git a/src/libnrtype/Layout-TNG.h b/src/libnrtype/Layout-TNG.h
index 8b46758f0..e06b8392f 100644
--- a/src/libnrtype/Layout-TNG.h
+++ b/src/libnrtype/Layout-TNG.h
@@ -629,7 +629,7 @@ public:
void reset() {
ascent = 0.8;
- descent = -0.2;
+ descent = 0.2;
xheight = 0.5;
ascent_max = 0.8;
descent_max = 0.2;
@@ -664,7 +664,7 @@ public:
// private:
double ascent; // Typographic ascent.
- double descent; // Typographic descent.
+ double descent; // Typographic descent. (Normally positive).
double xheight; // Height of 'x' measured from alphabetic baseline.
double ascent_max; // Maximum ascent of all glyphs in font.
double descent_max; // Maximum descent of all glyphs in font.
@@ -1189,6 +1189,10 @@ inline bool Layout::iterator::prevCharacter()
}//namespace Text
}//namespace Inkscape
+std::ostream &operator<<(std::ostream &out, const Inkscape::Text::Layout::FontMetrics &f);
+std::ostream &operator<<(std::ostream &out, const Inkscape::Text::Layout::FontMetrics *f);
+
+
#endif