From 15e9bd3d55aea4edf5d711986c59f2aac61922c6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= <fpeters@entrouvert.com>
Date: Wed, 26 Feb 2020 08:41:45 +0100
Subject: [PATCH] fonts: integrate Abril Fatface like other fonts (#40197)

---
 README                                        |   9 +++++++++
 debian/50fonts.py                             |   2 --
 debian/control                                |   2 +-
 debian/publik-base-theme.install              |   1 -
 debian/publik-base-theme.postinst             |  19 ++++++++++++++++++
 static/amiens-metropole/_vars.scss            |   2 +-
 static/amiens-metropole/style.scss            |   2 +-
 .../AbrilFatface/abrilfatface-regular.woff    | Bin 0 -> 33460 bytes
 .../includes/_font-abrilfatface-regular.scss  |   6 ------
 static/includes/_font-abrilfatface.scss       |   6 ++++++
 .../variants/amiens-metropole/theme.html      |   2 +-
 11 files changed, 38 insertions(+), 13 deletions(-)
 delete mode 100644 debian/50fonts.py
 delete mode 100644 debian/publik-base-theme.install
 create mode 100644 debian/publik-base-theme.postinst
 create mode 100644 static/fonts/AbrilFatface/abrilfatface-regular.woff
 delete mode 100644 static/includes/_font-abrilfatface-regular.scss
 create mode 100644 static/includes/_font-abrilfatface.scss

diff --git a/README b/README
index 8005e268..50f482b2 100644
--- a/README
+++ b/README
@@ -256,6 +256,15 @@ copyright notices:
   #
   # https://www.fontsquirrel.com/license/noto-sans
 
+* Abril Fatface
+  # Copyright (c) 2011, Copyright (c) 2011, TypeTogether
+  # (www.type-together.com info@type-together.com),
+  # with Reserved Font Names “Abril” and “Abril Fatface”
+  #
+  # This Font Software is licensed under the SIL Open Font License, Version 1.1.
+  #
+  # https://www.fontsquirrel.com/license/abril-fatface
+
 ~~~~
 
 Some theme variant files have their own specific licenses; refer to
diff --git a/debian/50fonts.py b/debian/50fonts.py
deleted file mode 100644
index d511c44b..00000000
--- a/debian/50fonts.py
+++ /dev/null
@@ -1,2 +0,0 @@
-# add xstatics with fonts
-INSTALLED_APPS += ('xstatic.pkg.abril_fatface',)
diff --git a/debian/control b/debian/control
index b7dbb01b..fa619516 100644
--- a/debian/control
+++ b/debian/control
@@ -8,7 +8,7 @@ Homepage: http://git.entrouvert.org/publik-base-theme.git
 
 Package: publik-base-theme
 Architecture: all
-Depends: ${shlibs:Depends}, ${misc:Depends}, python-gadjo, python-xstatic-abrilfatface, python3-xstatic-abrilfatface
+Depends: ${shlibs:Depends}, ${misc:Depends}, python-gadjo
 Conflicts: python-authentic2 (< 2.1.20.742.gb6ee096-0),
            python-django (<= 1:1.11),
            python-xstatic-roboto-fontface (< 0.5.0.0),
diff --git a/debian/publik-base-theme.install b/debian/publik-base-theme.install
deleted file mode 100644
index 63785ed1..00000000
--- a/debian/publik-base-theme.install
+++ /dev/null
@@ -1 +0,0 @@
-debian/50fonts.py        /etc/combo/settings.d
\ No newline at end of file
diff --git a/debian/publik-base-theme.postinst b/debian/publik-base-theme.postinst
new file mode 100644
index 00000000..7d115b28
--- /dev/null
+++ b/debian/publik-base-theme.postinst
@@ -0,0 +1,19 @@
+#! /bin/sh
+
+set -e
+
+case "$1" in
+  configure)
+    # remove old conffile if it was not edited.
+    if [ -e /etc/combo/settings.d/50fonts.py ]; then
+      HASH=$(md5sum < /etc/combo/settings.d/50fonts.py | cut -d ' ' -f1)
+      if [ x"$HASH" = x"3bb0e0249725a52c181a1e0ff9138de2" ]; then
+        echo rm /etc/combo/settings.d/50fonts.py
+      fi
+    fi
+    ;;
+esac
+
+#DEBHELPER#
+
+exit 0
diff --git a/static/amiens-metropole/_vars.scss b/static/amiens-metropole/_vars.scss
index a9cee327..b2f362ed 100644
--- a/static/amiens-metropole/_vars.scss
+++ b/static/amiens-metropole/_vars.scss
@@ -16,7 +16,7 @@ $nav-item-selected-color: white;
 $nav-item-hover-color: white;
 $nav-after-image: false;
 $button-background: darken($primary-color, 10%);
-$title-font-family: 'AbrilFatface-Regular', Arial, Helvetica, sans-serif;
+$title-font-family: 'Abril Fatface', Arial, Helvetica, sans-serif;
 $title-background: $primary-color;
 $title-weight: regular;
 $title-color: #CF0D8A;
diff --git a/static/amiens-metropole/style.scss b/static/amiens-metropole/style.scss
index c079e1d5..8e763d9f 100644
--- a/static/amiens-metropole/style.scss
+++ b/static/amiens-metropole/style.scss
@@ -1,6 +1,6 @@
 @charset "UTF-8";
 
-@import '../includes/font-abrilfatface-regular';
+@import '../includes/font-abrilfatface';
 @import 'vars';
 @import '../includes/publik';
 @import '../includes/categories';
diff --git a/static/fonts/AbrilFatface/abrilfatface-regular.woff b/static/fonts/AbrilFatface/abrilfatface-regular.woff
new file mode 100644
index 0000000000000000000000000000000000000000..a698d4e265f240b9a31d1fc4c4272a03eb381785
GIT binary patch
diff --git a/static/includes/_font-abrilfatface-regular.scss b/static/includes/_font-abrilfatface-regular.scss
deleted file mode 100644
index b77a63b7..00000000
--- a/static/includes/_font-abrilfatface-regular.scss
+++ /dev/null
@@ -1,6 +0,0 @@
-$font-path: '/static/xstatic/fonts' !default;
-
-@font-face {
-	font-family: 'AbrilFatface-Regular';
-	src: url('#{$font-path}/Regular/abrilfatface-regular.woff') format('woff');
-}
diff --git a/static/includes/_font-abrilfatface.scss b/static/includes/_font-abrilfatface.scss
new file mode 100644
index 00000000..15bde35e
--- /dev/null
+++ b/static/includes/_font-abrilfatface.scss
@@ -0,0 +1,6 @@
+@font-face {
+	font-family: 'Abril Fatface';
+	src: url(/static/fonts/AbrilFatface/abrilfatface-regular.woff) format('woff');
+	font-weight: normal;
+	font-style: normal;
+}
diff --git a/templates/variants/amiens-metropole/theme.html b/templates/variants/amiens-metropole/theme.html
index 9611ad9b..f565d167 100644
--- a/templates/variants/amiens-metropole/theme.html
+++ b/templates/variants/amiens-metropole/theme.html
@@ -2,7 +2,7 @@
 {% load static i18n combo gadjo %}
 
 {% block extra_top_head %}
-<link rel="preload" href="{{site_base}}/static/xstatic/fonts/Regular/abrilfatface-regular.woff" as="font" type="font/woff2" crossorigin>
+<link rel="preload" href="{{site_base}}/static/fonts/AbrilFatface/abrilfatface-regular.woff" as="font" type="font/woff" crossorigin>
 {% endblock %}
 
 {% block header-title %}
-- 
2.25.1

