monospacify, adjusted metrics, update readme, added comic-shanns-dtinth
authorThai on Cloud9 <dtinth@spacet.me>
Mon, 6 May 2019 05:42:00 +0000 (05:42 +0000)
committerThai on Cloud9 <dtinth@spacet.me>
Mon, 6 May 2019 05:42:00 +0000 (05:42 +0000)
.gitignore [new file with mode: 0644]
README.md
comic-shanns-dtinth.otf [new file with mode: 0644]
dtinth.py [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..35dedad
--- /dev/null
@@ -0,0 +1,2 @@
+vendor
+*.pyc
\ No newline at end of file
index 81d4a930158dc8d068c4cc7954ac0abc3ccc2131..58bd4fe75f7e650342998e363638d7a174384473 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,6 +1,11 @@
 # What it is
 A classy font.
 
+## Changes in dtinth’s fork
+1. All glyphs have been adjusted to have exactly the same width (using code based on [monospacifier](https://github.com/cpitclaudel/monospacifier))
+2. The glyph metrics have been adjusted to make it display better alongside system font.
+3. The name is changed to `Comic Shanns dtinth`.
+
 ## Usage
 You can download it and install it like any other font.
 
diff --git a/comic-shanns-dtinth.otf b/comic-shanns-dtinth.otf
new file mode 100644 (file)
index 0000000..3c0ae3b
Binary files /dev/null and b/comic-shanns-dtinth.otf differ
diff --git a/dtinth.py b/dtinth.py
new file mode 100644 (file)
index 0000000..0aee998
--- /dev/null
+++ b/dtinth.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python2
+# -*- coding: utf-8 -*-
+
+"""Update the glyph metrics so that they all really have the same size."""
+
+# Based on
+# - monospacifier: https://github.com/cpitclaudel/monospacifier/blob/master/monospacifier.py
+# - YosemiteAndElCapitanSystemFontPatcher: https://github.com/dtinth/YosemiteAndElCapitanSystemFontPatcher/blob/master/bin/patch
+
+import os
+import re
+import sys
+
+reload(sys)
+sys.setdefaultencoding('UTF8')
+
+import fontforge
+import psMat
+import unicodedata
+
+def height(font):
+    return float(font.capHeight)
+
+def adjust_height(source, template):
+    source.selection.all()
+    source.transform(psMat.scale(height(template) / height(source)))
+    for attr in ['ascent', 'descent',
+                'hhea_ascent', 'hhea_ascent_add',
+                'hhea_linegap',
+                'hhea_descent', 'hhea_descent_add',
+                'os2_winascent', 'os2_winascent_add',
+                'os2_windescent', 'os2_windescent_add',
+                'os2_typoascent', 'os2_typoascent_add',
+                'os2_typodescent', 'os2_typodescent_add',
+                ]:
+        setattr(source, attr, getattr(template, attr))
+    source.transform(psMat.scale(0.9))
+
+font = fontforge.open('comic-shanns.otf')
+ref = fontforge.open('vendor/Menlo.ttc')
+for g in font.glyphs():
+    uni = g.unicode
+    category = unicodedata.category(unichr(uni)) if 0 <= uni <= sys.maxunicode else None
+    if g.width > 0 and category not in ['Mn', 'Mc', 'Me']:
+        target_width = 510
+        if g.width != target_width:
+            delta = target_width - g.width
+            g.left_side_bearing += delta / 2
+            g.right_side_bearing += delta - g.left_side_bearing
+            g.width = target_width
+
+adjust_height(font, ref)
+font.sfnt_names = [] # Get rid of 'Prefered Name' etc.
+font.fontname = 'Comic Shanns dtinth'
+font.familyname = 'Comic Shanns dtinth'
+font.fullname = 'Comic Shanns dtinth'
+font.generate('comic-shanns-dtinth.otf')
\ No newline at end of file