[cantarell-fonts] Update font production script



commit 28991e06ac5b059a0a0124fce0ca2911e4e33985
Author: Nikolaus Waxweiler <madigens gmail com>
Date:   Mon Jan 25 16:49:26 2016 +0100

    Update font production script
    
    It will error out if the font source does not validate. Should catch
    more oopses. The generated files might not validate completely due to
    the way FontForge scripting seems to work.
    
    Version number is now automatically taken from what configure.ac says
    and inserted into the font at make-time.
    
    Obliques: Shift glyphs 20fU to the left, inspired by Thomas Phinney's
    presentation on "How to Space a Font". This thightens spacing.
    
    Rename Cantarell-Bold-Oblique.otf to Cantarell-BoldOblique.otf.

 configure.ac                           |    3 +-
 otf/Cantarell-Bold-Oblique.otf         |  Bin 118968 -> 0 bytes
 otf/Cantarell-Bold.otf                 |  Bin 100932 -> 100764 bytes
 otf/Cantarell-BoldOblique.otf          |  Bin 0 -> 118164 bytes
 otf/Cantarell-Oblique.otf              |  Bin 118184 -> 117820 bytes
 otf/Cantarell-Regular.otf              |  Bin 98420 -> 98272 bytes
 otf/Makefile.am                        |   12 ++--
 scripts/generate.sh                    |   90 +++++++++++++++++++++++----
 scripts/generate.sh.in                 |  103 ++++++++++++++++++++++++++++++++
 src/Cantarell-Regular.sfdir/font.props |    4 +-
 10 files changed, 189 insertions(+), 23 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 8c1650e..763d5c7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
 dnl Process this file with autoconf to produce a configure script.
 AC_PREREQ(2.53)
 
-AC_INIT([cantarell-fonts], [0.0.21],
+AC_INIT([cantarell-fonts], [0.00021],
         [http://bugzilla.gnome.org/enter_bug.cgi?product=cantarell-fonts])
 
 AM_INIT_AUTOMAKE([1.9 tar-ustar foreign dist-bzip2 no-dist-gzip])
@@ -57,6 +57,7 @@ fontconfig/Makefile
 src/Makefile
 otf/Makefile
 scripts/Makefile
+scripts/generate.sh
 ])
 
 AC_OUTPUT
diff --git a/otf/Cantarell-Bold.otf b/otf/Cantarell-Bold.otf
index 951aee6..a2807cb 100644
Binary files a/otf/Cantarell-Bold.otf and b/otf/Cantarell-Bold.otf differ
diff --git a/otf/Cantarell-BoldOblique.otf b/otf/Cantarell-BoldOblique.otf
new file mode 100644
index 0000000..f75f290
Binary files /dev/null and b/otf/Cantarell-BoldOblique.otf differ
diff --git a/otf/Cantarell-Oblique.otf b/otf/Cantarell-Oblique.otf
index 271733a..44693bb 100644
Binary files a/otf/Cantarell-Oblique.otf and b/otf/Cantarell-Oblique.otf differ
diff --git a/otf/Cantarell-Regular.otf b/otf/Cantarell-Regular.otf
index 3df7c1c..5a779d0 100644
Binary files a/otf/Cantarell-Regular.otf and b/otf/Cantarell-Regular.otf differ
diff --git a/otf/Makefile.am b/otf/Makefile.am
index 3abf0de..8eca8f4 100644
--- a/otf/Makefile.am
+++ b/otf/Makefile.am
@@ -1,16 +1,16 @@
 
 fontdir = $(FONTDIR)
 font_DATA = \
-       Cantarell-Regular.otf           \
-       Cantarell-Oblique.otf           \
-       Cantarell-Bold.otf \
-       Cantarell-Bold-Oblique.otf
+       Cantarell-Regular.otf      \
+       Cantarell-Oblique.otf      \
+       Cantarell-Bold.otf         \
+       Cantarell-BoldOblique.otf
 
 if SOURCE_REBUILD
-$(filter-out %-Oblique.otf,$(font_DATA)): %.otf: $(top_srcdir)/src/%.sfdir
+$(filter-out %Oblique.otf,$(font_DATA)): %.otf: $(top_srcdir)/src/%.sfdir
        /usr/bin/env fontforge -script $(top_srcdir)/scripts/generate.sh "$^"
 
-$(filter %-Oblique.otf,$(font_DATA)): %.otf: ;
+$(filter %Oblique.otf,$(font_DATA)): %.otf: ;
 endif
 
 EXTRA_DIST = $(font_DATA)
diff --git a/scripts/generate.sh b/scripts/generate.sh
old mode 100755
new mode 100644
index f5e7ac3..96577ea
--- a/scripts/generate.sh
+++ b/scripts/generate.sh
@@ -9,33 +9,95 @@ SetPref("TTFFoundry", "Cantarell")
 
 i = 1
 while (i < $argc)
-    Open($argv[i], 1)
+    Open($argv[i])
+    SetFontNames("", "", "", "", "", "0.00021")
+
+    if (Validate(1))
+      Error($argv[i] + " did not pass validation. Tolerate no technical flaws in the source! Run 'Validate' 
in FontForge to see and fix what's wrong. The generated files might not validate completely because FontForge 
is buggy.")
+    endif
+    
     SelectAll()
-    Simplify()
-    AddExtrema()
-    RoundToInt()
     CorrectDirection()
+
+    SelectGlyphsBoth()
+    UnlinkReference()
+    RemoveOverlap()
+    AddExtrema()
+    Simplify(1 | 8 | 16 | 32 | 64 | 128)
+
+    SelectAll()
     ClearHints()
     AutoHint()
+    RoundToInt()
     Generate($fontname + ".otf")
-    #generate oblique
+
+    # Using RoundToInt() above doesn't actually round everything to int. Ugh.
+    # Workaround: open generated file and RoundToInt() there, then regenerate.
+    # This can mess with the PS Private dictionary. Gah!
+    #Open($fontname + ".otf")
+    #SelectAll()
+    #RoundToInt()
+    #Generate($fontname + ".otf")
+    #
+    #Open($argv[i])
+
+    ###
+    # Generate synthetic oblique. Better than nothing.
+    SetItalicAngle(-8)
+
     weight=GetTTFName(0x409,2)
-    if($weight=="Regular") 
-      SetTTFName(0x409,2,"Oblique")
-      SetFontNames("Cantarell-Oblique", "", "Cantarell Oblique", "","","")
+    if ($weight == "Regular") 
+      SetTTFName(0x409, 2, "Oblique")
+      SetFontNames("Cantarell-Oblique", "", "Cantarell Oblique")
     else
-      SetTTFName(0x409,2,"Bold-Oblique")
-      SetFontNames("Cantarell-Bold-Oblique", "", "Cantarell Bold Oblique", "","","")
+      SetTTFName(0x409, 2, "BoldOblique")
+      SetFontNames("Cantarell-BoldOblique", "", "Cantarell Bold Oblique")
     endif
-    UnlinkReference() #workaround for shifting diacritics
+
+    # XXX: Does not work from the script, only works when done through the GUI.
+#    # To keep references, selectively unlink and remove overlap. First select
+#    # glyphs constructed out of references and splines and turn them into
+#    # splines-only. Also unlink diacritics and some misc. glyphs if they are
+#    # constructed out of other diacritics (e.g. 2x dotaccent -> dieresis). Skew
+#    # won't work correctly otherwise.
+#    SelectGlyphsBoth()
+#    SelectMore(0u02c6, 0u0331)
+#    SelectMore(0u0022)
+#    SelectMore(0u003a, 0u003b)
+#    UnlinkReference()
+#    RemoveOverlap()
+#    Simplify(1 | 8 | 16 | 32 | 64 | 128)
+#    RoundToInt()
+
+    SelectAll()
+    UnlinkReference()
+    RemoveOverlap()
+    Simplify(1 | 8 | 16 | 32 | 64 | 128)
+    RoundToInt()
     Skew(8)
-    Simplify()
     AddExtrema()
+    Simplify(1 | 8 | 16 | 32 | 64 | 128)
     RoundToInt()
-    CorrectDirection()
-    ClearHints()
+
+    # Can't validate oblique'd font because RoundToInt doesn't seem to round
+    # control handles to integers, causing missing extrema on a few glyphs that
+    # disappear when manually rounding to int in the GUI.
+    #if (Validate(1))
+    #  Error("Oblique'd " + $argv[i] + " did not pass validation. Fix the script.")
+    #endif
+
+    # Deselect combining diacritics before tightening spacing of the oblique.
+    # The tightening has been calculated according to Thomas Phinney's
+    # presentation on "How to Space a font", H * (tan i) = left shift, where H
+    # is 0.5 * average(cap height, x height) and i is the italic angle. I
+    # halved the result because it looks better.
+    SelectGlyphsSplines()
+    SelectFewer(0u0300, 0u0331)
+    Move(-20, 0)
+
     AutoHint()
     Generate($fontname + ".otf")
     Close()
+
     i++
 endloop
diff --git a/scripts/generate.sh.in b/scripts/generate.sh.in
new file mode 100755
index 0000000..1fdff67
--- /dev/null
+++ b/scripts/generate.sh.in
@@ -0,0 +1,103 @@
+#!/usr/bin/env fontforge
+
+if ($version < "20080330")
+    Error("Your version of FontForge is too old - 20080330 or newer is required");
+endif
+
+SetPref("FoundryName", "Cantarell")
+SetPref("TTFFoundry", "Cantarell")
+
+i = 1
+while (i < $argc)
+    Open($argv[i])
+    SetFontNames("", "", "", "", "", "@PACKAGE_VERSION@")
+
+    if (Validate(1))
+      Error($argv[i] + " did not pass validation. Tolerate no technical flaws in the source! Run 'Validate' 
in FontForge to see and fix what's wrong. The generated files might not validate completely due to the way 
FontForge scripting seems to work..")
+    endif
+    
+    SelectAll()
+    CorrectDirection()
+
+    SelectGlyphsBoth()
+    UnlinkReference()
+    RemoveOverlap()
+    AddExtrema()
+    Simplify(1 | 8 | 16 | 32 | 64 | 128)
+
+    SelectAll()
+    ClearHints()
+    AutoHint()
+    RoundToInt()
+    Generate($fontname + ".otf")
+
+    # Using RoundToInt() above doesn't actually round everything to int. Ugh.
+    # Workaround: open generated file and RoundToInt() there, then regenerate.
+    # This can mess with the PS Private dictionary. Gah!
+    #Open($fontname + ".otf")
+    #SelectAll()
+    #RoundToInt()
+    #Generate($fontname + ".otf")
+    #
+    #Open($argv[i])
+
+    ###
+    # Generate synthetic oblique. Better than nothing.
+    SetItalicAngle(-8)
+
+    weight=GetTTFName(0x409,2)
+    if ($weight == "Regular") 
+      SetTTFName(0x409, 2, "Oblique")
+      SetFontNames("Cantarell-Oblique", "", "Cantarell Oblique")
+    else
+      SetTTFName(0x409, 2, "BoldOblique")
+      SetFontNames("Cantarell-BoldOblique", "", "Cantarell Bold Oblique")
+    endif
+
+    # XXX: Does not work from the script, only works when done through the GUI.
+#    # To keep references, selectively unlink and remove overlap. First select
+#    # glyphs constructed out of references and splines and turn them into
+#    # splines-only. Also unlink diacritics and some misc. glyphs if they are
+#    # constructed out of other diacritics (e.g. 2x dotaccent -> dieresis). Skew
+#    # won't work correctly otherwise.
+#    SelectGlyphsBoth()
+#    SelectMore(0u02c6, 0u0331)
+#    SelectMore(0u0022)
+#    SelectMore(0u003a, 0u003b)
+#    UnlinkReference()
+#    RemoveOverlap()
+#    Simplify(1 | 8 | 16 | 32 | 64 | 128)
+#    RoundToInt()
+
+    SelectAll()
+    UnlinkReference()
+    RemoveOverlap()
+    Simplify(1 | 8 | 16 | 32 | 64 | 128)
+    RoundToInt()
+    Skew(8)
+    AddExtrema()
+    Simplify(1 | 8 | 16 | 32 | 64 | 128)
+    RoundToInt()
+
+    # Can't validate oblique'd font because RoundToInt doesn't seem to round
+    # control handles to integers, causing missing extrema on a few glyphs that
+    # disappear when manually rounding to int in the GUI.
+    #if (Validate(1))
+    #  Error("Oblique'd " + $argv[i] + " did not pass validation. Fix the script.")
+    #endif
+
+    # Deselect combining diacritics before tightening spacing of the oblique.
+    # The tightening has been calculated according to Thomas Phinney's
+    # presentation on "How to Space a font", H * (tan i) = left shift, where H
+    # is 0.5 * average(cap height, x height) and i is the italic angle. I
+    # halved the result because it looks better.
+    SelectGlyphsSplines()
+    SelectFewer(0u0300, 0u0331)
+    Move(-20, 0)
+
+    AutoHint()
+    Generate($fontname + ".otf")
+    Close()
+
+    i++
+endloop
diff --git a/src/Cantarell-Regular.sfdir/font.props b/src/Cantarell-Regular.sfdir/font.props
index 8ebf8fe..53b2f5a 100644
--- a/src/Cantarell-Regular.sfdir/font.props
+++ b/src/Cantarell-Regular.sfdir/font.props
@@ -23,7 +23,7 @@ OS2Version: 0
 OS2_WeightWidthSlopeOnly: 0
 OS2_UseTypoMetrics: 0
 CreationTime: 1236980653
-ModificationTime: 1453734255
+ModificationTime: 1453736445
 PfmFamily: 33
 TTFWeight: 400
 TTFWidth: 5
@@ -66,7 +66,7 @@ BlueValues 31 [-10 0 482 494 692 706 718 730]
 OtherBlues 11 [-265 -259]
 StdHW 4 [73]
 StdVW 4 [83]
-StemSnapH 10 [66 67 73]
+StemSnapH 16 [65 66 67 68 73]
 StemSnapV 4 [83]
 BlueScale 6 0.0536
 BlueShift 1 7


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]