fonts - 为什么使用 Edge Inspect 通过 Localhost 在设备中查看时 Typekit 字体不起作用?

标签 fonts localhost webfonts typekit adobe-edge-inspect

使用 Edge Inspect 测试本地运行的站点时,不会下载或呈现 Typekit 字体。

我已将 localhost 添加到我的 Typekit 工具包中允许的域中,还添加了我机器的 IP 地址。

在浏览器中查看时字体呈现良好,但在任何设备上都无法呈现。

最佳答案

我添加了 Adob​​e 支持人员给出的这个答案,希望它能帮助其他人解决这个问题。以下是直接引用:

When you're browsing a local website via the hostname localhost, which would not be accessible to any other devices on your network, Edge Inspect automatically gets your machine's local IP address (which is not the same as the external IP as shown on sites like whatismyip.com) and sends that to the mobile apps. For instance, let's say I have a Sinatra application running in Chrome on my Mac as http://localhost:4567. My iPhone wouldn't be able to understand the hostname "localhost", but it can see my Mac using its IP address 10.1.10.1, so Edge Inspect will navigate to http://10.1.10.1:4567.

So, to get fonts working, you could add both localhost and 10.1.10.1 to your kit. However, we don't recommend adding local IPs to kits because they tend to change without warning. (In my example above, the next time I turn on my computer its IP could have changed to 10.1.10.2, but all I would know is that fonts had stopped working on my devices again.)

To work around this, we recommend using some form of "dynamic DNS" — basically, a domain name that is automatically updated with your current IP and therefore will always point to your computer.

If you're using a Mac, the simplest thing would be to use your Mac's Bonjour hostname. Bonjour is a technology built into Mac OS X and iOS to help devices find each other automatically over networks.

To find your Bonjour hostname:

  1. Open System Preferences on your Mac.
  2. Choose the Sharing icon.
  3. Your Bonjour hostname will be displayed in the top area, under the "Computer Name" field.

You can add the hostname that appears there to your kit, and use it on any Apple device on your network. For example, my Bonjour name is Somename-rMBP.local, so I can browse to http://Somename-rMBP.local:4567 on any Mac or iOS device and see my Sinatra app.

Unfortunately, this simple solution will only work on Apple devices or Windows PCs with Apple's Bonjour software installed — you can't use this hostname with Android phones or tablets. If you need a hostname that will work on any device, there are a couple of options I'd recommend:

  1. A third-party service called Forward offers a way to easily forward ports from your computer to other devices anywhere on the internet. You can learn more about them and sign up for a 30-day trial here: https://forwardhq.com. Forward will give you a permanent domain name for your forwarded app that you can add to your kit, such as dev-yourcompany.fwd.wf.

  2. 37signals has a free "wildcard DNS" service called xip.io that will automatically forward traffic to a local IP address. You can get your current local IP address by opening System Preferences, then choosing Network. The IP address should be shown in the small text underneath the connection status for whatever connection is active (i.e. has a green dot next to it). Once you have the IP, you can access your computer at [YOUR IP].xip.io. To get fonts working, add *.xip.io to your kit. Remember that your IP may change, so if your site stops being accessible you should check to make sure you have the correct IP address.

关于fonts - 为什么使用 Edge Inspect 通过 Localhost 在设备中查看时 Typekit 字体不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13865222/

相关文章:

java - 天气图标字体

javascript - 创建用户时收到错误请求错误请求400(Firebase)

ruby-on-rails - Ruby on Rails 无法访问 http :/localhost:3000 on MAC

html - 使用 CSS 选择 Avenir Next 粗体变体(更新 10.10.2)

css - 加载 WebFonts 时出现异常问题

jsfiddle - 如何在 JSFiddle 中包含 Google 字体?

css - 将图标字体中的图标显示为带有下划线的 anchor 中的伪元素

fonts - 如何在 JavaFX 字体中强制抗锯齿?

iOS7 - 调整多行标签的字体大小以适合其框架

security - 如何保护 Jetty 仅允许来自环回(localhost)的访问