fix char_height zero
This commit is contained in:
parent
38966674f1
commit
a99905cff5
6 changed files with 10 additions and 12 deletions
|
@ -82,7 +82,7 @@ static void shape_text(text_line & line,
|
||||||
width_map[i] += tmp.advance();
|
width_map[i] += tmp.advance();
|
||||||
line.add_glyph(tmp, scale_factor);
|
line.add_glyph(tmp, scale_factor);
|
||||||
}
|
}
|
||||||
line.update_max_char_height(face->get_char_height());
|
line.update_max_char_height(face->get_char_height(size));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ public:
|
||||||
return face_;
|
return face_;
|
||||||
}
|
}
|
||||||
|
|
||||||
double get_char_height() const;
|
double get_char_height(double size) const;
|
||||||
|
|
||||||
bool set_character_sizes(double size);
|
bool set_character_sizes(double size);
|
||||||
bool set_unscaled_character_sizes();
|
bool set_unscaled_character_sizes();
|
||||||
|
|
|
@ -49,7 +49,7 @@ struct glyph_info
|
||||||
unscaled_ymax(0.0),
|
unscaled_ymax(0.0),
|
||||||
unscaled_advance(0.0),
|
unscaled_advance(0.0),
|
||||||
unscaled_line_height(0.0),
|
unscaled_line_height(0.0),
|
||||||
scale_multiplier(0.0),
|
scale_multiplier(1.0),
|
||||||
offset(),
|
offset(),
|
||||||
format() {}
|
format() {}
|
||||||
glyph_index_t glyph_index;
|
glyph_index_t glyph_index;
|
||||||
|
@ -68,8 +68,8 @@ struct glyph_info
|
||||||
pixel_position offset;
|
pixel_position offset;
|
||||||
char_properties_ptr format;
|
char_properties_ptr format;
|
||||||
|
|
||||||
double ymin() const { return floor(unscaled_ymin * scale_multiplier / y_scale); }
|
double ymin() const { return floor(unscaled_ymin * 64.0 * scale_multiplier / y_scale); }
|
||||||
double ymax() const { return ceil(unscaled_ymax * scale_multiplier / y_scale); }
|
double ymax() const { return ceil(unscaled_ymax * 64.0 * scale_multiplier / y_scale); }
|
||||||
double height() const { return ymax() - ymin(); };
|
double height() const { return ymax() - ymin(); };
|
||||||
double advance() const { return floor(unscaled_advance * scale_multiplier / x_scale); };
|
double advance() const { return floor(unscaled_advance * scale_multiplier / x_scale); };
|
||||||
double line_height() const { return floor(unscaled_line_height * scale_multiplier / y_scale); };
|
double line_height() const { return floor(unscaled_line_height * scale_multiplier / y_scale); };
|
||||||
|
|
|
@ -110,14 +110,11 @@ static void shape_text(text_line & line,
|
||||||
//Overwrite default advance with better value provided by HarfBuzz
|
//Overwrite default advance with better value provided by HarfBuzz
|
||||||
tmp.unscaled_advance = positions[i].x_advance * tmp.x_scale;
|
tmp.unscaled_advance = positions[i].x_advance * tmp.x_scale;
|
||||||
|
|
||||||
std::cerr << tmp.line_height() << ' ' <<
|
|
||||||
tmp.advance() << '\n';
|
|
||||||
|
|
||||||
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(tmp, scale_factor);
|
line.add_glyph(tmp, scale_factor);
|
||||||
}
|
}
|
||||||
line.update_max_char_height(face->get_char_height());
|
line.update_max_char_height(face->get_char_height(size));
|
||||||
break; //When we reach this point the current font had all glyphs.
|
break; //When we reach this point the current font had all glyphs.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ static void shape_text(text_line & line,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!shaped_status) continue;
|
if (!shaped_status) continue;
|
||||||
line.update_max_char_height(face->get_char_height());
|
line.update_max_char_height(face->get_char_height(size));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,12 +36,13 @@ font_face::font_face(FT_Face face)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
double font_face::get_char_height() const
|
double font_face::get_char_height(double size) const
|
||||||
{
|
{
|
||||||
if (char_height_ != 0.0) return char_height_;
|
if (char_height_ != 0.0) return char_height_;
|
||||||
glyph_info tmp;
|
glyph_info tmp;
|
||||||
tmp.glyph_index = FT_Get_Char_Index(face_, 'X');
|
tmp.glyph_index = FT_Get_Char_Index(face_, 'X');
|
||||||
glyph_dimensions(tmp);
|
glyph_dimensions(tmp);
|
||||||
|
tmp.scale_multiplier = size / face_->units_per_EM;
|
||||||
char_height_ = tmp.height();
|
char_height_ = tmp.height();
|
||||||
return char_height_;
|
return char_height_;
|
||||||
}
|
}
|
||||||
|
@ -96,7 +97,7 @@ void font_face::glyph_dimensions(glyph_info & glyph) const
|
||||||
|
|
||||||
glyph.unscaled_ymin = glyph_bbox.yMin * glyph.y_scale;
|
glyph.unscaled_ymin = glyph_bbox.yMin * glyph.y_scale;
|
||||||
glyph.unscaled_ymax = glyph_bbox.yMax * glyph.y_scale;
|
glyph.unscaled_ymax = glyph_bbox.yMax * glyph.y_scale;
|
||||||
glyph.unscaled_advance = face_->glyph->metrics.horiAdvance * glyph.x_scale;
|
glyph.unscaled_advance = face_->glyph->advance.x * glyph.x_scale;
|
||||||
glyph.unscaled_line_height = face_->size->metrics.height * glyph.y_scale;
|
glyph.unscaled_line_height = face_->size->metrics.height * glyph.y_scale;
|
||||||
|
|
||||||
//TODO: dimension_cache_.insert(std::pair<unsigned, char_info>(c, dim));
|
//TODO: dimension_cache_.insert(std::pair<unsigned, char_info>(c, dim));
|
||||||
|
|
Loading…
Reference in a new issue