font: move metrics from terminal struct to font struct

This commit is contained in:
Daniel Eklöf 2019-11-26 18:54:32 +01:00
parent 431800a8a5
commit bc86cd61c7
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
5 changed files with 35 additions and 34 deletions

View file

@ -377,21 +377,6 @@ initialize_fonts(struct terminal *term, const struct config *conf)
}
tll_free(font_names);
FT_Face ft_face = term->fonts[0]->face;
int max_x_advance = ft_face->size->metrics.max_advance / 64;
int height = ft_face->size->metrics.height / 64;
int descent = ft_face->size->metrics.descender / 64;
int ascent = ft_face->size->metrics.ascender / 64;
term->fextents.height = height * term->fonts[0]->pixel_size_fixup;
term->fextents.descent = -descent * term->fonts[0]->pixel_size_fixup;
term->fextents.ascent = ascent * term->fonts[0]->pixel_size_fixup;
term->fextents.max_x_advance = max_x_advance * term->fonts[0]->pixel_size_fixup;
LOG_DBG("metrics: height: %d, descent: %d, ascent: %d, x-advance: %d",
height, descent, ascent, max_x_advance);
return true;
}
@ -529,8 +514,8 @@ term_init(const struct config *conf, struct fdm *fdm, struct wayland *wayl,
goto err;
/* Cell dimensions are based on the font metrics. Obviously */
term->cell_width = (int)ceil(term->fextents.max_x_advance);
term->cell_height = (int)ceil(term->fextents.height);
term->cell_width = term->fonts[0]->max_x_advance;
term->cell_height = term->fonts[0]->height;
LOG_INFO("cell width=%d, height=%d", term->cell_width, term->cell_height);
/* Start the slave/client */