~alcinnz/fontconfig-pure

6e336e5ee4797190f83be2b381234980c7b680f5 — Adrian Cochrane 2 years ago 046b068
Define skeleton for parsing @font-face.
1 files changed, 19 insertions(+), 1 deletions(-)

M Graphics/Text/Font/Choose/FontSet.hs
M Graphics/Text/Font/Choose/FontSet.hs => Graphics/Text/Font/Choose/FontSet.hs +19 -1
@@ 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)