From 70ba7db1cebbe6eea45bfdd1ffd99cb8893ef992 Mon Sep 17 00:00:00 2001 From: dettier Date: Wed, 25 Feb 2015 16:36:23 +0500 Subject: [PATCH] New options for specifying font weight and style --- index.htm | 13 +++++++++++++ jQuery-FontSpy.js | 5 +++++ styles/main.css | 8 ++++++++ 3 files changed, 26 insertions(+) diff --git a/index.htm b/index.htm index e7610f4..1eec81d 100644 --- a/index.htm +++ b/index.htm @@ -9,6 +9,7 @@ + @@ -24,6 +25,7 @@
Lobster font .
+
Arvo Bold Italic font .
BROKEN font .
@@ -41,6 +43,17 @@ } }); + fontSpy('Arvo', { + fontWeight : 700, + fontStyle : 'italic', + success: function() { + $('#arvo-result').html("loaded successfully"); + }, + failure: function() { + $('#arvo-result').html("failed to load"); + } + }); + fontSpy('BROKEN', { success: function() { $('#broken-result').html("loaded successfully"); diff --git a/jQuery-FontSpy.js b/jQuery-FontSpy.js index 6547492..cbea131 100644 --- a/jQuery-FontSpy.js +++ b/jQuery-FontSpy.js @@ -23,6 +23,8 @@ var defaults = { font: fontFamilyName, fontClass: fontFamilyName.toLowerCase().replace( /\s/g, '' ), + fontStyle: 'normal', + fontWeight: 'normal', success: function() {}, failure: function() {}, testFont: 'Courier New', @@ -41,8 +43,11 @@ .css('left', '-9999px') .css('visibility', 'hidden') .css('fontFamily', config.testFont) + .css('fontWeight', config.fontWeight) + .css('fontStyle', config.fontStyle) .css('fontSize', '250px'); + $body.append($tester); var fallbackFontWidth = $tester.outerWidth(); diff --git a/styles/main.css b/styles/main.css index d99a18e..f5aba11 100644 --- a/styles/main.css +++ b/styles/main.css @@ -60,6 +60,14 @@ p { color: red; } +.arvo #arvo-result { + color: green; +} + +.no-arvo #arvo-result { + color: red; +} + .broken #broken-result { color: green; }