Skip to content

Commit c0a9b84

Browse files
authored
Merge pull request #30 from nativeapptemplate/fix/async-font-loading
Fix white screen on display page by self-hosting Inter font
2 parents 0beead0 + 4596137 commit c0a9b84

7 files changed

Lines changed: 23 additions & 5 deletions

File tree

83.3 KB
Binary file not shown.
47.3 KB
Binary file not shown.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* latin-ext */
2+
@font-face {
3+
font-family: 'Inter';
4+
font-style: normal;
5+
font-weight: 400 800;
6+
font-display: swap;
7+
src: url("/inter/inter-latin-ext.woff2") format('woff2');
8+
unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
9+
}
10+
/* latin */
11+
@font-face {
12+
font-family: 'Inter';
13+
font-style: normal;
14+
font-weight: 400 800;
15+
font-display: swap;
16+
src: url("/inter/inter-latin.woff2") format('woff2');
17+
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
18+
}

app/views/layouts/display.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<%# Be sure to add your own custom favicons %>
1919
<%= render "shared/favicons" %>
2020

21-
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap">
21+
<%= stylesheet_link_tag "vendor/inter", media: "all" %>
2222

2323
<%= yield :head %>
2424
</head>

app/views/layouts/errors.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<%# Be sure to add your own custom favicons %>
1919
<%= render "shared/favicons" %>
2020

21-
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap">
21+
<%= stylesheet_link_tag "vendor/inter", media: "all" %>
2222

2323
<%= yield :head %>
2424
</head>

app/views/layouts/minimal.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<%# Be sure to add your own custom favicons %>
1919
<%= render "shared/favicons" %>
2020

21-
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap">
21+
<%= stylesheet_link_tag "vendor/inter", media: "all" %>
2222

2323
<%= yield :head %>
2424
</head>

config/initializers/content_security_policy.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
Rails.application.configure do
88
config.content_security_policy do |policy|
99
policy.default_src :self
10-
policy.font_src :self, "https://fonts.gstatic.com"
10+
policy.font_src :self
1111
policy.img_src :self, :data
1212
policy.object_src :none
1313
policy.script_src :self
14-
policy.style_src :self, :unsafe_inline, "https://fonts.googleapis.com"
14+
policy.style_src :self, :unsafe_inline
1515
policy.connect_src :self
1616
policy.frame_src :self
1717
policy.base_uri :self

0 commit comments

Comments
 (0)