Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<script src="jQuery-FontSpy.js"></script>
<link rel="stylesheet" type="text/css" href="styles/main.css" />
<link href='http://fonts.googleapis.com/css?family=Arvo:400,700italic' rel='stylesheet' type='text/css'>

</head>
<body>
Expand All @@ -24,6 +25,7 @@
<hr/>
<main id="main">
<div>Lobster font <span id="lobster-result"></span>.</div>
<div>Arvo Bold Italic font <span id="arvo-result"></span>.</div>
<div>BROKEN font <span id="broken-result"></span>.</div>
</main>

Expand All @@ -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");
Expand Down
5 changes: 5 additions & 0 deletions jQuery-FontSpy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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();
Expand Down
8 changes: 8 additions & 0 deletions styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ p {
color: red;
}

.arvo #arvo-result {
color: green;
}

.no-arvo #arvo-result {
color: red;
}

.broken #broken-result {
color: green;
}
Expand Down