summaryrefslogtreecommitdiffstats
path: root/src/libnrtype
diff options
context:
space:
mode:
Diffstat (limited to 'src/libnrtype')
-rw-r--r--src/libnrtype/FontFactory.cpp4
-rw-r--r--src/libnrtype/FontInstance.cpp4
-rw-r--r--src/libnrtype/Layout-TNG-Compute.cpp6
-rw-r--r--src/libnrtype/Layout-TNG-Input.cpp10
-rw-r--r--src/libnrtype/Layout-TNG-OutIter.cpp22
-rw-r--r--src/libnrtype/Layout-TNG-Output.cpp26
-rw-r--r--src/libnrtype/font-lister.cpp10
7 files changed, 40 insertions, 42 deletions
diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp
index 27f8b57d0..583078803 100644
--- a/src/libnrtype/FontFactory.cpp
+++ b/src/libnrtype/FontFactory.cpp
@@ -461,8 +461,8 @@ void font_factory::GetUIFamilies(std::vector<PangoFontFamily *>& out)
std::sort(sorted.begin(), sorted.end(), ustringPairSort);
- for (size_t i = 0; i < sorted.size(); ++i) {
- out.push_back(sorted[i].first);
+ for (auto & i : sorted) {
+ out.push_back(i.first);
}
}
diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp
index c2abfb3f2..0c1d0f5ed 100644
--- a/src/libnrtype/FontInstance.cpp
+++ b/src/libnrtype/FontInstance.cpp
@@ -525,8 +525,8 @@ void font_instance::LoadGlyph(int glyph_id)
if ( doAdd ) {
Geom::PathVector pv = path_builder.peek();
// close all paths
- for (Geom::PathVector::iterator i = pv.begin(); i != pv.end(); ++i) {
- i->close();
+ for (auto & i : pv) {
+ i.close();
}
if ( !pv.empty() ) {
n_g.pathvector = new Geom::PathVector(pv);
diff --git a/src/libnrtype/Layout-TNG-Compute.cpp b/src/libnrtype/Layout-TNG-Compute.cpp
index 938763656..b69cad982 100644
--- a/src/libnrtype/Layout-TNG-Compute.cpp
+++ b/src/libnrtype/Layout-TNG-Compute.cpp
@@ -1709,10 +1709,10 @@ bool Layout::Calculator::_buildChunksInScanRun(ParagraphInfo const &para,
// Recalculate line_box_height after backing out chunks
*line_height = line_height_saved;
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++) {
- FontMetrics span_height = it_span->start.iter_span->line_height;
+ for (const auto & broken_span : it_chunk->broken_spans) {
+ FontMetrics span_height = broken_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 );
+ span_height.computeEffective( broken_span.start.iter_span->line_height_multiplier );
line_height->max( span_height );
}
}
diff --git a/src/libnrtype/Layout-TNG-Input.cpp b/src/libnrtype/Layout-TNG-Input.cpp
index a20fdde53..b523649e7 100644
--- a/src/libnrtype/Layout-TNG-Input.cpp
+++ b/src/libnrtype/Layout-TNG-Input.cpp
@@ -30,8 +30,8 @@ namespace Text {
void Layout::_clearInputObjects()
{
- for(std::vector<InputStreamItem*>::iterator it = _input_stream.begin() ; it != _input_stream.end() ; ++it) {
- delete *it;
+ for(auto & it : _input_stream) {
+ delete it;
}
_input_stream.clear();
@@ -72,9 +72,9 @@ void Layout::appendText(Glib::ustring const &text,
if (!optional_attributes->rotate.empty() && optional_attributes_offset >= optional_attributes->rotate.size()) {
SVGLength last_rotate;
last_rotate = 0.f;
- for (std::vector<SVGLength>::const_iterator it = optional_attributes->rotate.begin() ; it != optional_attributes->rotate.end() ; ++it)
- if (it->_set)
- last_rotate = *it;
+ for (auto it : optional_attributes->rotate)
+ if (it._set)
+ last_rotate = it;
new_source->rotate.resize(1, last_rotate);
}
new_source->textLength._set = optional_attributes->textLength._set;
diff --git a/src/libnrtype/Layout-TNG-OutIter.cpp b/src/libnrtype/Layout-TNG-OutIter.cpp
index d565bb923..77cedaa61 100644
--- a/src/libnrtype/Layout-TNG-OutIter.cpp
+++ b/src/libnrtype/Layout-TNG-OutIter.cpp
@@ -97,20 +97,20 @@ Layout::iterator Layout::getNearestCursorPositionTo(double x, double y) const
local_y = x;
}
// stage 1:
- for (unsigned span_index = 0 ; span_index < _spans.size() ; span_index++) {
+ for (const auto & _span : _spans) {
double span_left, span_right;
- if (_spans[span_index].x_start < _spans[span_index].x_end) {
- span_left = _spans[span_index].x_start;
- span_right = _spans[span_index].x_end;
+ if (_span.x_start < _span.x_end) {
+ span_left = _span.x_start;
+ span_right = _span.x_end;
} else {
- span_left = _spans[span_index].x_end;
- span_right = _spans[span_index].x_start;
+ span_left = _span.x_end;
+ span_right = _span.x_start;
}
- if ( local_x >= _chunks[_spans[span_index].in_chunk].left_x + span_left
- && local_x <= _chunks[_spans[span_index].in_chunk].left_x + span_right
- && local_y >= _spans[span_index].line(this).baseline_y + _spans[span_index].baseline_shift - _spans[span_index].line_height.ascent
- && local_y <= _spans[span_index].line(this).baseline_y + _spans[span_index].baseline_shift + _spans[span_index].line_height.descent) {
- return _cursorXOnLineToIterator(_chunks[_spans[span_index].in_chunk].in_line, local_x);
+ if ( local_x >= _chunks[_span.in_chunk].left_x + span_left
+ && local_x <= _chunks[_span.in_chunk].left_x + span_right
+ && local_y >= _span.line(this).baseline_y + _span.baseline_shift - _span.line_height.ascent
+ && local_y <= _span.line(this).baseline_y + _span.baseline_shift + _span.line_height.descent) {
+ return _cursorXOnLineToIterator(_chunks[_span.in_chunk].in_line, local_x);
}
}
diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp
index 014c2c521..6ff52f2a7 100644
--- a/src/libnrtype/Layout-TNG-Output.cpp
+++ b/src/libnrtype/Layout-TNG-Output.cpp
@@ -91,8 +91,8 @@ void Layout::_clearOutputObjects()
_paragraphs.clear();
_lines.clear();
_chunks.clear();
- for (std::vector<Span>::iterator it_span = _spans.begin() ; it_span != _spans.end() ; ++it_span)
- if (it_span->font) it_span->font->Unref();
+ for (auto & _span : _spans)
+ if (_span.font) _span.font->Unref();
_spans.clear();
_characters.clear();
_glyphs.clear();
@@ -755,10 +755,10 @@ void Layout::fitToPathAlign(SVGLength const &startOffset, Path const &path)
Path::cut_position *end_otp = const_cast<Path&>(path).CurvilignToPosition(1, &end_offset, unused);
if (end_otp != nullptr && end_otp[0].piece >= 0) {
bool on_same_subpath = true;
- for (size_t i = 0 ; i < path.pts.size() ; i++) {
- if (path.pts[i].piece <= start_otp[0].piece) continue;
- if (path.pts[i].piece >= end_otp[0].piece) break;
- if (path.pts[i].isMoveTo == polyline_moveto) {
+ for (const auto & pt : path.pts) {
+ if (pt.piece <= start_otp[0].piece) continue;
+ if (pt.piece >= end_otp[0].piece) break;
+ if (pt.isMoveTo == polyline_moveto) {
on_same_subpath = false;
break;
}
@@ -809,9 +809,9 @@ void Layout::fitToPathAlign(SVGLength const &startOffset, Path const &path)
char_index = next_cluster_char_index;
}
- for (unsigned span_index = 0 ; span_index < _spans.size() ; span_index++) {
- _spans[span_index].x_start += offset;
- _spans[span_index].x_end += offset;
+ for (auto & _span : _spans) {
+ _span.x_start += offset;
+ _span.x_end += offset;
}
_path_fitted = &path;
@@ -847,11 +847,11 @@ void Layout::transform(Geom::Affine const &transform)
{
// this is all massively oversimplified
// I can't actually think of anybody who'll want to use it at the moment, so it'll stay simple
- for (unsigned glyph_index = 0 ; glyph_index < _glyphs.size() ; glyph_index++) {
- Geom::Point point(_glyphs[glyph_index].x, _glyphs[glyph_index].y);
+ for (auto & _glyph : _glyphs) {
+ Geom::Point point(_glyph.x, _glyph.y);
point *= transform;
- _glyphs[glyph_index].x = point[0];
- _glyphs[glyph_index].y = point[1];
+ _glyph.x = point[0];
+ _glyph.y = point[1];
}
}
diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp
index 739b0b14b..9c9e07ad2 100644
--- a/src/libnrtype/font-lister.cpp
+++ b/src/libnrtype/font-lister.cpp
@@ -74,8 +74,8 @@ FontLister::FontLister()
font_factory::Default()->GetUIFamilies(familyVector);
// Traverse through the family names and set up the list store
- for (size_t i = 0; i < familyVector.size(); ++i) {
- const char* displayName = sp_font_family_get_name(familyVector[i]);
+ for (auto & i : familyVector) {
+ const char* displayName = sp_font_family_get_name(i);
if (displayName == nullptr || *displayName == '\0') {
continue;
@@ -90,7 +90,7 @@ FontLister::FontLister()
// ever decides to use this font
(*treeModelIter)[FontList.styles] = NULL;
// store the pango representation for generating the style
- (*treeModelIter)[FontList.pango_family] = familyVector[i];
+ (*treeModelIter)[FontList.pango_family] = i;
(*treeModelIter)[FontList.onSystem] = true;
}
}
@@ -1139,9 +1139,7 @@ void font_lister_cell_data_func2(GtkCellLayout * /*cell_layout*/,
/* See if font-family on system */
std::vector<Glib::ustring> tokens = Glib::Regex::split_simple("\\s*,\\s*", family);
- for (size_t i = 0; i < tokens.size(); ++i) {
-
- Glib::ustring token = tokens[i];
+ for (auto token : tokens) {
GtkTreeIter iter;
gboolean valid;