我的问题非常简单,症状很奇怪。
在我的HTML标题中,我已经包含了直接从Google字体加载字体的代码。
public class Test2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
sc.nextLine();
String[] strArr = new String[N];
for (int i = 0; i < N; i++) {
strArr[i] = sc.nextLine();
}
System.out.println(fun(strArr));
}
public static int fun(String[] arr) {
TreeSet<String> treeSet = new TreeSet<>();
for (int i = 0; i < arr.length; i++) {
char[] chars = arr[i].toCharArray();
Arrays.sort(chars);
treeSet.add(chars.toString());
}
return treeSet.size();
}
}
这是我的CSS:
function arrGen(n) {
var a = Array(n)
while (n--) a[n] = n
return a
}
// arrGen(10) => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
无论我选择什么样的自定义,字体似乎都是普通字体。我尝试使用Roboto Thin(Roboto:100)和Roboto Thin Italic(Roboto:100i),但实际上并没有改变。
我的代码中是否有任何遗漏?
答案 0 :(得分:1)
您正在加载具有700字体粗细的Roboto字体并尝试以100字体粗细显示它。使用以下网址嵌入:
<link href="https://fonts.googleapis.com/css?family=Roboto:100,100i,400,700" rel="stylesheet">
使用此链接,它可以正常使用。
更新:此代码段会详细解释您的信息。
.text {
font-family: 'Roboto', sans-serif;
color: #000;
}
.text-100 {
font-weight: 100;
}
.text-100i {
font-weight: 100;
font-style: italic;
}
.text-400 {
font-weight: 400;
}
.text-700 {
font-weight: 700;
}
&#13;
<link href="https://fonts.googleapis.com/css?family=Roboto:100,100i,400,700" rel="stylesheet">
<div class="text text-100">
Hello (Font weight: 100)
</div>
<div class="text text-100i">
Hello (Font weight: 100i)
</div>
<div class="text text-400">
Hello (Font weight: 400)
</div>
<div class="text text-700">
Hello (Font weight: 700)
</div>
&#13;
答案 1 :(得分:1)
它依赖于谷歌的女巫字体,在这种情况下:
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,700" rel="stylesheet">
您可以像这样接近CSS中的每个字体粗细:
// 300 weight
.text {
font-family: 'Roboto', sans-serif;
font-size: 300;
}
// 400 weight
.text {
font-family: 'Roboto', sans-serif;
font-size: 400;
}
// 700 weight
.text {
font-family: 'Roboto', sans-serif;
font-size: 700;
}
答案 2 :(得分:0)
您只需在CSS中设置体重字体
即可.text {
font-weight: 700;
}
答案 3 :(得分:0)
首先加载所有字体 - 只需使用
font-weight:100 | 300 | 700 / 其中任何一个 /。
Google字体基本上与 font-weight 属性配合使用。谷歌字体根据字体重量规格进行渲染。 例如 -
Case 1 - font-weight:100 then thin font will load.
Case 2 - font-weight:300 then light font will load.
Case 3 - font-weight:700 then bold font will load.
答案 4 :(得分:0)
在您的css文件中,添加:
@import url('https://fonts.googleapis.com/css?family=Roboto:400,700');
在顶部。
并且,在所需的类中使用它,如:
.class{
font-family: 'Roboto', sans-serif;
font-weight: 700;
}