From 94052bb7126b1b50949a39b8de9c9ce91aaaa4f4 Mon Sep 17 00:00:00 2001 From: Theodore Dubois Date: Mon, 10 Sep 2018 10:54:46 -0700 Subject: [PATCH] Add option to increase font thickness on macOS --- kitty/config_data.py | 5 +++++ kitty/core_text.m | 4 +++- kitty/state.c | 1 + kitty/state.h | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/kitty/config_data.py b/kitty/config_data.py index 5119278b0..049b8ad8d 100644 --- a/kitty/config_data.py +++ b/kitty/config_data.py @@ -779,6 +779,11 @@ o('macos_window_resizable', True, long_text=_(''' Disable this if you want kitty top-level (OS) windows to not be resizable on macOS. ''')) + +o('macos_thicken_font', 0, option_type=positive_float, long_text=_(''' +Draw an extra border around the font with the given width, to increase +legibility at small font sizes. +''')) # }}} g('shortcuts') # {{{ diff --git a/kitty/core_text.m b/kitty/core_text.m index a3b296b92..e13536726 100644 --- a/kitty/core_text.m +++ b/kitty/core_text.m @@ -372,7 +372,9 @@ render_glyphs(CTFontRef font, unsigned int width, unsigned int height, unsigned CGContextSetShouldAntialias(render_ctx, true); CGContextSetShouldSmoothFonts(render_ctx, true); CGContextSetGrayFillColor(render_ctx, 1, 1); // white glyphs - CGContextSetTextDrawingMode(render_ctx, kCGTextFill); + CGContextSetGrayStrokeColor(render_ctx, 1, 1); + CGContextSetLineWidth(render_ctx, global_state.opts.macos_thicken_font); + CGContextSetTextDrawingMode(render_ctx, kCGTextFillStroke); CGContextSetTextMatrix(render_ctx, CGAffineTransformIdentity); CGContextSetTextPosition(render_ctx, 0, height - baseline); CTFontDrawGlyphs(font, glyphs, positions, num_glyphs, render_ctx); diff --git a/kitty/state.c b/kitty/state.c index ffb157e33..4874e33ba 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -391,6 +391,7 @@ PYWRAP1(set_options) { S(macos_window_resizable, PyObject_IsTrue); S(x11_hide_window_decorations, PyObject_IsTrue); S(macos_hide_from_tasks, PyObject_IsTrue); + S(macos_thicken_font, PyFloat_AsDouble); PyObject *chars = PyObject_GetAttrString(opts, "select_by_word_characters"); if (chars == NULL) return NULL; diff --git a/kitty/state.h b/kitty/state.h index 5c978a0d7..1e83315b6 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -24,6 +24,7 @@ typedef struct { double repaint_delay, input_delay; bool focus_follows_mouse; bool macos_option_as_alt, macos_hide_titlebar, macos_hide_from_tasks, x11_hide_window_decorations, macos_quit_when_last_window_closed, macos_window_resizable; + float macos_thicken_font; int adjust_line_height_px, adjust_column_width_px; float adjust_line_height_frac, adjust_column_width_frac; float background_opacity, dim_opacity;