gorriecoe / silverstripe-webfonts
为 SilverStripe CMS 提供网络字体集成。
1.0.5
2018-04-14 20:57 UTC
Requires
- silverstripe/framework: ^4.0.2
README
为 SilverStripe CMS 提供网络字体集成,允许在 HTMLEditorField 和前端内使用字体。
要求
- silverstripe/framework ^4.0
安装
Composer 是推荐安装 SilverStripe 模块的方式。
$ composer require gorriecoe/silverstripe-webfonts
文档
TypeKit
在 config.yaml 中定义 TypeKitID
gorriecoe\Webfonts\View\Webfonts:
TypeKitID: '######'
以下之一可用于页面模板
$TypeKitScript
: 返回 JavaScript 嵌入代码。$TypeKitStyle
: 返回样式链接代码。$TypeKitID
: 返回 Typekit 套件 ID。$WebFontLoader
: 返回 web font loader 嵌入代码。
示例
<head> <title>Example.com</title> {$TypeKitScript} </head>
Google Fonts
在 config.yaml 中定义 GoogleFonts
gorriecoe\Webfonts\View\Webfonts:
GoogleFonts:
- 'Droid Sans'
- 'Droid Serif:bold'
以下之一可用于页面模板
$GoogleFonts
: 返回样式链接代码。$WebFontLoader
: 返回 web font loader 嵌入代码。
示例
<head> <title>Example.com</title> {$GoogleFonts} </head>
Fonts.com
在 config.yaml 中定义 FontsComID
gorriecoe\Webfonts\View\Webfonts:
FontsComID: '######'
以下之一可用于页面模板
$FontsCom
: 返回 JavaScript 链接代码。$FontsComID
: 返回 Font.com 项目 ID。$WebFontLoader
: 返回 web font loader 嵌入代码。
示例
<head> <title>Example.com</title> {$FontsCom} </head>
多个字体提供者
在 config.yaml 中按照上述方式定义选项
gorriecoe\Webfonts\View\Webfonts:
TypeKitID: '######'
GoogleFonts:
- 'Droid Sans'
- 'Droid Serif:bold'
$WebFontLoader
返回 web font loader 嵌入代码是推荐在页面模板中用于处理多个字体提供者的变量。
示例
<head> <title>Example.com</title> {$WebFontLoader} </head>
自定义字体
在 config.yaml 中定义 CustomFonts
gorriecoe\Webfonts\View\Webfonts:
CustomFonts:
'MyFont:Bold,Italic': '/fonts.css'
'FontAwesome': '//netdna.bootstrap.ac.cn/font-awesome/4.0.3/css/font-awesome.css'
$WebFontLoader
可用于页面模板以返回 web font loader 嵌入代码。