titledk / silverstripe-webfonts
用于处理网页字体的实用程序/助手
dev-master
2016-02-22 08:44 UTC
Requires
- silverstripe/framework: ~3.1
This package is not auto-updated.
Last update: 2024-09-14 15:27:07 UTC
README
用于处理网页字体的实用程序/助手。使用此模块,您可以通过yaml配置轻松添加本地和谷歌字体,并且它们将自动添加到网站和编辑器中。
配置示例
默认情况下,模块期望您的字体位于网站根目录下的fonts
目录中
SiteConfig:
extensions:
- WebfontsUtility_SiteConfigExtension
LeftAndMain:
extensions:
#only needed when needing this in the backend
- WebfontsUtility_LeftAndMainExtension
WebfontsUtility:
google_fonts:
'Devonshire':
'Bigelow+Rules':
'Rambla':
styles: '400,700,700italic'
local_fonts:
'Miso':
directory: 'miso'
styles: 'Regular,Bold'
filetypes: 'eot,woff,woff2,ttf,svg'
Regular:
filepattern: 'miso-regular-webfont'
style: 'font-style: normal;'
Bold:
filepattern: 'miso-bold-webfont'
style: 'font-style: bold;'
'Sansation':
directory: 'sansation'
styles: 'Light,Regular,Bold'
filetypes: 'eot,woff,ttf,svg'
Light:
filepattern: 'sansation_light-webfont'
style: 'font-style: normal;font-weight: 300;'
Regular:
filepattern: 'sansation_regular-webfont'
style: 'font-style: normal;font-weight: 400;'
Bold:
filepattern: 'sansation_bold-webfont'
style: 'font-style: normal;font-weight: 700;'
需求可以在init
方法中像这样加载
WebfontsUtility::Requirements();
//Use this for debugging
//echo WebfontsUtility::google_font_collection_link();
//echo WebfontsUtility::debug();
未来想法
当前状态下,字体是内联添加的。这可以通过使模块自动生成Scss/CSS/LESS文件来改进,这些文件随后可以包含到编译后的样式表中。