summaryrefslogtreecommitdiffstats
path: root/lib/private/Avatar.php
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-05-19 08:47:29 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-06-13 18:46:05 +0200
commit4432cfd445d2dea2792c0cc2550445506ba8a18a (patch)
treeab539f0097125a031d8d3e271fc63fe3298935e2 /lib/private/Avatar.php
parenteb3f43a0b5a96db92d63b0572104f3b4707ed664 (diff)
downloadnextcloud-server-4432cfd445d2dea2792c0cc2550445506ba8a18a.tar.gz
nextcloud-server-4432cfd445d2dea2792c0cc2550445506ba8a18a.zip
Embedded font
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'lib/private/Avatar.php')
-rw-r--r--lib/private/Avatar.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/private/Avatar.php b/lib/private/Avatar.php
index 0ea2b82f5ea..0164d73a2e3 100644
--- a/lib/private/Avatar.php
+++ b/lib/private/Avatar.php
@@ -68,6 +68,14 @@ class Avatar implements IAvatar {
*/
private $svgTemplate = '
<svg width="{size}" height="{size}" version="1.1" viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg">
+ <defs>
+ <style type="text/css">
+ @font-face {
+ font-family: Open Sans;
+ src: url({font});
+ }
+ </style>
+ </defs>
<rect width="100%" height="100%" fill="#{fill}"></rect>
<text x="50%" y="350" style="font-weight:600;font-size:278px;font-family:\'Open Sans\';text-anchor:middle;fill:#fff">{letter}</text>
</svg>';
@@ -287,9 +295,10 @@ class Avatar implements IAvatar {
$bgRGB = $this->avatarBackgroundColor($userDisplayName);
$bgHEX = sprintf("%02x%02x%02x", $bgRGB->r, $bgRGB->g, $bgRGB->b);
$letter = mb_strtoupper(mb_substr($userDisplayName, 0, 1), 'UTF-8');
+ $font = \OC::$WEBROOT.'/core/fonts/OpenSans-Semibold.ttf';
- $toReplace = ['{size}', '{fill}', '{letter}'];
- return str_replace($toReplace, [$size, $bgHEX, $letter], $this->svgTemplate);
+ $toReplace = ['{size}', '{fill}', '{letter}', '{font}'];
+ return str_replace($toReplace, [$size, $bgHEX, $letter, $font], $this->svgTemplate);
}
/**