At Fri, 26 Jul 2024 20:12:48 +0000, nia <n...@netbsd.org> wrote:
Subject: Re: Anti-alias title bars?
>
> On Fri, Jul 26, 2024 at 10:21:59AM -0500, Marc Coquand wrote:
> >
> > Heya ctwm people!
> >
> > I'm noticing on Netbsd 10.0 that the title bars are not anti-aliased,
> > and so they look a bit wonky with certain fonts.
> >
> > I'm curious if there is a way to anti-alias the title bars in ctwm?
>
> Hey, ctwm uses classic X11 XLFDs for selecting fonts,

Indeed.

> so it's currently not possible to use with modern ttf/otf
> scalable fonts, just bitmap fonts.

But that part is simply not true.  Even old X11 applications, when
linked against modern X11 libraries, can request TrueType fonts via XLFD
specs, i.e. they can request "scalable" fonts.

X11 has long had scalable Type1 fonts, though those are quite limited.
Since the advent of Xft though it's been possible for XLFD specs to also
reference TrueType fonts as well.  Indeed there are even TTF files
supplied natively in NetBSD since X11R6 with NetBSD-1.6 (i.e. since the
import of XFree86 4.2.0, back in 2002).

I use ctwm on a 318-dpi display and have "normal" sized fonts for menus
and title bars, icon labels, etc., primarily using an OTF font right
now, but for a long while I used a TTF font.

Watch what happens if you specify the actual desired resolution in the
XLFD spec:

$ xlsfonts -fn '-*-commitmono-medium-r-*-*-0-0-218-218-m-0-iso10646-1'
-misc-commitmono-medium-r-normal--0-0-218-218-m-0-iso10646-1
-misc-commitmono-medium-r-normal--0-0-218-218-m-0-iso10646-1

If you add '-ll' to that command you'll also find the lines:

      FONT_TYPE             TrueType
      RASTERIZER_NAME       FreeType

A couple of years ago I submitted patches to xfontsel that allow it to
select fonts with the correct display resolution when run with the
"-scaled" option.  These patches are included in the 1.1.0 release, and
so are included in NetBSD-10.

First off you have to tell the X server what your display's DPI is with
the '-dpi' option, if it doesn't already have the correct value.  You
can check with xdpyinfo(1):

         xdpyinfo | sed -n '/^screen/,+2p'

I see:

        screen #0:
          dimensions:    6016x3384 pixels (700x394 millimeters)
          resolution:    218x218 dots per inch

I'm running the Xserver on a macos desktop with XQuartz, and so that's
done with:

        defaults write org.xquartz.X11 dpi -int 218

(On macos you need to do some other tricks as well, including
configuring XQuartz to run full-screen, and running xrandr in your
~/.xinitrc or equivalent to set the display resolution properly as you
start the server because macos itself can't handle full resolution and
so the screen won't be in the highest resolution when you first start
XQuartz.)

Probably on NetBSD that could be most easily accomplished by simply
manually typing it on the 'startx' command line:

         startx -- -dpi 218

(i.e. exactly as shown in the second example in the startx(1) manual
page)

If you are using Xdm you can edit /etc/X11/xdm/Xservers to add the
option there.


Secondly you need to adjust your fonts and font aliases!

The first and most important part of this is that you have to explicitly
tell the Xft what the display resolution is, as it's not quite smart
enough to look that up on its own.  That's done by setting the following
X11 resources (the first one may be superfluous):

        *dpi:           218
        Xft.dpi:        218

You might also want:

        ! Do eliminate extra leading between lines!
        Xft.minspace:                   true

I think you have to make sure your fontpath includes the scalable fonts
(at least to use any of the Type1 fonts I think), (but do not include
any of the old bitmap font directories!):

$ xset q | sed -n '/Font/,+1p'
Font Path:
  
/Users/woods/.fonts/,/Users/woods/Library/Fonts,/opt/pkg/share/fonts/X11/TTF/,/opt/pkg/share/fonts/X11/intlfonts/TrueType,/opt/pkg/share/fonts/X11/intlfonts/Type1,/opt/X11/share/fonts/TTF/,/opt/X11/share/fonts/OTF/,/opt/X11/share/fonts/Type1/,/opt/X11/share/system_fonts/,/opt/X11/share/system_fonts/Supplemental


You'll need to use a scalable cursor font in order to be able to see
your mouse cursor (remap "cursor" to the scalable cursors font in your
~/.fonts/fonts.alias).  Once upon a time NetBSD shipped a usable Type1
scalable cursor font as /usr/X11R6/lib/X11/fonts/Type1/cursor.pfa, but
that seems to have disappeared with the move from xfree to xorg.  It
still comes with XQuartz though, and it officially comes from:

        https://gitlab.freedesktop.org/xorg/font/xfree86-type1

That should probably be imported to /usr/xsrc/external/mit/font-xfree86-type1

I'm pretty sure you can just download "cursor.pfa" to your ~/.fonts/ to
use it though.

Note that Xft fonts have to be installed on the system running the
client application(s), and configured with fontconfig.

You will also need to remap everything else from the default system
fonts.alias(*) file(s) into your ~/.fonts/fonts.alias as well, and you
also need to set a number of other resources for various apps, including
all the old Xt users.

(*) i.e. /usr/X11R7/lib/X11/fonts/misc/fonts.alias

Then there's the need to run fc-cache and perhaps a few other details
I've probably glossed over.

The only remaining problem, especially for a window manager, and
specifically for ctwm, is that all the pixmaps for icons supplied with
the system are rather small on a true hi-res display.  I don't have a
problem with that though -- I can fit more in the icon manager space!

For a quick look here's how I have Xt resources for ctwm configured (you
also need ~/.fonts/fonts.alias), see below; but for full details of how
I do this in a way that is (hopefully) still resolution independent (it
all still works to start XQuartz on my old iMac-27) see:

        https://github.com/robohack/dotfiles/

$ xrdb -query -all | sed '/VT100/q'
*StringConversionWarnings:      on
*dpi:   218
Xft.dpi:        218
Xft.antialias:  true
Xft.hinting:    true
Xft.minspace:   true
Emacs.FontBackend:      xft
Emacs.Font:     CommitMono:size=9
*Font:  -*-commitmono-medium-r-normal--0-72-218-218-m-0-iso8859-*
*font:  -*-commitmono-medium-r-normal--0-72-218-218-m-0-iso8859-*
*fontList:      -*-*-*-*-*--0-90-218-218-*-0-*-*
*SystemFont:    -*-commitmono-medium-r-normal--0-90-218-218-m-0-iso8859-*
*UserFont:      -*-commitmono-medium-r-normal--0-100-218-218-m-0-iso8859-*
xtDefaultFont:  -*-commitmono-medium-r-normal--0-90-218-218-m-0-iso8859-*
xtDefaultFontSet:       -*-*-*-*-*--*-*-218-218-m-0-*-*
*Tree*List*Font:        
-*-commitmono-medium-r-normal--0-90-218-218-m-0-iso8859-*
XtDefaultFont:  -*-commitmono-medium-r-normal--0-90-218-218-m-0-iso8859-*
XtDefaultFontSet:       -*-*-*-*-*--*-*-218-218-m-0-*-*
*pixelSizeList: 0
*pointSizeList: 80, 90, 100, 110, 120, 140, 160, 170, 180, 200, 240, 250, 300, 
350, 400
*customization: -color
*Scrollbar.foreground:  gray80
*Scrollbar.background:  gray50
*Scrollbar.thumb:       None
Xpdf*fontList:  -*-commitmono-medium-r-normal--0-90-218-218-m-0-iso8859-*
Xpdf.initialZoom:       page
Xpdf.toolTipEnable:     false
*zoomComboBox*fontList: variable
*XmTextField*fontlist:  fixed
*buttonFontList:        varbold
*defaultFontList:       fixed
*labelFontList: italic
*menubar*fontList:      varbold
*helpFont:      fixed
*textFontList:  fixed
*xrtGearFontListSelected:       bold
*renderFont:    true
*faceName:      CommitMono
*cursorBlink:   true
*SimpleMenu*menuLabel.font:     
-*-commitmono-bold-r-normal--*-100-218-218-m-0-iso8859-*
*SimpleMenu*font:       -*-commitmono-bold-r-normal--*-80-218-218-m-0-iso8859-*
*SimpleMenu*cursor:     hand2
*VT100.font:    -*-commitmono-medium-r-normal--0-75-218-218-m-0-iso8859-*


--
                                        Greg A. Woods <gwo...@acm.org>

Kelowna, BC     +1 250 762-7675           RoboHack <wo...@robohack.ca>
Planix, Inc. <wo...@planix.com>     Avoncote Farms <wo...@avoncote.ca>

Attachment: pgpHCg_UXpShq.pgp
Description: OpenPGP Digital Signature

Reply via email to