[dev] [st] parse relative font size instead of pixelsize

From: Nils Reuße <n.reusse_AT_hxgn.net>
Date: Tue, 17 Dec 2013 10:06:22 +0100

Hi suckless_AT_,

i tried to set a font and fontsize in config.h with the xft notation
FONT-SIZE:

     static char font[] = "Source Code Pro Medium-18:style=Regular";

The font was recognized, but not the font size, defaulting to 12. The
same was true when i used the size attribute:

     static char font[] = "Source Code Pro Medium:style=Regular:size=18";

After figuring out that only the attribute 'pixelsize' works, i changed
all occurrences of FC_PIXEL_SIZE to FC_SIZE in st.c (latest git, patch
below), and now it works with size (but obviously breaks with pixelsize).

I prefer size over pixelsize because size scales to the current display
resolution, while pixelsize has to be increased (either in config.h or
on starting st), e.g. if you switch between a non-hd (home) and hd
screen (work).

What do you think?

Best,
Nils


diff --git a/st.c b/st.c
index f883ac1..e888f32 100644
--- a/st.c
+++ b/st.c
_AT_@ -2841,11 +2841,11 @@ xloadfonts(char *fontstr, int fontsize) {
                  die("st: can't open font %s\n", fontstr);

          if(fontsize > 0) {
- FcPatternDel(pattern, FC_PIXEL_SIZE);
- FcPatternAddDouble(pattern, FC_PIXEL_SIZE, (double)fontsize);
+ FcPatternDel(pattern, FC_SIZE);
+ FcPatternAddDouble(pattern, FC_SIZE, (double)fontsize);
                  usedfontsize = fontsize;
          } else {
- result = FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval);
+ result = FcPatternGetDouble(pattern, FC_SIZE, 0, &fontval);
                  if(result == FcResultMatch) {
                          usedfontsize = (int)fontval;
                  } else {
_AT_@ -2853,7 +2853,7 @@ xloadfonts(char *fontstr, int fontsize) {
                           * Default font size is 12, if none given. This is to
                           * have a known usedfontsize value.
                           */
- FcPatternAddDouble(pattern, FC_PIXEL_SIZE, 12);
+ FcPatternAddDouble(pattern, FC_SIZE, 12);
                          usedfontsize = 12;
                  }
          }
Received on Tue Dec 17 2013 - 10:06:22 CET

This archive was generated by hypermail 2.3.0 : Tue Dec 17 2013 - 10:12:06 CET