mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2025-01-25 03:32:02 +02:00
gotta-patch-em-all: Create all fonts with unified release timestamp
[why] All the fonts will have different timestamps, and within each font the creation and modification date might also differ. That is quite confusing and makes automated testing very complicated. [how] Use one date-time for ALL fonts and for creation and modification date in the font file. But do not change the date-time if we already set that somewhere before :-} Also remove the 'special' properitary fontforge timestamp tables FFTM from the patched fonts. This is only possible since FontForge 20th Anniversary Edition. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
parent
a577d7261a
commit
40ded7c2f0
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# Nerd Fonts Version: 2.3.0-RC
|
||||
# Script Version: 1.1.1
|
||||
# Script Version: 1.2.0
|
||||
|
||||
# used for debugging
|
||||
# set -x
|
||||
@ -60,7 +60,6 @@ while getopts ":h-:" option; do
|
||||
info_only=$2
|
||||
echo "${LINE_PREFIX} 'Info Only' option given, only generating font info (not patching)"
|
||||
;;
|
||||
;;
|
||||
*)
|
||||
echo >&2 "Option '${OPTARG}' unknown"
|
||||
exit 1;;
|
||||
@ -100,6 +99,17 @@ done < <(find "$source_fonts_dir" -iregex ${like_pattern} -type f -print0)
|
||||
# print total number of source fonts found
|
||||
echo "$LINE_PREFIX Total source fonts found: ${#source_fonts[*]}"
|
||||
|
||||
# Use one date-time for ALL fonts and for creation and modification date in the font file
|
||||
if [ -z "${SOURCE_DATE_EPOCH}" ]
|
||||
then
|
||||
export SOURCE_DATE_EPOCH=$(date +%s)
|
||||
fi
|
||||
release_timestamp=$(date -R --date=@${SOURCE_DATE_EPOCH} 2>/dev/null) || {
|
||||
echo >&2 "$LINE_PREFIX Invalid release timestamp SOURCE_DATE_EPOCH: ${SOURCE_DATE_EPOCH}"
|
||||
exit 2
|
||||
}
|
||||
echo "$LINE_PREFIX Release timestamp is ${release_timestamp}"
|
||||
|
||||
function patch_font {
|
||||
local f=$1; shift
|
||||
local i=$1; shift
|
||||
|
11
font-patcher
11
font-patcher
@ -315,6 +315,11 @@ class font_patcher:
|
||||
|
||||
def generate(self, sourceFonts):
|
||||
sourceFont = sourceFonts[0]
|
||||
# the `PfEd-comments` flag is required for Fontforge to save '.comment' and '.fontlog'.
|
||||
if int(fontforge.version()) >= 20201107:
|
||||
gen_flags = (str('opentype'), str('PfEd-comments'), str('no-FFTM-table'))
|
||||
else:
|
||||
gen_flags = (str('opentype'), str('PfEd-comments'))
|
||||
if len(sourceFonts) > 1:
|
||||
layer = None
|
||||
# use first non-background layer
|
||||
@ -325,8 +330,7 @@ class font_patcher:
|
||||
outfile = os.path.normpath(os.path.join(
|
||||
sanitize_filename(self.args.outputdir, True),
|
||||
sanitize_filename(sourceFont.familyname) + ".ttc"))
|
||||
# the `PfEd-comments` flag is required for Fontforge to save '.comment' and '.fontlog'.
|
||||
sourceFonts[0].generateTtc(outfile, sourceFonts[1:], flags=(str('opentype'), str('PfEd-comments')), layer=layer)
|
||||
sourceFonts[0].generateTtc(outfile, sourceFonts[1:], flags=gen_flags, layer=layer)
|
||||
message = "\nGenerated: {} fonts in '{}'".format(len(sourceFonts), outfile)
|
||||
else:
|
||||
fontname = sourceFont.fullname
|
||||
@ -335,12 +339,11 @@ class font_patcher:
|
||||
outfile = os.path.normpath(os.path.join(
|
||||
sanitize_filename(self.args.outputdir, True),
|
||||
sanitize_filename(fontname) + self.args.extension))
|
||||
# the `PfEd-comments` flag is required for Fontforge to save '.comment' and '.fontlog'.
|
||||
bitmaps = str()
|
||||
if len(self.sourceFont.bitmapSizes):
|
||||
print("Preserving bitmaps {}".format(self.sourceFont.bitmapSizes))
|
||||
bitmaps = str('otf') # otf/ttf, both is bf_ttf
|
||||
sourceFont.generate(outfile, bitmap_type=bitmaps, flags=(str('opentype'), str('PfEd-comments')))
|
||||
sourceFont.generate(outfile, bitmap_type=bitmaps, flags=gen_flags)
|
||||
message = "\nGenerated: {} in '{}'".format(self.sourceFont.fullname, outfile)
|
||||
|
||||
# Adjust flags that can not be changed via fontforge
|
||||
|
Loading…
x
Reference in New Issue
Block a user