I've written a little patch for st that add the support for font size
property, so it's possibile to pass font in the form:
Monospace-10
or
Monospace:size=10
I don't know Xlib nor Fontconfig so i hope it's all correct.
--
Mariano
diff --git a/st.c b/st.c
index 2811876..582889f 100644
--- a/st.c
+++ b/st.c
@@ -2715,6 +2715,7 @@ xloadfonts(char *fontstr, int fontsize) {
FcPattern *pattern;
FcResult result;
double fontval;
+ double DPI;
if(fontstr[0] == '-') {
pattern = XftXlfdParse(fontstr, False, False);
@@ -2734,12 +2735,21 @@ xloadfonts(char *fontstr, int fontsize) {
if(result == FcResultMatch) {
usedfontsize = (int)fontval;
} else {
- /*
- * Default font size is 12, if none given. This is to
- * have a known usedfontsize value.
- */
- FcPatternAddDouble(pattern, FC_PIXEL_SIZE, 12);
- usedfontsize = 12;
+ /* Try to get size in Pt */
+ result = FcPatternGetDouble(pattern, FC_SIZE, 0,
&fontval);
+ if(result == FcResultMatch) {
+ DPI = XDisplayWidth(xw.dpy, xw.scr) /
+ (XDisplayWidthMM(xw.dpy, xw.scr) /
25.4);
+ usedfontsize = (int)DPI * fontval / 72;
+ FcPatternAddDouble(pattern, FC_PIXEL_SIZE,
usedfontsize);
+ } else {
+ /*
+ * Default font size is 12, if none given. This
+ * is to have a known usedfontsize value.
+ */
+ FcPatternAddDouble(pattern, FC_PIXEL_SIZE, 12);
+ usedfontsize = 12;
+ }
}
}