From b268c65591ae0c00ef0e8897f0885d3622c5f1b5 Mon Sep 17 00:00:00 2001 From: ryanoasis Date: Sat, 14 Nov 2015 16:49:18 -0500 Subject: [PATCH] Updates font naming convention to be more manageable and font variations to use the same Font Family (partially fixes: #25, #32, #42) --- font-patcher | 39 ++++++++++++++++------------- gotta-patch-em-all-font-patcher!.sh | 22 +++++++++++++++- 2 files changed, 43 insertions(+), 18 deletions(-) diff --git a/font-patcher b/font-patcher index 3ad931ecd..2fdd997aa 100755 --- a/font-patcher +++ b/font-patcher @@ -46,18 +46,14 @@ if actualVersion < minimumVersion: sys.exit(1) -verboseAdditionalFontNameSuffix = " Plus Nerd File Types" +verboseAdditionalFontNameSuffix = " Nerd Font" if args.windows: # attempt to shorten here on the additional name BEFORE trimming later - additionalFontNameSuffix = " PNFT" + additionalFontNameSuffix = " NF" else: additionalFontNameSuffix = verboseAdditionalFontNameSuffix -if args.single: - additionalFontNameSuffix += " Mono" - verboseAdditionalFontNameSuffix += " Mono" - if args.fontawesome: additionalFontNameSuffix += " Plus Font Awesome" verboseAdditionalFontNameSuffix += " Plus Font Awesome" @@ -70,11 +66,21 @@ if args.pomicons: additionalFontNameSuffix += " Plus Pomicons" verboseAdditionalFontNameSuffix += " Plus Pomicons" +# if all source glyphs included simplify the name +if args.fontawesome and args.octicons and args.pomicons: + additionalFontNameSuffix = " Nerd Font Complete" + verboseAdditionalFontNameSuffix = " Nerd Font Complete" + +# add mono signifier to end of name +if args.single: + additionalFontNameSuffix += " Mono" + verboseAdditionalFontNameSuffix += " Mono" + sourceFont = fontforge.open(args.font) fontname, style = re.match("^([^-]*)(?:(-.*))?$", sourceFont.fontname).groups() -familyname = sourceFont.familyname + additionalFontNameSuffix +familyname = sourceFont.familyname # fullname (filename) can always use long/verbose font name, even in windows fullname = sourceFont.fullname + verboseAdditionalFontNameSuffix fontname = fontname + additionalFontNameSuffix.replace(" ", "") @@ -169,7 +175,7 @@ symbolsPowerlineExtraRange2End = 0xE0C8 symbolsPowerlineExtraRange3Start = 0xE0CC symbolsPowerlineExtraRange3End = 0xE0D4 -symbolsOriginalRangeStart = 0xE4FE +symbolsOriginalRangeStart = 0xE4FA symbolsOriginalRangeEnd = 0xE52A symbolsDeviconsRangeStart = 0xE600 @@ -185,13 +191,7 @@ symbolsOcticonsRangeEnd = 0xF0DB sourceFontPomiconsStart = 0xE000 sourceFontPomiconsEnd = 0xE00A -#symbolsPowerlineRange1Start = 0xE0A0 -#symbolsPowerlineRange1End = 0xE0A2 - -#symbolsPowerlineRange2Start = 0xE0B0 -#symbolsPowerlineRange2End = 0xE0B3 - -sourceFontOriginalStart = 0xE5FE +sourceFontOriginalStart = 0xE5FA sourceFontOriginalEnd = 0xE62A sourceFontDeviconsStart = 0xE700 @@ -285,16 +285,21 @@ def copy_glyphs(sourceFont, sourceFontStart, sourceFontEnd, symbolFont, symbolFo for sym_glyph in symbolFont.selection.byGlyphs: #sym_attr = SYM_ATTR[sym_glyph.unicode] glyphName = sym_glyph.glyphname - if args.quiet == False: - print "updating glyph: " + str(sym_glyph) + " " + str(sym_glyph.glyphname) if exactEncoding: # use the exact same hex values for the source font as for the symbol font currentSourceFontGlyph = sym_glyph.encoding + copiedToSlot = sym_glyph.glyphname else: # use source font defined hex values based on passed in start and end # convince that this string really is a hex: currentSourceFontGlyph = int("0x" + sourceFontList[sourceFontCounter], 16) + copiedToSlot = sourceFontList[sourceFontCounter] + + if args.quiet == False: + print "updating glyph: " + str(sym_glyph) + " " + str(sym_glyph.glyphname) + " putting at: " + str(copiedToSlot) + + # Prepare symbol glyph dimensions sym_dim = get_dim(sym_glyph) diff --git a/gotta-patch-em-all-font-patcher!.sh b/gotta-patch-em-all-font-patcher!.sh index 0c618f64e..9b60483ef 100755 --- a/gotta-patch-em-all-font-patcher!.sh +++ b/gotta-patch-em-all-font-patcher!.sh @@ -13,6 +13,7 @@ type fontforge >/dev/null 2>&1 || { source_fonts_dir="${PWD}/unpatched-sample-fonts" patched_fonts_dir="${PWD}/patched-fonts" like_pattern='' +organizing_sub_dir="" if [ $# -eq 1 ] then @@ -38,7 +39,11 @@ function patch_font { local newly_created_font=$(find . -maxdepth 1 -name '*.[o,t]tf') echo "Newly created font: $newly_created_font" local patched_font_dir="${f%/*}/" + echo "patched font dir is $patched_font_dir" local patched_font_dir="${patched_font_dir/unpatched-sample-fonts/patched-fonts}" + echo "patched font dir is $patched_font_dir" + local patched_font_dir+=$organizing_sub_dir + echo "patched font dir is $patched_font_dir" [[ -d "$patched_font_dir" ]] || mkdir -p "$patched_font_dir" mkdir -p $patched_font_dir mv "$newly_created_font" "$patched_font_dir" @@ -59,36 +64,51 @@ function patch_font_batch { for f in "${source_fonts[@]}" do echo "$f" - if [[ "$f" =~ Hack ]] + if [[ "$f" =~ Hack ]] || [[ "$f" =~ SourceCodePro ]] then powerline="" else powerline="--powerline" fi + organizing_sub_dir="minimal/" + patch_font_batch "$f" $powerline + organizing_sub_dir="additional-variations/" + # font awesome variations patch_font_batch "$f" $powerline --fontawesome + patch_font_batch "$f" $powerline --fontawesome --powerlineextra # octicons variations: patch_font_batch "$f" $powerline --octicons + patch_font_batch "$f" $powerline --octicons --powerlineextra # pomicon variations: patch_font_batch "$f" $powerline --pomicons + patch_font_batch "$f" $powerline --pomicons --powerlineextra # fontawesome + octicons variations: patch_font_batch "$f" $powerline --fontawesome --octicons + patch_font_batch "$f" $powerline --fontawesome --octicons --powerlineextra # fontawesome + pomicons variations: patch_font_batch "$f" $powerline --fontawesome --pomicons + patch_font_batch "$f" $powerline --fontawesome --pomicons --powerlineextra # octicons + pomicons variations: patch_font_batch "$f" $powerline --octicons --pomicons + patch_font_batch "$f" $powerline --octicons --pomicons --powerlineextra # fontawesome + octicons + pomicons variations: patch_font_batch "$f" $powerline --fontawesome --octicons --pomicons + organizing_sub_dir="complete/" + + # fontawesome + octicons + pomicons + powerlineextra variations: + patch_font_batch "$f" $powerline --fontawesome --octicons --pomicons --powerlineextra + # un-comment to test this script (patch 1 font) #break done