straylightagency/fonts 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

straylightagency/fonts

Composer 安装命令:

composer require straylightagency/fonts

包简介

Helper to rend HTML tags to load fonts from services like Google Fonts, Adobe Fonts and Fontawesome

README 文档

README

Helper to rendering HTML tags to load fonts from services like Google Fonts, Bunny Fonts, Adobe Fonts or FontAwesome.

Installation

Require this package with composer.

composer require straylightagency/fonts

Laravel without auto-discovery:

If you do not use auto-discovery, add the ServiceProvider to the providers array in bootstrap/providers.php :

Straylightagency\Fonts\Laravel\FontsServiceProvider::class,

Then add this line to your facades in config/app.php :

'Fonts' => Straylightagency\Fonts\Laravel\Fonts::class,

Usage

Without Laravel

This package can be used without Laravel. Just instantiate the FontsManager class as a regular object.

use Straylightagency\Fonts\FontsManager;

$fontsManager = new FontsManager;

You can inject the object in your favorite dependency container.

With Laravel

The package provides by default a Facade for Laravel application. You can call methods directly using the Facade or use the alias instead.

Print the tags based on the fonts you need through a driver :

@php
    use Straylightagency\Fonts\Laravel\Fonts;

    Fonts::googleV2('Oswald', ['300', '400'])
         ->googleV2('Open Sans', ['300..800'])
         ->googleV2('Chakra Petch', 'ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700')
         ->fontawesome('12b534g387')
         ->print();
@endphp

API Documentation

Examples bellow are using Laravel Facade Fonts. The facade directly call the FontsManager class.

Define the driver to use by default when the method load is called.

FontsManager::setDefault(driver_name: string);

Add a new driver into the FontsManager. $closure must return an instance of the driver that extend the Driver class.

FontsManager::withDriver(driver_name: string, closure: Closure);

Get a driver by his name. If the driver has not already been instantiated, make a new instance.

FontsManager::use(driver_name: string);

Load a font using the default driver that was set using setDefault method. By default, it's the GoogleV2Driver.

FontsManager::load(font_name: string, font_weights: string|array = [ Fonts::regular ]);

Load a font using the Google Fonts driver

FontsManager::google(font_name: string, font_weights: string|array = [ Fonts::regular ]);

Load a font using the Google Fonts V2 driver

FontsManager::googleV2(font_name: string, font_weights: string|array = [ Fonts::regular ]);

Load a font using the BunnyFonts driver

FontsManager::bunny(font_name: string, font_weights: string|array = [ Fonts::regular ]);

Load a fonts kit from Adobe Fonts

FontsManager::adobe(kit_id: string);

Load an icons kit using the FontAwesome driver

FontsManager::fontawesome(kit_id: string);

Generate an HTML code of every driver instantiated with at least 1 font set.

$html = FontsManager::toHtml();

Print the code generated by the method toHtml

FontsManager::print();

Requirement

PHP 8.3 or above

See also

Credits

License

The MIT License (MIT).

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-31