# File: paratype-pt-public-fonts-all.spec

# Do the magic:
Source1000:                 vdb.lua
%include                    %{S:1000}

%global src                 file://PT_Public_Pack_OtTt.zip
    %{rem:
        Original name of the font archive is `PT Public Pack_OtTt.zip`. File name with spaces cause
        troubles on some platforms, so I renamed the downloaded archive to this name.

        Unfortunately, there is no direct link to download the font archive. Page
        <https://www.paratype.com/collections/pt/44157> uses scripts to show license, and then
        generates temporary link with short lifetime.

        Other sources (*.conf files) will be added by Lua script below.
    }
%global ver                 %{lua:
    --[[--
        There is no way to figure out the font version. Neither TTF file nor Paratype website
        contains version information. Let's use the downloading date (== the font archive
        modification date) as the version.
    --]]--
    spec( os.date( '%Y%m%d', posix.stat( expand( '%{S:0}' ), 'mtime' ) ) )
}
%global rel                 0.vdb.7
    %{rem:
        Usually I use release starting with zero for packages not released by Fedora. This is an
        exception: Fedora released PT Sans font family as pt-sans-fonts package, but they didn't
        release other fonts from PT Public pack.
    }

Version:                    %{ver}
Release:                    %{rel}%{?dist}
URL:                        https://www.paratype.com/collections/pt/44157

%global foundry             paratype
%global fontlicense         OFL
    %{rem:
        The font archive, downloaded from %{URL}, contains only font files, there is no license
        there. However, the SIL Open Font License version 1.1 is shown at the Paratype website when
        user press `Download` button to download this font archive.

        BTW, some fonts (PT Sans, PT Serif, PT Mono may be downloaded from another page of the
        Paratype website, <https://company.paratype.com/pt-sans-pt-serif>. In that case the font
        archive contains another license: PTFL, Paratype Font License (wich is also considered good
        by Fedora).
    }

Source0:                    file://PT_Public_Pack_OtTt.zip

Name:                       %{foundry}-pt-public-fonts-all
Summary:                    PT Public Pack, a collection of free fonts by Paratype foundry
License:                    %{fontlicense}
BuildArch:                  noarch

BuildRequires:              fonts-rpm-macros

%global fontorg             com.paratype
%global fontcontact         van.de.bugger@gmail.com
    %{rem: Inspite the macro name, it's packager contact, not font author contact. }

%{lua:

    local n = 0 -- Font number, will be bumped for each font, so font numbers will start from 1.
    local ver_rel = get( 'version' ) .. '-' .. get( 'release' )
    local foundry = get( 'foundry' )
    local requires = 'Requires'
    if rpm.vercmp( rpm_version(), '4.16.0' ) >= 0 then
        -- "Requires(meta)" tag was introduced in rpm 4.16.0.
        requires = requires .. '(meta)'
    end
    confs = {} -- .conf files.

    -- Declare a subpackage.
    local function font( family, summary, description )
        n = n + 1
        local c  = 100 + n  -- Source number of the corresponding .conf file.
        local id = ident( family )
        spec(
            sprintf( "%s: %s-%s-fonts = %s", requires, foundry, id, ver_rel ),
            sprintf( "Source%s: paratype-%s.conf", c, id )
        )
        set( 'fontfamily'      .. n, family                            )
        set( 'fontsummary'     .. n, summary                           )
        set( 'fonts'           .. n, sprintf( "'%s'_*/*.ttf", family ) )
        set( 'fontconfs'       .. n, sprintf( "65-%s.conf", id )       )
        set( 'fontdescription' .. n, reflow( description )             )
        confs[ c ] = id
    end

    font(
        'PT Astra Sans',
        'A variable-width sans-serif font family',
        '(No description provided by Paratype foundry.)'
    )
    font(
        'PT Astra Serif',
        'A variable-width serif font family',
        '(No description provided by Paratype foundry.)'
    )
    font(
        'PT Mono',
        'Monospaced font family of the PT Project series',
        [[
            PT Mono is a monospaced font of the PT Project series, the other families of the series
            are PT Sans and PT Serif.

            PT Mono was developed for the special needs — for use in forms, tables, work sheets
            etc. Equal widths of characters are very helpful in setting complex documents, with
            such font you may easily calculate size of entry fields, column widths in tables and so
            on. One of the most important area of use is Web sites of “electronic governments“
            where visitors have to fill different request forms.

            Designer Alexandra Korolkova with a participation of Isabella Chaeva. Released by
            ParaType in 2011.
        ]]
    )
    font(
        'PT Root UI',
        'A modern uniwidth font family for screen reading, interfaces, websites',
        [[
            PT Root UI is a special part of the PT Root typeface family, intended for screen
            reading, interfaces, websites, as well as wayfinding systems. PT Root UI is a modern
            uniwidth sans serif whose individual character widths are constant across all weights.
            This is especially convenient for headers, menu bars and interface elements.

            It consists of four styles of normal proportions, from Light to Bold.

            It has a broad language support, including the Latin Extended and Cyrillic (including
            Cyrillic Asian), different sets of figures and currency signs, fractions and indices,
            as well as a number of wayfinding signs and alternative forms.

            PT Root UI was designed by Vitaly Kuzmin and released by Paratype in 2018.
        ]]
    )
    font(
        'PT Sans',
        'Sans-serif font family of the PT Project series',
        [[
            It consists of 8 styles: regular and bold weights with corresponding italics form a
            standard computer font family; two narrow styles (regular and bold) are intended for
            documents that require tight set; two caption styles (regular and bold) are for texts
            of small point sizes.

            The design combines traditional conservative appearance with modern trends of
            humanistic sans serif and characterized by enhanced legibility. These features beside
            conventional use in business applications and printed stuff made the fonts quite
            useable for direction and guide signs, schemes, screens of information kiosks and other
            objects of urban visual communications.

            The fonts next to standard Latin and Cyrillic character sets contain signs of title
            languages of the national republics of Russian Federation and support the most of the
            languages of neighboring countries.

            The fonts were developed and released by ParaType in 2009 with financial support from
            Federal Agency of Print and Mass Communications of Russian Federation. Design by
            Alexandra Korolkova with assistance of Olga Umpeleva and supervision of Vladimir
            Yefimov.
        ]]
    )
    font(
        'PT Serif',
        'Serif font family of the PT Project series',
        [[
            PT Serif is a universal type family designed for use together with PT Sans released
            earlier. PT Serif coordinates with PT Sans on metrics, proportions, weights and design.

            It consists of six styles: regular and bold weights with corresponding italics form a
            standard computer font family; two caption styles (regular and italic) are for texts of
            small point sizes.

            The letterforms are distinguished by large x-height, modest stroke contrast, robust
            wedge-like serifs, and triangular terminals. Due to these features the face can be
            qualified as matched to modern trends of type design and of enhanced legibility.
            Mentioned characteristics beside conventional use in business applications and printed
            stuff make the fonts quite useable for advertising and display typography.

            Each font next to standard Latin and Cyrillic character sets contains alphabet glyphs
            of title languages of the national republics of Russian Federation and support the most
            of the languages of neighboring countries.

            The fonts were developed and released by ParaType in 2010 with financial support from
            Federal Agency of Print and Mass Communications of Russian Federation. Designed by
            Alexandra Korolkova with assistance of Olga Umpeleva and supervision of Vladimir
            Yefimov.
        ]]
    )
}

%description
%{text -- \
    The collection includes 6 font families: PT Serif, PT Sans, PT Mono, PT Root UI, PT Astra
    Serif, PT Astra Sans.

    All fonts included into the collection are released under SIL Open Font License version 1.1
    (aka OFL). The collection are available at Paratype website and can be downloaded as "PT
    Public Pack_OtTt.zip" archive. (There are some more fonts released by Paratype under OFL,
    but they are not part of the "PT Public Pack" for unknown reason.)
}

%fontpkg -a

%fontmetapkg

%prep
%setup -q -n Fonts
%{lua:
    for c, id in pairs( confs ) do
        spec( sprintf( "%%{__cp} %%{S:%d} 65-%s.conf", c, id ), '' )
    end
}

%build
%fontbuild -a

%install
%fontinstall -a

%check
%fontcheck -a

%files
%fontfiles -a

%changelog
* Sat May  6 2023 Van de Bugger - 20201114-0.vdb.7
- Minor spec update.

* Mon May 01 2023 Van de Bugger - 20201114-0.vdb.6
- F38 rebuild.

* Fri Nov 25 2022 Van de Bugger - 20201114-0.vdb.5
- F37 rebuild.

* Thu May 12 2022 Van de Bugger - 20201114-0.vdb.4
- F36 rebuild.

* Thu May  6 2021 Van de Bugger - 20201114-0.vdb.3
- F34 rebuild.

* Sun Nov 15 2020 Van de Bugger - 20201114-0.vdb.2
- Specific *-fonts packages couldn't satisfy paratype-pt-public-fonts-all requirements. Fixed.
- conf files renamed to have common prefix.

* Sun Nov 15 2020 Van de Bugger - 20201114-0.vdb.1
- First release.