use real max glyph height
- avoids breakage on fonts lacking an `X` glyph (#2506) - avoids needing to create and mutate a temporary glyph (#2516) - lots of minor visual changes - mostly improvements notably more correct collision boxes for lines with tall glyphs
This commit is contained in:
parent
74e872c48b
commit
8bc7a56cda
4 changed files with 7 additions and 18 deletions
|
@ -65,8 +65,6 @@ public:
|
|||
return face_;
|
||||
}
|
||||
|
||||
double get_char_height(double size) const;
|
||||
|
||||
bool set_character_sizes(double size);
|
||||
bool set_unscaled_character_sizes();
|
||||
|
||||
|
|
|
@ -117,6 +117,7 @@ static void shape_text(text_line & line,
|
|||
continue;
|
||||
}
|
||||
|
||||
double max_glyph_height = 0;
|
||||
for (unsigned i=0; i<num_glyphs; ++i)
|
||||
{
|
||||
glyph_info tmp;
|
||||
|
@ -127,15 +128,16 @@ static void shape_text(text_line & line,
|
|||
tmp.face = face;
|
||||
tmp.format = text_item.format;
|
||||
tmp.scale_multiplier = size / face->get_face()->units_per_EM;
|
||||
double tmp_height = tmp.height();
|
||||
if (tmp_height > max_glyph_height) max_glyph_height = tmp_height;
|
||||
//Overwrite default advance with better value provided by HarfBuzz
|
||||
tmp.unscaled_advance = positions[i].x_advance;
|
||||
|
||||
tmp.offset.set(positions[i].x_offset * tmp.scale_multiplier, positions[i].y_offset * tmp.scale_multiplier);
|
||||
width_map[glyphs[i].cluster] += tmp.advance();
|
||||
line.add_glyph(tmp, scale_factor);
|
||||
}
|
||||
}
|
||||
line.update_max_char_height(face->get_char_height(size));
|
||||
line.update_max_char_height(max_glyph_height);
|
||||
break; //When we reach this point the current font had all glyphs.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,8 +61,10 @@ public:
|
|||
|
||||
// Height of the tallest glyph in this line.
|
||||
double max_char_height() const { return max_char_height_; }
|
||||
|
||||
// Called for each font/style to update the maximum height of this line.
|
||||
void update_max_char_height(double max_char_height);
|
||||
|
||||
// Line height including line spacing.
|
||||
double line_height() const { return line_height_; }
|
||||
|
||||
|
@ -85,7 +87,7 @@ public:
|
|||
private:
|
||||
glyph_vector glyphs_;
|
||||
double line_height_; // Includes line spacing (returned by freetype)
|
||||
double max_char_height_; // Height of 'X' character of the largest font in this run. //TODO: Initialize this!
|
||||
double max_char_height_; // Max height of any glyphs in line - calculated by shaper
|
||||
double width_;
|
||||
double glyphs_width_;
|
||||
unsigned first_char_;
|
||||
|
|
|
@ -36,19 +36,6 @@ font_face::font_face(FT_Face face)
|
|||
glyph_info_cache_(),
|
||||
char_height_(0.0) {}
|
||||
|
||||
double font_face::get_char_height(double size) const
|
||||
{
|
||||
if (char_height_ != 0.0) return char_height_;
|
||||
glyph_info tmp;
|
||||
tmp.glyph_index = FT_Get_Char_Index(face_, 'X');
|
||||
if (glyph_dimensions(tmp))
|
||||
{
|
||||
tmp.scale_multiplier = size / face_->units_per_EM;
|
||||
char_height_ = tmp.height();
|
||||
}
|
||||
return char_height_;
|
||||
}
|
||||
|
||||
bool font_face::set_character_sizes(double size)
|
||||
{
|
||||
char_height_ = 0.0;
|
||||
|
|
Loading…
Reference in a new issue