这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/scripts/archive-fonts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ while read -r filename; do
(cd "$path" && tar rf "$outputdir/$basename.tar" --no-recursion "$file")
done < <(find "${searchdir}" -type f -exec bash -c 'printf "%s\000" "{}" | sed "s!\(.*\)/!\1|!"' \; | sort -z -u '-t|' -k2,2 | sort -z)

if [ $expected -ne 0 ]; then
if [ "$expected" -ne 0 ]; then
# Should never happen, but who knows
echo "${LINE_PREFIX} Did not pack expected number of font files! Likely same font names for different paths."
exit 1
Expand Down
59 changes: 51 additions & 8 deletions font-patcher
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from __future__ import absolute_import, print_function, unicode_literals

# Change the script version when you edit this script:
script_version = "4.16.3"
script_version = "4.18.0"

version = "3.3.0"
projectName = "Nerd Fonts"
Expand Down Expand Up @@ -358,7 +358,7 @@ class font_patcher:
self.sourceFont.encoding = 'UnicodeFull' # Update the font encoding to ensure that the Unicode glyphs are available
self.onlybitmaps = self.sourceFont.onlybitmaps # Fetch this property before adding outlines. NOTE self.onlybitmaps initialized and never used

if self.args.single:
if self.args.forcemono:
# Force width to be equal on all glyphs to ensure the font is considered monospaced on Windows.
# This needs to be done on all characters, as some information seems to be lost from the original font file.
self.set_sourcefont_glyph_widths()
Expand Down Expand Up @@ -832,12 +832,12 @@ class font_patcher:
logger.warning("Monospaced check: %s and %s",
report_advance_widths(self.sourceFont),
panose_check_to_text(panose_mono, self.sourceFont.os2_panose))
if self.args.single and not width_mono:
if self.args.forcemono and not width_mono:
logger.warning("Sourcefont is not monospaced - forcing to monospace not advisable, "
"results might be useless%s",
" - offending char: {:X}".format(offending_char) if offending_char is not None else "")
if self.args.single <= 1:
logger.critical("Font will not be patched! Give --mono (or -s, or --use-single-width-glyphs) twice to force patching")
if self.args.forcemono <= 1:
logger.critical("Font will not be patched! Give --mono (or -s) twice to force patching")
sys.exit(1)
if width_mono:
force_panose_monospaced(self.sourceFont)
Expand Down Expand Up @@ -1266,6 +1266,14 @@ class font_patcher:
logger.debug("Metrics is strange")
pass # Will fail the metrics check some line later

if self.args.cellopt:
logger.debug("Overriding cell Y{%d:%d} with Y{%d:%d}",
self.font_dim['ymin'], self.font_dim['ymax'],
self.args.cellopt[2], self.args.cellopt[3])
self.font_dim['ymin'] = self.args.cellopt[2]
self.font_dim['ymax'] = self.args.cellopt[3]
our_btb = self.args.cellopt[3] - self.args.cellopt[2]

# Calculate font height
self.font_dim['height'] = -self.font_dim['ymin'] + self.font_dim['ymax']
if self.font_dim['height'] == 0:
Expand All @@ -1288,7 +1296,7 @@ class font_patcher:
sys.exit(1)

self.font_dim['iconheight'] = self.font_dim['height']
if self.args.single and self.sourceFont.capHeight > 0:
if self.args.single and self.sourceFont.capHeight > 0 and not isinstance(self.args.cellopt, list):
# Limit the icon height on monospaced fonts because very slender and tall icons render
# excessivly tall otherwise. We ignore that effect for the other variants because it
# does not look so much out of place there.
Expand Down Expand Up @@ -1348,9 +1356,21 @@ class font_patcher:
if self.font_dim['width'] <= 0:
logger.critical("Can not detect sane font width")
sys.exit(1)
if isinstance(self.args.cellopt, list):
logger.debug("Overriding cell X{%d:%d} with X{%d:%d}",
self.font_dim['xmin'], self.font_dim['xmin'] + self.font_dim['width'],
self.args.cellopt[0], self.args.cellopt[1])
self.font_dim['xmin'] = self.args.cellopt[0]
self.font_dim['xmax'] = self.args.cellopt[1]
self.font_dim['width'] = self.args.cellopt[1]
logger.debug("Final font cell dimensions %d w x %d h%s",
self.font_dim['width'], self.font_dim['height'],
' (with icon cell {} h)'.format(int(self.font_dim['iconheight'])) if self.font_dim['iconheight'] != self.font_dim['height'] else '')
if self.args.cellopt:
logger.info("Cell coordinates %s%d:%d:%d:%d",
'' if not isinstance(self.args.cellopt, list) else 'overridden with ',
self.font_dim['xmin'], self.font_dim['width'],
self.font_dim['ymax'] - self.font_dim['height'], self.font_dim['ymax'])

self.xavgwidth.append(self.args.xavgwidth)
if isinstance(self.xavgwidth[-1], int) and self.xavgwidth[-1] == 0:
Expand Down Expand Up @@ -1974,7 +1994,9 @@ def setup_arguments():
# optional arguments
parser.add_argument('font', help='The path to the font to patch (e.g., Inconsolata.otf)')
parser.add_argument('-v', '--version', action='version', version=projectName + ": %(prog)s (" + version + ")")
parser.add_argument('-s', '--mono', '--use-single-width-glyphs', dest='single', default=False, action='count', help='Whether to generate the glyphs as single-width not double-width (default is double-width) (Nerd Font Mono)')
parser.add_argument('-s', '--mono', dest='forcemono', default=False, action='count', help='Create monospaced font, existing and added glyphs are single-width (implies --single-width-glyphs)')
parser.add_argument('--use-single-width-glyphs', dest='forcemono', default=False, action='count', help=argparse.SUPPRESS)
parser.add_argument('--single-width-glyphs', dest='single', default=False, action='store_true', help='Whether to generate the glyphs as single-width not double-width (default is double-width) (Nerd Font Mono)')
parser.add_argument('--variable-width-glyphs', dest='nonmono', default=False, action='store_true', help='Do not adjust advance width (no "overhang") (Nerd Font Propo)')
parser.add_argument('--debug', dest='debugmode', default=0, type=int, nargs='?', help='Verbose mode (optional: 1=just to file; 2*=just to terminal; 3=display and file)', const=2, choices=range(0, 3 + 1))
parser.add_argument('-q', '--quiet', dest='quiet', default=False, action='store_true', help='Do not generate verbose output')
Expand Down Expand Up @@ -2028,6 +2050,7 @@ def setup_arguments():
# <none> - copy from sourcefont (default)
# 0 - calculate from font according to OS/2-version-2
# 500 - set to 500
expert_group.add_argument('--cell', dest='cellopt', default=None, type=str, help='Adjust or quiery the call size, e.g. use "0:1000:-200:800" resp "?"')

# progress bar arguments - https://stackoverflow.com/questions/15008758/parsing-boolean-values-with-argparse
progressbars_group_parser.add_argument('--progressbars', dest='progressbars', action='store_true', help='Show percentage completion progress bars per Glyph Set (default)')
Expand Down Expand Up @@ -2088,10 +2111,29 @@ def setup_arguments():
font_complete = False
args.complete = font_complete

if args.forcemono:
args.single = True
if args.nonmono and args.single:
logger.warning("Specified contradicting --variable-width-glyphs and --use-single-width-glyph. Ignoring --variable-width-glyphs.")
logger.warning("Specified contradicting --variable-width-glyphs together with --mono or --single-width-glyphs. Ignoring --variable-width-glyphs.")
args.nonmono = False

if args.cellopt:
if args.cellopt != '?':
try:
parts = [ int(v) for v in args.cellopt.split(':') ]
if len(parts) != 4:
raise
except:
logger.critical("Parameter for --cell is not 4 colon seprated integer numbers: '%s'", args.cellopt)
sys.exit(2)
if parts[0] >= parts[1] or parts[2] >= parts[3]:
logger.critical("Parameter for --cell do not result in positive cell size: %d x %d",
parts[1] - parts[0], parts[3] - parts[2])
sys.exit(2)
if parts[0] != 0:
logger.warn("First parameter for --cell should be zero, this is probably not working")
args.cellopt = parts

make_sure_path_exists(args.outputdir)
if not os.path.isfile(args.font):
logger.critical("Font file does not exist: %s", args.font)
Expand Down Expand Up @@ -2126,6 +2168,7 @@ def setup_arguments():
logger.critical("Can not create single font files from True Type Collections")
sys.exit(1)

# The if might look ridiculous, but isinstance(False, int) is True!
if isinstance(args.xavgwidth, int) and not isinstance(args.xavgwidth, bool):
if args.xavgwidth < 0:
logger.critical("--xavgcharwidth takes no negative numbers")
Expand Down
8 changes: 4 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Install Nerd Fonts
__ScriptVersion="0.7"
__ScriptVersion="0.8"

# Default values for option variables:
quiet=false
Expand All @@ -15,7 +15,7 @@ installpath="user"
usage() {
cat << EOF
Usage: ./install.sh [-q -v -h] [[--copy | --link] --clean | --list | --remove]
[--use-single-width-glyphs] [--windows] [--otf | --ttf]
[--mono] [--windows] [--otf | --ttf]
[--install-to-user-path | --install-to-system-path ]
[FONT...]

Expand All @@ -36,7 +36,7 @@ General options:
with this script).
Can be combined with -L for a dry run.

-s, --use-single-width-glyphs Install single-width glyphs variants.
-s, --mono Install single-width glyphs variants.
-p, --use-proportional-glyphs Install proportional glyphs variants.

-U, --install-to-user-path Install fonts to users home font path [default].
Expand Down Expand Up @@ -87,7 +87,7 @@ while getopts "$optspec" optchar; do
[ "$mode" != "remove" ] && mode="list";;
remove) mode="remove";;
clean) clean=true;;
use-single-width-glyphs) variant="M";;
mono) variant="M";;
use-proportional-glyphs) variant="P";;
otf) extension="otf";;
ttf) extension="ttf";;
Expand Down
5 changes: 2 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,7 @@ positional arguments:
options:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-s, --mono, --use-single-width-glyphs
Whether to generate the glyphs as single-width not double-width (default is double-width) (Nerd Font Mono)
-s, --mono Whether to generate the glyphs as single-width not double-width (default is double-width) (Nerd Font Mono)
--variable-width-glyphs
Do not adjust advance width (no "overhang") (Nerd Font Propo)
--debug [{0,1,2,3}] Verbose mode (optional: 1=just to file; 2*=just to terminal; 3=display and file)
Expand Down Expand Up @@ -538,7 +537,7 @@ Expert Options:
```
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf -s -q
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --use-single-width-glyphs --quiet
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --mono --quiet

./font-patcher Inconsolata.otf --fontawesome
./font-patcher Inconsolata.otf --fontawesome --octicons --pomicons
Expand Down
5 changes: 2 additions & 3 deletions readme_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,7 @@ positional arguments:
options:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-s, --mono, --use-single-width-glyphs
Whether to generate the glyphs as single-width not double-width (default is double-width)
-s, --mono Whether to generate the glyphs as single-width not double-width (default is double-width)
-l, --adjust-line-height
Whether to adjust line heights (attempt to center powerline separators more evenly)
-q, --quiet, --shutup
Expand Down Expand Up @@ -404,7 +403,7 @@ Symbol Fonts:

./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf -s -q
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --use-single-width-glyphs --quiet
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --mono --quiet
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf -w
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --windows --quiet
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --windows --pomicons --quiet
Expand Down
5 changes: 2 additions & 3 deletions readme_es.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,7 @@ argumentos posicionales:
argumentos opcionales:
-h, --help muestra este mensaje de ayuda y sale
-v, --version muestra la versión del programa y sale
-s, --mono, --use-single-width-glyphs
Indica si genera los glifos como ancho simple, no doble (por defecto es ancho doble)
-s, --mono Indica si genera los glifos como ancho simple, no doble (por defecto es ancho doble)
-l, --adjust-line-height
Indica si se ajustan las alturas de línea (para intentar centrar los separadores de powerline más parejo)
-q, --quiet, --shutup
Expand Down Expand Up @@ -434,7 +433,7 @@ Symbol Fonts:
```
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf -s -q
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --use-single-width-glyphs --quiet
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --mono --quiet

./font-patcher Inconsolata.otf --fontawesome
./font-patcher Inconsolata.otf --fontawesome --octicons --pomicons
Expand Down
5 changes: 2 additions & 3 deletions readme_fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,7 @@ positional arguments:
options:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-s, --mono, --use-single-width-glyphs
Whether to generate the glyphs as single-width not double-width (default is double-width)
-s, --mono Whether to generate the glyphs as single-width not double-width (default is double-width)
-l, --adjust-line-height
Whether to adjust line heights (attempt to center powerline separators more evenly)
-q, --quiet, --shutup
Expand Down Expand Up @@ -465,7 +464,7 @@ Symbol Fonts:

./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf -s -q
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --use-single-width-glyphs --quiet
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --mono --quiet
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf -w
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --windows --quiet
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --windows --pomicons --quiet
Expand Down
5 changes: 2 additions & 3 deletions readme_hi.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,7 @@ positional arguments:
options:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-s, --mono, --use-single-width-glyphs
Whether to generate the glyphs as single-width not double-width (default is double-width)
-s, --mono Whether to generate the glyphs as single-width not double-width (default is double-width)
-l, --adjust-line-height
Whether to adjust line heights (attempt to center powerline separators more evenly)
-q, --quiet, --shutup
Expand Down Expand Up @@ -442,7 +441,7 @@ Symbol Fonts:

./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf -s -q
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --use-single-width-glyphs --quiet
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --mono --quiet
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf -w
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --windows --quiet
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --windows --pomicons --quiet
Expand Down
5 changes: 2 additions & 3 deletions readme_it.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,7 @@ positional arguments:
options:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-s, --mono, --use-single-width-glyphs
Whether to generate the glyphs as single-width not double-width (default is double-width)
-s, --mono Whether to generate the glyphs as single-width not double-width (default is double-width)
-l, --adjust-line-height
Whether to adjust line heights (attempt to center powerline separators more evenly)
-q, --quiet, --shutup
Expand Down Expand Up @@ -386,7 +385,7 @@ Symbol Fonts:

./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf -s -q
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --use-single-width-glyphs --quiet
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --mono --quiet
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf -w
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --windows --quiet
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --windows --pomicons --quiet
Expand Down
5 changes: 2 additions & 3 deletions readme_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,7 @@ positional arguments:
options:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-s, --mono, --use-single-width-glyphs
Whether to generate the glyphs as single-width not double-width (default is double-width)
-s, --mono Whether to generate the glyphs as single-width not double-width (default is double-width)
-l, --adjust-line-height
Whether to adjust line heights (attempt to center powerline separators more evenly)
-q, --quiet, --shutup
Expand Down Expand Up @@ -381,7 +380,7 @@ Symbol Fonts:

./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf -s -q
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --use-single-width-glyphs --quiet
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --mono --quiet
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf -w
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --windows --quiet
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --windows --pomicons --quiet
Expand Down
5 changes: 2 additions & 3 deletions readme_ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,7 @@ positional arguments:
options:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-s, --mono, --use-single-width-glyphs
Whether to generate the glyphs as single-width not double-width (default is double-width)
-s, --mono Whether to generate the glyphs as single-width not double-width (default is double-width)
-l, --adjust-line-height
Whether to adjust line heights (attempt to center powerline separators more evenly)
-q, --quiet, --shutup
Expand Down Expand Up @@ -382,7 +381,7 @@ Symbol Fonts:

./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf -s -q
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --use-single-width-glyphs --quiet
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --mono --quiet
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf -w
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --windows --quiet
./font-patcher Droid\ Sans\ Mono\ for\ Powerline.otf --windows --pomicons --quiet
Expand Down
Loading
Loading