projects
/
proportionaltomonofont
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
92b9df8
)
Update generate.py
author
Rev. Fr. Robert Bower <39407737+frrobert2@users.noreply.github.com>
Mon, 3 May 2021 15:47:58 +0000
(11:47 -0400)
committer
GitHub <noreply@github.com>
Mon, 3 May 2021 15:47:58 +0000
(11:47 -0400)
generate.py
patch
|
blob
|
history
diff --git
a/generate.py
b/generate.py
index 634f9076173f9978dca6fd80f083b2230651897a..4208499bdd796e3cf688307bc1d18b47fcd90344 100644
(file)
--- a/
generate.py
+++ b/
generate.py
@@
-2,15
+2,17
@@
# -*- coding: utf-8 -*-
"""
# -*- coding: utf-8 -*-
"""
-Generates the
Comic Mono font files based on Comic Shanns font.
+Generates the
Mono font files based on a proportional font
Required files:
Required files:
-- vendor/
comic-shanns.o
tf
-- vendor/
Cousine-Regular
.ttf
+- vendor/
fonttobechanged.t
tf
+- vendor/
referencefont
.ttf
Based on:
- monospacifier: https://github.com/cpitclaudel/monospacifier/blob/master/monospacifier.py
- YosemiteAndElCapitanSystemFontPatcher: https://github.com/dtinth/YosemiteAndElCapitanSystemFontPatcher/blob/master/bin/patch
Based on:
- monospacifier: https://github.com/cpitclaudel/monospacifier/blob/master/monospacifier.py
- YosemiteAndElCapitanSystemFontPatcher: https://github.com/dtinth/YosemiteAndElCapitanSystemFontPatcher/blob/master/bin/patch
+- https://github.com/dtinth/comic-mono-font
+- Comic Mono: https://github.com/dtinth/comic-mono-font
"""
import os
"""
import os
@@
-41,34
+43,43
@@
def adjust_height(source, template, scale):
]:
setattr(source, attr, getattr(template, attr))
source.transform(psMat.scale(scale))
]:
setattr(source, attr, getattr(template, attr))
source.transform(psMat.scale(scale))
-
+#change the next to lines to the font you want to convert and the reference font
+# make sure those two fonts are in the vendor directory
font = fontforge.open('vendor/comic-shanns.otf')
ref = fontforge.open('vendor/Cousine-Regular.ttf')
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']:
font = fontforge.open('vendor/comic-shanns.otf')
ref = fontforge.open('vendor/Cousine-Regular.ttf')
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']:
+ # change target width to either make characters norrow or wide
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
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
-
+# change next 4 lines to desired information
font.familyname = 'Comic Mono'
font.version = '0.1.1'
font.comment = 'https://github.com/dtinth/comic-mono-font'
font.copyright = 'https://github.com/dtinth/comic-mono-font/blob/master/LICENSE'
font.familyname = 'Comic Mono'
font.version = '0.1.1'
font.comment = 'https://github.com/dtinth/comic-mono-font'
font.copyright = 'https://github.com/dtinth/comic-mono-font/blob/master/LICENSE'
-
+#change number in adjust_height to make font shorter or taller
adjust_height(font, ref, 0.875)
font.sfnt_names = [] # Get rid of 'Prefered Name' etc.
adjust_height(font, ref, 0.875)
font.sfnt_names = [] # Get rid of 'Prefered Name' etc.
+#change to desired font name
font.fontname = 'ComicMono'
font.fontname = 'ComicMono'
+#change to desired full name
font.fullname = 'Comic Mono'
font.fullname = 'Comic Mono'
+#change to desired file name
font.generate('ComicMono.ttf')
font.selection.all()
font.generate('ComicMono.ttf')
font.selection.all()
+#Bold section
+#change to desired font name
font.fontname = 'ComicMono-Bold'
font.fontname = 'ComicMono-Bold'
+#change to desired full name
font.fullname = 'Comic Mono Bold'
font.weight = 'Bold'
font.changeWeight(32, "LCG", 0, 0, "squish")
font.fullname = 'Comic Mono Bold'
font.weight = 'Bold'
font.changeWeight(32, "LCG", 0, 0, "squish")
-font.generate('ComicMono-Bold.ttf')
\ No newline at end of file
+#change to desired file name
+font.generate('ComicMono-Bold.ttf')