generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from sowrensen/feat/custom-font
Custom font support
- Loading branch information
Showing
10 changed files
with
173 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@php | ||
/** | ||
* @var Sowren\SvgAvatarGenerator\SvgAvatarGenerator $generator | ||
*/ | ||
@endphp | ||
|
||
@if(($url = $generator->getCustomFontUrl()) && ($family = $generator->getFontFamily())) | ||
<style> | ||
/*<![CDATA[*/ | ||
@import url({{ $url }}); | ||
/*]]>*/ | ||
</style> | ||
<style> | ||
svg { | ||
font-family: {{ $family }}, "sans-serif"; | ||
} | ||
</style> | ||
@else | ||
<style> | ||
svg { | ||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; | ||
} | ||
</style> | ||
@endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Sowren\SvgAvatarGenerator\Exceptions; | ||
|
||
class InvalidUrlException extends \Exception | ||
{ | ||
public static function create(string $url): InvalidUrlException | ||
{ | ||
return new self("`{$url}` is not a valid URL."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
use Sowren\SvgAvatarGenerator\SvgAvatarGenerator; | ||
|
||
it('will have a custom font family defined', function () { | ||
$generator = new SvgAvatarGenerator('Saul Goodman'); | ||
|
||
$svg = (string) $generator | ||
->setCustomFontUrl('https://api.fontshare.com/v2/css?f[]=kola@400&display=swap') | ||
->setFontFamily('Kola') | ||
->render(); | ||
|
||
expect($svg) | ||
->toContain('Kola') | ||
->toContain('@import url(https://api.fontshare.com'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters