--paper-font-common-base
在加载任何组件之前,我有一个明确指定的 Polymer 2 应用程序:
--paper-font-common-base: {
font-family: 'Comic Sans';
/* Not really, nobody's that evil, but problem is there for any font */
};
然后,在加载 Polymer 组件时,例如paper-dialog
,将导入typography.html
<link rel="import" href="../paper-styles/typography.html">
依次typography.html
导入 Roboto并覆盖 mixin:
<link rel="import" href="../font-roboto/roboto.html">
...
<custom-style>
<style is="custom-style">
html {
--paper-font-common-base: {
font-family: 'Roboto', 'Noto', sans-serif;
-webkit-font-smoothing: antialiased;
};
这会覆盖我指定的字体,但也会从Google 的 CDN下载 Roboto ,我明确不希望它这样做。
例如,其他 Polymer 组件paper-radio-button
采用不同的方法:
/*
This element applies the mixin `--paper-font-common-base` but does not import `paper-styles/typography.html`.
In order to apply the `Roboto` font to this element, make sure you've imported `paper-styles/typography.html`.
*/
如何设置--paper-font-common-base
以便 Polymer 组件使用与我的应用程序其余部分相同的字体?