summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app-defaults/XFontSel4
-rw-r--r--xfontsel.c56
2 files changed, 50 insertions, 10 deletions
diff --git a/app-defaults/XFontSel b/app-defaults/XFontSel
index 371eab1..4faa810 100644
--- a/app-defaults/XFontSel
+++ b/app-defaults/XFontSel
@@ -36,8 +36,8 @@
*appDefaultsVersion: 1
-*pixelSizeList: 7, 30, 40, 50, 60
-*pointSizeList: 250, 300, 350, 400
+*pixelSizeList: 0
+*pointSizeList: 80, 90, 100, 110, 120, 140, 160, 170, 180, 200, 250, 300, 350, 400
XFontSel.cursor: left_ptr
*allowShellResize: true
diff --git a/xfontsel.c b/xfontsel.c
index cfa3d58..540fade 100644
--- a/xfontsel.c
+++ b/xfontsel.c
@@ -50,6 +50,7 @@ Modified: Mark Leisher <mleisher@crl.nmsu.edu> to deal with UCS sample text.
#include <X11/Xmu/Atoms.h>
#include <X11/Xmu/StdSel.h>
#include <X11/Xfuncs.h>
+#include <X11/Xlib.h>
#include "ULabel.h"
#define MIN_APP_DEFAULTS_VERSION 1
@@ -161,7 +162,8 @@ static void Syntax(const char *call)
" -sample string sample text to use for 1-byte fonts\n"
" -sample16 string sample text to use for 2-byte fonts\n"
" -sampleUCS string sample text to use for ISO10646 fonts\n"
- " -scaled use scaled instances of fonts\n");
+ " -scaled use scaled instances of fonts\n"
+ "plus any standard toolkit options\n");
exit (1);
}
@@ -278,7 +280,7 @@ see 'xfontsel' manual page."
);
}
- ScheduleWork(GetFontNames, (XtPointer)XtDisplay(topLevel), 0);
+ ScheduleWork(GetFontNames, (XtPointer)topLevel, 0);
pane = XtCreateManagedWidget("pane",panedWidgetClass,topLevel,NZ);
{
@@ -353,7 +355,7 @@ see 'xfontsel' manual page."
&wm_delete_window, 1);
XtAppMainLoop(appCtx);
- return 0;
+ exit(0);
}
@@ -446,7 +448,8 @@ struct ParseRec {
void GetFontNames(XtPointer closure)
{
- Display *dpy = (Display*)closure;
+ Widget topLevel = (Widget)closure;
+ Display *dpy = XtDisplay(topLevel);
ParseRec *parseRec;
int count;
char **fontNames;
@@ -500,7 +503,7 @@ void GetFontNames(XtPointer closure)
ScheduleWork((XtProc)XFreeFontNames,(XtPointer)fontNames,work_priority);
ScheduleWork((XtProc)XtFree, (XtPointer)parseRec, work_priority);
if (AppRes.scaled_fonts)
- ScheduleWork(FixScalables,(XtPointer)0,work_priority);
+ ScheduleWork(FixScalables,(XtPointer)topLevel, work_priority);
ScheduleWork(SortFields,(XtPointer)0,work_priority);
SetParsingFontCount(matchingFontCount);
if (strcmp(AppRes.pattern, DEFAULTPATTERN)) {
@@ -710,13 +713,50 @@ static void NewScalables(int f, char *slist)
/* Find all scalable fonts, defined as the set matching "0" in the pixel
* size field (field 6). Augment the match-lists for all other fields
* that are scalable. Add in new scalable pixel and point sizes given
- * in resources.
+ * in resources, along with the current Screen's actual resX and resY
+ * values.
*/
/*ARGSUSED*/
void FixScalables(XtPointer closure)
{
int i;
FieldValue *fval = fieldValues[6]->value;
+ Widget topLevel = (Widget) closure;
+ Display *dpy = XtDisplay(topLevel);
+ int scr = XScreenNumberOfScreen(XtScreenOfObject(topLevel));
+ double xres, yres;
+ static char xreslist[21]; /* log10(UINT64_MAX) == 19 */
+ static char yreslist[21];
+
+ /* from xdpyinfo.c:
+ * there are 2.54 centimeters to an inch; so there are 25.4 millimeters.
+ *
+ * dpi = N pixels / (M millimeters / (25.4 millimeters / 1 inch))
+ * = N pixels / (M inch / 25.4)
+ * = N * 25.4 pixels / M inch
+ */
+ xres = ((((double) DisplayWidth(dpy, scr)) * 25.4) /
+ ((double) DisplayWidthMM(dpy, scr)));
+ yres = ((((double) DisplayHeight(dpy, scr)) * 25.4) /
+ ((double) DisplayHeightMM(dpy, scr)));
+
+ /*
+ * xxx the "0" element is always added, so we can't force these here....
+ *
+ * However, what's interesting is that if the pattern contains '*' for these
+ * fields (i.e. instead of '0') then we end up with the menu containing "0,
+ * 100, xres", which makes for a really good demonstration of how scaling
+ * fonts without knowing the true screen resolution leads to very wonky
+ * results.
+ *
+ * xxx obviously these are static and related only to the screen of the
+ * Widget at the time this code executes and so you can't drag the Xfontsel
+ * winto to another screen with a different resolution and see things change
+ * dynamically -- you have to instantiate a new Xfontsel process on each
+ * different screen as desired.
+ */
+ sprintf(xreslist, "%d", (int) (xres + 0.5));
+ sprintf(yreslist, "%d", (int) (yres + 0.5));
for (i = fieldValues[6]->count; --i >= 0; fval++) {
if (fval->string && !strcmp(fval->string, "0")) {
@@ -726,8 +766,8 @@ void FixScalables(XtPointer closure)
NewScalables(6, AppRes.pixelSizeList);
AddScalables(7);
NewScalables(7, AppRes.pointSizeList);
- AddScalables(8);
- AddScalables(9);
+ NewScalables(8, xreslist);
+ NewScalables(9, yreslist);
AddScalables(11);
break;
}