Home > Web Front-end > CSS Tutorial > How to Load Fonts Across Domains with @font-face in Firefox?

How to Load Fonts Across Domains with @font-face in Firefox?

Patricia Arquette
Release: 2024-12-03 08:50:13
Original
481 people have browsed it

How to Load Fonts Across Domains with @font-face in Firefox?

Cross-Domain Font Loading with @font-face

In an attempt to establish a central font repository for multiple websites, a developer encountered a peculiar issue: @font-face fonts were accessible only on the subdomain where the repository resided. Despite successful linking to font-face.css on other sites, the fonts failed to load.

Cause

This behavior stems from Firefox's security policy, which deems cross-domain font embedding harmful.

Solution

To overcome this restriction, add the following code to the top-level .htaccess file on the subdomain hosting the fonts:

<FilesMatch "\.(ttf|ttc|otf|eot|woff)$">
    <IfModule mod_headers.c>
        Header set Access-Control-Allow-Origin "*"
    </IfModule>
</FilesMatch>
Copy after login

Access Restrictions

While the modified .htaccess allows all websites to access the fonts, the developer expressed a desire to restrict access to only authorized users. However, the W3C specification for Access-Control-Allow-Origin limits the options to a wildcard "*" or a specific domain.

The above is the detailed content of How to Load Fonts Across Domains with @font-face in Firefox?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template