aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2017-04-03 03:30:23 -0400
committerB. Watson <yalhcru@gmail.com>2017-04-03 03:30:23 -0400
commit229dc8d1b9372f89343b3742486496b06aeb813b (patch)
treefa1b881990fdcaacce218647732f77b667997dbb
downloadttf-console-fonts-229dc8d1b9372f89343b3742486496b06aeb813b.tar.gz
initial commit
-rw-r--r--.makepp/.done.mk13
-rw-r--r--.makepp/log39
-rw-r--r--Makefile17
-rw-r--r--README107
-rw-r--r--conv.sh55
-rw-r--r--fonts3
-rw-r--r--ttf2psfu.sh29
7 files changed, 263 insertions, 0 deletions
diff --git a/.makepp/.done.mk b/.makepp/.done.mk
new file mode 100644
index 0000000..13b01b0
--- /dev/null
+++ b/.makepp/.done.mk
@@ -0,0 +1,13 @@
+IMPLICIT_DEPS=
+SIGNATURE=1491194155,0
+META_DEPS=/usr/bin/touchconv.sh
+SORTED_DEPS=conv.shfonts/usr/bin/touchttf2psfu
+INCLUDE_SFXS=
+BUILD_SIGNATURE=1491194155,0
+COMMAND=sh conv.shtouch .done
+CWD=.
+DEP_SIGS=1491193945,13651491164712,811460917587,643521490771151,908
+IMPLICIT_TARGETS=
+INCLUDE_PATHS=
+ARCH=x86_64-linux-thread-multi
+END= \ No newline at end of file
diff --git a/.makepp/log b/.makepp/log
new file mode 100644
index 0000000..bca8776
--- /dev/null
+++ b/.makepp/log
@@ -0,0 +1,39 @@
+3/usr/bin/makepp
+VERSION2.05.22.2x86_64-linux-thread-multi
+LOAD43273760Makefile34441736/export/home/urchlay/ttf-console-fonts34441736
+TRY43273760
+USEdefault rule
+DEPEND43273760
+UP_TO_DATE43273760
+LOAD_INCL43040136makepp_builtin_rules.mk43030384/usr/share/makepp43273760
+LOAD_END43273760
+TRY43275680all34441736
+USEdefault rule
+DEPEND4327568043040760.done34441736
+TRY43040760
+USE/export/home/urchlay/ttf-console-fonts/Makefile:6
+SCAN_INFO43040760
+LEX_RULE43040760info not cached
+TRY43351016conv.sh34441736
+USEdefault rule
+DEPEND43351016
+UP_TO_DATE43351016
+PARSEtouch .done34441736/export/home/urchlay/ttf-console-fonts/Makefile:6
+TRY43480512touch43480296/usr/bin
+USEdefault rule
+DEPEND43480512
+UP_TO_DATE43480512
+DEPEND430407604335101643351160fonts344417364348051243351304ttf2psfu34441736
+TRY43351160
+USEdefault rule
+DEPEND43351160
+UP_TO_DATE43351160
+TRY43351304
+USEdefault rule
+DEPEND43351304
+UP_TO_DATE43351304
+BUILD_NONE43040760
+SUCCESS/export/home/urchlay/ttf-console-fonts/Makefile:643040760
+BUILD_PHONY43275680
+SUCCESSdefault rule43275680
+N_FILES110
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..64840e1
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,17 @@
+
+PSFDIR=/usr/share/kbd/consolefonts
+
+.PHONY: all clean install
+
+all: .done
+
+.done: conv.sh fonts ttf2psfu.sh
+ sh conv.sh
+ touch .done
+
+clean:
+ rm -f *.psfu *.psfu.gz *.log *.bdf .done
+
+install: all
+ mkdir -p $(DESTDIR)$(PSFDIR)
+ install -m0644 *.psfu.gz $(DESTDIR)$(PSFDIR)
diff --git a/README b/README
new file mode 100644
index 0000000..2010fda
--- /dev/null
+++ b/README
@@ -0,0 +1,107 @@
+ttf-console-fonts, by B. Watson <yalhcru@gmail.com>.
+
+Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
+
+ttf-console-fonts is a collection of Linux console fonts, converted from
+various TrueType fonts found in a typical Linux install.
+
+No TTF fonts are included here. Instead, the ones installed on your system
+(usually in /usr/share/fonts/TTF) are used. Also, I don't include prebuilt
+console fonts because I'm not so sure the licensing allows it (dammit,
+I'm a doc... uh, programmer, not a lawyer).
+
+The name is slightly misleading: obviously the console doesn't support
+TTF, only bitmap fonts in PSF format. What this package does is convert
+various TTFs into the PSF (aka .psfu) bitmapped font format used by
+the kernel.
+
+Notice that these are framebuffer fonts. Pretty much everyone these
+days is likely to be using the framebuffer console (thanks to kernel
+modesetting and Xorg's requirement for it). If you're somehow still using
+a VGA textmode console, only fonts 8 or 9 pixels wide are supported.
+For this package, that means the ones with "8x" in their filenames.
+
+If the converted fonts don't look the same to you on the console as the
+original fonts do in X, that's because X and most modern X applications
+do subpixel rendering for antialiasing. The Linux console doesn't support
+this at all.
+
+Another difference between TTF and console fonts: only 512 glyphs are
+allowed per console font. This means Unicode support will be limited.
+The generated fonts include the full ASCII set, plus Latin-1 (aka
+ISO-8859-1) and at least partial support for Latin-2. If your requirements
+are different, change SETS in conv.sh (read the bdf2psf documentation,
+and possibly the source code, to understand how this stuff works). One
+useful piece of information: the same glyph can represent more than one
+Unicode codepoint (if they have the same appearance, e.g. C in Latin
+and Cyrillic).
+
+Requirements:
+ - bdf2psf
+ - otf2bdf
+ - psftools
+
+For Slackware, the above are available on SlackBuilds.org. For Debian
+or Ubuntu, try apt-getting them.
+
+"Core system" requirements (included in Slackware, may need installing
+if you're on Debian/etc):
+
+ - fontconfig
+ - freetype2
+ - perl
+ - stuff like coreutils and bash
+ - whatever fonts are listed in the file 'fonts', of course.
+
+To build the fonts, simply run "make". If you get errors, especially
+"command not found" or "no such file or directory", you're missing a
+requirement (see above).
+
+After they're built, the fonts will have filenames like:
+
+dejavusansmono-8x12.psfu.gz
+
+The "8x12" is the pixel size (NOT the point size).
+
+If you're running in the console, you can test out the fonts by loading
+them with "setfont". If the results look OK, you can install the fonts via
+"make install" (if you're making a distro package, DESTDIR is supported).
+
+On Slackware, you can edit /etc/rc.d/rc.font to set the default system
+font to whichever one you like best. Don't forget to make rc.font
+executable. I have no idea how to set the default console font on other
+distributions (sorry).
+
+If you want to try converting other fonts, edit the file "fonts". The font
+names there are whatever "fc-list" calls the font. You can probably use
+wildcards or inexact matches (fc-list is pretty user-friendly). Whatever
+fonts you choose *must* be TrueType or OpenType (.ttf or .otf). They
+also *must* be "monospace" or "fixed width". Trying to convert
+proportional/variable-width fonts will "work", but the result won't be
+very pleasing to look at.
+
+If you don't like the sizes I picked, you can set SIZES in the
+environment. It's a space-separated list of point sizes. Example:
+
+SIZES="6 9 12 15" make
+
+Don't get too crazy with the cheez-wiz: the kernel (or at least the
+setfont command) has a font height limit of 32 rows. And in my testing, I
+found that fonts 31 or 32 rows tall would load, but displayed incorrectly.
+The practical limit (for my system at least) seems to be 30.
+
+The point sizes might be a bit different than they are in X. This is
+because Xorg's Xrandr extension is smart enough to know your monitor's
+actual DPI, and will scale TTFs to the correct size. The otf2bdf utility
+used here could theoretically do the same thing, but it doesn't: it
+just assumes 100x100 DPI. If your monitor doesn't have square pixels,
+this will be even more noticeable.
+
+If you're wondering how many rows/columns of text each font will give you,
+the calculation is simple enough: find out your framebuffer resolution
+(e.g. by running 'fbset' with no arguments), and divide the width of
+the fb by the width of the font (e.g. 1920/15 = 128, throw away any
+remainder). Do the same calculation for the height (e.g. 1080/27 = 40).
+Or, you could just load the font, then:
+
+kill -WINCH $$; echo $COLUMNS $LINES
diff --git a/conv.sh b/conv.sh
new file mode 100644
index 0000000..396d08a
--- /dev/null
+++ b/conv.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+
+# 20170403 bkw:
+
+# convert TTF (or OTF) fonts to *.psfu.gz fonts that can be used
+# on the Linux console.
+
+# conversion isn't done directly. instead, the TTF is rendered as a
+# BDF (via otf2bdf), then converted to a psfu via bdf2psf.
+
+# these are supposedly in points. yeah, right.
+SIZES=${SIZES:-8 12 15 19}
+
+warn() {
+ echo "$@" 1>&2
+}
+
+die() {
+ warn "$@"
+ exit 1
+}
+
+convfont() {
+ font="$1"
+ file="$( fc-list "$font" | head -n1 | cut -d: -f1 )"
+
+ psfname="$( basename "$( echo $file | cut -d. -f1 | tr A-Z a-z | tr -d " " )" )"
+ echo -n "$file => $psfname: "
+
+ if [ ! -e "$file" ]; then
+ warn "Font '$font' not found, skipping"
+ return 1
+ fi
+
+ for size in $SIZES; do
+ echo -n "$size"
+ sh ./ttf2psfu.sh -p $size "$file" &> $psfname.$size.log
+
+ # bug in file? if the width is double-digit, file prints HxW, but if
+ # width is single-digit it prints WxH, WTF?
+ #pxsize=$( file test.psfu | sed 's|.*, \(.*\)x\(.*\)$|\2x\1|' )
+
+ w="$( psf2txt test.psfu | sed -n '/^Width/s,.* ,,p' )"
+ h="$( psf2txt test.psfu | sed -n '/^Height/s,.* ,,p' )"
+ pxsize=${w}x${h}
+ gzip -9c < test.psfu > $psfname-$pxsize.psfu.gz
+ rm -f test.psfu
+ echo -n ":$pxsize "
+ done
+ echo
+}
+
+cat fonts | while read font; do
+ convfont "$font"
+done
diff --git a/fonts b/fonts
new file mode 100644
index 0000000..20b37d1
--- /dev/null
+++ b/fonts
@@ -0,0 +1,3 @@
+DejaVu Sans Mono:style=Book
+FreeMono:style=Regular
+Liberation Mono:style=Regular
diff --git a/ttf2psfu.sh b/ttf2psfu.sh
new file mode 100644
index 0000000..ef5a55a
--- /dev/null
+++ b/ttf2psfu.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+# uses otf2bdf and bdf2psf to turn a ttf/otf font into a console font.
+# all args are passed through to otf2bdf, please don't pass -o file.bdf.
+
+# right now, output is to test.psfu. This will change in the future.
+
+otf2bdf "$@" -c C -o tmp.bdf
+
+# lie to bdf2psf, dirty hack alert! bdf2psf needs the AVERAGE_WIDTH
+# to be a multiple of 10. And it messes up the kerning if we don't
+# add a fudge factor (the 30, below).
+AV=$( sed -n 's,AVERAGE_WIDTH ,,p' tmp.bdf )
+AV=$(( ( AV + 30 ) / 10 * 10 ))
+sed -i "/AVERAGE_WIDTH/s, .*, $AV," tmp.bdf
+
+SETDIR=/usr/share/bdf2psf
+
+# bdf2psf wants all this crap passed as a single argument with no
+# spaces. I need to be able to read and maybe modify the list, so:
+SETS="\
+$SETDIR/ascii.set+\
+$SETDIR/linux.set+\
+$SETDIR/fontsets/Lat2.256+\
+$SETDIR/fontsets/Uni1.512+\
+$SETDIR/useful.set\
+"
+
+bdf2psf --fb tmp.bdf $SETDIR/standard.equivalents $SETS 512 test.psfu