Skip to content

Commit

Permalink
fontSize convenience funtions
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyrosenbluth committed Mar 25, 2014
1 parent c76bec9 commit b421dd1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Diagrams/TwoD.hs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ module Diagrams.TwoD

-- * Text
, text, topLeftText, alignedText, baselineText
, font, fontSize, italic, oblique, bold
, font, setFontSize, italic, oblique, bold
, fontSize, fontSizeO, fontSizeL, fontSizeN

-- * Images
, Image, image
Expand Down
23 changes: 20 additions & 3 deletions src/Diagrams/TwoD/Text.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ module Diagrams.TwoD.Text (
-- ** Font family
, Font(..), getFont, font
-- ** Font size
, FontSize(..), getFontSize, fontSize, fontSizeA
, FontSize(..), getFontSize, setFontSize, fontSizeA
, fontSize, fontSizeN, fontSizeO, fontSizeL
-- ** Font slant
, FontSlant(..), FontSlantA, getFontSlant, fontSlant, italic, oblique
-- ** Font weight
Expand Down Expand Up @@ -181,8 +182,24 @@ getFontSize (FontSize (Last s)) = s
-- | Set the font size, that is, the size of the font's em-square as
-- measured within the current local vector space. The default size
-- is @1@.
fontSize :: (HasStyle a, V a ~ R2) => Measure Double -> a -> a
fontSize = applyGTAttr . FontSize . Last
setFontSize :: (HasStyle a, V a ~ R2) => Measure Double -> a -> a
setFontSize = applyGTAttr . FontSize . Last

-- | A convenient synonym for 'setFontSize (Global w)'.
fontSize :: (HasStyle a, V a ~ R2) => Double -> a -> a
fontSize w = setFontSize (Global w)

-- | A convenient synonym for 'setFontSize (Normalized w)'.
fontSizeN :: (HasStyle a, V a ~ R2) => Double -> a -> a
fontSizeN w = setFontSize (Normalized w)

-- | A convenient synonym for 'setFontSize (Output w)'.
fontSizeO :: (HasStyle a, V a ~ R2) => Double -> a -> a
fontSizeO w = setFontSize (Output w)

-- | A convenient sysnonym for 'setFontSize (Local w)'.
fontSizeL :: (HasStyle a, V a ~ R2) => Double -> a -> a
fontSizeL w = setFontSize (Local w)

-- | Apply a 'FontSize' attribute.
fontSizeA :: (HasStyle a, V a ~ R2) => FontSize -> a -> a
Expand Down

1 comment on commit b421dd1

@jeffreyrosenbluth
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Text needs work -- not correct yet !!!
Problem that both Text and FontSize are Transformable.
We need to figure out what to do here, we want text to be Transformable so that we can rotate it for example.
We want fontSize to be a Measure in which Local is transformable by default.

Please sign in to comment.