PageSourceSearch

https://ds-ch.org/modules/sejin7940_canvas/tpl/js/jquery.font.js?t=1663940243

js ds-ch.org collected 2026-10-07 03:56:24 UTC 1,785 bytes, 48 lines download raw bytes

1/*!
2* jquery.font
3* http://www.beseku.com/2009/04/22/detecting-installed-fonts-with-jquery/
4*
5* Copyright (c) 2009 Ben sekulowicz-Barclay
6*
7* Date: 2009-05-06 (Wed, 06 May 2009)
8* Revision: 1.1
9*/
10
11jQuery.font = {
12	
13	test: function(user_family, base_family, user_weight, base_weight) {
14		
15		// Define our defaults
16		var base = {family:'monospace', weight:'400'};
17		var user = {family:'monospace', weight:'400'};
18		
19		// Overwrite our defaults with user supplied values, if required...		
20		base.family = (typeof(base_family) != 'undefined')? base_family: base.family;
21		base.weight = (typeof(base_weight) != 'undefined')? base_weight: base.weight;
22		user.family = (typeof(user_family) != 'undefined')? user_family: user.family;
23		user.weight = (typeof(user_weight) != 'undefined')? user_weight: user.weight;	
24		
25		// Insert our test paragraph
26		$('body').prepend('<p id="jQuery-Font-Test" style="font-family:' + base.family + ';font-size:72px;font-weight:' + base.weight + ';height:auto;left:-9999px;position:absolute;top:-9999px;visibility:hidden;width:auto;">The quick brown fox jumps over a lazy dog.</p>');
27		
28		// Get our test paragraph's dimensions
29		var baseX = $('p#jQuery-Font-Test').width();
30		var baseY = $('p#jQuery-Font-Test').height();
31		
32		// Update our test paragraph with the user supplied family.weight
33		$('p#jQuery-Font-Test').css({
34			'font-family': (user.family + ',' + base.family),
35			'font-weight': user.weight
36		});
37		
38		// Get our test paragraph's dimensions, (again)
39		var userX = $('p#jQuery-Font-Test').width();
40		var userY = $('p#jQuery-Font-Test').height();
41		
42		// Remove our test paragraph
43		$('p#jQuery-Font-Test').remove();
44		
45		// If the dimensions change, the font has changed(!)
46		return(((userY != baseY) || (userX != baseX))? true: false);
47	}
48};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.