{-# LINE 2 "./Graphics/Rendering/Pango/Rendering.chs" #-}
module Graphics.Rendering.Pango.Rendering (
PangoItem,
pangoItemize,
pangoItemGetFontMetrics,
pangoItemGetFont,
pangoItemGetLanguage,
GlyphItem,
pangoShape,
glyphItemExtents,
glyphItemExtentsRange,
glyphItemIndexToX,
glyphItemXToIndex,
glyphItemGetLogicalWidths,
glyphItemSplit
) where
import System.Glib.FFI
import System.Glib.UTFString
import Graphics.Rendering.Pango.Structs ( pangoItemRawAnalysis, intToPu,
pangoItemRawGetOffset, pangoItemRawGetLength,
pangoItemGetFont, pangoItemGetLanguage)
import Graphics.Rendering.Pango.Types (PangoContext(..), Font(..))
import Graphics.Rendering.Pango.BasicTypes
{-# LINE 70 "./Graphics/Rendering/Pango/Rendering.chs" #-}
import Graphics.Rendering.Pango.Enums
{-# LINE 71 "./Graphics/Rendering/Pango/Rendering.chs" #-}
import Graphics.Rendering.Pango.Attributes
{-# LINE 72 "./Graphics/Rendering/Pango/Rendering.chs" #-}
import Graphics.Rendering.Pango.GlyphStorage
import System.Glib.GList
{-# LINE 74 "./Graphics/Rendering/Pango/Rendering.chs" #-}
{-# LINE 76 "./Graphics/Rendering/Pango/Rendering.chs" #-}
pangoItemize :: GlibString string => PangoContext -> string -> [PangoAttribute] -> IO [PangoItem]
pangoItemize pc str attrs = do
ps <- makeNewPangoString str
withAttrList ps attrs $ \alPtr -> do
glist <- withPangoString ps $ \_ l strPtr ->
(\(PangoContext arg1) arg2 arg3 arg4 arg5 arg6 -> withForeignPtr arg1 $ \argPtr1 ->pango_itemize argPtr1 arg2 arg3 arg4 arg5 arg6) pc strPtr 0 l alPtr nullPtr
piPtrs <- fromGList glist
piRaws <- mapM makeNewPangoItemRaw piPtrs
return (map (PangoItem ps) piRaws)
pangoItemGetFontMetrics :: PangoItem -> IO FontMetrics
pangoItemGetFontMetrics pi = do
font <- pangoItemGetFont pi
lang <- pangoItemGetLanguage pi
mPtr <- (\(Font arg1) (Language arg2) -> withForeignPtr arg1 $ \argPtr1 ->pango_font_get_metrics argPtr1 arg2) font lang
ascent <- pango_font_metrics_get_ascent mPtr
descent <- pango_font_metrics_get_descent mPtr
approximate_char_width <-
pango_font_metrics_get_approximate_char_width mPtr
approximate_digit_width <-
pango_font_metrics_get_approximate_digit_width mPtr
underline_position <-
pango_font_metrics_get_underline_position mPtr
underline_thickness <-
pango_font_metrics_get_underline_thickness mPtr
strikethrough_position <-
pango_font_metrics_get_strikethrough_position mPtr
strikethrough_thickness <-
pango_font_metrics_get_strikethrough_thickness mPtr
return (FontMetrics
(intToPu ascent)
(intToPu descent)
(intToPu approximate_char_width)
(intToPu approximate_digit_width)
(intToPu underline_position)
(intToPu underline_thickness)
(intToPu strikethrough_position)
(intToPu strikethrough_thickness)
)
pangoShape :: PangoItem -> IO GlyphItem
pangoShape pi@(PangoItem ps pir) =
withPangoString ps $ \_ _ strPtr -> withPangoItemRaw pir $ \pirPtr -> do
gsPtr <- pango_glyph_string_new
{-# LINE 142 "./Graphics/Rendering/Pango/Rendering.chs" #-}
gs <- makeNewGlyphStringRaw gsPtr
ofs <- pangoItemRawGetOffset pirPtr
len <- pangoItemRawGetLength pirPtr
(\arg1 arg2 arg3 (GlyphStringRaw arg4) -> withForeignPtr arg4 $ \argPtr4 ->pango_shape arg1 arg2 arg3 argPtr4) (strPtr `plusPtr` (fromIntegral ofs)) (fromIntegral len)
(pangoItemRawAnalysis pirPtr) gs
return (GlyphItem pi gs)
foreign import ccall unsafe "pango_itemize"
pango_itemize :: ((Ptr PangoContext) -> ((Ptr CChar) -> (CInt -> (CInt -> ((Ptr ()) -> ((Ptr ()) -> (IO (Ptr ()))))))))
foreign import ccall unsafe "pango_font_get_metrics"
pango_font_get_metrics :: ((Ptr Font) -> ((Ptr Language) -> (IO (Ptr ()))))
foreign import ccall unsafe "pango_font_metrics_get_ascent"
pango_font_metrics_get_ascent :: ((Ptr ()) -> (IO CInt))
foreign import ccall unsafe "pango_font_metrics_get_descent"
pango_font_metrics_get_descent :: ((Ptr ()) -> (IO CInt))
foreign import ccall unsafe "pango_font_metrics_get_approximate_char_width"
pango_font_metrics_get_approximate_char_width :: ((Ptr ()) -> (IO CInt))
foreign import ccall unsafe "pango_font_metrics_get_approximate_digit_width"
pango_font_metrics_get_approximate_digit_width :: ((Ptr ()) -> (IO CInt))
foreign import ccall unsafe "pango_font_metrics_get_underline_position"
pango_font_metrics_get_underline_position :: ((Ptr ()) -> (IO CInt))
foreign import ccall unsafe "pango_font_metrics_get_underline_thickness"
pango_font_metrics_get_underline_thickness :: ((Ptr ()) -> (IO CInt))
foreign import ccall unsafe "pango_font_metrics_get_strikethrough_position"
pango_font_metrics_get_strikethrough_position :: ((Ptr ()) -> (IO CInt))
foreign import ccall unsafe "pango_font_metrics_get_strikethrough_thickness"
pango_font_metrics_get_strikethrough_thickness :: ((Ptr ()) -> (IO CInt))
foreign import ccall unsafe "pango_glyph_string_new"
pango_glyph_string_new :: (IO (Ptr GlyphStringRaw))
foreign import ccall unsafe "pango_shape"
pango_shape :: ((Ptr CChar) -> (CInt -> ((Ptr ()) -> ((Ptr GlyphStringRaw) -> (IO ())))))