#!/usr/bin/make -f

# For version variables
include /usr/share/dpkg/default.mk

%:
	dh $@

override_dh_auto_build:
	# We build the font from source, but we distribute the upstream build in the binary package
	# due to RFN and our inability to rebuilt it bit-for-bit identical
	mkdir -p build
	fontforge -lang=ff -c 'Open("src/Play-Regular-TTF.sfd"); Generate("build/Play-Regular.ttf")'
	fontforge -lang=ff -c 'Open("src/Play-Bold-TTF.sfd"); Generate("build/Play-Bold.ttf")'

	fontforge -lang=ff -c 'Open("Play-Regular.ttf"); Generate("Play-Regular.otf")'
	fontforge -lang=ff -c 'Open("Play-Bold.ttf"); Generate("Play-Bold.otf")'

get-orig-source:
	git clone --depth 1 --filter=blob:none --sparse \
	    https://github.com/googlefonts/googlefontdirectory-hg.git \
	    googlefontdirectory-hg
	git -C googlefontdirectory-hg sparse-checkout set ofl/play
	mkdir $(DEB_SOURCE)-$(DEB_VERSION_UPSTREAM).orig
	cp -a googlefontdirectory-hg/ofl/play/src \
	    $(DEB_SOURCE)-$(DEB_VERSION_UPSTREAM).orig/
	for f in DESCRIPTION.en_us.html METADATA.json OFL.txt Play-Bold.ttf Play-Regular.ttf ; do \
	    cp googlefontdirectory-hg/ofl/play/$$f $(DEB_SOURCE)-$(DEB_VERSION_UPSTREAM).orig/ ; \
	done
	XZ="-6" tar --create --xz --owner root --group root --mode a+rX \
		-f $(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM).orig.tar.xz \
		$(DEB_SOURCE)-$(DEB_VERSION_UPSTREAM).orig
	rm -rf googlefontdirectory-hg $(DEB_SOURCE)-$(DEB_VERSION_UPSTREAM).orig
