- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 .Net Core MVC 应用程序,它使用 DinkToPdf(包装 libwkhtmltox.dll)从 HTML 创建 PDF 文件。我使用的字体之一是 .woff 字体,这在我的本地计算机上运行良好。但是在 Azure 中,不应用该字体。
我读过其他线程,指出应将 mimeType 添加到 .Net Core 的 FileExtensionContentTypeProvider 中,而不是添加到 .Net 应用程序中的 web.config 中。
var provider = new FileExtensionContentTypeProvider();
provider.Mappings[".woff"] = "font/woff";
provider.Mappings[".ttf"] = "font/ttf";
provider.Mappings[".otf"] = "font/otf";
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "fonts")),
RequestPath = "/fonts",
ContentTypeProvider = provider
});
我也尝试过不同的 mimeTypes,但相信这些是正确的。您可以看到我还添加了 .ttf 和 .otf 来查看 Azure 是否存在其中一个问题,而另一个没有问题。然后我按照下面的方式引用 css 中的字体...
@font-face {
font-family: 'barcode';
src: url(../fonts/fre3of9x.woff) format('woff'), url(../fonts/fre3of9x.ttf) format('ttf'), url(../fonts/CODE39.otf) format('otf');
font-weight: normal;
font-style: normal; }
我在 Azure 中看不到任何可以设置的内容,所以我遇到了麻烦。有人可以帮忙吗?
最佳答案
我假设您正在使用的 Azure 应用服务基本上只是 IIS。 IIS 不提供对 WOFF 的现成支持。这将要求您将 web.config 添加到项目的根目录,并确保将其部署到应用服务。以下是 web.config 中需要包含的内容。
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".woff" mimeType="font/font-woff" />
<mimeMap fileExtension=".woff2" mimeType="font/font-woff" />
</staticContent>
</system.webServer>
</configuration>
希望这有帮助。
您可能必须显式删除扩展并将其添加回来。这是我在一些我知道有效的网站中使用的方法。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".woff" mimeType="font/font-woff" />
<mimeMap fileExtension=".woff2" mimeType="font/font-woff" />
</staticContent>
</system.webServer>
</configuration>
关于c# - 如何在 Azure 中为 .NEt 核心应用程序应用 woff 字体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54128265/
我下载了一个.Woff字体(Ubuntu),下面是相关代码: @font-face { font-family: 'Ubuntu'; font-style: normal; font-
是否有任何 javascript 库可以将 WOFF(和 WOFF2)字体缩小到仅 SVG 图像中使用的字形?例如,给定一个字体和一个字符串数组,它将返回显示这些字符串所需的最小字体。 我的第一个想法
我有一个 .woff 字体,它在 Windows 平台上的渲染效果很差。我怀疑这可能是由于缺乏提示信息,但我需要确保。 你能推荐一种可以检查字体文件并告诉我其中是否存在提示指标的工具吗? 最佳答案 T
我正在使用 gulp-iconfont将一组 svg 图标转换为 woff 字体。 在图标转换为字体之前,它看起来如下: 它在 woff 文件中的显示方式: 我的 gulp 任务如下: gulp.ta
我尝试以多种不同的方式设置 MIME 类型,例如: 但无论如何我都会收到错误:Uncaught SyntaxError: Unexpected t
所以 mozilla 提出了一种新的网络字体,我不太喜欢那个世界,但我想让自己保持最新状态。那么,既然连微软都支持它,那么伟大的事情是什么,为什么我作为一个网络开发者应该关心呢? 和旧版有什么区别?我
在我管理的网站上,我们有几个 .woff 文件,每种字体一个。为了节省加载时间,我想减少发出的请求数量。是否可以将这些 woff 文件合并为一个资源? 最佳答案 您可以使用 base64 将 woff
我需要将 metadata.xml 添加到我使用 font-squirrel 创建的 WOFF 文件,以便将它与 @font-face 一起使用。 我想像这样向 WOFF 文件添加一个 metadat
我在我的网站上使用@font-face 但它不起作用,.woff 文件出现 404 错误。我的字体位于根目录但找不到字体 这是我的字体 css 文件,有什么问题吗? @font-face {
我定义了以下 @font-face 规则: @font-face { font-family: "MyFont"; src: url(MyFont.eot); src: url
我一直在使用 GitHub 用户@hanikesn(见下文)的一个很棒的开源 python 脚本,它通过命令行(Mac OS X 上的终端)将单个 WOFF 文件转换回 OTF 格式。 就像现在一样,
Google Page Speed inisght 仍然告诉我对某些 .woff 字体使用浏览器缓存: /fontawesome-webfont.woff?v=4.6.1/rssocial-font.
您将字体放在哪里以便 CSS 可以访问它们? 我在 .woff 文件中使用浏览器的非标准字体。假设它的“awesome-font”存储在文件“awesome-font.woff”中。 最佳答案 生成
在 PageSpeed Insights 中,我不断看到利用浏览器缓存我正在使用的特定图标集/字体的消息:iconFont.woff(2 天) 我已将 .htaccess 设置为: ## EXPIRE
我发现一些 Google Webfonts 现在使用 WOFF 2.0。我可以以某种方式将现有的 WOFF 字体转换为这种新的(据说是更好的格式)吗?又如何? 最佳答案 当然!您可以将现有的 woff
我一直在尝试使用各种命令行和在线工具将 TTF 转换为 WOFF。我尝试过以下操作: 命令行: sfntwoff:https://people-mozilla.org/~jkew/woff/ ttf2
我有一个 SVG 字体文件,这正是我想要的。当我通过转换器 ( http://onlinefontconverter.com/ ) 运行它时,输出的 WOFF 文件在 Chome 和 IE9 中显示不
我使用样式包捆绑我所有的 CSS,并使用样式渲染。 bundles.Add(new StyleBundle("~/content/assets") .Inclu
如何设置.gitconfig 来识别*.woff 文件?我尝试: *.eot binary *.ttf binary *.woff binary *.woff2 binary 但是我有 fatal:
当前的 Windows 和 Linux 二进制文件(在带有 http://phantomjs.org/build.html 的 Ubuntu 14.04 上构建)都不接受 woff 字体(通过 CSS
我是一名优秀的程序员,十分优秀!