diff --git a/Makefile.am b/Makefile.am
index 567f4623..b8c7eab0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,7 +9,7 @@ MAINTAINERCLEANFILES = Makefile.in \
config.h.in \
install-sh
-SUBDIRS = util lib programs include
+SUBDIRS = util lib programs include fonts
if BUILD_DOCS
SUBDIRS += doc
diff --git a/configure.ac b/configure.ac
index 72c340bf..79bdb991 100644
--- a/configure.ac
+++ b/configure.ac
@@ -60,6 +60,21 @@ done
AC_SUBST(MCDE_DIALECT_CFLAGS)
LT_INIT
+dnl MCDE: Xft (from MakroDE): anti-aliased fonts in dtterm through fontconfig.
+dnl On by default -- the desktop draws Hack (fonts/) -- and --disable-xft keeps
+dnl the classic fontset renderer for machines without freetype.
+AC_ARG_ENABLE([xft],
+ AS_HELP_STRING([--disable-xft], [no Xft text renderer in dtterm (default: enabled)]),
+ [enable_xft="$enableval"], [enable_xft=yes])
+XFTLIB=""
+XFT_CFLAGS=""
+if test "$enable_xft" = yes; then
+ PKG_CHECK_MODULES([XFT], [xft fontconfig])
+ XFTLIB="$XFT_LIBS"
+ AC_DEFINE([HAVE_XFT], [1], [dtterm can draw through Xft])
+fi
+AC_SUBST(XFTLIB)
+AC_SUBST(XFT_CFLAGS)
AC_PREFIX_DEFAULT(/usr/dt)
@@ -343,6 +358,11 @@ AC_ARG_WITH([calendar-dir],
[AS_HELP_STRING([--with-calendar-dir=DIR], [calendar spool of rpc.cmsd (default /var/spool/calendar)])],
[MCDE_CALENDAR_DIR=$withval], [MCDE_CALENDAR_DIR=/var/spool/calendar])
AC_SUBST(MCDE_CALENDAR_DIR)
+dnl the system's fontconfig, which config/fonts.conf includes before adding the
+dnl MCDE fonts (fonts/Makefile.am)
+MCDE_FC_CONFDIR=`$PKG_CONFIG --variable=confdir fontconfig 2>/dev/null`
+test -n "$MCDE_FC_CONFDIR" || MCDE_FC_CONFDIR=/etc/fonts
+AC_SUBST(MCDE_FC_CONFDIR)
CDE_USER_TOP=.dt
AC_SUBST(CDE_INSTALLATION_TOP)
@@ -636,6 +656,7 @@ LIBS="${EXTRA_LIBS} ${LIBS} ${PTHREAD_LIBS}"
dnl All of the makefiles we need to generate go here...
AC_CONFIG_FILES([
Makefile
+fonts/Makefile
util/Makefile
util/tradcpp/Makefile
diff --git a/fonts/Makefile.am b/fonts/Makefile.am
new file mode 100644
index 00000000..ed7662e5
--- /dev/null
+++ b/fonts/Makefile.am
@@ -0,0 +1,25 @@
+MAINTAINERCLEANFILES = Makefile.in
+
+# MCDE: the fonts that come with the desktop -- Hack, the default (hack/README).
+# They are installed under the CDE tree; every MCDE program adds this directory
+# to fontconfig for itself (FcConfigAppFontAddDir), so nothing in the system's
+# font configuration has to change.
+hackdir = $(CDE_INSTALLATION_TOP)/fonts/hack
+dist_hack_DATA = hack/Hack-Regular.ttf hack/Hack-Bold.ttf hack/Hack-Italic.ttf \
+ hack/Hack-BoldItalic.ttf hack/LICENSE hack/README
+
+# The session's fontconfig file: the system's own configuration, plus the
+# directory above. Xsession.d/0070.dtfonts exports FONTCONFIG_FILE for the
+# session, Dtlogin*environment for the login screen; every X program of the
+# session then finds Hack, MCDE's or not.
+fontconfdir = $(CDE_INSTALLATION_TOP)/config
+fontconf_DATA = fonts.conf
+CLEANFILES = fonts.conf
+fonts.conf: Makefile
+ { echo ''; \
+ echo ''; \
+ echo ''; \
+ echo ''; \
+ echo ' $(MCDE_FC_CONFDIR)/fonts.conf'; \
+ echo ' $(CDE_INSTALLATION_TOP)/fonts'; \
+ echo ''; } > $@
diff --git a/fonts/hack/Hack-Bold.ttf b/fonts/hack/Hack-Bold.ttf
new file mode 100644
index 00000000..7cf7f96d
Binary files /dev/null and b/fonts/hack/Hack-Bold.ttf differ
diff --git a/fonts/hack/Hack-BoldItalic.ttf b/fonts/hack/Hack-BoldItalic.ttf
new file mode 100644
index 00000000..ecdf7bb2
Binary files /dev/null and b/fonts/hack/Hack-BoldItalic.ttf differ
diff --git a/fonts/hack/Hack-Italic.ttf b/fonts/hack/Hack-Italic.ttf
new file mode 100644
index 00000000..cb8ed48e
Binary files /dev/null and b/fonts/hack/Hack-Italic.ttf differ
diff --git a/fonts/hack/Hack-Regular.ttf b/fonts/hack/Hack-Regular.ttf
new file mode 100644
index 00000000..9f75ef0a
Binary files /dev/null and b/fonts/hack/Hack-Regular.ttf differ
diff --git a/fonts/hack/LICENSE b/fonts/hack/LICENSE
new file mode 100644
index 00000000..1d418c2d
--- /dev/null
+++ b/fonts/hack/LICENSE
@@ -0,0 +1,86 @@
+Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: fonts-hack
+Upstream-Contact: Christopher Simpkins
+Source: https://github.com/source-foundry/Hack
+
+Files: *
+Copyright:
+ 2003 Bitstream Inc.
+ 2018 Christopher Simpkins
+License: Expat and BitstreamVera
+Comment:
+ Bitstream Vera Sans Mono is Copyright Bitstream Inc. and licensed under the
+ Bitstream Vera License with Reserved Font Names "Bitstream" and "Vera".
+ .
+ DejaVu modifications of the original Bitstream Vera Sans Mono typeface have
+ been committed to the public domain.
+ .
+ The work in the Hack project is licensed under the MIT (Expat) License.
+
+Files: debian/*
+Copyright:
+ 2015 Paride Legovini
+ 2016-2025 Fabian Greffrath
+License: gnu-simple-permissive-license
+ Copying and distribution of this file, with or without modification,
+ are permitted in any medium without royalty provided the copyright
+ notice and this notice are preserved. This file is offered as-is,
+ without any warranty.
+
+License: Expat
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+ .
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ .
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+
+License: BitstreamVera
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of the fonts accompanying this license ("Fonts") and associated documentation
+ files (the "Font Software"), to reproduce and distribute the Font Software,
+ including without limitation the rights to use, copy, merge, publish,
+ distribute, and/or sell copies of the Font Software, and to permit persons to
+ whom the Font Software is furnished to do so, subject to the following
+ conditions:
+ .
+ The above copyright and trademark notices and this permission notice shall be
+ included in all copies of one or more of the Font Software typefaces.
+ .
+ The Font Software may be modified, altered, or added to, and in particular the
+ designs of glyphs or characters in the Fonts may be modified and additional
+ glyphs or characters may be added to the Fonts, only if the fonts are renamed
+ to names not containing either the words "Bitstream" or the word "Vera".
+ .
+ This License becomes null and void to the extent applicable to Fonts or Font
+ Software that has been modified and is distributed under the "Bitstream Vera"
+ names.
+ .
+ The Font Software may be sold as part of a larger software package but no copy
+ of one or more of the Font Software typefaces may be sold by itself.
+ .
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
+ TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME FOUNDATION
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL,
+ SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO
+ USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
+ .
+ Except as contained in this notice, the names of Gnome, the Gnome Foundation,
+ and Bitstream Inc., shall not be used in advertising or otherwise to promote
+ the sale, use or other dealings in this Font Software without prior written
+ authorization from the Gnome Foundation or Bitstream Inc., respectively. For
+ further information, contact: fonts at gnome dot org.
diff --git a/fonts/hack/README b/fonts/hack/README
new file mode 100644
index 00000000..b8d2e8a0
--- /dev/null
+++ b/fonts/hack/README
@@ -0,0 +1,11 @@
+Hack 3.003 -- the default font of MCDE (Konrad, 2026-11-09)
+
+Hack is an open source typeface for source code by Source Foundry, based on
+Bitstream Vera Sans Mono and DejaVu Sans Mono: https://sourcefoundry.org/hack/
+
+Licence: Expat (MIT) for the Hack modifications and the Bitstream Vera Licence
+for the Bitstream Vera glyphs -- both allow redistribution; see LICENSE, which
+is the Debian copyright file of the package these files were taken from.
+
+Source of these four files: Debian package fonts-hack 3.003-4,
+/usr/share/fonts/truetype/hack/ (the upstream v3.003 release, unmodified).
diff --git a/lib/DtTerm/TermPrim/Makefile.am b/lib/DtTerm/TermPrim/Makefile.am
index 6c404dd7..5e541b4c 100644
--- a/lib/DtTerm/TermPrim/Makefile.am
+++ b/lib/DtTerm/TermPrim/Makefile.am
@@ -20,6 +20,7 @@ libTermPrim_la_SOURCES = TermPrim.c \
TermPrimRenderMb.c \
TermPrimRenderFont.c \
TermPrimRenderFontSet.c \
+ TermPrimRenderXft.c \
TermPrimRenderLineDraw.c \
TermPrimRepType.c \
TermPrimScroll.c \
@@ -38,3 +39,12 @@ libTermPrim_la_SOURCES += TermPrimGetPty-svr4.c
else
libTermPrim_la_SOURCES += TermPrimGetPty-pts.c
endif
+
+# MakroDE addition (13b): dtterm draws through Xft for entries that are Xft fonts. configure.ac
+# checks for it; debian/control carries the Build-Depends. The classic fontset path does not
+# need any of this, so a machine that lacks Xft still builds -- it just has one way fewer.
+libTermPrim_la_LIBADD = $(XFTLIB)
+
+# Only set when --enable-xft was given: Xft.h includes , which lives in
+# /usr/include/freetype2 on this system, and pkg-config is what knows that.
+AM_CPPFLAGS += $(XFT_CFLAGS)
diff --git a/lib/DtTerm/TermPrim/TermPrim.c b/lib/DtTerm/TermPrim/TermPrim.c
index 2221afd3..7ec73b00 100644
--- a/lib/DtTerm/TermPrim/TermPrim.c
+++ b/lib/DtTerm/TermPrim/TermPrim.c
@@ -60,6 +60,10 @@ extern char * _DtTermPrimGetMessage( char *filename, int set, int n, char *s );
#include "TermPrimPendingTextP.h"
#include "TermPrimRenderFont.h"
#include "TermPrimRenderFontSet.h"
+#include /* HAVE_XFT */
+#ifdef HAVE_XFT
+#include "TermPrimRenderXft.h"
+#endif
#include "TermPrimSelectP.h"
#include "TermPrimSetUtmp.h"
#include "TermPrimUtil.h"
@@ -653,7 +657,8 @@ _DtTermPrimGetFontSet
Widget w,
XmFontList fontList,
XFontSet *fontSet,
- XFontStruct **font
+ XFontStruct **font,
+ void **xftFont /* an XftFont* when HAVE_XFT, opaque otherwise */
)
{
XmFontContext fontContext;
@@ -663,6 +668,7 @@ _DtTermPrimGetFontSet
*fontSet = (XFontSet) 0;
*font = (XFontStruct *) 0;
+ if (xftFont) *xftFont = (void *) 0;
if (!XmFontListInitFontContext(&fontContext, fontList)) {
(void) fprintf(stderr, "XmFontListInitFontContext() failed\n");
@@ -675,7 +681,14 @@ _DtTermPrimGetFontSet
/*SUPPRESS 624*/
while ((fontListEntry = XmFontListNextEntry(fontContext))) {
pointer = XmFontListEntryGetFont(fontListEntry, &fontType);
- if (fontType == XmFONT_IS_FONTSET) {
+ if (fontType == XmFONT_IS_XFT) {
+ /* MakroDE addition (13b): the entry is an Xft font. This is a third kind of font,
+ not a different way of spelling the old ones -- the pointer is an XftFont*, and
+ treating it as an XFontSet would draw nonsense. */
+ if (xftFont)
+ *xftFont = (void *) pointer; /* the caller knows it is an XftFont* */
+ }
+ else if (fontType == XmFONT_IS_FONTSET) {
int i;
int num_fonts;
XFontStruct **fonts;
@@ -746,11 +759,31 @@ CreateRenderFont
XFontStruct *font = (XFontStruct *) 0;
/* get our fontset from the fontlist... */
- (void) _DtTermPrimGetFontSet(w, fontList, &fontSet, &font);
+#ifdef HAVE_XFT
+ void *xftFont = 0; /* opaque: the core does not name an Xft type */
+ (void) _DtTermPrimGetFontSet(w, fontList, &fontSet, &font, &xftFont);
+#else
+ (void) _DtTermPrimGetFontSet(w, fontList, &fontSet, &font, (void **) 0);
+#endif
/* generate a TermFont from either the fontset or the font... */
- if (fontSet) {
- termFont = _DtTermPrimRenderFontSetCreate(w, fontSet);
+ /* MakroDE (13b): EITHER an Xft font or a font set arrives -- never both. A guard on
+ fontSet alone would make the Xft branch unreachable, which is the one thing a branch
+ like this must not be. */
+ if (fontSet
+#ifdef HAVE_XFT
+ || xftFont != 0
+#endif
+ ) {
+#ifdef HAVE_XFT
+ /* MakroDE (13b): only the Xft piece is guarded. The fontset branch below is needed on
+ every machine, with or without Xft -- guarding the whole construct would have taken
+ the classic path away from exactly the machines that need it. */
+ if (xftFont != 0)
+ termFont = _DtTermPrimRenderXftCreate(w, (XftFont *) xftFont); /* cast inside the guard */
+ else
+#endif
+ termFont = _DtTermPrimRenderFontSetCreate(w, fontSet);
} else {
termFont = _DtTermPrimRenderFontCreate(w, font);
}
@@ -816,6 +849,23 @@ AdjustWindowUnits
tw->term.ascent = -fontSetExtents->max_logical_extent.y;
tw->term.tpd->ascent = tw->term.ascent;
+ tw->term.tpd->cellWidth = tw->term.widthInc;
+ tw->term.tpd->cellHeight = tw->term.heightInc;
+ } else if (!tw->term.font && tw->term.tpd->termFont) {
+ /* MCDE: a renderer without an X font structure (Xft): its own
+ * extents give the cell. The probe is one wchar_t, which the
+ * renderer reads as one character in either locale mode.
+ */
+ wchar_t probe = L'M';
+ int width = 0, height = 0, ascent = 0;
+
+ _DtTermPrimRenderFontExtents(w, tw->term.tpd->termFont,
+ (unsigned char *) &probe, 1, &width, &height, &ascent);
+ tw->term.widthInc = width > 0 ? width : 1;
+ tw->term.heightInc = height > 0 ? height : 1;
+ tw->term.ascent = ascent;
+ tw->term.tpd->ascent = ascent;
+
tw->term.tpd->cellWidth = tw->term.widthInc;
tw->term.tpd->cellHeight = tw->term.heightInc;
} else {
diff --git a/lib/DtTerm/TermPrim/TermPrimI.h b/lib/DtTerm/TermPrim/TermPrimI.h
index 2b864385..fcc190a0 100644
--- a/lib/DtTerm/TermPrim/TermPrimI.h
+++ b/lib/DtTerm/TermPrim/TermPrimI.h
@@ -59,7 +59,8 @@ _DtTermPrimGetFontSet
Widget w,
XmFontList fontList,
XFontSet *fontSet,
- XFontStruct **font
+ XFontStruct **font,
+ void **xftFont /* MakroDE (13b): an XftFont* when HAVE_XFT, opaque here */
);
#ifdef __cplusplus
diff --git a/lib/DtTerm/TermPrim/TermPrimRender.c b/lib/DtTerm/TermPrim/TermPrimRender.c
index 6c02de6c..011b3321 100644
--- a/lib/DtTerm/TermPrim/TermPrimRender.c
+++ b/lib/DtTerm/TermPrim/TermPrimRender.c
@@ -1566,3 +1566,13 @@ _DtTermPrimRenderText(
(void) (*(font->renderFunction))(w, font, fg, bg, flags, x, y, string, len);
return;
}
+
+/* MCDE: the extents of a run in FONT, through the renderer that made it */
+void
+_DtTermPrimRenderFontExtents(Widget w, TermFont font, unsigned char *string,
+ int len, int *widthReturn, int *heightReturn, int *ascentReturn)
+{
+ if (font && font->extentsFunction)
+ (*font->extentsFunction)(w, font, string, len, widthReturn,
+ heightReturn, ascentReturn);
+}
diff --git a/lib/DtTerm/TermPrim/TermPrimRender.h b/lib/DtTerm/TermPrim/TermPrimRender.h
index b8f513d7..e206b9d1 100644
--- a/lib/DtTerm/TermPrim/TermPrimRender.h
+++ b/lib/DtTerm/TermPrim/TermPrimRender.h
@@ -84,5 +84,10 @@ extern XtInputCallbackProc _termReadPty(XtPointer client_data, int *source,
extern void _termCompleteScroll(Widget w);
extern void _DtTermPrimFillScreenGap(Widget w);
extern void _DtTermPrimRenderPadLine(Widget w);
+/* MCDE: the extents of a run in FONT, through the renderer that made it (an
+ * Xft font has no XFontStruct the caller could measure) */
+extern void _DtTermPrimRenderFontExtents(Widget w, TermFont font,
+ unsigned char *string, int len, int *widthReturn, int *heightReturn,
+ int *ascentReturn);
#endif /* _Dt_TermPrimRender_h */
/* DON'T ADD ANYTHING AFTER THIS #endif... */
diff --git a/lib/DtTerm/TermPrim/TermPrimRenderFont.c b/lib/DtTerm/TermPrim/TermPrimRenderFont.c
index 1675a71d..75f6c4c0 100644
--- a/lib/DtTerm/TermPrim/TermPrimRenderFont.c
+++ b/lib/DtTerm/TermPrim/TermPrimRenderFont.c
@@ -27,6 +27,7 @@
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
+#include
#include "TermHeader.h"
#include "TermPrimP.h"
#include "TermPrimDebug.h"
@@ -108,6 +109,30 @@ FontRenderFunction(
(void) shortSleep(100000);
}
+ if (tpd->mbCurMax > 1) {
+ /* MCDE: in a multibyte locale (UTF-8, since dtterm calls setlocale) the
+ * buffer holds wchar_t; one font draws them as 16-bit characters --
+ * the code point for an ISO 10646 font, and byte1 0 for an 8-bit one.
+ * Characters beyond the 16-bit plane are drawn as '?'.
+ */
+ XChar2b *s2 = (XChar2b *) XtMalloc((Cardinal) (len * sizeof(XChar2b)));
+ wchar_t *wc = (wchar_t *) string;
+ int i;
+
+ for (i = 0; i < len; i++) {
+ unsigned long c = (unsigned long) wc[i] > 0xffffUL ?
+ (unsigned long) '?' : (unsigned long) wc[i];
+
+ s2[i].byte1 = (unsigned char) (c >> 8);
+ s2[i].byte2 = (unsigned char) (c & 0xff);
+ }
+ (void) XDrawImageString16(XtDisplay(w), XtWindow(w), tpd->renderGC.gc,
+ x, y + fontStruct->ascent, s2, len);
+ if (TermIS_OVERSTRIKE(flags))
+ (void) XDrawString16(XtDisplay(w), XtWindow(w), tpd->renderGC.gc,
+ x + 1, y + fontStruct->ascent, s2, len);
+ XtFree((char *) s2);
+ } else {
(void) XDrawImageString(XtDisplay(w), /* Display */
XtWindow(w), /* Drawable */
tpd->renderGC.gc, /* GC */
@@ -126,6 +151,7 @@ FontRenderFunction(
(char *) string, /* string */
len); /* length */
}
+ }
/* handle the underline enhancement... */
/* draw the underline... */
diff --git a/lib/DtTerm/TermPrim/TermPrimRenderXft.c b/lib/DtTerm/TermPrim/TermPrimRenderXft.c
new file mode 100644
index 00000000..86268e85
--- /dev/null
+++ b/lib/DtTerm/TermPrim/TermPrimRenderXft.c
@@ -0,0 +1,354 @@
+/*
+ * TermPrimRenderXft.c -- drawing text through Xft, behind the TermFont interface.
+ *
+ * MakroDE addition. SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2026 Konrad Lother
+ *
+ * WHAT THIS IS. The third TermFont implementation, next to the font set and the single font. dtterm
+ * asks for a TermFont and does not care which one it gets; this one renders through freetype, so the
+ * terminal can use the same fonts the rest of a modern desktop uses instead of an XLFD bitmap.
+ *
+ * ONE XftDraw, FOR THE LIFE OF THE TERMINAL. An XftDraw is bound to a Drawable and a visual, and
+ * rebuilding it per painted string is exactly the cost this fork cannot pay on the hardware it must
+ * keep running on. It is created here, in the create function, and kept in the record.
+ *
+ * WHAT ARRIVES (MCDE, 2026-11-09). In a multibyte locale (UTF-8) the buffer is wchar_t, one per
+ * character -- as the fontset renderer's XwcDrawString reads it; otherwise bytes. The first
+ * version read it as UTF-8 bytes and drew three empty boxes after every character
+ * (build/mcde-shots/dtterm-xft.png); each character is now placed in its own cell.
+ *
+ * AND THE CLASSIC PATH STAYS. This file does not replace the fontset renderer; it is one of the
+ * choices the caller makes, so a machine that cannot afford freetype per glyph still has a terminal.
+ */
+
+/* wcwidth() is XSI (POSIX.1-2008): ask for it before the first system header */
+#ifndef _XOPEN_SOURCE
+#define _XOPEN_SOURCE 700
+#endif
+#include
+#include
+#include
+#include
+
+#include "cde_config.h" /* HAVE_XFT, written by configure */
+
+#ifdef HAVE_XFT
+#include
+
+/* Same include order as the two renderers beside this one: TermHeader.h FIRST, because it is
+ * the project entry point that brings in the Motif and Intrinsic types the render headers
+ * expect. Without it, TermPrimRenderP.h pulls TermPrimRender.h in ahead of them and Widget,
+ * Pixel and the rest are unknown types. */
+#include "TermHeader.h"
+#include "TermPrimP.h"
+#include "TermPrimDebug.h"
+#include "TermPrimRenderP.h"
+#include "TermPrimRenderXft.h"
+
+/* MCDE: how many other fonts one terminal font may borrow glyphs from */
+#define MCDE_XFT_FALLBACKS 8
+
+typedef struct _TermFontXftRec {
+ XftFont *font;
+ XftDraw *draw; /* created ONCE, kept here, never per string */
+ XftFont *fallback[MCDE_XFT_FALLBACKS]; /* MCDE: fonts for what the font lacks */
+ int nfallback;
+ int ascent;
+ int height;
+ int width;
+} TermFontXftRec, *TermFontXft;
+
+/*
+ * MCDE: the cells a run covers, and the code point of one character. In a
+ * multibyte locale (UTF-8) the buffer holds wchar_t, one per character, and
+ * LEN counts characters; otherwise it holds bytes (the fontset renderer
+ * makes the same distinction, XmbDrawString or XwcDrawString). A wide
+ * character (wcwidth 2) takes two cells, a combining one (0) none.
+ */
+static FcChar32
+XftCharAt(struct termData *tpd, unsigned char *string, int i, int *cells)
+{
+ if (tpd->mbCurMax > 1) {
+ wchar_t wc = ((wchar_t *) string)[i];
+ int n = wcwidth(wc);
+
+ *cells = n < 0 ? 1 : n;
+ return (FcChar32) wc;
+ }
+ *cells = 1;
+ return (FcChar32) string[i]; /* single-byte locales: ISO 8859-1 */
+}
+
+static Bool
+XftColorFromPixel(Widget w, Pixel pixel, Visual *visual, Colormap cmap,
+ XftColor *out)
+{
+ XColor xc;
+ XRenderColor xr;
+
+ xc.pixel = pixel;
+ if (!XQueryColor(XtDisplay(w), cmap, &xc))
+ return False;
+ xr.red = xc.red;
+ xr.green = xc.green;
+ xr.blue = xc.blue;
+ xr.alpha = 0xffff;
+ return XftColorAllocValue(XtDisplay(w), visual, cmap, &xr, out);
+}
+
+/*
+ * MCDE: draws like XwcDrawImageString does for the fontset renderer -- the
+ * background of the cells first, then every character at its own cell
+ * (x + column * cellWidth) on the baseline (y + ascent). Placing each
+ * character keeps the grid even where a glyph comes from a fallback font of
+ * another width. Underline, overstrike (the bold of terminals) and secure
+ * (hidden) text as the other renderers draw them.
+ */
+/*
+ * MCDE: the font that draws C -- the terminal font, or a font fontconfig
+ * finds for that character at the same pixel size (a check mark, CJK ...).
+ * Up to MCDE_XFT_FALLBACKS of them are kept per terminal font; beyond that,
+ * or if nothing has the character, the terminal font draws its box.
+ */
+static XftFont *
+XftFontFor(Display *dpy, TermFontXft xf, FcChar32 c)
+{
+ FcPattern *pat, *match;
+ FcCharSet *cs;
+ FcResult res;
+ XftFont *f;
+ double px = 0;
+ int i;
+
+ if (XftCharExists(dpy, xf->font, c))
+ return xf->font;
+ for (i = 0; i < xf->nfallback; i++)
+ if (XftCharExists(dpy, xf->fallback[i], c))
+ return xf->fallback[i];
+ if (xf->nfallback == MCDE_XFT_FALLBACKS)
+ return xf->font;
+
+ (void) FcPatternGetDouble(xf->font->pattern, FC_PIXEL_SIZE, 0, &px);
+ if ((pat = FcPatternCreate()) == 0)
+ return xf->font;
+ if ((cs = FcCharSetCreate()) != 0) {
+ (void) FcCharSetAddChar(cs, c);
+ (void) FcPatternAddCharSet(pat, FC_CHARSET, cs);
+ FcCharSetDestroy(cs);
+ }
+ if (px > 0)
+ (void) FcPatternAddDouble(pat, FC_PIXEL_SIZE, px);
+ match = XftFontMatch(dpy, DefaultScreen(dpy), pat, &res);
+ FcPatternDestroy(pat);
+ if (match == 0)
+ return xf->font;
+ f = XftFontOpenPattern(dpy, match); /* owns MATCH from here */
+ if (f == 0) {
+ FcPatternDestroy(match);
+ return xf->font;
+ }
+ if (!XftCharExists(dpy, f, c)) {
+ XftFontClose(dpy, f);
+ return xf->font;
+ }
+ xf->fallback[xf->nfallback++] = f;
+ return f;
+}
+
+/* the XftDraw of the widget's window, made once the window exists */
+static XftDraw *
+XftEnsureDraw(Widget w, TermFontXft xf)
+{
+ if (xf->draw == 0 && XtIsRealized(w))
+ xf->draw = XftDrawCreate(XtDisplay(w), XtWindow(w),
+ DefaultVisual(XtDisplay(w), DefaultScreen(XtDisplay(w))),
+ DefaultColormap(XtDisplay(w), DefaultScreen(XtDisplay(w))));
+ return xf->draw;
+}
+
+static void
+XftRenderFunction(
+ Widget w,
+ TermFont font,
+ Pixel fg,
+ Pixel bg,
+ unsigned long flags,
+ int x,
+ int y,
+ unsigned char *string,
+ int len
+)
+{
+ TermFontXft xf = (TermFontXft) font->fontInfo;
+ DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
+ struct termData *tpd = tw->term.tpd;
+ Display *dpy = XtDisplay(w);
+ Visual *visual = DefaultVisual(dpy, DefaultScreen(dpy));
+ Colormap cmap = DefaultColormap(dpy, DefaultScreen(dpy));
+ XftColor fgc, bgc;
+ int cw, i, col, cells, n, total = 0;
+ FcChar32 c;
+
+ if (xf == 0 || xf->font == 0 || string == 0 || len <= 0 ||
+ XftEnsureDraw(w, xf) == 0)
+ return;
+ cw = tpd->cellWidth > 0 ? tpd->cellWidth : xf->width;
+
+ if (!XftColorFromPixel(w, fg, visual, cmap, &fgc))
+ return;
+ if (!XftColorFromPixel(w, bg, visual, cmap, &bgc)) {
+ XftColorFree(dpy, visual, cmap, &fgc);
+ return;
+ }
+
+ for (i = 0; i < len; i++) {
+ (void) XftCharAt(tpd, string, i, &cells);
+ total += cells;
+ }
+ XftDrawRect(xf->draw, &bgc, x, y, (unsigned) (total * cw),
+ (unsigned) (tpd->cellHeight > 0 ? tpd->cellHeight : xf->height));
+
+ /* hidden text (secure): the cells only */
+ if (TermIS_SECURE(flags))
+ len = 0;
+
+ for (i = 0, col = 0; i < len; i++) {
+ c = XftCharAt(tpd, string, i, &cells);
+ /* a combining character sits on the cell before it */
+ n = cells == 0 && col > 0 ? col - 1 : col;
+ if (c != ' ' && c != 0) {
+ XftFont *f = XftFontFor(dpy, xf, c);
+
+ XftDrawString32(xf->draw, &fgc, f, x + n * cw,
+ y + xf->ascent, &c, 1);
+ if (TermIS_OVERSTRIKE(flags))
+ XftDrawString32(xf->draw, &fgc, f, x + n * cw + 1,
+ y + xf->ascent, &c, 1);
+ }
+ col += cells;
+ }
+
+ if (TermIS_UNDERLINE(flags))
+ XftDrawRect(xf->draw, &fgc, x, y + tpd->cellHeight - 1,
+ (unsigned) (total * cw), 1);
+
+ XftColorFree(dpy, visual, cmap, &bgc);
+ XftColorFree(dpy, visual, cmap, &fgc);
+}
+
+static void
+XftDestroyFunction(
+ Widget w,
+ TermFont font
+)
+{
+ TermFontXft xf;
+
+ (void) w;
+ if (font == 0)
+ return;
+ xf = (TermFontXft) font->fontInfo;
+ if (xf != 0)
+ {
+ if (xf->draw != 0)
+ XftDrawDestroy(xf->draw);
+ {
+ int i;
+
+ for (i = 0; i < xf->nfallback; i++)
+ XftFontClose(XtDisplay(w), xf->fallback[i]);
+ }
+ (void) XtFree((char *) xf);
+ }
+ (void) XtFree((char *) font);
+}
+
+static void
+XftExtentsFunction(
+ Widget w,
+ TermFont font,
+ unsigned char *string,
+ int len,
+ int *widthReturn,
+ int *heightReturn,
+ int *ascentReturn
+)
+{
+ TermFontXft xf = (TermFontXft) font->fontInfo;
+
+ if (xf == 0)
+ return;
+
+ if (widthReturn != 0)
+ {
+ /* MCDE: the cells the run covers, as XftRenderFunction draws it */
+ DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
+ struct termData *tpd = tw->term.tpd;
+ int cw = tpd->cellWidth > 0 ? tpd->cellWidth : xf->width;
+ int i, cells, total = 0;
+
+ for (i = 0; string != 0 && i < len; i++) {
+ (void) XftCharAt(tpd, string, i, &cells);
+ total += cells;
+ }
+ *widthReturn = total * cw;
+ }
+ if (heightReturn != 0)
+ *heightReturn = xf->height;
+ if (ascentReturn != 0)
+ *ascentReturn = xf->ascent;
+}
+
+TermFont
+_DtTermPrimRenderXftCreate(
+ Widget w,
+ XftFont *xftFont
+)
+{
+ TermFont font;
+ TermFontXft xf;
+
+ if (w == 0 || xftFont == 0)
+ return 0;
+
+ xf = (TermFontXft) XtCalloc(1, sizeof(TermFontXftRec));
+ if (xf == 0)
+ return 0;
+
+ xf->font = xftFont;
+ xf->ascent = xftFont->ascent;
+ xf->height = xftFont->ascent + xftFont->descent;
+ xf->width = xftFont->max_advance_width;
+
+ /* THE ONE DRAWABLE, made at the first drawing (XftEnsureDraw): the font is
+ created in the widget's Initialize, before the widget has a window, and an
+ XftDraw on window 0 made the first string a BadDrawable that ended dtterm
+ (MCDE, 2026-11-09). */
+ xf->draw = 0;
+
+ font = (TermFont) XtCalloc(1, sizeof(struct _TermFontRec));
+ if (font == 0)
+ {
+ (void) XtFree((char *) xf);
+ return 0;
+ }
+
+ font->fontInfo = (XtPointer) xf;
+ font->renderFunction = XftRenderFunction;
+ font->destroyFunction = XftDestroyFunction;
+ font->extentsFunction = XftExtentsFunction;
+
+ return font;
+}
+
+/*
+ * NO #else BRANCH, AND THAT IS THE POINT. The first version had one, and it NAMED TermFont, Widget
+ * and XftFont while defining a function that would never exist -- which is exactly the dependency
+ * this file exists to avoid. Without Xft those three types do not exist, so the "there is no
+ * renderer" stub could not compile, and a source in _SOURCES is always compiled. A function that
+ * does not exist must not be written down.
+ *
+ * An empty translation unit is legal C, the caller already guards its call with the same macro
+ * (TermPrim.c), and nothing links against a stub that pretends to create something.
+ */
+#endif /* HAVE_XFT */
diff --git a/lib/DtTerm/TermPrim/TermPrimRenderXft.h b/lib/DtTerm/TermPrim/TermPrimRenderXft.h
new file mode 100644
index 00000000..47be4680
--- /dev/null
+++ b/lib/DtTerm/TermPrim/TermPrimRenderXft.h
@@ -0,0 +1,33 @@
+/*
+ * TermPrimRenderXft.h -- the Xft renderer, behind the same TermFont interface as the others.
+ *
+ * MakroDE addition. SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2026 Konrad Lother
+ *
+ * WHY A THIRD RENDERER RATHER THAN A BRANCH INSIDE THE FONTSET ONE. dtterm already chooses between
+ * TermPrimRenderFontSet (a font set) and TermPrimRenderFont (a single struct) when it builds its
+ * TermFont. Xft is a third kind of font with a third way of drawing, so it is a third renderer --
+ * everything above it is unchanged, which is the whole point of that interface existing.
+ *
+ * WHY THE DRAWABLE IS IN THE RECORD. XftDraw is bound to a Drawable and a visual; creating one per
+ * painted string would re-resolve the glyph cache every time. The whole performance question of Xft
+ * in a terminal is answered right here: ONE XftDraw per TermFont, for the life of the terminal.
+ *
+ * WHY XftDrawStringUtf8 AND NOT XftDrawString32. The render interface hands over BYTES, and
+ * since area 13 those bytes are UTF-8. XftDrawString32 would take FcChar32 and interpret the
+ * same buffer a second time -- a second reading of one buffer, not a better one. (An earlier
+ * draft of this comment claimed String32; the code and the measurement say otherwise.)
+ */
+
+#ifndef _Dt_TermPrimRenderXft_h
+#define _Dt_TermPrimRenderXft_h
+
+#include "TermPrim.h"
+#include
+
+extern TermFont _DtTermPrimRenderXftCreate(
+ Widget w,
+ XftFont *font
+);
+
+#endif /* _Dt_TermPrimRenderXft_h */
diff --git a/pkgsrc/PLIST b/pkgsrc/PLIST
index 82bf4298..c810b31d 100644
--- a/pkgsrc/PLIST
+++ b/pkgsrc/PLIST
@@ -2597,17 +2597,25 @@ dt/config/Xsession.d/0010.dtpaths
dt/config/Xsession.d/0020.dtims
dt/config/Xsession.d/0030.dttmpdir
dt/config/Xsession.d/0060.dtsysenv
+dt/config/Xsession.d/0070.dtfonts
dt/config/Xsession.d/0080.dtlaunch
dt/config/Xsetup
dt/config/Xstartup
dt/config/dtspcdenv
dt/config/dtterm.ti
dt/config/en_US.UTF-8
+dt/config/fonts.conf
dt/config/ims/start.conf
dt/config/svc/CDE.lcx
dt/config/sys.dtprofile
dt/copyright
dt/examples/dtlaunch/snippets.example
+dt/fonts/hack/Hack-Bold.ttf
+dt/fonts/hack/Hack-BoldItalic.ttf
+dt/fonts/hack/Hack-Italic.ttf
+dt/fonts/hack/Hack-Regular.ttf
+dt/fonts/hack/LICENSE
+dt/fonts/hack/README
dt/include/Dt/Action.h
dt/include/Dt/ComboBox.h
dt/include/Dt/Dnd.h
diff --git a/programs/dtlogin/config/0070.dtfonts b/programs/dtlogin/config/0070.dtfonts
new file mode 100755
index 00000000..174b4e7f
--- /dev/null
+++ b/programs/dtlogin/config/0070.dtfonts
@@ -0,0 +1,12 @@
+#!/bin/ksh
+#
+# 0070.dtfonts -- MCDE: the fonts of MCDE for every program of the session
+#
+# Sourced by Xsession (Xsession.d). config/fonts.conf includes the system's
+# fontconfig configuration and adds the fonts that come with MCDE (Hack, the
+# default); every X program started from here on finds them.
+#
+if [ -r "$DT_INSTALL/config/fonts.conf" ]; then
+ FONTCONFIG_FILE=$DT_INSTALL/config/fonts.conf
+ export FONTCONFIG_FILE
+fi
diff --git a/programs/dtlogin/config/Makefile.am b/programs/dtlogin/config/Makefile.am
index 950a5603..7904d5c6 100644
--- a/programs/dtlogin/config/Makefile.am
+++ b/programs/dtlogin/config/Makefile.am
@@ -76,7 +76,7 @@ dist_configs_DATA = Xaccess Xconfig Xfailsafe Xservers
dist_configs_SCRIPTS = sys.dtprofile Xfailsafe Xreset Xsetup Xstartup
xsessdir=$(CDE_INSTALLATION_TOP)/config/Xsession.d
-dist_xsess_SCRIPTS = 0060.dtsysenv 0080.dtlaunch
+dist_xsess_SCRIPTS = 0060.dtsysenv 0070.dtfonts 0080.dtlaunch
dist_bin_SCRIPTS = Xsession
diff --git a/programs/dtlogin/config/Xconfig.src b/programs/dtlogin/config/Xconfig.src
index 6d474df3..8b8b6b71 100644
--- a/programs/dtlogin/config/Xconfig.src
+++ b/programs/dtlogin/config/Xconfig.src
@@ -116,6 +116,9 @@ XCOMM on the display. User variables can also be specified in the Xsession file
XCOMM
XCOMM Dtlogin*environment:
+XCOMM MCDE: the fonts of MCDE (Hack) for the login screen and every session
+Dtlogin*environment: FONTCONFIG_FILE=CDE_INSTALLATION_TOP/config/fonts.conf
+
XCOMM #########################################################################
XCOMM To specify a default user PATH environment variable.
diff --git a/programs/dtlogin/config/Xresources.src b/programs/dtlogin/config/Xresources.src
index f2e9b547..3783fcc6 100644
--- a/programs/dtlogin/config/Xresources.src
+++ b/programs/dtlogin/config/Xresources.src
@@ -162,6 +162,16 @@ Dtlogin*login_text.columns: %|nls-4-#20#|
Dtlogin*passwd_text.columns: %|nls-5-#20#|
+!! MCDE: anti-aliased text (Xft) in Hack on the login screen
+Dtlogin*renderTable: mcde
+Dtlogin*textRenderTable: mcde
+Dtlogin*labelRenderTable: mcde
+Dtlogin*buttonRenderTable: mcde
+Dtlogin*mcde.fontType: FONT_IS_XFT
+Dtlogin*mcde.fontName: Hack
+Dtlogin*mcde.fontSize: 10
+Dtlogin*greeting*mcde.fontSize: 16
+
!!######################################################################
!!
!! MISC
diff --git a/programs/dtsession/sys.resources.src b/programs/dtsession/sys.resources.src
index 86652267..85346dd4 100644
--- a/programs/dtsession/sys.resources.src
+++ b/programs/dtsession/sys.resources.src
@@ -219,4 +219,16 @@ XCOMM else
XCOMM endif
XCOMM endif
+!! MCDE: anti-aliased text (Xft) in every Motif program, in Hack, the font
+!! that comes with MCDE (fonts/hack; config/fonts.conf makes it known). A
+!! render table wins over the *FontList of sys.font; text, labels and buttons
+!! have tables of their own (dtterm and text fields read textRenderTable).
+*renderTable: mcde
+*textRenderTable: mcde
+*labelRenderTable: mcde
+*buttonRenderTable: mcde
+*mcde.fontType: FONT_IS_XFT
+*mcde.fontName: Hack
+*mcde.fontSize: 10
+
!################ eof #######################
diff --git a/programs/dtterm/DtTermMain.c b/programs/dtterm/DtTermMain.c
index 7540b8ad..d540b6d5 100644
--- a/programs/dtterm/DtTermMain.c
+++ b/programs/dtterm/DtTermMain.c
@@ -1134,6 +1134,23 @@ main(int argc, char **argv)
Boolean iAmTheServer = False;
#endif /* SUN_TERMINAL_SERVER */
+ /*
+ * MakroDE: setlocale() FIRST, before anything touches the toolkit.
+ *
+ * This is the one call this program never made, and it is why dtterm has no
+ * UTF-8: the engine is ALREADY wide-character based -- TermPrimBufferWc.c with
+ * wcwidth, BYTES_PER_CHAR following MB_CUR_MAX, and XmbDrawString /
+ * XwcDrawString in the font-set renderer -- but under the C locale MB_CUR_MAX
+ * is 1, so the engine takes its single-byte path for every character. The
+ * multibyte machinery was there and unreachable.
+ *
+ * LC_ALL rather than LC_CTYPE alone: the character type is what MB_CUR_MAX
+ * follows, but a terminal is the last program that should disagree with the
+ * shell it runs about messages and collation either. ( was already
+ * included here; the call itself was simply never made.)
+ */
+ (void) setlocale(LC_ALL, "");
+
(void) atexit(AtExitProc);
if (c = getenv("dttermDebugFlags")) {