gpt4 book ai didi

ruby-on-rails - Rails 为 MIME 类型错误的 .otf 文件提供服务。应用程序/vnd.oasis.opendocument.formula-template

转载 作者:行者123 更新时间:2023-12-03 15:36:07 24 4
gpt4 key购买 nike

这是我所做的:

首先我在 app/assets 目录中创建了一个 fonts 文件夹。


然后我配置 Assets 管道以识别这个新文件夹。

config/environments/development.rb:

# Add the fonts path
config.assets.paths << Rails.root.join('app', 'assets', 'fonts')

# Precompile additional assets
config.assets.precompile += %w( .svg .eot .woff .ttf .otf )

接下来,我在config/initializers/mime_types.rb中配置mime类型:

# Be sure to restart your server when you modify this file.

# Here are some example that came with the default Rails project.

# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone

Rack::Mime::MIME_TYPES['.otf'] = 'application/x-font-opentype'

最后,我在 SCSS 中引用字体:

@font-face {
font-family: 'ArnoProDisplay';
src: url('ArnoPro-Display.otf');
font-weight: normal;
font-style: normal;
}

我正在使用谷歌浏览器,控制台显示:

Resource interpreted as Font but transferred with MIME type
application/vnd.oasis.opendocument.formula-template:
"http://localhost:3000/assets/ArnoPro-Display.otf".

我可以在“网络”选项卡中正确看到字体:

enter image description here

最佳答案

更新

解决方案 1

application/x-font-opentype 更改为 font/opentype 。来源:font mime type

Rack::Mime::MIME_TYPES['.otf'] = 'font/opentype'

清除缓存

rake tmp:cache:clear

在重新启动服务器之前。


如果解决方案1不起作用,你应该创建文件.htaccess并添加这个

AddType application/vnd.oasis.opendocument.formula-template .otf

关于ruby-on-rails - Rails 为 MIME 类型错误的 .otf 文件提供服务。应用程序/vnd.oasis.opendocument.formula-template,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16817356/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com