From: Alexander Ebert Date: Tue, 29 Oct 2013 13:39:57 +0000 (+0100) Subject: Serving fonts through getFont.php X-Git-Tag: 2.0.0_Beta_11~14^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2b2cc9f5efef8639ffb1db2ce8b5d102688e599b;p=GitHub%2FWoltLab%2FWCF.git Serving fonts through getFont.php --- diff --git a/wcfsetup/install/files/font/getFont.php b/wcfsetup/install/files/font/getFont.php new file mode 100644 index 0000000000..9961622c33 --- /dev/null +++ b/wcfsetup/install/files/font/getFont.php @@ -0,0 +1,48 @@ + + */ + +// allow font fetching from all domains (CORS) +header('Access-Control-Allow-Origin: *'); + +// ignore request if client seems to already have fetched this file +if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) || !empty($_SERVER['HTTP_IF_NONE_MATCH'])) { + header("HTTP/1.1 304 Not Modified"); + exit; +} + +// list of known font types +$types = array( + 'eot' => 'application/vnd.ms-fontobject', + 'woff' => 'application/x-woff', // best supported, but this is not the right one according to http://www.w3.org/TR/WOFF/#appendix-b + 'ttf' => 'application/octet-stream' +); + +if (!empty($_GET['type'])) { + if (isset($types[$_GET['type']])) { + $filename = 'fontawesome-webfont.' . $_GET['type']; + $data = file_get_contents($filename); + + // send cache and type headers + header('Content-Type: ' . $types[$_GET['type']]); + header('Cache-control: max-age=31536000, private'); + header('Expires: ' . gmdate("D, d M Y H:i:s", time() + 31536000) . ' GMT'); + header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($filename)) . ' GMT'); + header('Content-Length: ' . strlen($data)); + + die($data); + } + + die("Invalid type '" . $_GET['type'] . "' given"); +} + +die("Missing type parameter"); diff --git a/wcfsetup/install/files/style/icon.less b/wcfsetup/install/files/style/icon.less index 74587d182f..2f7d58e27d 100644 --- a/wcfsetup/install/files/style/icon.less +++ b/wcfsetup/install/files/style/icon.less @@ -1,9 +1,10 @@ +/* do NOT reference fonts directly, always make use of 'getFont.php' */ @font-face { font-family: 'FontAwesome'; - src: url('../font/fontawesome-webfont.eot?v=3.2.1'); - src: url('../font/fontawesome-webfont.eot?#iefix&v=3.2.1') format('embedded-opentype'), - url('../font/fontawesome-webfont.woff?v=3.2.1') format('woff'), - url('../font/fontawesome-webfont.ttf?v=3.2.1') format('truetype'); + src: url('../font/getFont.php?type=eot&v=3.2.1'); + src: url('../font/getFont.php?type=eot&v=3.2.1#iefix') format('embedded-opentype'), + url('../font/getFont.php?type=woff&v=3.2.1') format('woff'), + url('../font/getFont.php?type=ttf&v=3.2.1') format('truetype'); font-weight: normal; font-style: normal; }