Updates to font patcher and all fonts patcher scripts

* support for octicons, font-awesome, added missing combinations
* added font versioning
* misc fixes
* all fonts patcher pattern param support
This commit is contained in:
ryanoasis 2015-08-10 18:33:21 -04:00
parent 9a9eec8306
commit bbe17fd6b8
3 changed files with 652 additions and 121 deletions

View file

@ -17,16 +17,21 @@ except ImportError:
# argparse stuff
parser = argparse.ArgumentParser(description='Patches a given font with programming and web development related glyphs (mainly for vim-webdevicons)')
parser = argparse.ArgumentParser(description='Patches a given font with programming and web development related glyphs (mainly for https://github.com/ryanoasis/vim-devicons)')
parser.add_argument('font', help='The path to the font to be patched (e.g. Inconsolata.otf)')
parser.add_argument('-s', '--use-single-width-glyphs', dest='single', action='store_true', help='Whether to generate the glyphs as single-width not double-width (default is double-width)', default=False)
parser.add_argument('-q', '--quiet', '--shutup', dest='quiet', action='store_true', help='Do not generate verbose output', default=False)
parser.add_argument('-w', '--windows', '--limit-font-name-length', dest='windows', action='store_true', help='Limit the internal font name to a maximum of 31 characters (for safe Windows compatiblity)', default=False)
parser.add_argument('--fontawesome', dest='fontawesome', action='store_true', help='Add Font Awesome Glyphs (http://fortawesome.github.io/Font-Awesome/)', default=False)
parser.add_argument('--octicons', dest='octicons', action='store_true', help='Add Octicons Glyphs (https://octicons.github.com/)', default=False)
parser.add_argument('--pomicons', dest='pomicons', action='store_true', help='Add Pomicon Glyphs (https://github.com/gabrielelana/pomicons)', default=False)
args = parser.parse_args()
#print "using fontforge package version: " + str(fontforge.__version__) + " " + str(fontforge.version())
#print type(fontforge.version())
#print int(fontforge.version())
version = "0.4.0"
minimumVersion = 20141231
actualVersion = int(fontforge.version())
#actualVersion = 20120731 # for testing invalid version
@ -36,40 +41,116 @@ if actualVersion < minimumVersion:
print "Please use at least version: " + str(minimumVersion)
sys.exit(1)
additionalFontNameSuffix = " Plus Nerd File Types"
verboseAdditionalFontNameSuffix = " Plus Nerd File Types"
if args.windows:
# attempt to shorten here on the additional name BEFORE trimming later
additionalFontNameSuffix = " PNFT"
else:
additionalFontNameSuffix = verboseAdditionalFontNameSuffix
if args.single:
additionalFontNameSuffix += " Mono"
verboseAdditionalFontNameSuffix += " Mono"
if args.fontawesome:
additionalFontNameSuffix += " Plus Font Awesome"
verboseAdditionalFontNameSuffix += " Plus Font Awesome"
if args.octicons:
additionalFontNameSuffix += " Plus Octicons"
verboseAdditionalFontNameSuffix += " Plus Octicons"
if args.pomicons:
additionalFontNameSuffix += " Plus Pomicons"
verboseAdditionalFontNameSuffix += " Plus Pomicons"
sourceFont = fontforge.open(args.font)
# rename font
fontname, style = re.match("^([^-]*)(?:(-.*))?$", sourceFont.fontname).groups()
sourceFont.familyname = sourceFont.familyname + additionalFontNameSuffix
sourceFont.fullname = sourceFont.fullname + additionalFontNameSuffix
sourceFont.fontname = fontname + additionalFontNameSuffix.replace(" ", "")
familyname = sourceFont.familyname + additionalFontNameSuffix
# fullname (filename) can always use long/verbose font name, even in windows
fullname = sourceFont.fullname + verboseAdditionalFontNameSuffix
fontname = fontname + additionalFontNameSuffix.replace(" ", "")
if args.windows:
maxLength = 31
fullname += " Windows Compatible"
# now make sure less than 32 characters name length
#if len(fullname) > maxLength:
# fullname = fullname[:maxLength]
if len(fontname) > maxLength:
fontname = fontname[:maxLength]
if len(fullname) > maxLength:
familyname = familyname[:maxLength]
# rename font
def replace_all(text, dic):
for i, j in dic.iteritems():
text = text.replace(i, j)
return text
# comply with SIL Open Font License (OFL)
reservedFontNameReplacements = {'source': 'sauce', 'Source': 'Sauce', 'hermit': 'hurmit', 'Hermit': 'Hurmit'}
sourceFont.familyname = replace_all(familyname, reservedFontNameReplacements)
sourceFont.fullname = replace_all(fullname, reservedFontNameReplacements)
sourceFont.fontname = replace_all(fontname, reservedFontNameReplacements)
sourceFont.appendSFNTName('English (US)', 'Preferred Family', sourceFont.familyname)
sourceFont.appendSFNTName('English (US)', 'Compatible Full', sourceFont.fullname)
sourceFont.version = version
# glyph font
sourceFont_em_original = sourceFont.em
symbols = fontforge.open("glyph-source-fonts/original-source.otf")
#symbols = fontforge.open("glyph-source-fonts/icomoon.ttf")
symbols2 = fontforge.open("glyph-source-fonts/devicons.ttf")
powerlineSymbols = fontforge.open("glyph-source-fonts/PowerlineSymbols.otf")
symbolsDevicons = fontforge.open("glyph-source-fonts/devicons.ttf")
fontawesome = fontforge.open("glyph-source-fonts/FontAwesome.otf")
octicons = fontforge.open("glyph-source-fonts/octicons.ttf")
pomicons = fontforge.open("glyph-source-fonts/Pomicons.otf")
symbolsRangeStart = 0xE500
symbolsRangeEnd = 0xE527
symbolsOriginalRangeStart = 0xE4FE
symbolsOriginalRangeEnd = 0xE52A
symbols2RangeStart = 0xE600
symbols2RangeEnd = 0xE6C5
symbolsPowerlineRange1Start = 0xE0A0
symbolsPowerlineRange1End = 0xE0A2
sourceFontRange1Start = 0xE600
sourceFontRange1End = 0xE627
symbolsPowerlineRange2Start = 0xE0B0
symbolsPowerlineRange2End = 0xE0B3
symbolsDeviconsRangeStart = 0xE600
symbolsDeviconsRangeEnd = 0xE6C5
symbolsFontAwesomeRangeStart = 0xF000
symbolsFontAwesomeRangeEnd = 0xF23A
symbolsOcticonsRangeStart = 0xF000
symbolsOcticonsRangeEnd = 0xF0DB
symbolsPomiconsRangeStart = 0xE000
symbolsPomiconsRangeEnd = 0xE00A
sourceFontOriginalStart = 0xE5FE
sourceFontOriginalEnd = 0xE62A
sourceFontDeviconsStart = 0xE700
sourceFontDeviconsEnd = 0xE7C5
sourceFontFontAwesomeStart = 0xF000
sourceFontFontAwesomeEnd = 0xF23A
sourceFontOcticonsStart = 0xF400
sourceFontOcticonsEnd = 0xF4DB
sourceFontPomiconsStart = 0xE000
sourceFontPomiconsEnd = 0xE00A
sourceFontRange2Start = 0xE700
sourceFontRange2End = 0xE7C5
SYM_ATTR = {
# Right/left-aligned glyphs will have their advance width reduced in order to overlap the next glyph slightly
@ -82,14 +163,12 @@ SYM_ATTR = {
0x2b81: { 'align': 'l', 'stretch': 'xy', 'overlap': True },
0x2b82: { 'align': 'r', 'stretch': 'xy', 'overlap': True },
0x2b83: { 'align': 'r', 'stretch': 'xy', 'overlap': True },
#0xe612: { 'align': 'l', 'stretch': 'xy', 'overlap': False },
0xe611: { 'align': 'c', 'stretch': 'xy', 'overlap': False },
}
# Force the em size to be equal
symbols.em = sourceFont.em
symbols2.em = sourceFont.em
symbolsDevicons.em = sourceFont.em
# Initial font dimensions
font_dim = {
@ -121,9 +200,6 @@ for glyph in range(0x00, 0x17f) + range(0x2500, 0x2600):
# Calculate font height
font_dim['height'] = abs(font_dim['ymin']) + font_dim['ymax']
print "font_dim height = " + str(font_dim['height'])
print "font_dim width = " + str(font_dim['width'])
# Update the font encoding to ensure that the Unicode glyphs are available
sourceFont.encoding = 'ISO10646'
@ -138,6 +214,7 @@ def get_dim(glyph):
'ymin' : bbox[1],
'xmax' : bbox[2],
'ymax' : bbox[3],
'width' : bbox[2] + (-bbox[0]),
'height': bbox[3] + (-bbox[1]),
}
@ -156,13 +233,7 @@ def copy_glyphs(sourceFont, sourceFontStart, sourceFontEnd, symbolFont, symbolFo
sourceFont.selection.select(("ranges","unicode"),sourceFontStart,sourceFontEnd)
for sym_glyph in symbolFont.selection.byGlyphs:
sym_attr = False
if sym_glyph.unicode in SYM_ATTR:
print "found unicode in SYM_ATTR"
sym_attr = SYM_ATTR[sym_glyph.unicode]
print sym_attr
print "done found unicode"
#sym_attr = SYM_ATTR[sym_glyph.unicode]
if args.quiet == False:
print "updating glyph: " + str(sym_glyph)
# convince that this string really is a hex:
@ -179,82 +250,71 @@ def copy_glyphs(sourceFont, sourceFontStart, sourceFontEnd, symbolFont, symbolFo
sourceFont.selection.select(currentSourceFontGlyph)
sourceFont.paste()
#if args.single:
if args.single:
# Now that we have copy/pasted the glyph, it's time to scale and move it
#print "sym_attr:"
#print sym_attr
#print sym_attr['stretch']
if sym_attr:
# Handle glyph stretching
if 'x' in sym_attr['stretch']:
print "Stretch x"
# Stretch the glyph horizontally
scale_ratio = font_dim['width'] / sym_dim['width']
sourceFont.transform(psMat.scale(scale_ratio, 1))
#if 'x' in sym_attr['stretch']:
# # Stretch the glyph horizontally
# scale_ratio = font_dim['width'] / sym_dim['width']
# sourceFont.transform(psMat.scale(scale_ratio, 1))
if 'y' in sym_attr['stretch']:
print "Stretch y"
# Stretch the glyph vertically
scale_ratio = font_dim['height'] / sym_dim['height']
sourceFont.transform(psMat.scale(1, scale_ratio))
#if 'y' in sym_attr['stretch']:
# # Stretch the glyph vertically
# scale_ratio = font_dim['height'] / sym_dim['height']
# Use the dimensions from the pasted and stretched glyph
sym_dim = get_dim(sourceFont[currentSourceFontGlyph])
# sourceFont.transform(psMat.scale(1, scale_ratio))
# Center-align the glyph vertically
font_ycenter = font_dim['height'] / 2
sym_ycenter = sym_dim['height'] / 2
# Use the dimensions from the pasted and stretched glyph
sym_dim = get_dim(sourceFont[currentSourceFontGlyph])
# First move it to the ymax (top)
sourceFont.transform(psMat.translate(0, font_dim['ymax'] - sym_dim['ymax']))
# Center-align the glyph vertically
font_ycenter = font_dim['height'] / 2
sym_ycenter = sym_dim['height'] / 2
# Then move it the y center difference
sourceFont.transform(psMat.translate(0, sym_ycenter - font_ycenter))
# First move it to the ymax (top)
sourceFont.transform(psMat.translate(0, font_dim['ymax'] - sym_dim['ymax']))
# Ensure that the glyph doesn't extend outside the font's bounding box
if sym_dim['width'] > font_dim['width']:
print "sym_dim width " + str(sym_dim['width'])
print "font_dim width " + str(font_dim['width'])
# The glyph is too wide, scale it down to fit
scale_matrix = psMat.scale(font_dim['width'] / sym_dim['width'], 1)
# Then move it the y center difference
sourceFont.transform(psMat.translate(0, sym_ycenter - font_ycenter))
sourceFont.transform(scale_matrix)
# Ensure that the glyph doesn't extend outside the font's bounding box
if sym_dim['width'] > font_dim['width']:
# The glyph is too wide, scale it down to fit
scale_matrix = psMat.scale(font_dim['width'] / sym_dim['width'], 1)
# Use the dimensions from the stretched glyph
sym_dim = get_dim(sourceFont[currentSourceFontGlyph])
print "Bbox: " + str(sym_dim)
sourceFont.transform(scale_matrix)
# Use the dimensions from the stretched glyph
sym_dim = get_dim(sourceFont[currentSourceFontGlyph])
print "sym_dim width NOW: " + str(sym_dim['width'])
# Handle glyph alignment
#if sym_attr['align'] == 'c':
# # Center align
# align_matrix = psMat.translate(font_dim['width'] / 2 - sym_dim['width'] / 2 , 0)
align_matrix = psMat.translate(font_dim['width'] / 2 - sym_dim['width'] / 2 , 0)
#elif sym_attr['align'] == 'r':
# # Right align
# align_matrix = psMat.translate(font_dim['width'] - sym_dim['width'], 0)
#else:
# No alignment (left alignment)
#align_matrix = psMat.translate(0, 0)
# Handle glyph alignment
#if sym_attr['align'] == 'c':
# # Center align
# align_matrix = psMat.translate(font_dim['width'] / 2 - sym_dim['width'] / 2 , 0)
align_matrix = psMat.translate(font_dim['width'] / 2 - sym_dim['width'] / 2 , 0)
#elif sym_attr['align'] == 'r':
# # Right align
# align_matrix = psMat.translate(font_dim['width'] - sym_dim['width'], 0)
#else:
# No alignment (left alignment)
#align_matrix = psMat.translate(0, 0)
sourceFont.transform(align_matrix)
sourceFont.transform(align_matrix)
#if sym_attr['overlap'] is True:
# overlap_width = sourceFont.em / 48
#if sym_attr['overlap'] is True:
# overlap_width = sourceFont.em / 48
# # Stretch the glyph slightly horizontally if it should overlap
# sourceFont.transform(psMat.scale((sym_dim['width'] + overlap_width) / sym_dim['width'], 1))
# # Stretch the glyph slightly horizontally if it should overlap
# sourceFont.transform(psMat.scale((sym_dim['width'] + overlap_width) / sym_dim['width'], 1))
# if sym_attr['align'] == 'l':
# # The glyph should be left-aligned, so it must be moved overlap_width to the left
# # This only applies to left-aligned glyphs because the glyph is scaled to the right
# sourceFont.transform(psMat.translate(-overlap_width, 0))
# if sym_attr['align'] == 'l':
# # The glyph should be left-aligned, so it must be moved overlap_width to the left
# # This only applies to left-aligned glyphs because the glyph is scaled to the right
# sourceFont.transform(psMat.translate(-overlap_width, 0))
# Ensure the font is considered monospaced on Windows
#sourceFont[currentSourceFontGlyph].width = font_dim['width']
# Ensure the font is considered monospaced on Windows
sourceFont[currentSourceFontGlyph].width = font_dim['width']
sourceFontCounter += 1
# reset selection so iteration works propertly @todo fix? rookie misunderstanding?
@ -263,8 +323,19 @@ def copy_glyphs(sourceFont, sourceFontStart, sourceFontEnd, symbolFont, symbolFo
return
copy_glyphs(sourceFont, sourceFontRange1Start, sourceFontRange1End, symbols, symbolsRangeStart, symbolsRangeEnd)
copy_glyphs(sourceFont, sourceFontRange2Start, sourceFontRange2End, symbols2, symbols2RangeStart, symbols2RangeEnd)
copy_glyphs(sourceFont, sourceFontOriginalStart, sourceFontOriginalEnd, symbols, symbolsOriginalRangeStart, symbolsOriginalRangeEnd)
copy_glyphs(sourceFont, symbolsPowerlineRange1Start, symbolsPowerlineRange1End, powerlineSymbols, symbolsPowerlineRange1Start, symbolsPowerlineRange1End)
copy_glyphs(sourceFont, symbolsPowerlineRange2Start, symbolsPowerlineRange2End, powerlineSymbols, symbolsPowerlineRange2Start, symbolsPowerlineRange2End)
copy_glyphs(sourceFont, sourceFontDeviconsStart, sourceFontDeviconsEnd, symbolsDevicons, symbolsDeviconsRangeStart, symbolsDeviconsRangeEnd)
if args.fontawesome:
copy_glyphs(sourceFont, sourceFontFontAwesomeStart, sourceFontFontAwesomeEnd, fontawesome, symbolsFontAwesomeRangeStart, symbolsFontAwesomeRangeEnd)
if args.octicons:
copy_glyphs(sourceFont, sourceFontOcticonsStart, sourceFontOcticonsEnd, octicons, symbolsOcticonsRangeStart, symbolsOcticonsRangeEnd)
if args.pomicons:
copy_glyphs(sourceFont, sourceFontPomiconsStart, sourceFontPomiconsEnd, pomicons, symbolsPomiconsRangeStart, symbolsPomiconsRangeEnd)
extension = os.path.splitext(sourceFont.path)[1]

View file

@ -0,0 +1,325 @@
#!/bin/bash
# version: 0.4.0
# Set source and target directories
source_fonts_dir="${PWD}/unpatched-sample-fonts"
patched_fonts_dir="${PWD}/patched-fonts"
like_pattern=''
if [ $# -eq 1 ]
then
like_pattern=$1
echo "Parameter given, limiting search and patch to pattern '$like_pattern' given"
fi
#find_command="`find \"$source_fonts_dir\" \( -name '*.[o,t]tf' -or -name '*.pcf.gz' \) -type f -print0`"
#find_command="find $source_fonts_dir -name '*.[o,t]tf' -type f -print0"
# Execute patcher on each unpatched font
## -0 to handle space in file name
#eval "$find_command" | xargs -0 -I % echo "%" "$patched_fonts_dir/%"
# Copy generated font to it's patched subdirectory
#IFS=$'\n'
#source_fonts=( $("`find $source_fonts_dir -name '*.[o,t]tf' -type f -print0`") )
#source_fonts=( $(find $source_fonts_dir -name '*.[o,t]tf' -type f -print0) )
#source_fonts=( $($find_command) )
# correct way to output find results into an array (when files have space chars, etc)
# source: http://stackoverflow.com/questions/8213328/bash-script-find-output-to-array
source_fonts=()
while IFS= read -d $'\0' -r file ; do
source_fonts=("${source_fonts[@]}" "$file")
done < <(find $source_fonts_dir -name "$like_pattern*.[o,t]tf" -type f -print0)
#done < <( eval($find_command) )
#echo "${source_fonts[@]}"
# print total number of source fonts found
echo "Total source fonts found: ${#source_fonts[*]}"
#printf "\n"
#printf "---------------- \n"
#exit
#find_new_generated_font="find . -maxdepth 1 -name '*.[o,t]tf' -type f -print0"
# Use for loop iterate through source fonts
# $f stores current value
for f in "${source_fonts[@]}"
do
#echo -n "$f "
#echo -n "./font-patcher $f "
./font-patcher -q "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
#echo "Moved newly created font to: $patched_font_dir"
./font-patcher -q -s "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
./font-patcher -q -w "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
./font-patcher -q -s -w "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
# font awesome variations
./font-patcher --fontawesome -q "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
./font-patcher --fontawesome -q -s "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
./font-patcher --fontawesome -q -w "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
./font-patcher --fontawesome -q -s -w "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
# octicons variations:
./font-patcher --octicons -q "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
./font-patcher --octicons -q -s "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
./font-patcher --octicons -q -w "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
./font-patcher --octicons -q -s -w "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
# pomicon variations:
./font-patcher --pomicons -q "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
./font-patcher --pomicons -q -s "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
./font-patcher --pomicons -q -w "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
./font-patcher --pomicons -q -s -w "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
# fontawesome + octicons variations:
./font-patcher --fontawesome --octicons -q "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
./font-patcher --fontawesome --octicons -q -s "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
./font-patcher --fontawesome --octicons -q -w "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
./font-patcher --fontawesome --octicons -q -s -w "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
# fontawesome + pomicons variations:
./font-patcher --fontawesome --pomicons -q "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
./font-patcher --fontawesome --pomicons -q -s "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
./font-patcher --fontawesome --pomicons -q -w "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
./font-patcher --fontawesome --pomicons -q -s -w "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
# octicons + pomicons variations:
./font-patcher --octicons --pomicons -q "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
./font-patcher --octicons --pomicons -q -s "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
./font-patcher --octicons --pomicons -q -w "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
./font-patcher --octicons --pomicons -q -s -w "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
# fontawesome + octicons + pomicons variations:
./font-patcher --fontawesome --octicons --pomicons -q "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
./font-patcher --fontawesome --octicons --pomicons -q -s "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
./font-patcher --fontawesome --octicons --pomicons -q -w "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
./font-patcher --fontawesome --octicons --pomicons -q -s -w "$f"
printf "\n---------------\n"
newly_created_font=$(find -maxdepth 1 -name '*.[o,t]tf')
echo "newly_created_font = $newly_created_font"
patched_font_dir="${f%/*}/"
patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}"
mv "$newly_created_font" $patched_font_dir
# un-comment to test this script (patch 1 font)
#break
done
echo "All unpatched fonts re-patched to their respective sub-directories in $patched_fonts_dir"

201
readme.md
View file

@ -1,22 +1,65 @@
nerd-filetype-glyphs-fonts-patcher v0.2.0
=========================================
<h1 align="center">
<img src="images/nerd-fonts-logo.png" alt="nerd fonts">
</h1>
[![GitHub version](https://badge.fury.io/gh/ryanoasis%2Fnerd-fonts.svg)](http://badge.fury.io/gh/ryanoasis%2Fnerd-fonts)
***
| **[Fonts](#patched-fonts)** | **[Patcher](#font-patcher)** |
|-----------------------------|------------------------------|
| [![fonts-logo-small](images/nerd-fonts-character-logo-md.png)](#patched-fonts) | [![patcher-logo-small](images/nerd-fonts-patcher-logo-md.png)](#font-patcher) |
***
* A python fontforge command line script to patch any font
* patched-fonts folder contains pre-patched fonts provided for use with [vim-webdevicons](https://github.com/ryanoasis/vim-webdevicons) [(see list below)](#patched-fonts)
* A [fontforge python script](#font-patcher) to patch any font
* Over **20** already [patched font families](#patched-fonts)
* Over **1,700** unique combinations/variations of patched fonts [(more details)](#combinations)
* Over **900** glyphs/icons combined [(more details)](#combinations)
![image](https://github.com/ryanoasis/vim-webdevicons/wiki/screenshots/v0.3.4/fontforge-glyph-set-1.png)
## Table of Contents
- [font nerd icons](#)
- [Glyph sets](#glyph-sets)
- [Usage](#usage)
- [Patched Fonts List](#patched-fonts)
- [Combinations](#combinations)
- [Font Install Script (Linux & Mac OS X)](#font-install-script)
- [Font Patcher](#font-patcher)
- [Gotta Patch 'em All Font Patcher!](#gotta-patch-em-all)
- [Other Good Fonts to Patch](#other-good-fonts-to-patch)
- [Rationale](#rationale)
- [Other](#other)
- [License](#license)
... and more ...
## Glyph Sets
* Particularly created for use with [vim-webdevicons](https://github.com/ryanoasis/vim-webdevicons) vim plugin to add glyphs (icons) as labels for files based on the filetype extension or entire path
### Seti-UI + Custom
* [Seti-UI] / icomoon plus misc custom glyphs
![image](https://github.com/ryanoasis/nerd-filetype-glyphs-fonts-patcher/wiki/screenshots/v0.4.0/fontforge-glyph-set-1.png)
### [devicons][vorillaz-devicons]
* [devicons][vorillaz-devicons] from [vorillaz-devicons]
![image](https://github.com/ryanoasis/nerd-filetype-glyphs-fonts-patcher/wiki/screenshots/v0.4.0/fontforge-glyph-set-2.png)
### [font-awesome][font-awesome]
* [font-awesome][font-awesome] (experimental and work-in-progress)
![image](https://github.com/ryanoasis/nerd-filetype-glyphs-fonts-patcher/wiki/screenshots/v0.4.0/fontforge-glyph-set-font-awesome-1.png)
![image](https://github.com/ryanoasis/nerd-filetype-glyphs-fonts-patcher/wiki/screenshots/v0.4.0/fontforge-glyph-set-font-awesome-2.png)
![image](https://github.com/ryanoasis/nerd-filetype-glyphs-fonts-patcher/wiki/screenshots/v0.4.0/fontforge-glyph-set-font-awesome-3.png)
### [octicons][octicons]
* [octicons][octicons] (experimental and work-in-progress)
![image](https://github.com/ryanoasis/nerd-filetype-glyphs-fonts-patcher/wiki/screenshots/v0.4.0/fontforge-glyph-set-octicons.png)
### Pomicons][gabrielelana-pomicons]
* [Pomicons][gabrielelana-pomicons] from [gabrielelana-pomicons]
![image](https://github.com/ryanoasis/nerd-filetype-glyphs-fonts-patcher/wiki/screenshots/v0.4.0/fontforge-glyph-set-pomicons.png)
### powerline-extra-symbols][ryanoasis-powerline-extra-symbols]
* Work In Progress... :)
![image](https://raw.githubusercontent.com/ryanoasis/powerline-extra-symbols/master/fontforge.png)
## Usage
### Option A
Typical install of any of the [provided patched fonts](#patched-fonts)
or
Install any of the already [provided patched fonts](#patched-fonts)
### Option B
@ -28,39 +71,85 @@ See: [Font Patcher](#font-patcher) for usage
## Patched Fonts
| Currently Included Patched Fonts (double width glyphs) | em size |
|-------------------------------------------------------------|----------|
| Anonymice Powerline Plus Nerd File Types | 2048 |
| Droid Sans Mono for Powerline Plus Nerd File Types | 2048 |
| Literation Mono Powerline Plus Nerd File Types | 2048 |
| ProggyCleanTT Plus Nerd File Types | 2048 |
| Sauce Code Powerline Plus Nerd File Types | 1000 |
| Ubuntu Mono derivative Powerline Plus Nerd File Types | 1000 |
| Ubuntu Mono Plus Nerd File Types | 1000 |
| Font Name | em size | status |
|-------------------------------------------------------------------------------------------|----------|--------------------------|
| [3270 Plus Nerd File Types](patched-fonts/3270) | 1000 | [TEST] |
| [Anonymice Powerline Plus Nerd File Types](patched-fonts/AnonymousPro) | 2048 | [TEST] |
| [Aurulent Sans Mono Plus Nerd File Types](patched-fonts/AurulentSansMono) | 1000 | [TEST] |
| [Bitstream Vera Sans Mono Plus Nerd File Types](patched-fonts/BitstreamVeraSansMono) | 2048 | [TEST] |
| [DejaVu Sans Mono Plus Nerd File Types](patched-fonts/DejaVuSansMono) | 2048 | [TEST] |
| [Droid Sans Mono for Powerline Plus Nerd File Types](patched-fonts/DroidSansMono) | 2048 | [TEST] |
| [Fira Mono for Powerline Plus Nerd File Types](patched-fonts/FiraMono) | 1000 | [TEST] |
| [Heavy Data Mono for Powerline Plus Nerd File Types](patched-fonts/HeavyData) | 2048 | [TEST] |
| [Hermut Plus Nerd File Types](patched-fonts/Hermit) | 1000 | [TEST] |
| [Inconsolata for Powerline Plus Nerd File Types](patched-fonts/Inconsolata) | 1000 | [TEST] |
| [Lekton for Powerline Plus Nerd File Types](patched-fonts/Lekton) | 1000 | [TEST] |
| [Literation Mono for Powerline Plus Nerd File Types](patched-fonts/LiberationMono) | 2048 | [TEST] |
| [Meslo for Powerline Plus Nerd File Types](patched-fonts/Meslo) | 2048 | [TEST] |
| [Monofur for Powerline Plus Nerd File Types](patched-fonts/Monofur) | 2400 | [TEST] |
| [M+ (MPlus) for Powerline Plus Nerd File Types](patched-fonts/MPlus) | 1000 | [TEST] |
| [ProFont (Windows tweaked) for Powerline Plus Nerd File Types](patched-fonts/Profont) | 1200 | [TEST] |
| [ProFont (x11) for Powerline Plus Nerd File Types](patched-fonts/ProFont) | 1000 | [FAIL] |
| [ProggyCleanTT Plus Nerd File Types](patched-fonts/ProggyClean) | 2048 | |
| [Sauce Code Powerline Plus Nerd File Types](patched-fonts/SourceCodePro) | 1000 | [TEST] |
| [Terminess for Powerline Plus Nerd File Types](patched-fonts/Terminus) | 1000 | [FAIL](https://github.com/ryanoasis/nerd-fonts/issues/16) |
| [Ubuntu Mono derivative Powerline Plus Nerd File Types](patched-fonts/UbuntuMono) | 1000 | [TEST] |
| [Ubuntu Mono Plus Nerd File Types](patched-fonts/UbuntuMono) | 1000 | [TEST] |
| Currently Included Absolute Mono Patched Fonts (single width glyphs)| em size |
|---------------------------------------------------------------------|----------|
| Anonymice Powerline Plus Nerd File Types Mono | 2048 |
| Droid Sans Mono for Powerline Plus Nerd File Types Mono | 2048 |
| Literation Mono Powerline Plus Nerd File Types Mono | 2048 |
| ProggyCleanTT Plus Nerd File Types Mono | 2048 |
| Sauce Code Powerline Plus Nerd File Types Mono | 1000 |
| Ubuntu Mono derivative Powerline Plus Nerd File Types Mono | 1000 |
| Ubuntu Mono Plus Nerd File Types Mono | 1000 |
* Variations include:
* extra glyphs that are *double* or *single* (monospaced) width
* [Font Awesome][font-awesome]
* [GitHub Octicons][octicons]
* [Pomicons][gabrielelana-pomicons]
* Full Windows Compatibility (WIP)
## Font Patcher
## Combinations
Patching the font of your own choosing for use with the [vim-webdevicons](https://github.com/ryanoasis/vim-webdevicons) vim plugin:
* Over 1,700 unique variations/combinations (Power Set) of patched fonts:
* 54 font variations (just counting otf and ttf)
* 32 (2⁵) combinations (1 no flags, 5 flagged options)
* Calculated combinations (32 * 54) = 1,728
* Combinations for each font are any combination of (plus no flags option):
* Monospaced extra glyphs
* Windows Compatible
* [Font Awesome][font-awesome]
* [GitHub Octicons][octicons]
* [Pomicons][gabrielelana-pomicons]
## Glyphs Combined
![image](https://github.com/ryanoasis/nerd-filetype-glyphs-fonts-patcher/wiki/screenshots/v0.4.0/sankey-glyphs-combined-diagram.png)
Diagram created using [@SankeyMATIC](http://sankeymatic.com/)
## Font Install Script
* Linux & Mac OS X
> ./install.sh
### Examples
./install.sh
All fonts installed to /home/ryan/.fonts
<h2 align="center" id="font-patcher">
<img src="images/nerd-fonts-patcher-logo.png" alt="Nerd Fonts Patcher">
</h2>
Patching the font of your own choosing for use with the [vim-devicons](https://github.com/ryanoasis/vim-devicons) vim plugin:
* requires: python2, python-fontforge package
* usage:
> ./font-patcher PATH_TO_FONT
```
./font-patcher PATH_TO_FONT
```
```
usage: font-patcher [-h] [-s] [-q] font
usage: font-patcher [-h] [-s] [-q] [-w] [--fontawesome] [--octicons]
[--pomicons]
font
Patches a given font with programming and web development related glyphs
(mainly for vim-webdevicons)
(mainly for https://github.com/ryanoasis/vim-devicons)
positional arguments:
font The path to the font to be patched (e.g.
@ -73,6 +162,14 @@ optional arguments:
double-width (default is double-width)
-q, --quiet, --shutup
Do not generate verbose output
-w, --windows, --limit-font-name-length
Limit the internal font name to a maximum of 31
characters (for safe Windows compatiblity)
--fontawesome Add Font Awesome Glyphs (http://fortawesome.github.io
/Font-Awesome/)
--octicons Add Octicons Glyphs (https://octicons.github.com/)
--pomicons Add Pomicon Glyphs
(https://github.com/gabrielelana/pomicons)
```
### Examples
@ -80,9 +177,47 @@ optional arguments:
./font-patcher unpatched-sample-fonts/Droid\ Sans\ Mono\ for\ Powerline.otf
./font-patcher unpatched-sample-fonts/Droid\ Sans\ Mono\ for\ Powerline.otf -s -q
./font-patcher unpatched-sample-fonts/Droid\ Sans\ Mono\ for\ Powerline.otf --use-single-width-glyphs --quiet
./font-patcher unpatched-sample-fonts/Droid\ Sans\ Mono\ for\ Powerline.otf -w
./font-patcher unpatched-sample-fonts/Droid\ Sans\ Mono\ for\ Powerline.otf --windows --quiet
./font-patcher unpatched-sample-fonts/Droid\ Sans\ Mono\ for\ Powerline.otf --windows --pomicons --quiet
./font-patcher Inconsolata.otf --fontawesome
./font-patcher Inconsolata.otf --fontawesome --octicons --pomicons
./font-patcher Inconsolata.otf
<a name="gotta-patch-em-all"></a>
## Gotta Patch 'em All Font Patcher!
* re-patches **all** fonts in the unpatched directory
* mostly for Contributor/Dev use only
* can optionally limit to specific font pattern (second example)
```
./gotta-patch-em-all-font-patcher\!.sh
./gotta-patch-em-all-font-patcher\!.sh Hermit
```
## Other Good Fonts to Patch
* a list of additional good fonts to patch that I cannot provide or share due to the license:
* [Input Mono](http://input.fontbureau.com/)
* Coming soon with external hosting :)
* [PragmataPro](http://www.fsd.it/fonts/pragmatapro.htm)
## Rationale
* Originally created for use with [vim-devicons] vim plugin to add glyphs (icons) as labels for files based on the filetype extension or entire path
## Other
* project/repo previously known as 'nerd-filetype-glyphs-fonts-patcher', 'font-nerd-icons'
## License
see [LICENSE](LICENSE)
[vim-devicons]:https://github.com/ryanoasis/vim-devicons
[vorillaz-devicons]:http://vorillaz.github.io/devicons/
[font-awesome]:https://github.com/FortAwesome/Font-Awesome
[octicons]:https://github.com/github/octicons
[gabrielelana-pomicons]:https://github.com/gabrielelana/pomicons
[Seti-UI]:https://atom.io/themes/seti-ui
[ryanoasis-powerline-extra-symbols]:https://github.com/ryanoasis/powerline-extra-symbols