[FIX] website: allow non 400 normal google font

When adding a google font, the website test if it is valid with an URL
like:

https://fonts.googleapis.com/css?family=Open+Sans+Condensed

but this is only testing the normal with weight 400 version which might
not be available (for "open sans condensed" only 300 and 700 weight is
available).

Instead with this fix we try:

https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,300i,400,400i,700,700i

which is what is being queried when the font is really used and will
only fail if all types are missing (in which case it is a good thing
that it fails).

opw-2678485

closes odoo/odoo#80564

X-original-commit: 126ccaecb876c17dd6b7e34aef4aa4927d13b8f7
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
This commit is contained in:
Nicolas Lempereur
2021-11-30 12:52:26 +00:00
parent 2d3b99e13d
commit d0ba6c26e6
@@ -199,7 +199,7 @@ const FontFamilyPickerUserValueWidget = SelectUserValueWidget.extend({
let isValidFamily = false;
try {
const result = await fetch("https://fonts.googleapis.com/css?family=" + m[1], {method: 'HEAD'});
const result = await fetch("https://fonts.googleapis.com/css?family=" + m[1]+':300,300i,400,400i,700,700i', {method: 'HEAD'});
// Google fonts server returns a 400 status code if family is not valid.
if (result.ok) {
isValidFamily = true;