--- /dev/null
+# Copyright © 2012, 2014-2015, 2020, 2022 Nick Bowler
+# License GPLv3+: GNU General Public License version 3 or any later version.
+# This is free software: you are free to change and redistribute it.
+# There is NO WARRANTY, to the extent permitted by law.
+
+EAPI=7
+
+inherit desktop xdg
+
+DESCRIPTION="An X viewer for PDF files"
+HOMEPAGE="http://www.foolabs.com/xpdf/"
+SRC_URI="https://xpdfreader-dl.s3.amazonaws.com/old/$P.tar.gz"
+
+LICENSE="|| ( GPL-2 GPL-3 )"
+SLOT="0"
+KEYWORDS="~amd64"
+
+DEPEND=">=x11-libs/motif-2.3:0
+ media-libs/freetype:2
+ app-text/libpaper:=
+ x11-libs/libX11
+ x11-libs/libXpm"
+RDEPEND="$DEPEND
+ media-fonts/urw-fonts"
+
+PATCHES=(
+ "$FILESDIR/xpdf-Add-Gentoo-font-path.patch"
+ "$FILESDIR/xpdf-cve-2022-38171.patch"
+ "$FILESDIR/xpdf-libpaper2.patch"
+)
+
+src_configure() {
+ econf --with-freetype2-includes=${EROOT%/}/usr/include/freetype2
+}
+
+src_install() {
+ dobin xpdf/xpdf
+ doman doc/xpdf.1
+ doman doc/xpdfrc.5
+ dodoc README ANNOUNCE CHANGES
+ newicon xpdf/xpdfIcon.xpm xpdf.xpm
+
+ insinto /etc
+ newins doc/sample-xpdfrc xpdfrc
+ newdoc doc/sample-xpdfrc xpdfrc.example
+
+ insinto /usr/share/applications
+ doins "$FILESDIR/xpdf.desktop"
+}