问题描述
我已将包含Roboto字体的目录添加到FontProvider。 Pdf可以找到Roboto字体,但是无法正常工作。当我使用 font-weight:900时,它总是使用Roboto-Black;当我使用 font-weight:normal; font-style:normal 时,请选择font-style:Bold; 和Roboto-Light而不是Roboto-Regular。这就是为什么我要在CSS中使用@font-face
。但是我无法做到。这是我所做的:
FontProvider fontProvider = new DefaultFontProvider(false,false,false);
fontProvider.AddDirectory(fonts);
properties.SetFontProvider(fontProvider);
...
在CSS中:
@font-face {
font-family: 'Roboto';
src: local('Roboto-Regular.ttf');
src: local('Roboto-Regular.ttf') format('truetype'),url('Fonts/Roboto/Roboto-Regular.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
.test {
font-family: 'Roboto';
background-color: #c9c9c9;
font-weight: normal;
font-style: normal;
}
<div class="test">
Hello World. This is Roboto Font.
</div>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)