Open Source

Class Index | File Index

Classes


Namespace fiveui.font


Defined in: prelude.js.

Namespace Summary
Constructor Attributes Constructor Name and Description
 

Utilities for dealing with fonts.

Method Summary
Method Attributes Method Name and Description
<static>  
fiveui.font.getFont(jElt)

Extracts the font-family, font-size (in px, as an int), and font-weight from a jQuery object.

<static>  
fiveui.font.validate(allow, font)

Validate a font property object extracted using fiveui.font.getFont().

Namespace Detail
fiveui.font

Utilities for dealing with fonts.

Method Detail
<static> {!Object} fiveui.font.getFont(jElt)

Extracts the font-family, font-size (in px, as an int), and font-weight from a jQuery object.

Parameters:
{!Object} jElt
A jQuery object to extract font info from
Throws:
{ParseError}
if the font size cannot be parsed
Returns:
{!Object} An object with properties: 'family', 'size', and 'weight'

<static> {!boolean} fiveui.font.validate(allow, font)

Validate a font property object extracted using fiveui.font.getFont().

The `allow` parameter should be an object whose top level property names are (partial) font family names (e.g. 'Verdana'). For each font family name there should be an object whose properties are font weights (e.g. 'bold'), and for each font weight there should be an array of allowable sizes (e.g. [10, 11, 12]).

The `font` parameter should be an object containing 'family', 'weight', and 'size' properties. These are returned by @see fiveui.font.getFont().

> allow = { 'Verdana': { 'bold': [10, 12], 'normal': [10, 12]}};
> font = { family: 'Verdana Arial sans-serif', size: "10", weight: "normal" };
> fiveui.font.validate(allow, font) -> true
Parameters:
{!Object} allow
Object containing allowable font sets (see description and examples)
{!Object} font
object to check
font.family
A partial font family name (e.g. 'Verdana')
font.weight
A font weight (e.g. 'bold')
font.size
A font size string (e.g. "10")
Returns:
{!boolean}