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
master
Alessandro Mauri 3 years ago
parent b507e7c439
commit a7df717cf0
  1. 2
      TODO
  2. 2
      data/core/docview.lua
  3. 12
      src/main.c

@ -16,6 +16,7 @@
[ ] that command can be what is selected [ ] that command can be what is selected
[ ] console: accept input [ ] console: accept input
[ ] doc: detect file changes with hash [ ] doc: detect file changes with hash
[ ] add horizontal scroll
[ ] add a cross to close tab [ ] add a cross to close tab
[ ] add context menu to various things [ ] add context menu to various things
[ ] document and selection context menu [ ] document and selection context menu
@ -53,3 +54,4 @@
[x] implement visual "ruler" at column 80 [x] implement visual "ruler" at column 80
[ ] show hidden files config and binding [ ] show hidden files config and binding
[ ] syntax: highlight FIXME TODO BUG FIX and IMPROVEMENT keywords [ ] syntax: highlight FIXME TODO BUG FIX and IMPROVEMENT keywords
[ ] do not open doc in new tab if current tab has an unchanged document

@ -331,7 +331,7 @@ function DocView:draw_line_body(idx, x, y)
local w = math.ceil(1 * SCALE) local w = math.ceil(1 * SCALE)
local lh = self:get_line_height() local lh = self:get_line_height()
local color = style.guide or style.selection 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 end
-- draw line's text -- draw line's text

@ -2,18 +2,26 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <math.h>
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "api/api.h" #include "api/api.h"
#include "renderer.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; SDL_Window *window;
static double get_scale(void) static double get_scale(void)
{ {
float dpi; float dpi, s;
SDL_GetDisplayDPI(0, NULL, &dpi, NULL); 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) static void get_exe_filename(char *buf, int sz)

Loading…
Cancel
Save