diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2019-07-28 10:45:01 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2019-07-28 10:45:01 +0000 |
| commit | 175dc9cf9483e389c2440a68b9472b1befc4d459 (patch) | |
| tree | dbccbea46f0d646b3da28c5c79da9b000dd08304 | |
| parent | main: calculate *all* font metrics from the FreeType face (diff) | |
cairo-ft: remove all usages of cairo-ft
| -rw-r--r-- | font.c | 38 | ||||
| -rw-r--r-- | main.c | 34 | ||||
| -rw-r--r-- | meson.build | 3 | ||||
| -rw-r--r-- | render.c | 4 | ||||
| -rw-r--r-- | terminal.h | 3 |
5 files changed, 4 insertions, 78 deletions
@@ -5,7 +5,6 @@ #include <assert.h> #include <fontconfig/fontconfig.h> -#include <cairo-ft.h> #define LOG_MODULE "font" #include "log.h" @@ -43,12 +42,6 @@ font_from_name(const char *name, struct font *font) return false; } - cairo_font_options_t *options = cairo_font_options_create(); - cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_DEFAULT); - cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_DEFAULT); - cairo_font_options_set_subpixel_order(options, CAIRO_SUBPIXEL_ORDER_DEFAULT); - cairo_ft_font_options_substitute(options, pattern); - FcDefaultSubstitute(pattern); FcResult result; @@ -98,39 +91,8 @@ font_from_name(const char *name, struct font *font) if (FcPatternGetBool(final_pattern, FC_ANTIALIAS, 0, &fc_antialias) != FcResultMatch) fc_antialias = FcTrue; - cairo_font_options_set_hint_style( - options, fc_hinting ? CAIRO_HINT_STYLE_DEFAULT : CAIRO_HINT_STYLE_NONE); - cairo_font_options_set_antialias( - options, fc_antialias ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE); - - cairo_font_face_t *face = cairo_ft_font_face_create_for_pattern( - final_pattern); - FcPatternDestroy(final_pattern); - if (cairo_font_face_status(face) != CAIRO_STATUS_SUCCESS) { - LOG_ERR("%s: failed to create cairo font face", name); - cairo_font_face_destroy(face); - return false; - } - - cairo_matrix_t matrix, ctm; - cairo_matrix_init_identity(&ctm); - cairo_matrix_init_scale(&matrix, size, size); - - cairo_scaled_font_t *scaled_font = cairo_scaled_font_create( - face, &matrix, &ctm, options); - - cairo_font_options_destroy(options); - cairo_font_face_destroy(face); - - if (cairo_scaled_font_status(scaled_font) != CAIRO_STATUS_SUCCESS) { - LOG_ERR("%s: failed to create scaled font", name); - cairo_scaled_font_destroy(scaled_font); - return false; - } - font->face = ft_face; - font->font = scaled_font; return true; } @@ -485,34 +485,6 @@ main(int argc, char *const *argv) term.cell_width = (int)ceil(term.fextents.max_x_advance); term.cell_height = (int)ceil(term.fextents.height); - /* Glyph cache */ - for (size_t i = 0; i < sizeof(term.fonts) / sizeof(term.fonts[0]); i++) { - struct font *f = &term.fonts[i]; - - for (int j = 0; j < 256; j++) { - cairo_glyph_t *glyphs = NULL; - int count = 0; - - char c = j; - cairo_status_t status = cairo_scaled_font_text_to_glyphs( - f->font, 0, 0 + term.fextents.ascent, - &c, 1, &glyphs, &count, - NULL, NULL, NULL); - - if (status != CAIRO_STATUS_SUCCESS) - continue; - - if (count == 0) - continue; - - assert(glyphs != NULL); - assert(count == 1); - - f->glyph_cache[j].glyphs = glyphs; - f->glyph_cache[j].count = count; - } - } - term.wl.display = wl_display_connect(NULL); if (term.wl.display == NULL) { LOG_ERR("failed to connect to wayland; no compositor running?"); @@ -927,12 +899,6 @@ out: for (size_t i = 0; i < sizeof(term.fonts) / sizeof(term.fonts[0]); i++) { struct font *f = &term.fonts[i]; - if (f->font != NULL) - cairo_scaled_font_destroy(f->font); - - for (size_t j = 0; j < 256; j++) - cairo_glyph_free(f->glyph_cache[j].glyphs); - if (f->face != NULL) FT_Done_Face(f->face); } diff --git a/meson.build b/meson.build index a6da9aba..95a139d7 100644 --- a/meson.build +++ b/meson.build @@ -23,7 +23,6 @@ math = cc.find_library('m') threads = dependency('threads') fontconfig = dependency('fontconfig') cairo = dependency('cairo') -cairo_ft = dependency('cairo-ft') wayland_protocols = dependency('wayland-protocols') wayland_client = dependency('wayland-client') wayland_cursor = dependency('wayland-cursor') @@ -78,7 +77,7 @@ executable( 'tllist.h', 'vt.c', 'vt.h', wl_proto_src + wl_proto_headers, - dependencies: [threads, math, cairo, cairo_ft, fontconfig, wayland_client, wayland_cursor, xkb], + dependencies: [threads, math, cairo, fontconfig, wayland_client, wayland_cursor, xkb], install: true) custom_target( @@ -61,15 +61,17 @@ gseq_flush(struct terminal *term, struct buffer *buf) if (gseq.count == 0) return; + assert(NULL); struct rgb fg = color_hex_to_rgb(gseq.foreground); if (gseq.attrs.dim) color_dim(&fg); +#if 0 cairo_set_scaled_font(buf->cairo, attrs_to_font(term, &gseq.attrs)->font); cairo_set_source_rgb(buf->cairo, fg.r, fg.g, fg.b); cairo_show_glyphs(buf->cairo, gseq.glyphs, gseq.count); - +#endif gseq.g = gseq.glyphs; gseq.count = 0; } @@ -213,7 +213,6 @@ struct glyph_cache { struct font { FT_Face face; - cairo_scaled_font_t *font; struct { double position; double thickness; @@ -222,8 +221,6 @@ struct font { double position; double thickness; } strikeout; - - struct glyph_cache glyph_cache[256]; }; enum cursor_style { CURSOR_BLOCK, CURSOR_UNDERLINE, CURSOR_BAR }; |
