summaryrefslogtreecommitdiff
path: root/st/x.c
diff options
context:
space:
mode:
Diffstat (limited to 'st/x.c')
-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();