From 65b212fa1bd7f1cfb66b72234b91a19dc93f8a30 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 26 Nov 2017 11:24:18 +0530 Subject: [PATCH] Add a config option to control the line thickness for box drawing characters Fixes #183 --- kitty/config.py | 8 ++++++++ kitty/fonts/box_drawing.py | 10 +++++++++- kitty/kitty.conf | 6 ++++++ kitty/main.py | 2 ++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/kitty/config.py b/kitty/config.py index a34a53471..b05c00522 100644 --- a/kitty/config.py +++ b/kitty/config.py @@ -220,6 +220,13 @@ def adjust_line_height(x): return int(x) +def box_drawing_scale(x): + ans = tuple(float(x.strip()) for x in x.split(',')) + if len(ans) != 4: + raise ValueError('Invalid box_drawing scale, must have four entries') + return ans + + type_map = { 'adjust_line_height': adjust_line_height, 'scrollback_lines': positive_int, @@ -249,6 +256,7 @@ type_map = { 'use_system_wcwidth': to_bool, 'macos_hide_titlebar': to_bool, 'macos_option_as_alt': to_bool, + 'box_drawing_scale': box_drawing_scale, } for name in ( diff --git a/kitty/fonts/box_drawing.py b/kitty/fonts/box_drawing.py index 4d83859c8..9ed5ff5b8 100644 --- a/kitty/fonts/box_drawing.py +++ b/kitty/fonts/box_drawing.py @@ -9,9 +9,17 @@ from itertools import repeat from kitty.utils import get_logical_dpi +scale = (0.001, 1, 1.5, 2) + + +def set_scale(new_scale): + global scale + scale = tuple(new_scale) + + def thickness(level=1, horizontal=True): dpi = get_logical_dpi()[0 if horizontal else 1] - pts = (0.001, 1, 1.5, 2)[level] + pts = scale[level] return int(math.ceil(pts * dpi / 72.0)) diff --git a/kitty/kitty.conf b/kitty/kitty.conf index 7c34dc732..b03db6b4e 100644 --- a/kitty/kitty.conf +++ b/kitty/kitty.conf @@ -31,6 +31,12 @@ font_size_delta 2 # 100% to reduce line height (but this might cause rendering artifacts). adjust_line_height 0 +# Change the sizes of the lines used for the box drawing unicode characters +# These values are in pts. They will be scaled by the monitor DPI to arrive at +# a pixel value. There must be four values corresponding to thin, normal, thick, +# and very thick lines; +box_drawing_scale 0.001, 1, 1.5, 2 + # The foreground color foreground #dddddd diff --git a/kitty/main.py b/kitty/main.py index 25f397c4d..c624c03e5 100644 --- a/kitty/main.py +++ b/kitty/main.py @@ -26,6 +26,7 @@ from .fast_data_types import ( glfw_init, glfw_init_hint_string, glfw_swap_interval, glfw_terminate, glfw_window_hint, install_sigchld_handler, set_logical_dpi, set_options ) +from .fonts.box_drawing import set_scale from .layout import all_layouts from .utils import ( color_as_int, detach, end_startup_notification, get_logical_dpi, @@ -170,6 +171,7 @@ def initialize_window(window, opts, debug_gl=False): def run_app(opts, args): set_options(opts) setup_opengl(opts) + set_scale(opts.box_drawing_scale) load_cached_values() if 'window-size' in cached_values and opts.remember_window_size: ws = cached_values['window-size']