【发布时间】:2021-10-07 23:38:54
【问题描述】:
我的应用程序以前在 Angular 10 上。我升级到 Angular 11 没有任何问题 - 然后立即转到 Angular 12。一切编译正常,应用程序运行良好。我遇到的唯一问题是我的字体现在不同了。
不同——我的意思是我使用的“Open Sans”谷歌网络字体——更轻,不像以前那样粗体。我可以将我的应用程序的生产版本(Angular 10)放在我的本地版本(Angular 12)旁边——并检查这些元素,它们看起来是一样的。他们都在使用字体并很好地加载字体——主要区别在于字体粗细。我的 Angular 10 版本的字体更加大胆。我可以将 Angular 12 字体粗细设置为 900,但它仍然不如以前的常规粗细粗体。我根本没有改变字体。它仍然是相同的导入。
我正在使用 Bootstrap 和 Angular Material(版本 12)。我正在使用自定义排版:
$custom-typography: mat.define-typography-config(
$font-family: 'Open Sans, sans-serif',
$display-4: mat.define-typography-level(112px, 112px, 300),
$display-3: mat.define-typography-level(56px, 56px, 400),
$display-2: mat.define-typography-level(45px, 48px, 400),
$display-1: mat.define-typography-level(34px, 40px, 400),
$headline: mat.define-typography-level(24px, 32px, 400),
$title: mat.define-typography-level(20px, 32px, 500),
$subheading-2: mat.define-typography-level(16px, 28px, 400),
$subheading-1: mat.define-typography-level(15px, 24px, 400),
$body-2: mat.define-typography-level(14px, 24px, 500),
$body-1: mat.define-typography-level(14px, 20px, 400),
$caption: mat.define-typography-level(12px, 20px, 400),
$button: mat.define-typography-level(14px, 14px, 500),
$input: mat.define-typography-level(inherit, 1.125, 400),
);
@include mat.typography-hierarchy($custom-typography);
// Override typography for a specific Angular Material components.
@include mat.checkbox-typography($custom-typography);
// Override typography for all Angular Material, including mat-base-typography and all components.
@include mat.all-component-typographies($custom-typography);
@include mat.core($custom-typography);
除了升级过程中自动迁移的语法之外,上面的代码没有改变。我可以检查页面上的各种元素,并且所有字体粗细看起来都是错误的——即使页面背后的代码是相同的。
下面是一个小比较。 LEFT 是 Angular 10 上的当前产品——而 RIGHT 是 Angular 12 上当前的本地产品。这是一个非常微妙的字体粗细问题,我无法弄清楚。有什么帮助吗?
【问题讨论】:
标签: javascript angular sass fonts angular-material