diff options
author | Eon S. Jeon <esjeon@hyunmu.am> | 2013-12-17 15:14:19 -0500 |
---|---|---|
committer | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2014-01-03 15:26:25 +0100 |
commit | e8dba89164fe70647a413b8568b545ff2d887a78 (patch) | |
tree | 540ca3dcac547f9a754ef6ebd7dd3c132c3131af | |
parent | 33da67dac035b0d592f984bce90aec8d815b38a8 (diff) | |
download | st-patched-e8dba89164fe70647a413b8568b545ff2d887a78.tar.bz2 st-patched-e8dba89164fe70647a413b8568b545ff2d887a78.tar.xz st-patched-e8dba89164fe70647a413b8568b545ff2d887a78.zip |
query pixel size from matched font
Sorry for another duplicated mail. I found the patch is malformed
significantly. I've been away from my laptop for a while, so I'm quite
unfamiliar with the settings on this system...
-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); |