[hackers] [st] query pixel size from matched font || Eon S. Jeon

From: <git_AT_suckless.org>
Date: Fri, 03 Jan 2014 15:27:18 +0100

commit e8dba89164fe70647a413b8568b545ff2d887a78
Author: Eon S. Jeon <esjeon_AT_hyunmu.am>
Date: Tue Dec 17 15:14:19 2013 -0500

    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...

diff --git a/st.c b/st.c
index 4fb3311..82bfd3d 100644
--- a/st.c
+++ b/st.c
_AT_@ -398,7 +398,7 @@ static void xinit(void);
 static void xloadcols(void);
 static int xsetcolorname(int, const char *);
 static int xloadfont(Font *, FcPattern *);
-static void xloadfonts(char *, int);
+static void xloadfonts(char *, double);
 static int xloadfontset(Font *);
 static void xsettitle(char *);
 static void xresettitle(void);
_AT_@ -478,7 +478,7 @@ static char *opt_font = NULL;
 static int oldbutton = 3; /* button event on startup: 3 = release */
 
 static char *usedfont = NULL;
-static int usedfontsize = 0;
+static double usedfontsize = 0;
 
 /* Font Ring Cache */
 enum {
_AT_@ -2826,9 +2826,9 @@ xloadfont(Font *f, FcPattern *pattern) {
 }
 
 void
-xloadfonts(char *fontstr, int fontsize) {
+xloadfonts(char *fontstr, double fontsize) {
         FcPattern *pattern;
- FcResult result;
+ FcResult r_sz, r_psz;
         double fontval;
 
         if(fontstr[0] == '-') {
_AT_@ -2842,12 +2842,16 @@ xloadfonts(char *fontstr, int fontsize) {
 
         if(fontsize > 0) {
                 FcPatternDel(pattern, FC_PIXEL_SIZE);
+ FcPatternDel(pattern, FC_SIZE);
                 FcPatternAddDouble(pattern, FC_PIXEL_SIZE, (double)fontsize);
                 usedfontsize = fontsize;
         } else {
- result = FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval);
- if(result == FcResultMatch) {
- usedfontsize = (int)fontval;
+ r_psz = FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval);
+ r_sz = FcPatternGetDouble(pattern, FC_SIZE, 0, &fontval);
+ if(r_psz == FcResultMatch) {
+ usedfontsize = fontval;
+ } else if(r_sz == FcResultMatch) {
+ usedfontsize = -1;
                 } else {
                         /*
                          * Default font size is 12, if none given. This is to
_AT_@ -2864,6 +2868,12 @@ xloadfonts(char *fontstr, int fontsize) {
         if(xloadfont(&dc.font, pattern))
                 die("st: can't open font %s
", fontstr);
 
+ if(usedfontsize < 0) {
+ FcPatternGetDouble(dc.font.match->pattern,
+ FC_PIXEL_SIZE, 0, &fontval);
+ usedfontsize = fontval;
+ }
+
         /* Setting character width and height. */
         xw.cw = CEIL(dc.font.width * cwscale);
         xw.ch = CEIL(dc.font.height * chscale);
Received on Fri Jan 03 2014 - 15:27:18 CET

This archive was generated by hypermail 2.3.0 : Fri Jan 03 2014 - 15:36:18 CET