@@ 1,4 1,4 @@
--- NOTE: Untested!
+{-# LANGUAGE OverloadedStrings #-}
module Graphics.Text.Font.Choose.FontSet where
import Graphics.Text.Font.Choose.Pattern
@@ 11,6 11,9 @@ import Foreign.Marshal.Array (peekArray)
import Control.Monad (forM)
import Control.Exception (bracket)
+-- For CSS bindings
+import Stylist.Parse (StyleSheet(..), parseProperties)
+
type FontSet = [Pattern]
------
@@ 56,3 59,18 @@ foreign import ccall "get_fontSet_fonts" get_fontSet_fonts :: FontSet_ -> IO (Pt
thawFontSet_ :: IO FontSet_ -> IO FontSet
thawFontSet_ cb = bracket (throwNull <$> cb) fcFontSetDestroy thawFontSet
+
+------
+--- CSS Bindings
+------
+
+data FontFaceParser a = FontFaceParser { cssFonts :: FontSet, cssInner :: a}
+
+instance StyleSheet a => StyleSheet (FontFaceParser a) where
+ setPriorities v (FontFaceParser x self) = FontFaceParser x $ setPriorities v self
+ addRule (FontFaceParser x self) rule = FontFaceParser x $ addRule self rule
+
+ addAtRule self "font-face" toks =
+ let (props, toks') = parseProperties toks in (self, toks')
+ addAtRule (FontFaceParser x self) key toks =
+ let (a, b) = addAtRule self key toks in (FontFaceParser x a, b)