I remember when adding color emoji to dwm on Arch Linux was simple as just installing a package from AUR.
I wanted to make dwm run with emoji support on Linux Mint.
The libxft-dev package on my machine was 2.3.4 so I had to install libxft from source
and change some compile flags.
Ofcourse if your default package manager can install libxft package which is
newer than 2.3.5 release, then you don't have to do it like me.
Prerequisite
- Uninstall the
libxft-devpackage (if you have)- Just to be sure to avoid the conflict by installing same package
- Install required dependencies
Install libXft from source
Get the libxft source code.
git clone https://gitlab.freedesktop.org/xorg/lib/libxft.git
cd libxft
Install dependencies. For Linux Mint, I had to install these packages.
sudo apt install build-essential autoconf libtool pkg-config libfreetype6-dev \
libxrender-dev libfontconfig1-dev xutils-dev
Since the bgra patch was merged to master since the 2.3.5 release, make sure that the source code is new and above of that release.
git checkout libXft-2.3.8
Run the autogen.sh shell script to setup automatically for you.
./autogen.sh
Now compile it and install. It shouldn't take a while to compile.
If you see an error like something.h not found, this is likely that you do
not have required header files installed.
make
sudo make install
Modify config.mk
Thankfully, there are not many things to change.
Change the X11LIB, X11INC, and FLAGS for each of them as followings.
st
diff --git a/config.mk b/config.mk
index ef6de39..98635f3 100644
--- a/config.mk
+++ b/config.mk
@@ -7,8 +7,8 @@ VERSION = 0.8.5
PREFIX = /usr/local
MANPREFIX = $(PREFIX)/share/man
-X11INC = /usr/X11R6/include
-X11LIB = /usr/X11R6/lib
+X11LIB = /usr/local/lib
+X11INC = /usr/local/include
PKG_CONFIG = pkg-config
@@ -25,7 +25,7 @@ LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft -lXrender\
# flags
STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
STCFLAGS = $(INCS) $(STCPPFLAGS) $(CPPFLAGS) $(CFLAGS)
-STLDFLAGS = $(LIBS) $(LDFLAGS)
+STLDFLAGS = -Xlinker -rpath=$(X11LIB) $(LIBS) $(LDFLAGS)
# OpenBSD:
#CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
dmenu
diff --git a/config.mk b/config.mk
index 566348b..29b99bd 100644
--- a/config.mk
+++ b/config.mk
@@ -5,8 +5,8 @@ VERSION = 5.2
PREFIX = /usr/local
MANPREFIX = $(PREFIX)/share/man
-X11INC = /usr/X11R6/include
-X11LIB = /usr/X11R6/lib
+X11INC = /usr/local/include
+X11LIB = /usr/local/lib
# Xinerama, comment if you don't want it
XINERAMALIBS = -lXinerama
@@ -26,7 +26,7 @@ LIBS = -L$(X11LIB) -lX11 $(XINERAMALIBS) $(FREETYPELIBS)
# flags
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" $(XINERAMAFLAGS)
CFLAGS = -std=c99 -pedantic -Wall -Os $(INCS) $(CPPFLAGS)
-LDFLAGS = $(LIBS)
+LDFLAGS = -Xlinker -rpath=$(X11LIB) $(LIBS)
# compiler and linker
CC = cc
dwm
diff --git a/config.mk b/config.mk
index c1434f2..e753b31 100644
--- a/config.mk
+++ b/config.mk
@@ -7,8 +7,8 @@ VERSION = 6.4
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man
-X11INC = /usr/X11R6/include
-X11LIB = /usr/X11R6/lib
+X11INC = /usr/local/include
+X11LIB = /usr/local/lib
# Xinerama, comment if you don't want it
XINERAMALIBS = -lXinerama
@@ -30,7 +30,7 @@ LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-r
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
-LDFLAGS = ${LIBS}
+LDFLAGS = -Xlinker -rpath=$(X11LIB) $(LIBS)
# Solaris
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
Additional modifying for dmenu
For dmenu, there is a code block which disallow using color fonts.
Remove or comment out the codeblock below in drw.c to allow rendering color fonts.
FcBool iscol;
if(FcPatternGetBool(xfont->pattern, FC_COLOR, 0, &iscol) == FcResultMatch && iscol) {
XftFontClose(drw->dpy, xfont);
return NULL;
}
Optionally you can use the patch file as following.
cd dmenu
wget https://tools.suckless.org/dmenu/patches/allow-color-font/dmenu-allow-color-font-5.0.diff
patch -p1 < dmenu-allow-color-font-5.0.diff
Add color font to config.h
Install color font if you have not yet.
The popular ones I know are Noto Color Emoji and JoyPixel.
Install them with your package manager of your choice.
static const char *fonts[] = { "Hack:size=10", "TakaoGothic:size=10", "NotoColorEmoji:size=10" };
Add something like this in your config.h
Compile and install
That's it! Don't forget to restart your xsession.