From a7df717cf0f3fd5b75f8d2ee4fe3ed8257292407 Mon Sep 17 00:00:00 2001 From: Alessandro Mauri Date: Tue, 6 Jul 2021 22:54:50 +0200 Subject: [PATCH] set SCALE according to dpi claculate the scale so that fonts of 14pt will be of physical size 3mm, this can be changed setting the macro name FONT_14PT_SIZE_MM in main.c --- TODO | 2 ++ data/core/docview.lua | 2 +- src/main.c | 12 ++++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index 995d895..5abe9fd 100644 --- a/TODO +++ b/TODO @@ -16,6 +16,7 @@ [ ] that command can be what is selected [ ] console: accept input [ ] doc: detect file changes with hash +[ ] add horizontal scroll [ ] add a cross to close tab [ ] add context menu to various things [ ] document and selection context menu @@ -53,3 +54,4 @@ [x] implement visual "ruler" at column 80 [ ] show hidden files config and binding [ ] syntax: highlight FIXME TODO BUG FIX and IMPROVEMENT keywords +[ ] do not open doc in new tab if current tab has an unchanged document diff --git a/data/core/docview.lua b/data/core/docview.lua index 849595b..eb81e9c 100644 --- a/data/core/docview.lua +++ b/data/core/docview.lua @@ -331,7 +331,7 @@ function DocView:draw_line_body(idx, x, y) local w = math.ceil(1 * SCALE) local lh = self:get_line_height() local color = style.guide or style.selection - renderer.draw_rect(x + config.line_limit * sw, y, sw, lh, color) + renderer.draw_rect(x + config.line_limit * sw, y, w, lh, color) end -- draw line's text diff --git a/src/main.c b/src/main.c index cf018a5..c76b097 100644 --- a/src/main.c +++ b/src/main.c @@ -2,18 +2,26 @@ #include #include +#include #include #include "api/api.h" #include "renderer.h" +#define MAX(a,b) ((a)>(b)?(a):(b)) + +// TODO: configuration here is required +#define FONT_14PT_SIZE_MM 3 + SDL_Window *window; static double get_scale(void) { - float dpi; + float dpi, s; SDL_GetDisplayDPI(0, NULL, &dpi, NULL); - return 1.0; + s = (1.0/dpi)*25.4; // size of a point + // as per standard 14 point should be 3mm + return floor((FONT_14PT_SIZE_MM/(14*s))*10)/10.0; } static void get_exe_filename(char *buf, int sz)