我想用谷歌字体添加一个字体,我注意到一个奇怪的行为.
我想添加一个只有拉丁子集的字体,我不想要latin-ext,cyrillic或者cyrillic-ext子集,以减轻代码.我明白这是默认行为,所以我这样做了:
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Philosopher">
Run Code Online (Sandbox Code Playgroud)
在Firefox(以及其他不支持WOFF2的浏览器)中,我得到了正确的输出:
@font-face {
font-family: 'Philosopher';
font-style: normal;
font-weight: 400;
src: local('Philosopher'), url(http://fonts.gstatic.com/s/philosopher/v7/OttjxgcoEsufOGSINYBGLbrIa-7acMAeDBVuclsi6Gc.woff) format('woff');
}
Run Code Online (Sandbox Code Playgroud)
但在Chrome中,我得到了这个:
/* cyrillic */
@font-face {
font-family: 'Philosopher';
font-style: normal;
font-weight: 400;
src: local('Philosopher'), url(http://fonts.gstatic.com/s/philosopher/v7/OttjxgcoEsufOGSINYBGLV4sYYdJg5dU2qzJEVSuta0.woff2) format('woff2');
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* latin */
@font-face {
font-family: 'Philosopher';
font-style: normal;
font-weight: 400;
src: local('Philosopher'), url(http://fonts.gstatic.com/s/philosopher/v7/OttjxgcoEsufOGSINYBGLZQV2lvL5Ba9FjAYK6Lx0Qk.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
Run Code Online (Sandbox Code Playgroud)
我想,也许拉丁子集不再是默认行为了,所以我添加了我<link>的subsetGET参数:
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Philosopher&subset=latin"> …Run Code Online (Sandbox Code Playgroud) 我找不到让情感主题与 TypeScript 一起使用的方法。
import React from "react";
import { ThemeProvider } from "emotion-theming";
import styled from "@emotion/styled";
const theme = {
colors: {
gray: "#ccc",
},
};
const MyComponent = styled.div((props) => ({
color: props.theme.colors.gray,
}));
const App = () => (
<ThemeProvider theme={theme}>
<MyComponent />
</ThemeProvider>
);
export default App;
Run Code Online (Sandbox Code Playgroud)
文档说:“默认情况下,props.theme 有任何类型注释并且工作时没有任何错误”。但我有一个props.theme.colors.gray:属性“颜色”在类型“对象”上不存在。ts(2339)
我在这里错过了什么吗?
一个例子比长篇大论更好:
// Backery.service.ts
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { Backery } from './Backery.entity';
@Injectable()
export class BackeryService {
constructor(
@InjectRepository(Backery)
private readonly backeryRepository: Repository<Backery>,
) {}
static myStaticMethodToGetPrice() {
return 1;
}
otherMethod() {
this.backeryRepository.find();
/* ... */
}
}
Run Code Online (Sandbox Code Playgroud)
// Backery.resolver.ts
import { Bakery } from './Bakery.entity';
import { BakeryService } from './Bakery.service';
@Resolver(() => Bakery)
export class BakeryResolver {
constructor() {}
@ResolveField('price', () => …Run Code Online (Sandbox Code Playgroud)