【发布时间】:2014-01-28 08:06:15
【问题描述】:
我正在尝试使用来自谷歌字体的自定义字体:
<link href='http://fonts.googleapis.com/css?family=Karla|Quantico|Audiowide' rel='stylesheet' type='text/css'>
我已经将它们与这个 css 一起用于普通文本:
.customFont{
font-family: 'Karla' ;
}
<h1 class="customFont"> My text </h1>
但是,当我尝试在 SVG 文本元素(例如图形中的节点文本)中添加这种带有 d3.js 的字体时,它会删除我尝试添加到类中的所有其他样式:
.customFont {
font-family: 'Karla' ;
font-weight : bold;
pointer-events: none;
stroke:#fff;
stroke-width:1px;
fill-opacity: 1;
fill: #000;
}
它将字体系列更改为自定义 Karla,但不会保留所有其他属性。如何在一个类中获取新字体和其他属性?
【问题讨论】:
-
你能告诉我们你用来设置字体的代码吗?