blank-canvas-0.6: 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 () Source

Sets the text context's font properties.

Examples

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 Source

A data type that can represent a browser font.

Methods

jsCanvasFont :: a -> Builder Source

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

font

data Font Source

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.

defFont :: [FontFamily] -> Font Source

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 Source

Shorthand for CaptionFont.

icon :: Font Source

Shorthand for IconFont.

menu :: Font Source

Shorthand for MenuFont.

font-style

data FontStyle Source

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.

font-variant

font-weight

data FontWeight Source

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.

bold :: FontWeight Source

Shorthand for BoldWeight.

font-size

xSmall :: FontSize Source

Shorthand for XSmallSize.

small :: FontSize Source

Shorthand for SmallSize.

medium :: FontSize Source

Shorthand for MediumSize.

large :: FontSize Source

Shorthand for LargeSize.

xLarge :: FontSize Source

Shorthand for XLargeSize.

larger :: FontSize Source

Shorthand for LargerSize.

line-height

font-family

data FontFamily Source

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 Source 
Ord FontFamily Source 
Read FontFamily Source 
Show FontFamily Source 
IsString FontFamily Source 
TextShow FontFamily Source 
IsString [FontFamily] Source

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.

Normal values

class Default a => NormalProperty a where Source

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

Minimal complete definition

Nothing

Methods

normal :: a Source

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

(defFont [sansSerif]) { lineHeight = normal }

Lengths

data Length Source

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

Constructors

Em

The height of the current font.

Fields

runLength :: Double
 
Ex

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

Fields

runLength :: Double
 
Ch

The width of the character 0 in the current font.

Fields

runLength :: Double
 
Rem

The height of the font relative to the root element.

Fields

runLength :: Double
 
Vh

One percent of the height of the viewport.

Fields

runLength :: Double
 
Vw

One percent of the width of the viewport.

Fields

runLength :: Double
 
Vmin

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

Fields

runLength :: Double
 
Vmax

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

Fields

runLength :: Double
 
Px

One device pixel (dot) of the display.

Fields

runLength :: Double
 
Mm

One millimeter.

Fields

runLength :: Double
 
Cm

One centimeter (10 millimeters).

Fields

runLength :: Double
 
In

One inch (~2.54 centimeters).

Fields

runLength :: Double
 
Pt

One point (1/72 inches).

Fields

runLength :: Double
 
Pc

One pica (12 points).

Fields

runLength :: Double
 

class LengthProperty a where Source

Designates CSS properties that can consist of a Length.

Methods

fromLength :: Length -> a Source

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

Constructs a LengthProperty value with Em units.

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

Constructs a LengthProperty value with Ex units.

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

Constructs a LengthProperty value with Ch units.

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

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

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

Constructs a LengthProperty value with Vh units.

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

Constructs a LengthProperty value with Vw units.

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

Constructs a LengthProperty value with Em units.

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

Constructs a LengthProperty value with Vmax units.

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

Constructs a LengthProperty value with Px units.

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

Constructs a LengthProperty value with Mm units.

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

Constructs a LengthProperty value with Cm units.

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

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

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

Constructs a LengthProperty value with Pt units.

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

Constructs a LengthProperty value with Pc units.

Percentages

class PercentageProperty a where Source

Designates CSS properties that can consist of a Percentage.

Methods

percent :: Percentage -> a Source

Create a CSS property value from a Percentage.