Giter Site home page Giter Site logo

1j01 / font-detective Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gabriel/font-detect-js

9.0 3.0 1.0 255 KB

Font detection using Javascript and... formerly Flash

Home Page: https://1j01.github.io/font-detective/

License: MIT License

CoffeeScript 36.28% HTML 18.74% JavaScript 44.98%
font fonts font-detection detection system-fonts available-fonts library javascript typeface typefaces javascript-library

font-detective's Introduction

Font Detective

Note: v1.x supported getting a full list of fonts with Flash; v2.x drops support for Flash.

Detects available system fonts with JavaScript, from a list of common fonts.

See a demo. You can edit the sample text.

<script src="lib/font-detective.js"></script>
<script>
	FontDetective.each(function(font){
		$("<option>")
			.val(font)
			.text(font.name)
			.appendTo("select");
		
		font.name; // e.g. 'Arial'
		font.toString(); // e.g. '"Arial"'
	});
	
	FontDetective.all(function(fonts){
		console.log(fonts);
	});
</script>

Documentation

FontDetective.each(callback)

  • Calls back with a Font every time a font is detected and tested
  • Fonts are tested in chunks to avoid totally freezing the page

FontDetective.all(callback)

  • Calls back with an Array of Fonts when all fonts are detected and tested

FontDetective.preload()

  • Starts detecting fonts immediately
  • Not needed if you're going to call all or each right away

FontDetective.Font

  • Fonts are returned as instances of this class
  • The font.name property can be used to display the name of the font
  • The font can be used anywhere you'd use a font-family (e.g. div.style.fontFamily = font)

Node.js

For detecting fonts from Node.js, see font-manager

License

MIT-licensed, see LICENSE for details

font-detective's People

Contributors

1j01 avatar beanmilk avatar gabriel avatar loadedsith avatar sturob avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

wsimo

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.