Closed IamGianluca closed 2 years ago
Xft.dpi: 192
yes it is surprising how well that works with dwm, it is not intended to though. You may notice some oddities like if you use the winicon patch that the icons are tiny compared to the text. Systray icons may also be small, not sure as I haven't tested.
Is there a way to set the st font size in config.def.h?
Just a heads up that the intention is that you change your personal config.h
file rather than the default configuration. In dwm this is controlled here:
https://github.com/bakkeby/dwm-flexipatch/blob/90f9b2d9820b8da03d54a64e523aa1f104b4ff2b/config.def.h#L149
while in st this is controlled here: https://github.com/bakkeby/st-flexipatch/blob/cc36f7c256850c72dcefef455ec8d0ed19156cac/config.def.h#L8
static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true";
As for the reason why the st font size does not scale with the Xft.dpi
setting appears to be that it is using FcFontMatch
rather than XftFontMatch
, at least according to this commit:
https://git.suckless.org/st/commit/528241aa3835e2f1f052abeeaf891737712955a0.html
I tried those changes out and they seem to work. Not sure why it was never merged into upstream st, maybe it was simply missed or forgotten. I do not see this being discussed in the mailing list.
If you are using a stock st then you can apply those minor changes manually.
If you are using st-flexipatch then I just pushed an update where you can enable the above using the USE_XFTFONTMATCH_PATCH
toggle.
If you are using st-flexipatch then I just pushed an update where you can enable the above using the USE_XFTFONTMATCH_PATCH toggle.
Did you forget to apply the changes to the font2 patch too? You should also fix the font2 patch so that it accepts point size in fonts too, because if you don't use pixelsize, you can't zoom the spare fonts. It shouldn't be too hard, because I made that fix a long time ago, but unfortunately I can't seem to find it right now.
@veltza no I didn't think about that, will have to have a look. Tanks.
Did you forget to apply the changes to the font2 patch too? You should also fix the font2 patch so that it accepts point size in fonts too, because if you don't use pixelsize, you can't zoom the spare fonts. It shouldn't be too hard, because I made that fix a long time ago, but unfortunately I can't seem to find it right now.
I just found the fix, if it helps.
diff --git a/patch/font2.c b/patch/font2.c
index 7477ced..ea4a26b 100644
--- a/patch/font2.c
+++ b/patch/font2.c
@@ -26,7 +26,7 @@ void
xloadsparefonts(void)
{
FcPattern *pattern;
- double sizeshift, fontval;
+ double fontval;
int fc;
char **fp;
@@ -54,15 +54,19 @@ xloadsparefonts(void)
if (!pattern)
die("can't open spare font %s\n", *fp);
- if (defaultfontsize > 0) {
- sizeshift = usedfontsize - defaultfontsize;
- if (sizeshift != 0 &&
- FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval) ==
+ if (defaultfontsize > 0 && defaultfontsize != usedfontsize) {
+ if (FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval) ==
FcResultMatch) {
- fontval += sizeshift;
+ fontval *= usedfontsize / defaultfontsize;
FcPatternDel(pattern, FC_PIXEL_SIZE);
FcPatternDel(pattern, FC_SIZE);
FcPatternAddDouble(pattern, FC_PIXEL_SIZE, fontval);
+ } else if (FcPatternGetDouble(pattern, FC_SIZE, 0, &fontval) ==
+ FcResultMatch) {
+ fontval *= usedfontsize / defaultfontsize;
+ FcPatternDel(pattern, FC_PIXEL_SIZE);
+ FcPatternDel(pattern, FC_SIZE);
+ FcPatternAddDouble(pattern, FC_SIZE, fontval);
}
}
@@ -91,4 +95,4 @@ xloadsparefonts(void)
FcPatternDestroy(pattern);
}
-}
\ No newline at end of file
+}
Thanks @veltza, that seems to work fine. Have integrated that now. I suppose that addition was never added for the font2 patch on the suckless patches page.
Thank you for the reply @bakkeby!
Xft.dpi: 192
yes it is surprising how well that works with dwm, it is not intended to though.
I found it recommended in the ArchWiki, but it also looks like a hack. I wonder if it is more robust to achieve the same result via the --scale
setting in xrandr
. I can try when I have more time this weekend.
Just a heads up that the intention is that you change your personal
config.h
file rather than the default configuration.
Please correct me if I'm wrong. The whole workflow to enable a patch in your repos should be:
git clone
the repo & cd into the repo foldersudo make clean install
― this will create the patches.h
and config.h
filespatches.h
sudo make clean install
Similarly, if we want to change any config, we would have to edit config.h
.
If you are using st-flexipatch then I just pushed an update where you can enable the above using the
USE_XFTFONTMATCH_PATCH
toggle.
I was using the version of st
that comes preinstalled with dwm-flexipatch. I didn't notice you also have a repo for st-flexipatch
.
I've tried to install st-flexipatch
, enabled the patch in patches.h
and then run sudo make clean install
. After logging off and on, I still have the same issue. Am I doing something wrong?
Please correct me if I'm wrong. The whole workflow to enable a patch in your repos should be:
git clone
the repo & cd into the repo foldersudo make clean install
― this will create the patches.h and config.h files- Enable the patches we want by editing
patches.h
sudo make clean install
- Similarly, if we want to change any config, we would have to edit
config.h
.
Yes except that I'd change 2. to be just make
to create the patches.h and config.h files, as otherwise the files will be owned by the root user.
I am just mentioning this because a lot of people will recommend editing config.def.h and deleting config.h every time you (re-)compile.
I was using the version of st that comes preinstalled with dwm-flexipatch.
Actually dwm-flexipatch will use st as per the configuration, but it doesn't come with it. Presumably you must have installed this separately before, like with dmenu.
I've tried to install
st-flexipatch
, enabled the patch in patches.h and then runsudo make clean install
. After logging off and on, I still have the same issue. Am I doing something wrong?
You do not need to log off and on, just starting a new terminal should suffice.
You are not doing anything wrong. The Xft.dpi
setting scales the point size, but the default configuration specifies the size using pixel size which is unaffected:
static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true";
So if you change pixelsize=12
to size=14
then I think that it should work.
Changing pixelsize=12
to size=11
worked! Thank you @bakkeby :pray:
Hi,
I'm new to
dwm
and very grateful fordmw-flexipatch
― it really makes the journey easier.I have a laptop with a HiDPI monitor (Dell XPS 13 9350). When using GNOME/Wayland, I generally set the scaling to 200%.
When starting
dwm
, without making any changes, everything is super tiny.I've partially addressed the problem by adding
Xft.dpi: 192
to the~/.Xresources
file as suggested in the Arch Wiki (although, I'm using Ubuntu 22.04):After that, every application and the
dwm
menu have my desired resolution. However,st
still has a very small resolution. Below is a screenshot that hopefully clarifies what I mean. On the left is ast
window, withvim
open and the desired font size. A newst
window with the default font size is on the top right tile.So far, I've dealt with the issue by interactively increasing the font size (
Ctrl+Shift+PgUp
), but would like to fix the issue entirely. How can I achieve that?One more thing, I've noticed that if I run
st -f 'monospace:size=10'
, a newst
window starts with the desired resolution. Is there a way to set thest
font size inconfig.def.h
?