summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 8a11492b3401659cf9196b86e715eca593d06833 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# Maintainer: tinywrkb <tinywrkb@gmail.com>
# Contributor: Antonio Rojas <arojas@archlinux.org>

pkgbase=noto-fonts-vf
pkgname=(noto-fonts{,-slim}-vf)
pkgver=20210725
pkgrel=1
pkgdesc='Google Noto variable fonts'
url='https://www.google.com/get/noto/'
license=(custom:SIL)
arch=(any)
_commit=5444496f4489ba6a4da2d7d7e9faa09ddb735e3b
source=("${pkgbase}-${pkgver}.tar.gz::https://github.com/googlefonts/noto-fonts/archive/${_commit}.tar.gz"
        {46,66}-noto-{mono,serif,sans}.conf)
sha256sums=('e27d5d8e8e706481c666953c541ed718ab0a6f53ac71239fa4d0dc53b7234299'
            'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP')

prepare(){
  cd noto-fonts-*/

  # generate missing font lists
  echo
  echo 'Generating font missing and duplicate (italic) font lists'
  comm -23 \
    <(ls unhinted/variable-ttf | sed 's/-VF.ttf//' | sort) \
    <(ls unhinted/ttf | sort) \
    | grep Italic | sed 's/-Italic//' \
    > var_italic

  comm -13 \
    <(ls unhinted/variable-ttf | sed 's/-VF.ttf//' | sort) \
    <(ls unhinted/ttf | sort) \
    > stat_only

  comm -13 \
    <(ls unhinted/slim-variable-ttf | sed 's/-VF.ttf//' | sort) \
    <(ls unhinted/variable-ttf | sed 's/-VF.ttf//' | sort) \
    | grep -v Italic \
    > missing_var_slim

  echo
  echo 'Removing unneeded italic static fonts...'
  # remove unneeded italic type faces
  while read -r fontname; do
    [ -f unhinted/variable-ttf/${fontname}-VF.ttf ] &&
      continue
    rm -v unhinted/ttf/${fontname}/${fontname}-*Italic*.ttf
  done < var_italic
}


_package(){
  optdepends=('noto-fonts-cjk-vf: CJK characters'
              'noto-fonts-emoji: Emoji characters')
  conflicts=(noto-fonts{,-extra,} ttf-croscore)
  provides=(noto-fonts{,-extra,} ttf-croscore ttf-font)

  cd noto-fonts-*/

  case $pkgname in
    *-slim-vf)
      _vfsrc=unhinted/slim-variable-ttf
      ;;
    *)
      _vfsrc=unhinted/variable-ttf
      ;;
  esac

  pushd $_vfsrc
  for f in *.ttf; do
    install -Dm644 $f \
      "$pkgdir"/usr/share/fonts/noto/${f//-VF.ttf}.ttf
  done
  popd

  ## install missings fonts
  echo
  echo 'Installing static variants of the missing variable fonts..'
  while read -r fontname; do
    if [ -f "${pkgdir}"/usr/share/fonts/noto/${fontname}.ttf ]; then
      echo "  $fontname is already installed as a variable font."
      continue
    fi
    echo "  Installing $fontname static fonts"
    case $pkgname in
      *-slim-vf)
        for face in Regular Medium SemiBold Bold; do
          [ -f unhinted/ttf/${fontname}/${fontname}-${face}.ttf ] &&
            install -v -t "${pkgdir}"/usr/share/fonts/noto/ \
              unhinted/ttf/${fontname}/${fontname}-${face}.ttf
        done
        ;;
      *)
        install -v -t "${pkgdir}"/usr/share/fonts/noto/ \
          unhinted/ttf/${fontname}/${fontname}-*.ttf
        ;;
    esac
  done < stat_only

  ## install missings font in the slim variable fonts package
  if [[ $pkgname == *-slim-vf ]]; then
    echo
    echo 'Installing static variants of the missing slim variable fonts..'
    while read -r fontname; do
      for face in Regular Medium SemiBold Bold; do
        [ -f unhinted/ttf/${fontname}/${fontname}-${face}.ttf ] &&
          install -v -t "${pkgdir}"/usr/share/fonts/noto/ \
            unhinted/ttf/${fontname}/${fontname}-${face}.ttf
      done
    done < missing_var_slim
  fi

  # install configs
  echo
  echo 'Installing configs...'
  install -Dm644 -t "$pkgdir"/usr/share/fontconfig/conf.avail/ \
    ../{46,66}-noto-{mono,serif,sans}.conf
  install -dm755 "$pkgdir"/usr/share/fontconfig/conf.default
  ln -s  -t "$pkgdir"/usr/share/fontconfig/conf.default/ \
    ../conf.avail/{46,66}-noto-{mono,serif,sans}.conf

  install -Dm644 LICENSE -t "$pkgdir"/usr/share/licenses/${pkgname}/
}

package_noto-fonts-vf(){
  _package
}

package_noto-fonts-slim-vf(){
  pkgdesc+=' (limited type faces)'
  _package
}