angular - Angular Material 图标中 fontSet 的默认值是多少?
问题描述
我的应用程序中有一些自定义图标,这些图标是通过设置 fontSet 属性来呈现的
<mat-icon fontSet="myFont" fontIcon="my-icon"></mat-icon>
现在,我想保持一致并使用它们的字体设置来渲染 Angular Material 图标,如下所示
<mat-icon fontSet="md" fontIcon="add"></mat-icon>
但它不起作用。所以我想知道fontSet
Angular Material图标中的默认值是什么?
解决方案
为了使用 fontSet 你必须声明你的自定义字体:
@font-face {
font-family: 'icomoon';
src: url('path.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
你有 2 个选项可以将它与 angular Mat-Icon 一起使用
1) 申请班级
.MyIconClass
{
font-family: 'MyFontFamily' !important;
}
2) 注册到 AppComponent
constructor(iconRegistry: MatIconRegistry) {
iconRegistry.registerFontClassAlias('MyFontFamily', 'MyIconClass');
}
然后您将能够显示该图标:
<mat-icon fontSet="MyIconClass" fontIcon="LigatureOrUnicodeToDisplay"></mat-icon>
或者
<mat-icon fontSet="MyIconClass">LigatureOrUnicodeToDisplay</mat-icon>
如果你和我一样,不想有更多的参数,只需用你自己的字体替换 .material-icons 。
.material-icons {
font-family: 'MyFontFamily';
...
}
然后你就可以像这样使用它了
连字显示
我喜欢。
您可以使用此链接创建您自己的带有 svg 的图标集合。
快乐编码。
推荐阅读
- regex - Oracle正则表达式匹配列值的多个部分
- php - 在 Laravel 中,如何为不同的客户名称制作多个仪表板?
- python - 将 2 个列表的公共元素存储为 0 和 1
- reactjs - 如何在 next.js 上正确实现 next/link 与 SSR
- python - 在 Python 中使用函数更改变量值
- python - 我可以在 python 中拆分推文数据吗?
- machine-learning - 如何为 KNeighborsClassifier 选择权重函数
- r - 无法安装ggpubr。尝试了其他解决方案但不起作用
- python - 如何使用 relativedelta 将 DatetimeIndex 移动 x 个月?
- javascript - JavaScript事件监听器使字符在箭头右键按下时向右移动