summaryrefslogtreecommitdiff
path: root/st
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2024-10-10 19:49:25 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2024-10-10 19:49:25 +0900
commit170af86eced1c4c15c47617e80a29498f4f2f576 (patch)
tree2c9be851f206137fb413b84879dd9658ac71b54f /st
parentc03a1a680b86c43e2bf29df97de9825ab5c20caa (diff)
Init
Diffstat (limited to 'st')
-rw-r--r--st/x.c34
1 files changed, 18 insertions, 16 deletions
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();