diff options
| -rw-r--r-- | st.c | 24 |
1 files changed, 17 insertions, 7 deletions
| @@ -398,7 +398,7 @@ static void xinit(void); | |||
| 398 | static void xloadcols(void); | 398 | static void xloadcols(void); |
| 399 | static int xsetcolorname(int, const char *); | 399 | static int xsetcolorname(int, const char *); |
| 400 | static int xloadfont(Font *, FcPattern *); | 400 | static int xloadfont(Font *, FcPattern *); |
| 401 | static void xloadfonts(char *, int); | 401 | static void xloadfonts(char *, double); |
| 402 | static int xloadfontset(Font *); | 402 | static int xloadfontset(Font *); |
| 403 | static void xsettitle(char *); | 403 | static void xsettitle(char *); |
| 404 | static void xresettitle(void); | 404 | static void xresettitle(void); |
| @@ -478,7 +478,7 @@ static char *opt_font = NULL; | |||
| 478 | static int oldbutton = 3; /* button event on startup: 3 = release */ | 478 | static int oldbutton = 3; /* button event on startup: 3 = release */ |
| 479 | 479 | ||
| 480 | static char *usedfont = NULL; | 480 | static char *usedfont = NULL; |
| 481 | static int usedfontsize = 0; | 481 | static double usedfontsize = 0; |
| 482 | 482 | ||
| 483 | /* Font Ring Cache */ | 483 | /* Font Ring Cache */ |
| 484 | enum { | 484 | enum { |
| @@ -2826,9 +2826,9 @@ xloadfont(Font *f, FcPattern *pattern) { | |||
| 2826 | } | 2826 | } |
| 2827 | 2827 | ||
| 2828 | void | 2828 | void |
| 2829 | xloadfonts(char *fontstr, int fontsize) { | 2829 | xloadfonts(char *fontstr, double fontsize) { |
| 2830 | FcPattern *pattern; | 2830 | FcPattern *pattern; |
| 2831 | FcResult result; | 2831 | FcResult r_sz, r_psz; |
| 2832 | double fontval; | 2832 | double fontval; |
| 2833 | 2833 | ||
| 2834 | if(fontstr[0] == '-') { | 2834 | if(fontstr[0] == '-') { |
| @@ -2842,12 +2842,16 @@ xloadfonts(char *fontstr, int fontsize) { | |||
| 2842 | 2842 | ||
| 2843 | if(fontsize > 0) { | 2843 | if(fontsize > 0) { |
| 2844 | FcPatternDel(pattern, FC_PIXEL_SIZE); | 2844 | FcPatternDel(pattern, FC_PIXEL_SIZE); |
| 2845 | FcPatternDel(pattern, FC_SIZE); | ||
| 2845 | FcPatternAddDouble(pattern, FC_PIXEL_SIZE, (double)fontsize); | 2846 | FcPatternAddDouble(pattern, FC_PIXEL_SIZE, (double)fontsize); |
| 2846 | usedfontsize = fontsize; | 2847 | usedfontsize = fontsize; |
| 2847 | } else { | 2848 | } else { |
| 2848 | result = FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval); | 2849 | r_psz = FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval); |
| 2849 | if(result == FcResultMatch) { | 2850 | r_sz = FcPatternGetDouble(pattern, FC_SIZE, 0, &fontval); |
| 2850 | usedfontsize = (int)fontval; | 2851 | if(r_psz == FcResultMatch) { |
| 2852 | usedfontsize = fontval; | ||
| 2853 | } else if(r_sz == FcResultMatch) { | ||
| 2854 | usedfontsize = -1; | ||
| 2851 | } else { | 2855 | } else { |
| 2852 | /* | 2856 | /* |
| 2853 | * Default font size is 12, if none given. This is to | 2857 | * Default font size is 12, if none given. This is to |
| @@ -2864,6 +2868,12 @@ xloadfonts(char *fontstr, int fontsize) { | |||
| 2864 | if(xloadfont(&dc.font, pattern)) | 2868 | if(xloadfont(&dc.font, pattern)) |
| 2865 | die("st: can't open font %s\n", fontstr); | 2869 | die("st: can't open font %s\n", fontstr); |
| 2866 | 2870 | ||
| 2871 | if(usedfontsize < 0) { | ||
| 2872 | FcPatternGetDouble(dc.font.match->pattern, | ||
| 2873 | FC_PIXEL_SIZE, 0, &fontval); | ||
| 2874 | usedfontsize = fontval; | ||
| 2875 | } | ||
| 2876 | |||
| 2867 | /* Setting character width and height. */ | 2877 | /* Setting character width and height. */ |
| 2868 | xw.cw = CEIL(dc.font.width * cwscale); | 2878 | xw.cw = CEIL(dc.font.width * cwscale); |
| 2869 | xw.ch = CEIL(dc.font.height * chscale); | 2879 | xw.ch = CEIL(dc.font.height * chscale); |
