Use correct typeface for avatar generator

Signed-off-by: Jan-Christoph Borchardt <hey@jancborchardt.net>
This commit is contained in:
Jan-Christoph Borchardt 2018-10-23 13:13:35 +02:00
parent 3259d427ee
commit 354b72b9d3
No known key found for this signature in database
GPG Key ID: CBD846FC845CBE17
2 changed files with 17 additions and 17 deletions

View File

@ -62,7 +62,7 @@ class Avatar implements IAvatar {
/**
* https://github.com/sebdesign/cap-height -- for 500px height
* Open Sans cap-height is 0.72 and we want a 200px caps height size (0.4 letter-to-total-height ratio, 500*0.4=200). 200/0.72 = 278px.
* Nunito cap-height is 0.72 and we want a 200px caps height size (0.4 letter-to-total-height ratio, 500*0.4=200). 200/0.72 = 278px.
* Since we start from the baseline (text-anchor) we need to shift the y axis by 100px (half the caps height): 500/2+100=350
*
* @var string
@ -70,7 +70,7 @@ class Avatar implements IAvatar {
private $svgTemplate = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="{size}" height="{size}" version="1.1" viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg">
<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>
<text x="50%" y="350" style="font-weight:normal;font-size:278px;font-family:\'Nunito\';text-anchor:middle;fill:#fff">{letter}</text>
</svg>';
/**
@ -317,7 +317,7 @@ class Avatar implements IAvatar {
return false;
}
try {
$font = __DIR__ . '/../../core/fonts/OpenSans-Semibold.ttf';
$font = __DIR__ . '/../../core/fonts/Nunito-Regular.ttf';
$svg = $this->getAvatarVector($size);
$avatar = new Imagick();
$avatar->setFont($font);
@ -347,7 +347,7 @@ class Avatar implements IAvatar {
$white = imagecolorallocate($im, 255, 255, 255);
imagefilledrectangle($im, 0, 0, $size, $size, $background);
$font = __DIR__ . '/../../core/fonts/OpenSans-Semibold.ttf';
$font = __DIR__ . '/../../core/fonts/Nunito-Regular.ttf';
$fontSize = $size * 0.4;

View File

@ -235,7 +235,7 @@ class AvatarTest extends \Test\TestCase {
$svg = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="64" height="64" version="1.1" viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg">
<rect width="100%" height="100%" fill="#0082c9"></rect>
<text x="50%" y="350" style="font-weight:600;font-size:278px;font-family:\'Open Sans\';text-anchor:middle;fill:#fff">A</text>
<text x="50%" y="350" style="font-weight:normal;font-size:278px;font-family:\'Nunito\';text-anchor:middle;fill:#fff">A</text>
</svg>';
$this->assertEquals($avatar, $svg);
}