GithubHelp home page GithubHelp logo

jennifersimonds / fontdetect Goto Github PK

View Code? Open in Web Editor NEW
67.0 67.0 10.0 470 KB

A JavaScript class you can use to determine whether a webfont got loaded, which font is being used by an element, or react to a webfont getting loaded (or failing to load).

License: MIT License

JavaScript 100.00%

fontdetect's People

Contributors

ahmadazimi avatar jennifersimonds avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fontdetect's Issues

FontDetect failing in IE

Hi Jennifer,
Outstanding work on this library!
One issue we're seeing is in this code in IE 11
FontDetect.isFontLoaded('FontAwesome')
This always returns false, no matter how the browser security is setup for font downloads.
Conversely, this always returns true
FontDetect.isFontLoaded('Trebuchet MS')

When I switch over to Firefox or chrome and run
FontDetect.isFontLoaded('FontAwesome')
It returns true, so the issue seems to only appear in IE.

Any thoughts on this?

Visible Alphabet

I'm concerned that the inserted alphabet characters are potentially visible to search engines, screen readers and other accessibility tools. Anything that uses javascript but suppresses all or most CSS will display the double alphabet before any content.

  • What would be the downside of loading the alphabet later in the HTML?
  • If loading the test text first is necessary, would it be possible to load characters other than the double alphabet? Some configurable site specific text for instance?

isFontLoaded doesn't seem work on font names with spaces

Neither onLoad or onFail are executed in onFontLoaded when the name contains spaces like many google fonts do ex. "Open Sans" not sure why spaces should matter I can see in the isFontLoaded method you switch the test elements font family over a few font stacks to check if dimensions are affected in order to detect.

I added a log to check what the font-family is set to in each of those loops and it returns what I'd expect ex. 'Open Sans',sans-serif so not sure why it fails.

I also noticed inconsistencies with isFontLoaded

I tested the following fonts knowing that I had NOT included them and they returned mixed results (they should have all returned false):

console.log('Open Sans', fontdetect.isFontLoaded('Open Sans'));

logged true

console.log('Happy Monkey', fontdetect.isFontLoaded('Happy Monkey'));

logged false

console.log('Press Start 2P', fontdetect.isFontLoaded('Press Start 2P'));

logged true

Have you noticed this behaviour?

isFontLoaded doesn't work with fonts that begin with digits

If you try to load a font from a local file, AND the name begins with a digit, AND the file isn't found, then it comes back thinking it was successful.

It works correctly if the filename begins with a letter OR the file is found OR you're loading a nonexistent font from an external source.

This may be related to issue #1.

[enhancement] Add missing bower.json.

Hey, maintainer(s) of JenniferSimonds/FontDetect!

We at VersionEye are working hard to keep up the quality of the bower's registry.

We just finished our initial analysis of the quality of the Bower.io registry:

7530 - registered packages, 224 of them doesnt exists anymore;

We analysed 7306 existing packages and 1070 of them don't have bower.json on the master branch ( that's where a Bower client pulls a data ).

Sadly, your library JenniferSimonds/FontDetect is one of them.

Can you spare 15 minutes to help us to make Bower better?

Just add a new file bower.json and change attributes.

{
  "name": "JenniferSimonds/FontDetect",
  "version": "1.0.0",
  "main": "path/to/main.css",
  "description": "please add it",
  "license": "Eclipse",
  "ignore": [
    ".jshintrc",
    "**/*.txt"
  ],
  "dependencies": {
    "<dependency_name>": "<semantic_version>",
    "<dependency_name>": "<Local_folder>",
    "<dependency_name>": "<package>"
  },
  "devDependencies": {
    "<test-framework-name>": "<version>"
  }
}

Read more about bower.json on the official spefication and nodejs semver library has great examples of proper versioning.

NB! Please validate your bower.json with jsonlint before commiting your updates.

Thank you!

Timo,
twitter: @versioneye
email: [email protected]
VersionEye - no more legacy software!

Does not work in Firefox due to innertext

Hi @JenniferSimonds

First off, thanks for the plugin. It's really good to have a tidy, neat solution to the font loading problem. :)

I've noticed the plugin does not work in Firefox, at least not for me. This seems to be because Firefox does not support setting element text using innerText (line 52).

An easy way to show this in the console is:

var span = document.createElement("span");
span.innerText = "foo";
console.log(span.outerHTML);

> "<span></span>"

Changing line 52 from span.innerText = aChars[eLang]; to span.textContent = aChars[eLang]; seems to solve the issue (although this won't work in IE8 or lower, but I think that's fine for most people).

I hope this helps!

Restructure directories & versioning

The directories need to be restructured and the version numbers need to conform to the Semantic Versioning spec. The current Master is only supposed to contain the most recent version of the files, so there's no reason to keep older versions inside the same branch.

  1. Directory structure:

    .git
    .gitignore
    README.MD
    LICENSE.TXT
    lib/
    fontdetect.js
    fontdetect.min.js

  2. Versioning: The API per se hasn't changed, but the location & name of the JS file has. So I think it needs to be named v3.0.0. See http://semver.org/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.