aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-07-28 10:39:56 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-07-28 10:39:56 +0000
commitc399c329b67d1655cf6fa48a180f29c5019a7c88 (patch)
tree003eacd0dfe630451ad5dcfbd8f67e32a1d26f0b
parentrender: use FreeType face from font, instead of from cairo's scaled font (diff)
main: calculate *all* font metrics from the FreeType face
-rw-r--r--main.c25
-rw-r--r--terminal.h8
2 files changed, 24 insertions, 9 deletions
diff --git a/main.c b/main.c
index 31de1b58..80ec053e 100644
--- a/main.c
+++ b/main.c
@@ -428,10 +428,10 @@ main(int argc, char *const *argv)
for (size_t i = 0; i < sizeof(term.fonts) / sizeof(term.fonts[0]); i++) {
struct font *f = &term.fonts[i];
- if (f->font == NULL)
+ if (f->face == NULL)
continue;
- FT_Face ft_face = cairo_ft_scaled_font_lock_face(f->font);
+ FT_Face ft_face = f->face;
double x_scale = ft_face->size->metrics.x_scale / 65526.;
double height = ft_face->size->metrics.height / 64;
@@ -464,18 +464,27 @@ main(int argc, char *const *argv)
LOG_DBG("strikeout: pos=%f, thick=%f",
f->strikeout.position, f->strikeout.thickness);
+ }
+
+ {
+ 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;
- cairo_ft_scaled_font_unlock_face(f->font);
+ term.fextents.height = height;
+ term.fextents.descent = -descent;
+ term.fextents.ascent = ascent;
+ term.fextents.max_x_advance = max_x_advance;
+
+ LOG_WARN("metrics: height: %d, descent: %d, ascent: %d, x-advance: %d",
+ height, descent, ascent, max_x_advance);
}
- cairo_scaled_font_extents(term.fonts[0].font, &term.fextents);
term.cell_width = (int)ceil(term.fextents.max_x_advance);
term.cell_height = (int)ceil(term.fextents.height);
- LOG_DBG("font: height: %.2f, x-advance: %.2f",
- term.fextents.height, term.fextents.max_x_advance);
- assert(term.fextents.max_y_advance == 0);
-
/* Glyph cache */
for (size_t i = 0; i < sizeof(term.fonts) / sizeof(term.fonts[0]); i++) {
struct font *f = &term.fonts[i];
diff --git a/terminal.h b/terminal.h
index ed8adf0d..6c0b81f1 100644
--- a/terminal.h
+++ b/terminal.h
@@ -325,7 +325,13 @@ struct terminal {
struct grid *grid;
struct font fonts[4];
- cairo_font_extents_t fextents;
+ //cairo_font_extents_t fextents;
+ struct {
+ int height;
+ int descent;
+ int ascent;
+ int max_x_advance;
+ } fextents;
struct wayland wl;
struct {