blank-canvas-0.6.3: HTML5 Canvas Graphics Library

Copyright(C) 2014-2015 The University of Kansas
LicenseBSD-style (see the file LICENSE)
MaintainerAndy Gill
StabilityBeta
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

Graphics.Blank.Font

Contents

Description

This module exposes an overloaded version of the font function that can accept a Font ADT argument. This may be of interest if you desire stronger type safety than Text-based fonts provide.

Note that this module's font function conflicts with font from Graphics.Blank. Make sure to hide font from Graphics.Blank if you use font from this module.

Synopsis

Overloaded font

font :: CanvasFont canvasFont => canvasFont -> Canvas () #

Sets the text context's font properties.

Examples

Expand
font (defFont "Gill Sans Extrabold") { fontSize = 40 # pt }
font (defFont sansSerif) { fontSize = 80 # percent }
font (defFont serif) {
    fontWeight = bold
  , fontStyle  = italic
  , fontSize   = large
}

class CanvasFont a where #

A data type that can represent a browser font.

Minimal complete definition

jsCanvasFont

Methods

jsCanvasFont :: a -> Builder #

Convert a value into a JavaScript string representing a font value.

Instances
CanvasFont Text # 
Instance details

Defined in Graphics.Blank.Types.Font

Methods

jsCanvasFont :: Text -> Builder #

CanvasFont Font # 
Instance details

Defined in Graphics.Blank.Types.Font

Methods

jsCanvasFont :: Font -> Builder #

font

data Font #

A CSS-style font data type.

Constructors

FontProperties

A font specified by its individual longhand properties.

CaptionFont

The font used for captioned controls (e.g., buttons, drop-downs, etc.)

IconFont

The font used to label icons.

MenuFont

The font used in menus (e.g., dropdown menus and menu lists).

MessageBoxFont

The font used in dialog boxes.

SmallCaptionFont

The font used for labeling small controls.

StatusBarFont

The font used in window status bars.

Instances
Eq Font # 
Instance details

Defined in Graphics.Blank.Types.Font

Methods

(==) :: Font -> Font -> Bool #

(/=) :: Font -> Font -> Bool #

Ord Font # 
Instance details

Defined in Graphics.Blank.Types.Font

Methods

compare :: Font -> Font -> Ordering #

(<) :: Font -> Font -> Bool #

(<=) :: Font -> Font -> Bool #

(>) :: Font -> Font -> Bool #

(>=) :: Font -> Font -> Bool #

max :: Font -> Font -> Font #

min :: Font -> Font -> Font #

Read Font # 
Instance details

Defined in Graphics.Blank.Types.Font

Show Font # 
Instance details

Defined in Graphics.Blank.Types.Font

Methods

showsPrec :: Int -> Font -> ShowS #

show :: Font -> String #

showList :: [Font] -> ShowS #

IsString Font # 
Instance details

Defined in Graphics.Blank.Types.Font

Methods

fromString :: String -> Font #

TextShow Font # 
Instance details

Defined in Graphics.Blank.Types.Font

JSArg Font # 
Instance details

Defined in Graphics.Blank.Types.Font

Methods

showbJS :: Font -> Builder #

CanvasFont Font # 
Instance details

Defined in Graphics.Blank.Types.Font

Methods

jsCanvasFont :: Font -> Builder #

defFont :: [FontFamily] -> Font #

Creates a new font from the FontFamily list, using the Default instances for the other five longhand properties. If you only wish to change certain properties and leave the others alone, this provides a convenient mechanism for doing so:

(defFont ["Gill Sans Extrabold", sansSerif]) {
    fontStyle  = italic
  , fontSize   = 12 # px
  , lineHeight = 14 # px
}

caption :: Font #

Shorthand for CaptionFont.

icon :: Font #

Shorthand for IconFont.

menu :: Font #

Shorthand for MenuFont.

messageBox :: Font #

Shorthand for MessageBoxFont.

statusBar :: Font #

Shorthand for StatusBarFont.

font-style

data FontStyle #

Specifies if a Font is italic or oblique.

Constructors

NormalStyle

Selects a font classified as normal (default).

ItalicStyle

Selects a font that is labeled italic, or if one is not available, one labeled oblique.

ObliqueStyle

Selects a font that is labeled oblique.

Instances
Bounded FontStyle # 
Instance details

Defined in Graphics.Blank.Types.Font

Enum FontStyle # 
Instance details

Defined in Graphics.Blank.Types.Font

Eq FontStyle # 
Instance details

Defined in Graphics.Blank.Types.Font

Ord FontStyle # 
Instance details

Defined in Graphics.Blank.Types.Font

Read FontStyle # 
Instance details

Defined in Graphics.Blank.Types.Font

Show FontStyle # 
Instance details

Defined in Graphics.Blank.Types.Font

Ix FontStyle # 
Instance details

Defined in Graphics.Blank.Types.Font

IsString FontStyle # 
Instance details

Defined in Graphics.Blank.Types.Font

Default FontStyle # 
Instance details

Defined in Graphics.Blank.Types.Font

Methods

def :: FontStyle #

TextShow FontStyle # 
Instance details

Defined in Graphics.Blank.Types.Font

NormalProperty FontStyle # 
Instance details

Defined in Graphics.Blank.Types.Font

Methods

normal :: FontStyle #

italic :: FontStyle #

Shorthand for ItalicStyle.

oblique :: FontStyle #

Shorthand for ObliqueStyle.

font-variant

data FontVariant #

Specifies the face of a Font.

Constructors

NormalVariant

A normal font face (default).

SmallCapsVariant

A font face with small capital letters for lowercase characters.

Instances
Bounded FontVariant # 
Instance details

Defined in Graphics.Blank.Types.Font

Enum FontVariant # 
Instance details

Defined in Graphics.Blank.Types.Font

Eq FontVariant # 
Instance details

Defined in Graphics.Blank.Types.Font

Ord FontVariant # 
Instance details

Defined in Graphics.Blank.Types.Font

Read FontVariant # 
Instance details

Defined in Graphics.Blank.Types.Font

Show FontVariant # 
Instance details

Defined in Graphics.Blank.Types.Font

Ix FontVariant # 
Instance details

Defined in Graphics.Blank.Types.Font

IsString FontVariant # 
Instance details

Defined in Graphics.Blank.Types.Font

Default FontVariant # 
Instance details

Defined in Graphics.Blank.Types.Font

Methods

def :: FontVariant #

TextShow FontVariant # 
Instance details

Defined in Graphics.Blank.Types.Font

NormalProperty FontVariant # 
Instance details

Defined in Graphics.Blank.Types.Font

Methods

normal :: FontVariant #

font-weight

data FontWeight #

Specifies the boldness of a Font. Note that FontWeight is an instance of Num so that the nine numeric weights can be used directly. For example:

(defFont [sansSerif]) { fontWeight = 900 }

Attempting to use a numeric weight other than the nine given will result in a runtime error.

Instances
Bounded FontWeight # 
Instance details

Defined in Graphics.Blank.Types.Font

Enum FontWeight # 
Instance details

Defined in Graphics.Blank.Types.Font

Eq FontWeight # 
Instance details

Defined in Graphics.Blank.Types.Font

Num FontWeight # 
Instance details

Defined in Graphics.Blank.Types.Font

Ord FontWeight # 
Instance details

Defined in Graphics.Blank.Types.Font

Read FontWeight # 
Instance details

Defined in Graphics.Blank.Types.Font

Show FontWeight # 
Instance details

Defined in Graphics.Blank.Types.Font

Ix FontWeight # 
Instance details

Defined in Graphics.Blank.Types.Font

IsString FontWeight # 
Instance details

Defined in Graphics.Blank.Types.Font

Default FontWeight # 
Instance details

Defined in Graphics.Blank.Types.Font

Methods

def :: FontWeight #

TextShow FontWeight # 
Instance details

Defined in Graphics.Blank.Types.Font

NormalProperty FontWeight # 
Instance details

Defined in Graphics.Blank.Types.Font

Methods

normal :: FontWeight #

bold :: FontWeight #

Shorthand for BoldWeight.

bolder :: FontWeight #

Shorthand for BolderWeight.

font-size

data FontSize #

The desired height of Font glyphs.

Examples

Expand
(defFont [sansSerif]) { fontSize = xxSmall }
(defFont [sansSerif]) { fontSize = 30 # pt }
(defFont [sansSerif]) { fontSize = 50 # percent }
Instances
Eq FontSize # 
Instance details

Defined in Graphics.Blank.Types.Font

Ord FontSize # 
Instance details

Defined in Graphics.Blank.Types.Font

Read FontSize # 
Instance details

Defined in Graphics.Blank.Types.Font

Show FontSize # 
Instance details

Defined in Graphics.Blank.Types.Font

IsString FontSize # 
Instance details

Defined in Graphics.Blank.Types.Font

Default FontSize # 
Instance details

Defined in Graphics.Blank.Types.Font

Methods

def :: FontSize #

TextShow FontSize # 
Instance details

Defined in Graphics.Blank.Types.Font

PercentageProperty FontSize # 
Instance details

Defined in Graphics.Blank.Types.Font

LengthProperty FontSize # 
Instance details

Defined in Graphics.Blank.Types.Font

xxSmall :: FontSize #

Shorthand for XXSmallSize.

xSmall :: FontSize #

Shorthand for XSmallSize.

small :: FontSize #

Shorthand for SmallSize.

medium :: FontSize #

Shorthand for MediumSize.

large :: FontSize #

Shorthand for LargeSize.

xLarge :: FontSize #

Shorthand for XLargeSize.

xxLarge :: FontSize #

Shorthand for XXLargeSize.

larger :: FontSize #

Shorthand for LargerSize.

smaller :: FontSize #

Shorthand for SmallerSize.

line-height

data LineHeight #

The height of the line boxes in a Font.

Examples

Expand
(defFont [sansSerif]) { lineHeight = normal }
(defFont [sansSerif]) { lineHeight = 50 }
(defFont [sansSerif]) { lineHeight = 30 # em }
(defFont [sansSerif]) { lineHeight = 70 # percent }
Instances
Eq LineHeight # 
Instance details

Defined in Graphics.Blank.Types.Font

Fractional LineHeight # 
Instance details

Defined in Graphics.Blank.Types.Font

Num LineHeight # 
Instance details

Defined in Graphics.Blank.Types.Font

Ord LineHeight # 
Instance details

Defined in Graphics.Blank.Types.Font

Read LineHeight # 
Instance details

Defined in Graphics.Blank.Types.Font

Show LineHeight # 
Instance details

Defined in Graphics.Blank.Types.Font

IsString LineHeight # 
Instance details

Defined in Graphics.Blank.Types.Font

Default LineHeight # 
Instance details

Defined in Graphics.Blank.Types.Font

Methods

def :: LineHeight #

TextShow LineHeight # 
Instance details

Defined in Graphics.Blank.Types.Font

PercentageProperty LineHeight # 
Instance details

Defined in Graphics.Blank.Types.Font

LengthProperty LineHeight # 
Instance details

Defined in Graphics.Blank.Types.Font

NormalProperty LineHeight # 
Instance details

Defined in Graphics.Blank.Types.Font

Methods

normal :: LineHeight #

font-family

data FontFamily #

The name of a Font family. Note that both FontFamily and [FontFamily] are instances of IsString, so it is possible to produce FontFamily values in several different ways. For example, these are all of type FontFamily:

FontFamilyName "Gill Sans Extrabold"
"Gill Sans Extrabold" :: FontFamily
serif
"serif" :: FontFamily

These are all of type [FontFamily]:

[FontFamilyName "Helvetica", serif]
["Helvetica", "serif"] :: [FontFamily]
"Helvetica, serif" :: [FontFamily]

Constructors

FontFamilyName Text

The name of a custom font family.

SerifFamily

A generic font family where glyphs have serifed endings.

SansSerifFamily

A generic font family where glyphs do not have serifed endings.

MonospaceFamily

A generic font family where all glyphs have the same fixed width.

CursiveFamily

A generic font family with cursive glyphs.

FantasyFamily

A generic font family where glyphs have decorative, playful representations.

Instances
Eq FontFamily # 
Instance details

Defined in Graphics.Blank.Types.Font

Ord FontFamily # 
Instance details

Defined in Graphics.Blank.Types.Font

Read FontFamily # 
Instance details

Defined in Graphics.Blank.Types.Font

Show FontFamily # 
Instance details

Defined in Graphics.Blank.Types.Font

IsString FontFamily # 
Instance details

Defined in Graphics.Blank.Types.Font

TextShow FontFamily # 
Instance details

Defined in Graphics.Blank.Types.Font

IsString [FontFamily] #

There are two separate IsString instances for FontFamily so that single font families and lists of font families alike can be converted from string literals.

Instance details

Defined in Graphics.Blank.Types.Font

Methods

fromString :: String -> [FontFamily] #

serif :: FontFamily #

Shorthand for SerifFamily.

Normal values

class Default a => NormalProperty a where #

A convenient way to use the Default normal value for several Font longhand properties.

Methods

normal :: a #

The default value for a CSS property. For example, it can be used like this:

(defFont [sansSerif]) { lineHeight = normal }
Instances
NormalProperty LineHeight # 
Instance details

Defined in Graphics.Blank.Types.Font

Methods

normal :: LineHeight #

NormalProperty FontWeight # 
Instance details

Defined in Graphics.Blank.Types.Font

Methods

normal :: FontWeight #

NormalProperty FontVariant # 
Instance details

Defined in Graphics.Blank.Types.Font

Methods

normal :: FontVariant #

NormalProperty FontStyle # 
Instance details

Defined in Graphics.Blank.Types.Font

Methods

normal :: FontStyle #

Lengths

data Length #

Denotes CSS distance measurements, especially in the context of Fonts.

Constructors

Em

The height of the current font.

Fields

Ex

The height of the character x (x-height) in the current font.

Fields

Ch

The width of the character 0 in the current font.

Fields

Rem

The height of the font relative to the root element.

Fields

Vh

One percent of the height of the viewport.

Fields

Vw

One percent of the width of the viewport.

Fields

Vmin

One percent of the minimum of the viewport height and width.

Fields

Vmax

One percent of the maximum of the viewport height and width.

Fields

Px

One device pixel (dot) of the display.

Fields

Mm

One millimeter.

Fields

Cm

One centimeter (10 millimeters).

Fields

In

One inch (~2.54 centimeters).

Fields

Pt

One point (1/72 inches).

Fields

Pc

One pica (12 points).

Fields

Instances
Eq Length # 
Instance details

Defined in Graphics.Blank.Types.CSS

Methods

(==) :: Length -> Length -> Bool #

(/=) :: Length -> Length -> Bool #

Ord Length # 
Instance details

Defined in Graphics.Blank.Types.CSS

Read Length # 
Instance details

Defined in Graphics.Blank.Types.CSS

Show Length # 
Instance details

Defined in Graphics.Blank.Types.CSS

IsString Length # 
Instance details

Defined in Graphics.Blank.Types.CSS

Methods

fromString :: String -> Length #

TextShow Length # 
Instance details

Defined in Graphics.Blank.Types.CSS

LengthProperty Length # 
Instance details

Defined in Graphics.Blank.Types.CSS

Methods

fromLength :: Length -> Length #

class LengthProperty a where #

Designates CSS properties that can consist of a Length.

Minimal complete definition

fromLength

Methods

fromLength :: Length -> a #

Instances
LengthProperty Length # 
Instance details

Defined in Graphics.Blank.Types.CSS

Methods

fromLength :: Length -> Length #

LengthProperty LineHeight # 
Instance details

Defined in Graphics.Blank.Types.Font

LengthProperty FontSize # 
Instance details

Defined in Graphics.Blank.Types.Font

em :: LengthProperty a => Double -> a #

Constructs a LengthProperty value with Em units.

ex :: LengthProperty a => Double -> a #

Constructs a LengthProperty value with Ex units.

ch :: LengthProperty a => Double -> a #

Constructs a LengthProperty value with Ch units.

rem_ :: LengthProperty a => Double -> a #

Constructs a LengthProperty value with Rem units. rem_ has an underscore to distinguish it from rem.

vh :: LengthProperty a => Double -> a #

Constructs a LengthProperty value with Vh units.

vw :: LengthProperty a => Double -> a #

Constructs a LengthProperty value with Vw units.

vmin :: LengthProperty a => Double -> a #

Constructs a LengthProperty value with Em units.

vmax :: LengthProperty a => Double -> a #

Constructs a LengthProperty value with Vmax units.

px :: LengthProperty a => Double -> a #

Constructs a LengthProperty value with Px units.

mm :: LengthProperty a => Double -> a #

Constructs a LengthProperty value with Mm units.

cm :: LengthProperty a => Double -> a #

Constructs a LengthProperty value with Cm units.

in_ :: LengthProperty a => Double -> a #

Constructs a LengthProperty value with Im units. This function has an underscore to distinguish it from the Haskell keyword.

pt :: LengthProperty a => Double -> a #

Constructs a LengthProperty value with Pt units.

pc :: LengthProperty a => Double -> a #

Constructs a LengthProperty value with Pc units.

Percentages

class PercentageProperty a where #

Designates CSS properties that can consist of a Percentage.

Minimal complete definition

percent

Methods

percent :: Percentage -> a #

Create a CSS property value from a Percentage.