简体   繁体   English

我在哪里可以获得材质图标“灯泡”或其他缺少的 Angular 材质图标?

[英]Where can I get the Material Icon 'Bulb' or other missing Angular Material icons?

Situation情况

I was looking for the Material bulb icon.我正在寻找 Material 灯泡图标。 At this page it is stated as from Google, but I couldn't find it on the official Material icon resource https://material.io/resources/icons/?style=baseline .在此页面上,它被声明为来自 Google,但我在官方 Material 图标资源https://material.io/resources/icons/?style=baseline上找不到它。

Our designer had this bulb too and used a Google Material template.我们的设计师也有这个灯泡,并使用了 Google Material 模板。

What I want to achieve?我想达到什么目标?

I need the shortcut to use it for the <mat-icon> component, which I currently don't have.我需要将它用于<mat-icon>组件的快捷方式,我目前没有。 Like this:像这样:

<mat-icon>bulb</mat-icon>

A pratical example would be: https://stackblitz.com/edit/angular-oksuuj一个实际的例子是: https : //stackblitz.com/edit/angular-oksuuj

In this, the icon file_download does exist in the Angular MatIconModule, but not in the official material.io page.其中,图标file_download确实存在于 Angular MatIconModule 中,但不存在于官方material.io页面中。

I found the solution for that.我找到了解决方案。 Google's official icon library on Github is not maintained anymore, but there is one fork which contains the latest icons and a updated page.谷歌在 Github 上的官方图标库不再维护,但有一个包含最新图标和更新页面的分支。

material-icons.scss material-icons.scss

@font-face {
  font-family: 'Material Icons';
  font-style: normal;
  font-weight: 400;
  src: url(../font/MaterialIcons-Regular.eot); /* For IE6-8 */
  src: local('Material Icons'),
  local('MaterialIcons-Regular'),
  url(../font/MaterialIcons-Regular.woff2) format('woff2'),
  url(../font/MaterialIcons-Regular.woff) format('woff'),
  url(../font/MaterialIcons-Regular.ttf) format('truetype');
}

I just replaced my font files locally with those in this repo (fork of the material icon repo):我只是用这个 repo 中的字体文件在本地替换了我的字体文件(材质图标 repo 的分支):

and then it worked using lightbulb as shortcut.然后它使用lightbulb作为快捷方式。

<mat-icon>lightbulb</mat-icon>

I had an interesting issue, maybe this helps a few people.我有一个有趣的问题,也许这对一些人有帮助。

If you're looking for that piece of code to import the google fonts, you may copy paste the code into your IDE.如果您正在寻找那段代码来导入谷歌字体,您可以将代码复制粘贴到您的 IDE 中。 If you do so, pay attention to change the double quotes from those used in books to those used for programming.如果这样做,请注意将双引号从书籍中使用的双引号更改为用于编程的双引号。 You'll get no error, but it just won't work.你不会得到任何错误,但它只是行不通。

So always copy this one :所以总是复制这个

<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

Not this one:不是这个

<link href=”https://fonts.googleapis.com/icon?family=Material+Icons” rel=”stylesheet”>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM