chengyin / WhatFont-Bookmarklet

The core of WhatFont Tool
http://chengyinliu.com/whatfont.html
University of Illinois/NCSA Open Source License
489 stars 75 forks source link

Can't view font in very simple pages #6

Open Wilfred opened 11 years ago

Wilfred commented 11 years ago

I did write a tweet referencing a JSFiddle, but I suspect that's just an iframe issue. My issue occurs without an iframe. With the following HTML:

<!DOCTYPE html>
<html>
    <head>
        <title>
        </title>
        <link href="cursive.css" rel="stylesheet">
    </head>
    <body>
        <span class="cursive">what font am I, whatfont?</span>
    </body>
</html>

And the following stylesheet:

span {
    font-family: Cursive;
    border: 1px solid green;
}

I can't start whatfont, clicking the icon doesn't do anything.

morgansoftware commented 8 years ago

If you run that code on your local machine (via the file:/// protocol), WhatFont cannot run (as you said). If you run that code on a web server (not via the file:/// protocol), WhatFont works fine.

The issue is not with WhatFont. The issue is that Chrome extensions (i.e. WhatFont) are not allowed to run in pages loaded via the file:/// protocol for security reasons. This is a JavaScript security feature to prevent malicious web pages from accessing your files.

Fixes #6

adamculpepper commented 4 years ago

I'd really like this too. I know this likely wouldn't be possible on the bookmarklet, but seems like it could be on the Chrome extension. Take a look at how the Chrome extension Stylus is doing it maybe @chengyin? They have an option called "Allow access to file URLs" that does exactly this. :)

image