├── src ├── Exceptions │ └── UnknownFontSetException.php ├── Font.php ├── Components │ └── BunnyFonts.php ├── Facades │ └── BunnyFonts.php ├── BunnyFontsServiceProvider.php ├── FontSet.php ├── BunnyFontsManager.php └── FontFamily.php ├── CHANGELOG.md ├── LICENSE.md ├── README.md └── composer.json /src/Exceptions/UnknownFontSetException.php: -------------------------------------------------------------------------------- 1 | font->value)->lower()->replace(' ', '-')->append(':')->append(implode(',', $this->weights)); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Components/BunnyFonts.php: -------------------------------------------------------------------------------- 1 | set = Facades\BunnyFonts::getSet($set); 16 | } 17 | 18 | public function render() 19 | { 20 | return $this->set->toHtml(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Facades/BunnyFonts.php: -------------------------------------------------------------------------------- 1 | name('bunny-fonts'); 14 | } 15 | 16 | public function packageBooted() 17 | { 18 | Blade::component('bunny-fonts', Components\BunnyFonts::class); 19 | Blade::directive('bunnyFonts', function (string $expression) { 20 | return "toHtml(); ?>"; 21 | }); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `laravel-bunny-fonts` will be documented in this file. 4 | 5 | ## v2.1.0 - 2025-12-11 6 | 7 | ### What's Changed 8 | 9 | * Update font enum by @ryangjchandler in https://github.com/ryangjchandler/laravel-bunny-fonts/pull/13 10 | 11 | **Full Changelog**: https://github.com/ryangjchandler/laravel-bunny-fonts/compare/v2.0.0...v2.1.0 12 | 13 | ## v2.0.0 - 2025-09-16 14 | 15 | ### What's Changed 16 | 17 | * Add Laravel 12 support by @ryangjchandler in https://github.com/ryangjchandler/laravel-bunny-fonts/pull/9 18 | 19 | ### New Contributors 20 | 21 | * @ryangjchandler made their first contribution in https://github.com/ryangjchandler/laravel-bunny-fonts/pull/9 22 | 23 | **Full Changelog**: https://github.com/ryangjchandler/laravel-bunny-fonts/compare/v1.0.0...v2.0.0 24 | 25 | ## v1.0.0 - 2024-05-02 26 | 27 | * Initial release. 28 | -------------------------------------------------------------------------------- /src/FontSet.php: -------------------------------------------------------------------------------- 1 | 11 | */ 12 | protected array $fonts = []; 13 | 14 | public function add(FontFamily $font, array $weights = [400]): static 15 | { 16 | $this->fonts[] = new Font($font, $weights); 17 | 18 | return $this; 19 | } 20 | 21 | public function getFonts(): array 22 | { 23 | return $this->fonts; 24 | } 25 | 26 | public function toHtml() 27 | { 28 | $base = ''; 29 | $families = []; 30 | 31 | foreach ($this->fonts as $font) { 32 | $families[] = $font->toBunnyString(); 33 | } 34 | 35 | return $base."\n".''; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/BunnyFontsManager.php: -------------------------------------------------------------------------------- 1 | sets['default'] = new FontSet; 12 | } 13 | 14 | public function default(): FontSet 15 | { 16 | return $this->sets['default']; 17 | } 18 | 19 | public function add(FontFamily $font, array $weights = [400]): FontSet 20 | { 21 | return $this->default()->add($font, $weights); 22 | } 23 | 24 | public function set(string $name): FontSet 25 | { 26 | return $this->sets[$name] ??= new FontSet; 27 | } 28 | 29 | /** 30 | * @throws Exceptions\UnknownFontSetException 31 | */ 32 | public function getSet(string $name = 'default'): FontSet 33 | { 34 | if (! isset($this->sets[$name])) { 35 | throw Exceptions\UnknownFontSetException::make($name); 36 | } 37 | 38 | return $this->sets[$name]; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Ryan Chandler 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Manage Bunny Fonts programatically in your Laravel projects. 2 | 3 | [![Latest Version on Packagist](https://img.shields.io/packagist/v/ryangjchandler/laravel-bunny-fonts.svg?style=flat-square)](https://packagist.org/packages/ryangjchandler/laravel-bunny-fonts) 4 | [![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/ryangjchandler/laravel-bunny-fonts/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/ryangjchandler/laravel-bunny-fonts/actions?query=workflow%3Arun-tests+branch%3Amain) 5 | [![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/ryangjchandler/laravel-bunny-fonts/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/ryangjchandler/laravel-bunny-fonts/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain) 6 | [![Total Downloads](https://img.shields.io/packagist/dt/ryangjchandler/laravel-bunny-fonts.svg?style=flat-square)](https://packagist.org/packages/ryangjchandler/laravel-bunny-fonts) 7 | 8 | This package provides a small set of utilities for managing Bunny Fonts programatically. 9 | 10 | ## Installation 11 | 12 | You can install the package via Composer: 13 | 14 | ```bash 15 | composer require ryangjchandler/laravel-bunny-fonts 16 | ``` 17 | 18 | ## Usage 19 | 20 | Inside of your `AppServiceProvider::boot()` method, use the `BunnyFonts` class to register font families and variants. 21 | 22 | ```php 23 | use RyanChandler\BunnyFonts\Facades\BunnyFonts; 24 | use RyanChandler\BunnyFonts\FontFamily; 25 | 26 | public function boot() 27 | { 28 | BunnyFonts::add(FontFamily::AbhayaLibre, weights: [400, 500, 600]) 29 | ->add(FontFamily::FiraCode, weights: [ 30 | 400 31 | ]); 32 | } 33 | ``` 34 | 35 | > This package provides a `FontFamily` enum that contains all fonts available on Bunny! 36 | > 37 | > If you want to preview a font, click through to the enum and use the handy link in the comment above the case. 38 | 39 | Inside of your Blade templates, use the `` component or `@bunnyFonts()` directive to render the necessary HTML tags and load your fonts. 40 | 41 | ### Sets 42 | 43 | Out of the box this package provides a `default` set of fonts. Calling `add()` directly on the `BunnyFonts` class will register fonts under the `default` set. 44 | 45 | If your site uses different fonts in different places, it's still possible to register them using this package by creating a custom "set". 46 | 47 | ```php 48 | public function boot() 49 | { 50 | BunnyFonts::set('shop') 51 | ->add(FontFamily::Inter, [400, 500, 700]); 52 | } 53 | ``` 54 | 55 | Then when you use the Blade component or directive, you can provide the set you wish to render. 56 | 57 | ```blade 58 | 59 | 60 | @bunnyFonts('shop') 61 | ``` 62 | 63 | ## Testing 64 | 65 | ```bash 66 | composer test 67 | ``` 68 | 69 | ## Changelog 70 | 71 | Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. 72 | 73 | ## Contributing 74 | 75 | Please see [CONTRIBUTING](CONTRIBUTING.md) for details. 76 | 77 | ## Security Vulnerabilities 78 | 79 | Please review [our security policy](../../security/policy) on how to report security vulnerabilities. 80 | 81 | ## Credits 82 | 83 | - [Ryan Chandler](https://github.com/ryangjchandler) 84 | - [All Contributors](../../contributors) 85 | 86 | ## License 87 | 88 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 89 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ryangjchandler/laravel-bunny-fonts", 3 | "description": "Manage Bunny Fonts programatically in your Laravel projects.", 4 | "keywords": [ 5 | "Ryan Chandler", 6 | "laravel", 7 | "laravel-bunny-fonts" 8 | ], 9 | "homepage": "https://github.com/ryangjchandler/laravel-bunny-fonts", 10 | "license": "MIT", 11 | "authors": [ 12 | { 13 | "name": "Ryan Chandler", 14 | "email": "support@ryangjchandler.co.uk", 15 | "role": "Developer" 16 | } 17 | ], 18 | "require": { 19 | "php": "^8.3", 20 | "spatie/laravel-package-tools": "^1.16", 21 | "illuminate/contracts": "^12.0" 22 | }, 23 | "require-dev": { 24 | "illuminate/http": "*", 25 | "larastan/larastan": "^3.0", 26 | "laravel/pint": "^1.14", 27 | "nunomaduro/collision": "^8.1.1", 28 | "orchestra/testbench": "^10.0.0", 29 | "pestphp/pest": "^4.0", 30 | "pestphp/pest-plugin-arch": "^4.0", 31 | "pestphp/pest-plugin-laravel": "^4.0", 32 | "phpstan/extension-installer": "^1.4", 33 | "phpstan/phpstan-deprecation-rules": "^2.0", 34 | "phpstan/phpstan-phpunit": "^2.0", 35 | "spatie/laravel-ray": "^1.35" 36 | }, 37 | "autoload": { 38 | "psr-4": { 39 | "RyanChandler\\BunnyFonts\\": "src/", 40 | "RyanChandler\\BunnyFonts\\Database\\Factories\\": "database/factories/" 41 | } 42 | }, 43 | "autoload-dev": { 44 | "psr-4": { 45 | "RyanChandler\\BunnyFonts\\Tests\\": "tests/", 46 | "Workbench\\App\\": "workbench/app/", 47 | "Workbench\\Database\\Factories\\": "workbench/database/factories/", 48 | "Workbench\\Database\\Seeders\\": "workbench/database/seeders/" 49 | } 50 | }, 51 | "scripts": { 52 | "post-autoload-dump": [ 53 | "@clear", 54 | "@prepare", 55 | "@composer run prepare" 56 | ], 57 | "clear": "@php vendor/bin/testbench package:purge-skeleton --ansi", 58 | "prepare": "@php vendor/bin/testbench package:discover --ansi", 59 | "build": "@php vendor/bin/testbench workbench:build --ansi", 60 | "start": [ 61 | "Composer\\Config::disableProcessTimeout", 62 | "@composer run build", 63 | "@php vendor/bin/testbench serve" 64 | ], 65 | "analyse": "vendor/bin/phpstan analyse", 66 | "test": "vendor/bin/pest", 67 | "test-coverage": "vendor/bin/pest --coverage", 68 | "format": "vendor/bin/pint", 69 | "serve": [ 70 | "Composer\\Config::disableProcessTimeout", 71 | "@build", 72 | "@php vendor/bin/testbench serve --ansi" 73 | ], 74 | "lint": [ 75 | "@php vendor/bin/pint", 76 | "@php vendor/bin/phpstan analyse" 77 | ] 78 | }, 79 | "config": { 80 | "sort-packages": true, 81 | "allow-plugins": { 82 | "pestphp/pest-plugin": true, 83 | "phpstan/extension-installer": true 84 | } 85 | }, 86 | "extra": { 87 | "laravel": { 88 | "providers": [ 89 | "RyanChandler\\BunnyFonts\\BunnyFontsServiceProvider" 90 | ], 91 | "aliases": { 92 | "BunnyFonts": "RyanChandler\\BunnyFonts\\Facades\\BunnyFonts" 93 | } 94 | } 95 | }, 96 | "minimum-stability": "dev", 97 | "prefer-stable": true 98 | } -------------------------------------------------------------------------------- /src/FontFamily.php: -------------------------------------------------------------------------------- 1 |