diff options
Diffstat (limited to 'exampleData/ruleSets/fontRules.json')
-rw-r--r-- | exampleData/ruleSets/fontRules.json | 56 |
1 files changed, 24 insertions, 32 deletions
diff --git a/exampleData/ruleSets/fontRules.json b/exampleData/ruleSets/fontRules.json index 4f6a2d3..6a725d1 100644 --- a/exampleData/ruleSets/fontRules.json +++ b/exampleData/ruleSets/fontRules.json @@ -1,42 +1,34 @@ /* * fontRules.json - * Author: Benjamin Jones <bjones@galois.com> * * Simple rules for checking that fonts (family/weight/size) of specific elements are * in a specific set. * - * Test using exampleData/basic/testFontRules.html */ -{ 'name': "Fonts (family/size/style) are in a specified set" -, 'description': "All fonts used on a page should be in a specificed set" +{ 'name': "Fonts" +, 'description': "Guidelines regarding site fonts" , 'rules': [ - { 'id': 1, 'name': "Font set" - , 'description': "Font (family/weight/size) should be in the set ..." - , 'rule': - function() { //---------------------------------------------- - var allowableFonts = { - "Verdana": { "bold": ["25", "22", "12", "10"] - , "normal": ["12", "11", "10"] } , - "Arial": { "bold": ["25", "22", "12", "10"] - , "normal": ["12", "11", "10"] } , - "Tahoma": { "bold": ["25", "22", "12", "10"] - , "normal": ["12", "11", "10"] } } - fiveui.query('body *').each( - function(i, elt) { - var family = $(elt).css('font-family'); - var sizeTxt = $(elt).css('font-size'); - var size = /([1-9][0-9])/.exec(sizeTxt)[0]; - var weight = $(elt).css('font-weight'); - console.log('Found font: ' + family + size + weight); - if (!(family in allowableFonts) || - !(weight in allowableFonts[family]) || - !(size in allowableFonts[family][weight])) { - report('Disallowed font: ' + - family + size + weight, $(elt)); - } - }); - } //--------------------------------------------------------- - }//============================================================== - ] + //--------------------------------------------------------- + { 'name': "Font properties check" + , 'description': "Verify that fonts (family, size, weight) are \"standard\"" + , 'rule': + function() { + var allow = { + "Verdana": { "bold": [25, 22, 12, 10] + , "normal": [12, 11, 10] }}; + fiveui.query('body p,:header').each( + function(i, elt) { + var font = fiveui.font.getFont($(elt)); + if (!fiveui.font.validate(allow, font)) { + report('non-standard font: ' + + font.family + ", " + + font.size + ", " + + font.weight, $(elt)); + } + }); + } + }//, + //--------------------------------------------------------- +] } |