summaryrefslogtreecommitdiff
path: root/fonts/punknova
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /fonts/punknova
Initial commit
Diffstat (limited to 'fonts/punknova')
-rw-r--r--fonts/punknova/Makefile50
-rw-r--r--fonts/punknova/NEWS10
-rw-r--r--fonts/punknova/README57
-rw-r--r--fonts/punknova/documentation/documentation-sources/sample.tex21
-rw-r--r--fonts/punknova/documentation/sample.pdfbin0 -> 138145 bytes
-rw-r--r--fonts/punknova/punknova-bold.otfbin0 -> 432928 bytes
-rw-r--r--fonts/punknova/punknova-boldslanted.otfbin0 -> 412488 bytes
-rw-r--r--fonts/punknova/punknova-regular.otfbin0 -> 453944 bytes
-rw-r--r--fonts/punknova/punknova-slanted.otfbin0 -> 431484 bytes
-rw-r--r--fonts/punknova/source/punkfont-bold.mp4
-rw-r--r--fonts/punknova/source/punkfont-boldslanted.mp5
-rw-r--r--fonts/punknova/source/punkfont-regular.mp2
-rw-r--r--fonts/punknova/source/punkfont-slanted.mp4
-rwxr-xr-xfonts/punknova/tools/build.py221
14 files changed, 374 insertions, 0 deletions
diff --git a/fonts/punknova/Makefile b/fonts/punknova/Makefile
new file mode 100644
index 0000000000..22fe0e8e6a
--- /dev/null
+++ b/fonts/punknova/Makefile
@@ -0,0 +1,50 @@
+NAME=punknova
+SRCNAME=punkfont
+VERSION=1003
+
+SRC=source
+TOOLS=tools
+DOC=documentation
+DOCSRC=$(DOC)/$(DOC)-sources
+DIST=$(NAME)-$(VERSION)
+
+FF=$(TOOLS)/build.py
+
+FONTS=regular bold slanted boldslanted
+DOCS=sample
+
+MP=$(FONTS:%=$(SRC)/$(SRCNAME)-%.mp)
+OTF=$(FONTS:%=$(NAME)-%.otf)
+TEX=$(DOCS:%=$(DOCSRC)/%.tex)
+PDF=$(DOCS:%=$(DOC)/%.pdf)
+
+all: otf
+
+otf: $(OTF)
+doc: $(PDF)
+
+$(NAME)-%.otf: $(SRC)/$(SRCNAME)-%.mp $(MP)
+ @echo "Building $@"
+ @$(FF) $< $@ $(VERSION)
+
+$(DOC)/%.pdf: $(DOCSRC)/%.tex
+ @echo "Building $@"
+ @context --nonstopmode --result=$@ $< 1>/dev/null
+
+dist: $(OTF) $(PDF)
+ @echo "Making dist tarball"
+ @mkdir -p $(DIST)/$(SRC)
+ @mkdir -p $(DIST)/$(TOOLS)
+ @mkdir -p $(DIST)/$(DOC)
+ @mkdir -p $(DIST)/$(DOCSRC)
+ @cp $(MP) $(DIST)/$(SRC)
+ @cp $(OTF) $(DIST)
+ @cp $(FF) $(DIST)/$(TOOLS)
+ @cp -r $(PDF) $(DIST)/$(DOC)
+ @cp -r $(TEX) $(DIST)/$(DOCSRC)
+ @cp -r Makefile NEWS $(DIST)
+ @cp README.md $(DIST)/README
+ @zip -r $(DIST).zip $(DIST)
+
+clean:
+ @rm -rf $(OTF) $(DIST) $(DIST).zip
diff --git a/fonts/punknova/NEWS b/fonts/punknova/NEWS
new file mode 100644
index 0000000000..7442aebb99
--- /dev/null
+++ b/fonts/punknova/NEWS
@@ -0,0 +1,10 @@
+2011/11/22, version 1.003:
+ * 1.002 files had bogus GPOS table, re-built with newer version of
+ FontForge.
+
+2010/09/12, version 1.002:
+ * Add slanted and bold slanted fonts.
+ * Split the MP sources into base and drivers
+
+2010/08/06, version 1.001:
+ * First public release.
diff --git a/fonts/punknova/README b/fonts/punknova/README
new file mode 100644
index 0000000000..8cecb0dfd9
--- /dev/null
+++ b/fonts/punknova/README
@@ -0,0 +1,57 @@
+The Punk Nova font
+==================
+
+This is an OpenType implementation of Donald Knuth's
+[Punk font](http://tug.org/TUGboat/Articles/tb09-2/tb21knut.pdf).
+
+The original Metafont sources were adapted to a more MetaPost friendly
+form by Taco Hoekwater et al.
+
+Punk is a dynamic font, every time a glyph is requested Matafont draws
+a unique instance of it. On the other hand, OpenType is static, glyph
+outlines are drawn once and stored in the font and the renderer can not
+alter those outlines. To emulate the dynamic nature of Punk, we generate
+several alternate shapes of each glyph and store them in the font.
+Alternate shapes are mapped to the base character using OpenType
+["Randomize"](http://www.microsoft.com/typography/otspec/features_pt.htm#rand)
+feature (rand), which tells the renderer to select glyphs randomly from
+the list of alternate shapes.
+
+The PostScript outlines of the glyphs are generated by MetaPost, a
+Python script then uses FontForge to import the glyphs into an OpenType
+CFF font. Since this year is the 2^5 anniversary of TeX, each lower case
+letter have 2^5 variants, 2^4 for each upper case and 2^3 for the rest.
+
+This font is free software, you can do whatever you want with it as long
+as you use different font and file names. The exact copyright statement is:
+
+ "Unlimited copying and redistribution of this file are permitted as long
+ as this file is not modified. Modifications are permitted, but only if
+ the resulting file is not named 'punknova.otf' and the (internal)
+ fontname differs from 'Punk Nova'."
+
+The MetaPost source has the following notice:
+
+ This file is a merge of the original punk files by Donald Knuth, who
+ added this comment:
+
+ Font inspired by Gerard and Marjan Unger's lectures,
+ Feb 1985
+
+ The regular punk files are part of TeXLive and in Metafont format. All
+ errors introduced are ours. We also changed the encoding to unicode. In
+ due time we might add a few more more characters. We still need to
+ improve some of the metrics which involves a bit of trial and error. The
+ font just covers basic latin shapes but in ConTeXt MkIV we add virtual
+ composed shapes. There is a module m-punk.tex that implements this. This
+ derivate is also used in mk.tex (mk.pdf) which is one of our tests for
+ LuaTeX. We published an article on it in the MAPS (NTG magazine).
+
+ 2008, Taco Hoekwater & Hans Hagen
+
+The MAPS article is [available online](http://www.ntg.nl/maps/37/).
+
+
+Khaled Hosny
+
+6 Aug. 2010
diff --git a/fonts/punknova/documentation/documentation-sources/sample.tex b/fonts/punknova/documentation/documentation-sources/sample.tex
new file mode 100644
index 0000000000..17209e35b7
--- /dev/null
+++ b/fonts/punknova/documentation/documentation-sources/sample.tex
@@ -0,0 +1,21 @@
+\definefontfeature[punk][mode=node,script=latn,rand=yes,kern=yes,tlig=yes]
+
+\starttypescript [serif] [punknova]
+ \definefontsynonym[Serif] [file:punknova-regular] [features=punk]
+ \definefontsynonym[SerifBold] [file:punknova-bold] [features=punk]
+ \definefontsynonym[SerifItalic] [file:punknova-slanted] [features=punk]
+ \definefontsynonym[SerifBoldItalic] [file:punknova-boldslanted][features=punk]
+\stoptypescript
+
+\starttypescript [punknova]
+ \definetypeface [punknova] [rm] [serif] [punknova] [default]
+\stoptypescript
+
+\setupbodyfont[punknova]
+
+\starttext
+\rm \input knuth\par
+\bf \input knuth\par
+\it \input knuth\par
+\bi \input knuth\par
+\stoptext
diff --git a/fonts/punknova/documentation/sample.pdf b/fonts/punknova/documentation/sample.pdf
new file mode 100644
index 0000000000..c986455fab
--- /dev/null
+++ b/fonts/punknova/documentation/sample.pdf
Binary files differ
diff --git a/fonts/punknova/punknova-bold.otf b/fonts/punknova/punknova-bold.otf
new file mode 100644
index 0000000000..570859aed1
--- /dev/null
+++ b/fonts/punknova/punknova-bold.otf
Binary files differ
diff --git a/fonts/punknova/punknova-boldslanted.otf b/fonts/punknova/punknova-boldslanted.otf
new file mode 100644
index 0000000000..ab1f1814fd
--- /dev/null
+++ b/fonts/punknova/punknova-boldslanted.otf
Binary files differ
diff --git a/fonts/punknova/punknova-regular.otf b/fonts/punknova/punknova-regular.otf
new file mode 100644
index 0000000000..0b0299f8ca
--- /dev/null
+++ b/fonts/punknova/punknova-regular.otf
Binary files differ
diff --git a/fonts/punknova/punknova-slanted.otf b/fonts/punknova/punknova-slanted.otf
new file mode 100644
index 0000000000..2e1c7c404a
--- /dev/null
+++ b/fonts/punknova/punknova-slanted.otf
Binary files differ
diff --git a/fonts/punknova/source/punkfont-bold.mp b/fonts/punknova/source/punkfont-bold.mp
new file mode 100644
index 0000000000..1c62963f9a
--- /dev/null
+++ b/fonts/punknova/source/punkfont-bold.mp
@@ -0,0 +1,4 @@
+boolean bold_punk ; bold_punk := true ;
+
+input "punkfont-definitions.mp" ;
+input "punkfont-characters.mp" ;
diff --git a/fonts/punknova/source/punkfont-boldslanted.mp b/fonts/punknova/source/punkfont-boldslanted.mp
new file mode 100644
index 0000000000..3e5fa1561d
--- /dev/null
+++ b/fonts/punknova/source/punkfont-boldslanted.mp
@@ -0,0 +1,5 @@
+boolean bold_punk ; bold_punk := true ;
+boolean slanted_punk ; slanted_punk := true ;
+
+input "punkfont-definitions.mp" ;
+input "punkfont-characters.mp" ;
diff --git a/fonts/punknova/source/punkfont-regular.mp b/fonts/punknova/source/punkfont-regular.mp
new file mode 100644
index 0000000000..2a03aae81d
--- /dev/null
+++ b/fonts/punknova/source/punkfont-regular.mp
@@ -0,0 +1,2 @@
+input "punkfont-definitions.mp" ;
+input "punkfont-characters.mp" ;
diff --git a/fonts/punknova/source/punkfont-slanted.mp b/fonts/punknova/source/punkfont-slanted.mp
new file mode 100644
index 0000000000..5c1ff46b23
--- /dev/null
+++ b/fonts/punknova/source/punkfont-slanted.mp
@@ -0,0 +1,4 @@
+boolean slanted_punk ; slanted_punk := true ;
+
+input "punkfont-definitions.mp" ;
+input "punkfont-characters.mp" ;
diff --git a/fonts/punknova/tools/build.py b/fonts/punknova/tools/build.py
new file mode 100755
index 0000000000..b98af0638e
--- /dev/null
+++ b/fonts/punknova/tools/build.py
@@ -0,0 +1,221 @@
+#!/usr/bin/python
+
+import os
+import sys
+import fontforge
+import glob
+import subprocess
+import tempfile
+import shutil as sh
+
+def run_mpost(file, tempdir):
+ subprocess.call(
+ ['mpost',
+ '&mfplain',
+ '\mode=localfont;',
+ 'scale_factor:=100.375;',
+ 'outputtemplate:="%c.eps";',
+ 'input %s;' % file,
+ 'bye'],
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+ cwd=tempdir,
+ )
+
+def import_glyphs(font, instance, tempdir):
+ print "Importing glyph variants set '%s'" % instance
+
+ glyph_files = glob.glob(os.path.join(tempdir, "*.eps"))
+
+ for file in glyph_files:
+ code = int(os.path.splitext(os.path.basename(file))[0])
+ char = unichr(code)
+
+ if char.isupper() and int(instance) > 15:
+ continue
+
+ if not char.isupper() and not char.islower() and int(instance) > 7:
+ continue
+
+ if instance == "0":
+ glyph = font.createChar(code)
+ else:
+ glyph = font.createChar(-1, font[code].glyphname+"."+instance)
+
+ glyph.importOutlines(file, ("toobigwarn", "correctdir", "handle_eraser"))
+
+def do_instances(font, instances, mpfile, tempdir):
+ for instance in range(instances):
+ instance = str(instance)
+ instance_dir = os.path.join(tempdir, instance)
+ os.mkdir (instance_dir)
+ run_mpost (mpfile, instance_dir)
+ import_glyphs(font, instance, instance_dir)
+
+def get_alt(code, name):
+ instances = 8
+ alt = ()
+ char = unichr(code)
+
+ if char.islower():
+ instances = 32
+ elif char.isupper():
+ instances = 16
+
+ for i in range(1,instances):
+ alt = alt + ("%s.%d" %(name, i),)
+
+ return alt
+
+def add_gsub(font, instances):
+ print "Adding glyph substitution rules..."
+
+ font.addLookup(
+ "Randomize lookup",
+ "gsub_alternate",
+ (),
+ (
+ ('rand',
+ (
+ ('DFLT', ('dflt',)),
+ ('grek', ('dflt',)),
+ ('latn', ('dflt',))
+ )
+ ),
+ ))
+ font.addLookupSubtable("Randomize lookup", "Randomize subtable")
+
+ for glyph in font.glyphs():
+ if glyph.unicode != -1:
+ glyph.addPosSub("Randomize subtable",
+ get_alt(glyph.unicode, glyph.glyphname))
+
+def greek_caps(font, instances):
+ print "Adding missing Greek capitals..."
+
+ caps = {
+ "Alpha" : "A",
+ "Beta" : "B",
+ "Epsilon": "E",
+ "Zeta" : "Z",
+ "Eta" : "H",
+ "Iota" : "I",
+ "Kappa" : "K",
+ "Mu" : "M",
+ "Nu" : "N",
+ "Omicron": "O",
+ "Rho" : "P",
+ "Tau" : "T",
+ "Chi" : "X"
+ }
+ for c in caps:
+ name = caps[c]
+ glyph = font.createChar(-1, c)
+ glyph.addReference(name)
+ glyph.useRefsMetrics(name)
+ glyph.unlinkRef()
+ glyph.addPosSub("Randomize subtable",
+ get_alt(font.createMappedChar(name).unicode, name))
+
+def autowidth(font):
+ print "Auto spacing..."
+
+ font.selection.all()
+ if font.fullname.find("Slanted"):
+ font.autoWidth(40, 0, 20)
+ else:
+ font.autoWidth(70, 10, 40)
+ font.round() # this one is needed to make simplify more reliable
+ font.simplify()
+ font.removeOverlap()
+ font.round()
+ font.autoHint()
+
+def autokern(font, instances):
+ print "Auto kerning..."
+
+ font.addLookup(
+ "Kern lookup",
+ "gpos_pair",
+ (),
+ (
+ ('kern',
+ (
+ ('DFLT', ('dflt',)),
+ ('grek', ('dflt',)),
+ ('latn', ('dflt',))
+ )
+ ),
+ ))
+ font.addLookupSubtable("Kern lookup", "Kern subtable")
+
+ list1 = ["A", "V", "a", "v", "W", "w", "o", "O", "T", "L", "Y", "l", "y"]
+ list2 = [ ]
+
+ for a in list1:
+ list2.append(a)
+ alt = get_alt(font.createMappedChar(a).unicode, a)
+ for b in alt:
+ list2.append(b)
+
+ list1 = list2
+
+ font.autoKern("Kern subtable", 150, list1, list2, onlyCloser=True)
+
+def finalise(font):
+ space = font.createChar(32)
+ space.width = 400
+
+def usage():
+ print "Usage: %s INFILE.mp OUTFILE.otf VERSION" % sys.argv[0]
+
+if __name__ == "__main__":
+ if len(sys.argv) < 3:
+ usage()
+ sys.exit()
+
+ infile = sys.argv[1]
+ outfile = sys.argv[2]
+ version = sys.argv[3]
+
+ basefile = os.path.basename(infile)
+
+ style = basefile.split("-")[1]
+ style = os.path.splitext(style)[0].title()
+ if style == "Boldslanted":
+ style = "Bold Slanted"
+
+ tempdir = tempfile.mkdtemp()
+ mpfile = os.path.abspath(infile)
+ instances = 32
+
+ font = fontforge.font()
+
+ if style != "Regular":
+ font.fontname = "PunkNova-%s" % style.replace(" ", "")
+ font.fullname = "Punk Nova %s" % style
+ else:
+ font.fontname = "PunkNova"
+ font.fullname = "Punk Nova"
+
+ font.familyname = "Punk Nova"
+ font.weight = style
+ font.version = '00%.03f' %(float(version)/1000)
+ font.encoding = "Unicode"
+
+ font.copyright = "Unlimited copying and redistribution of this file are\
+ permitted as long as this file is not modified. Modifications are permitted,\
+ but only if the resulting file is not named '%s' and the (internal) fontname\
+ differs from '%s'." % (outfile, font.familyname)
+
+ do_instances(font, instances, mpfile, tempdir)
+ add_gsub (font, instances)
+ greek_caps (font, instances)
+ autowidth (font)
+ autokern (font, instances)
+ finalise (font)
+
+ sh.rmtree (tempdir)
+
+ print "Saving file '%s'..." % outfile
+# font.save()
+ font.generate(outfile)