# File: larsenwork-monoid-fonts.spec #

Source1000:                 vdb.lua
%include                    %{S:1000}

%Global Foundry             LarsenWork
%Global Family              Monoid
%global ver                 0.61
%global rel                 0.vdb.16

Version:                    %{ver}
Release:                    %{rel}%{?dist}
URL:                        https://%{foundry}.com/%{family}/

Source0:                    https://github.com/%{foundry}/%{family}/archive/%{ver}.tar.gz#/%{family}-%{ver}.tar.gz
Source1:                    %{foundry}-%{family}-fonts.conf
Source2:                    %{name}-build.vdb.py

Patch1:                     %{foundry}-%{family}-fonts-xrange.vdb.patch
    # There is no xrange function in Python 3.5.
    # range function exists in both 3.5 and 2.7.

BuildRequires:              fontforge
BuildRequires:              fonts-rpm-macros
BuildRequires:              python >= 2.7
    # Scripts/build.py explicitly uses python2.7.
    # Scripts/fontbuilder.py uses dict comprehension which introduced in python 2.7.

Requires:                   filesystem
    # % {_datadir}/appdata
    # % {_datadir}/doc
Requires:                   fontpackages-filesystem
    # % {_datadir}/fonts

%global fontfamily          %{Family}
%global fontlicense         OFL or MIT
%global fontsummary         Open Source Coding Font
%global fontdescription     %{text -- \
    %{rem: Description build from pieces taken from <https://larsenwork.com/monoid/>.}

    Monoid is optimized for coding with bitmap-like sharpness at 12px/9pt even on low res displays.
    Semi-condensed and distinguishable glyphs with short ascenders + descenders, big apertures and
    supersized operators + punctuation. More than 750 Latin, Greek, Cyrillic, ligature, alternate
    and Powerline glyphs.

    This package is built with "Alt $" option and no ligatures.
}
%global fontdocs            Readme.md
%global fonts               _build/%{Family}-{Regular,Bold,Italic}.ttf
%global fontconfs           65-%{family}.conf

%fontpkg

%prep
%setup -q -n %{family}-%{version}
%patch1
%{__cp} %{S:1} ./65-%{family}.conf
# Look into fontforge rpm package, find version of Python the fontforge.so is built for.
pv=$( \
    %{__rpm} -ql fontforge \
    | %{__grep} -E -e '^/usr/lib.*/python.*/site-packages/fontforge\.so$' \
    | %{__sed} -e 's|^/usr/lib.*/python\(.*\)/site-packages/fontforge\.so$|\1|' \
    | head -n 1 \
)
[ -n "$pv" ] || false
# Use this python version for running build script.
%{__sed} -e 's|^\(#!/usr/bin/python\)$|\1'"$pv"'|' "%{S:2}" > build.py
%{__chmod} a+x build.py

%build
PYTHONPATH="%{_builddir}/%{family}-%{ver}/Scripts:$PYTHONPATH" \
    ./build.py ./Source/%{Family}{,-Bold,-Italic}.sfdir
%fontbuild

%check
%fontcheck

%install
%fontinstall

%fontfiles

%changelog
* Wed Nov 23 2022 Van de Bugger - 0.61-0.vdb.16
- F37 rebuild.

* Thu May 12 2022 Van de Bugger - 0.61-0.vdb.15
- Rebuild for F36.

* Sun Nov  7 2021 Van de Bugger - 0.61-0.vdb.14
- Rebuild for F35.
- vdb.lua updated.

* Thu May  6 2021 Van de Bugger - 0.61-0.vdb.13
- Rebuild for F34.

* Mon Nov 16 2020 Van de Bugger - 0.61-0.vdb.12
- Build script reworked to build only one font variant.
- Fontconfig file added.
- metainfo.xml is generated by Fedora font macros.
- m4 is dropped from build requirements.
- Ligatures turned off.

* Tue Nov 03 2020 Van de Bugger - 0.61-0.vdb.11
- Fedora's fontpkg macro used.
- Package renamed to larsenwork-monoid-fonts to follow Fedora's guidelines.
- F33.

* Wed Nov 06 2019 Van de Bugger - 0.61-0.vdb.10
- App Id set to com.larsenwork.monoid.
- Metainfo file renamed to use App Id instead of plain font name.
- Author checks added.

* Sat Nov 02 2019 Van de Bugger - 0.61-0.vdb.9
- appstream is disabled on OpenSuse and Mageia.

* Sun Mar 24 2019 Van de Bugger - 0.61-0.8.vdb
- vdb.lua updated, _install_D macro used.

* Sat Mar 23 2019 Van de Bugger - 0.61-0.7.vdb
- Rebuilt for F30.
- vdb.lua updated.
- NOTE: Release changed in non-backward-compatible way. Sorry.

* Wed Jan 16 2019 Van de Bugger - 0.61-6.vdb
- vdb.lua updated.

* Wed Nov 01 2017 Van de Bugger - 0.61-5.vdb
- vdb.lua used.

* Fri Dec 02 2016 Van de Bugger — 0.61-4.vdb
- Build script patched to work with Python 3.5.
- Python interpreter is selected automatically depending on fontforge package.

* Thu Jun 30 2016 Van de Bugger - 0.61-3.vdb
- RHEL support dropped.
- Minor changes ported from other my specs.

* Wed Jun 29 2016 Van de Bugger - 0.61-2.vdb
- Minor changes in spec file.

* Fri Feb 5 2016 Van de Bugger - 0.61-1
- First release.