be explicit about copy needed to safely pass glyph_info into text_line - closes #2337

This commit is contained in:
Dane Springmeyer 2014-08-05 17:03:30 -07:00
parent 7a013e8151
commit ce8aee1994
4 changed files with 5 additions and 5 deletions

View file

@ -113,7 +113,7 @@ static void shape_text(text_line & line,
tmp.offset.set(positions[i].x_offset * tmp.scale_multiplier, positions[i].y_offset * tmp.scale_multiplier); tmp.offset.set(positions[i].x_offset * tmp.scale_multiplier, positions[i].y_offset * tmp.scale_multiplier);
width_map[glyphs[i].cluster] += tmp.advance(); width_map[glyphs[i].cluster] += tmp.advance();
line.add_glyph(std::move(tmp), scale_factor); line.add_glyph(tmp, scale_factor);
} }
} }
line.update_max_char_height(face->get_char_height(size)); line.update_max_char_height(face->get_char_height(size));

View file

@ -107,7 +107,7 @@ static void shape_text(text_line & line,
face->glyph_dimensions(tmp); face->glyph_dimensions(tmp);
tmp.scale_multiplier = size / face->get_face()->units_per_EM; tmp.scale_multiplier = size / face->get_face()->units_per_EM;
width_map[i] += tmp.advance(); width_map[i] += tmp.advance();
line.add_glyph(std::move(tmp), scale_factor); line.add_glyph(tmp, scale_factor);
++i; ++i;
} }
} }

View file

@ -43,7 +43,7 @@ public:
text_line(unsigned first_char, unsigned last_char); text_line(unsigned first_char, unsigned last_char);
// Append glyph. // Append glyph.
void add_glyph(glyph_info && glyph, double scale_factor_); void add_glyph(glyph_info const& glyph, double scale_factor_);
// Preallocate memory. // Preallocate memory.
void reserve(glyph_vector::size_type length); void reserve(glyph_vector::size_type length);

View file

@ -36,7 +36,7 @@ text_line::text_line(unsigned first_char, unsigned last_char)
first_line_(false) first_line_(false)
{} {}
void text_line::add_glyph(glyph_info && glyph, double scale_factor_) void text_line::add_glyph(glyph_info const& glyph, double scale_factor_)
{ {
line_height_ = std::max(line_height_, glyph.line_height() + glyph.format->line_spacing); line_height_ = std::max(line_height_, glyph.line_height() + glyph.format->line_spacing);
double advance = glyph.advance(); double advance = glyph.advance();
@ -49,7 +49,7 @@ void text_line::add_glyph(glyph_info && glyph, double scale_factor_)
// Only add character spacing if the character is not a zero-width part of a cluster. // Only add character spacing if the character is not a zero-width part of a cluster.
width_ += advance + glyphs_.back().format->character_spacing * scale_factor_; width_ += advance + glyphs_.back().format->character_spacing * scale_factor_;
} }
glyphs_.push_back(std::move(glyph)); glyphs_.push_back(glyph);
} }