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).
straylightagency/fonts 适用场景与选型建议
straylightagency/fonts 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「fonts」 「FontAwesome」 「google-fonts」 「bunny-fonts」 「adobe-fonts」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 straylightagency/fonts 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 straylightagency/fonts 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 straylightagency/fonts 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
FontAwesome5 for Magento2
PHP class to add Font Awesome 5+'s SVG icons inline without Javascript.
Fontawesome Bundle for Symfony3+
Automatically preload fonts from the Sage mix manifest
Automatically downloads external CSS fonts (Google Fonts, Font Awesome, ...) and serves them locally for GDPR compliance
A Filament form component for selecting Google Fonts with real-time previews, search functionality, and category filtering.
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 29
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-31