From 170af86eced1c4c15c47617e80a29498f4f2f576 Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Thu, 10 Oct 2024 19:49:25 +0900 Subject: Init --- st/x.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'st/x.c') diff --git a/st/x.c b/st/x.c index 989d3dc..27b980d 100644 --- a/st/x.c +++ b/st/x.c @@ -1045,21 +1045,6 @@ xloadfonts(const char *fontstr, double fontsize) FcPattern *pattern; double fontval; - // Get screen resolution - Display *dpy = XOpenDisplay(NULL); - if (!dpy) { - die("can't open display\n"); - } - int screen = DefaultScreen(dpy); - int width = XDisplayWidth(dpy, screen); - int height = XDisplayHeight(dpy, screen); - XCloseDisplay(dpy); // Close the display after getting resolution - // - // If the resolution is under 1024x768, set the fontsize to 12 - if (width <= 1024 && height <= 768) { - fontsize = 12; - } - if (fontstr[0] == '-') pattern = XftXlfdParse(fontstr, False, False); else @@ -1327,7 +1312,24 @@ xinit(int cols, int rows) die("could not init fontconfig.\n"); usedfont = (opt_font == NULL)? fonts[currentfont] : opt_font; - xloadfonts(usedfont, 0); + + // Get screen resolution + Display *dpy = XOpenDisplay(NULL); + if (!dpy) { + die("can't open display\n"); + } + int screen = DefaultScreen(dpy); + int width = XDisplayWidth(dpy, screen); + int height = XDisplayHeight(dpy, screen); + XCloseDisplay(dpy); // Close the display after getting resolution + + // If the resolution is under 1024x768, set the fontsize to 12 + if (width <= 1024 && height <= 768) { + xloadfonts(usedfont, 12); + } else { + xloadfonts(usedfont, 0); + } + /* spare fonts */ xloadsparefonts(); -- cgit v1.2.3