{-# LINE 2 "./Graphics/Rendering/Pango/Context.chs" #-}
-- -*-haskell-*-
-- GIMP Toolkit (GTK) - text layout functions Context
--
-- Author : Axel Simon
--
-- Created: 16 October 2005
--
-- Copyright (C) 1999-2005 Axel Simon
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License, or (at your option) any later version.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
--
--
-- |
-- Maintainer : gtk2hs-users@lists.sourceforge.net
-- Stability : provisional
-- Portability : portable (depends on GHC)
--
-- This module defines 'PangoContext's,
-- an environment that provides information on available fonts,
-- internationalization and output capabilities of the medium. Given
-- such a context, text can be rendered into strings of glyphs (see
-- 'Graphics.Rendering.Pango.Rendering') or, at a more abstract level, using
-- layouts (see 'Graphics.Rendering.Pango.Layout.Layout').
--
-- * A 'PangoContext' is a prerequisite for all text rendering functions.
-- A context can be created from scratch or, more conveniently, by using
-- default settings that are already used in the application. When text
-- is rendered through Gdk, use
-- 'Graphics.UI.Gtk.Abstract.Widget.widgetCreatePangoContext', if you use
-- the Cairo rendering engine, a new context can be acquired using
-- 'Graphics.Rendering.Pango.Cairo.cairoCreateContext'.
--
-- * The properties of a 'PangoContext' can be changed which, in turn, has
-- an effect on how text is rendered. To reflect such a change in the
-- rendered text, call 'Graphics.Rendering.Pango.Layout.layoutContextChanged'.
--
module Graphics.Rendering.Pango.Context (
-- * Types and Methods for 'PangoContext's
  PangoContext,
  PangoContextClass,
  contextListFamilies,
-- contextLoadFont,
-- contextLoadFontSet,
  contextGetMetrics,
  contextSetFontDescription,
  contextGetFontDescription,
  Language,
  emptyLanguage,
  languageFromString,
  contextSetLanguage,
  contextGetLanguage,
  contextSetTextDir,
  contextGetTextDir,

  contextSetTextGravity,
  contextGetTextGravity,
  contextSetTextGravityHint,
  contextGetTextGravityHint,


  contextGetMatrix,
  contextSetMatrix,

  ) where

import Control.Monad (liftM)

import System.Glib.FFI
import Graphics.Rendering.Pango.Enums
import Graphics.Rendering.Pango.Structs
import System.Glib.GObject (makeNewGObject)
import Graphics.Rendering.Pango.Types
{-# LINE 82 "./Graphics/Rendering/Pango/Context.chs" #-}
import Graphics.Rendering.Pango.BasicTypes
{-# LINE 83 "./Graphics/Rendering/Pango/Context.chs" #-}
import Graphics.Rendering.Pango.Enums ( FontMetrics(..) )
import Graphics.Rendering.Cairo.Matrix
{-# LINE 85 "./Graphics/Rendering/Pango/Context.chs" #-}



{-# LINE 88 "./Graphics/Rendering/Pango/Context.chs" #-}


-- | Retrieve a list of all available font families.
--
-- * A font family is the name of the font without further attributes
-- like slant, variant or size.
--
contextListFamilies :: PangoContext -> IO [FontFamily]
contextListFamilies :: PangoContext -> IO [FontFamily]
contextListFamilies PangoContext
c = (Ptr CInt -> IO [FontFamily]) -> IO [FontFamily]
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr CInt -> IO [FontFamily]) -> IO [FontFamily])
-> (Ptr CInt -> IO [FontFamily]) -> IO [FontFamily]
forall a b. (a -> b) -> a -> b
$ \Ptr CInt
sizePtr -> (Ptr (Ptr FontFamily) -> IO [FontFamily]) -> IO [FontFamily]
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr (Ptr FontFamily) -> IO [FontFamily]) -> IO [FontFamily])
-> (Ptr (Ptr FontFamily) -> IO [FontFamily]) -> IO [FontFamily]
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr FontFamily)
ptrPtr -> do
  (\(PangoContext ForeignPtr PangoContext
arg1) Ptr (Ptr FontFamily)
arg2 Ptr CInt
arg3 -> ForeignPtr PangoContext -> (Ptr PangoContext -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoContext
arg1 ((Ptr PangoContext -> IO ()) -> IO ())
-> (Ptr PangoContext -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoContext
argPtr1 ->Ptr PangoContext -> Ptr (Ptr FontFamily) -> Ptr CInt -> IO ()
pango_context_list_families Ptr PangoContext
argPtr1 Ptr (Ptr FontFamily)
arg2 Ptr CInt
arg3) PangoContext
c Ptr (Ptr FontFamily)
ptrPtr Ptr CInt
sizePtr
  Ptr FontFamily
ptr <- Ptr (Ptr FontFamily) -> IO (Ptr FontFamily)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr FontFamily)
ptrPtr
  CInt
size <- Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
sizePtr
  -- c2hs gets FontFamily*** wrong as FontFamily**, therefore the cast
  [Ptr FontFamily]
familyPtrs <- Int -> Ptr (Ptr FontFamily) -> IO [Ptr FontFamily]
forall a. Storable a => Int -> Ptr a -> IO [a]
peekArray (CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
size) (Ptr FontFamily -> Ptr (Ptr FontFamily)
forall a b. Ptr a -> Ptr b
castPtr Ptr FontFamily
ptr)
  [FontFamily]
fams <- (Ptr FontFamily -> IO FontFamily)
-> [Ptr FontFamily] -> IO [FontFamily]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((ForeignPtr FontFamily -> FontFamily, FinalizerPtr FontFamily)
-> IO (Ptr FontFamily) -> IO FontFamily
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
makeNewGObject (ForeignPtr FontFamily -> FontFamily, FinalizerPtr FontFamily)
forall {a}. (ForeignPtr FontFamily -> FontFamily, FinalizerPtr a)
mkFontFamily (IO (Ptr FontFamily) -> IO FontFamily)
-> (Ptr FontFamily -> IO (Ptr FontFamily))
-> Ptr FontFamily
-> IO FontFamily
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr FontFamily -> IO (Ptr FontFamily)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return) [Ptr FontFamily]
familyPtrs
  Ptr () -> IO ()
g_free (Ptr FontFamily -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr Ptr FontFamily
ptr)
  [FontFamily] -> IO [FontFamily]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return [FontFamily]
fams

-- | Query the metrics of the given font implied by the font description.
--
contextGetMetrics :: PangoContext -> FontDescription -> Language ->
                     IO FontMetrics
contextGetMetrics :: PangoContext -> FontDescription -> Language -> IO FontMetrics
contextGetMetrics PangoContext
pc FontDescription
fd Language
l = do
  Ptr ()
mPtr <- (\(PangoContext ForeignPtr PangoContext
arg1) (FontDescription ForeignPtr FontDescription
arg2) (Language Ptr Language
arg3) -> ForeignPtr PangoContext
-> (Ptr PangoContext -> IO (Ptr ())) -> IO (Ptr ())
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoContext
arg1 ((Ptr PangoContext -> IO (Ptr ())) -> IO (Ptr ()))
-> (Ptr PangoContext -> IO (Ptr ())) -> IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ \Ptr PangoContext
argPtr1 ->ForeignPtr FontDescription
-> (Ptr FontDescription -> IO (Ptr ())) -> IO (Ptr ())
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FontDescription
arg2 ((Ptr FontDescription -> IO (Ptr ())) -> IO (Ptr ()))
-> (Ptr FontDescription -> IO (Ptr ())) -> IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ \Ptr FontDescription
argPtr2 ->Ptr PangoContext
-> Ptr FontDescription -> Ptr Language -> IO (Ptr ())
pango_context_get_metrics Ptr PangoContext
argPtr1 Ptr FontDescription
argPtr2 Ptr Language
arg3) PangoContext
pc FontDescription
fd Language
l
  CInt
ascent <- Ptr () -> IO CInt
pango_font_metrics_get_ascent Ptr ()
mPtr
  CInt
descent <- Ptr () -> IO CInt
pango_font_metrics_get_descent Ptr ()
mPtr
  CInt
approximate_char_width <-
      Ptr () -> IO CInt
pango_font_metrics_get_approximate_char_width Ptr ()
mPtr
  CInt
approximate_digit_width <-
      Ptr () -> IO CInt
pango_font_metrics_get_approximate_digit_width Ptr ()
mPtr

  CInt
underline_position <-
      Ptr () -> IO CInt
pango_font_metrics_get_underline_position Ptr ()
mPtr
  CInt
underline_thickness <-
      Ptr () -> IO CInt
pango_font_metrics_get_underline_thickness Ptr ()
mPtr
  CInt
strikethrough_position <-
      Ptr () -> IO CInt
pango_font_metrics_get_strikethrough_position Ptr ()
mPtr
  CInt
strikethrough_thickness <-
      Ptr () -> IO CInt
pango_font_metrics_get_strikethrough_thickness Ptr ()
mPtr

  FontMetrics -> IO FontMetrics
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
-> Double
-> Double
-> Double
-> Double
-> Double
-> Double
-> Double
-> FontMetrics
FontMetrics
          (CInt -> Double
intToPu CInt
ascent)
          (CInt -> Double
intToPu CInt
descent)
          (CInt -> Double
intToPu CInt
approximate_char_width)
          (CInt -> Double
intToPu CInt
approximate_digit_width)

          (CInt -> Double
intToPu CInt
underline_thickness)
          (CInt -> Double
intToPu CInt
underline_position)
          (CInt -> Double
intToPu CInt
strikethrough_thickness)
          (CInt -> Double
intToPu CInt
strikethrough_position)

         )

-- | Set the default 'FontDescription' of this context.
--
contextSetFontDescription :: PangoContext -> FontDescription -> IO ()
contextSetFontDescription :: PangoContext -> FontDescription -> IO ()
contextSetFontDescription PangoContext
pc FontDescription
fd =
  (\(PangoContext ForeignPtr PangoContext
arg1) (FontDescription ForeignPtr FontDescription
arg2) -> ForeignPtr PangoContext -> (Ptr PangoContext -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoContext
arg1 ((Ptr PangoContext -> IO ()) -> IO ())
-> (Ptr PangoContext -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoContext
argPtr1 ->ForeignPtr FontDescription
-> (Ptr FontDescription -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FontDescription
arg2 ((Ptr FontDescription -> IO ()) -> IO ())
-> (Ptr FontDescription -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr FontDescription
argPtr2 ->Ptr PangoContext -> Ptr FontDescription -> IO ()
pango_context_set_font_description Ptr PangoContext
argPtr1 Ptr FontDescription
argPtr2) PangoContext
pc FontDescription
fd

-- | Get the current 'FontDescription' of this context.
--
contextGetFontDescription :: PangoContext -> IO FontDescription
contextGetFontDescription :: PangoContext -> IO FontDescription
contextGetFontDescription PangoContext
pc = do
  Ptr FontDescription
fdPtrConst <- (\(PangoContext ForeignPtr PangoContext
arg1) -> ForeignPtr PangoContext
-> (Ptr PangoContext -> IO (Ptr FontDescription))
-> IO (Ptr FontDescription)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoContext
arg1 ((Ptr PangoContext -> IO (Ptr FontDescription))
 -> IO (Ptr FontDescription))
-> (Ptr PangoContext -> IO (Ptr FontDescription))
-> IO (Ptr FontDescription)
forall a b. (a -> b) -> a -> b
$ \Ptr PangoContext
argPtr1 ->Ptr PangoContext -> IO (Ptr FontDescription)
pango_context_get_font_description Ptr PangoContext
argPtr1) PangoContext
pc
  Ptr FontDescription
fdPtr <- Ptr FontDescription -> IO (Ptr FontDescription)
pango_font_description_copy Ptr FontDescription
fdPtrConst
  Ptr FontDescription -> IO FontDescription
makeNewFontDescription Ptr FontDescription
fdPtr

foreign import ccall unsafe "pango_font_description_copy"
  pango_font_description_copy :: Ptr FontDescription ->
                                 IO (Ptr FontDescription)

-- | Set the default 'Language' of this context.
--
contextSetLanguage :: PangoContext -> Language -> IO ()
contextSetLanguage :: PangoContext -> Language -> IO ()
contextSetLanguage = (\(PangoContext ForeignPtr PangoContext
arg1) (Language Ptr Language
arg2) -> ForeignPtr PangoContext -> (Ptr PangoContext -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoContext
arg1 ((Ptr PangoContext -> IO ()) -> IO ())
-> (Ptr PangoContext -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoContext
argPtr1 ->Ptr PangoContext -> Ptr Language -> IO ()
pango_context_set_language Ptr PangoContext
argPtr1 Ptr Language
arg2)
{-# LINE 163 "./Graphics/Rendering/Pango/Context.chs" #-}

-- | Get the current 'Language' of this context.
--
contextGetLanguage :: PangoContext -> IO Language
contextGetLanguage :: PangoContext -> IO Language
contextGetLanguage PangoContext
pc = (Ptr Language -> Language) -> IO (Ptr Language) -> IO Language
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Ptr Language -> Language
Language (IO (Ptr Language) -> IO Language)
-> IO (Ptr Language) -> IO Language
forall a b. (a -> b) -> a -> b
$
                        (\(PangoContext ForeignPtr PangoContext
arg1) -> ForeignPtr PangoContext
-> (Ptr PangoContext -> IO (Ptr Language)) -> IO (Ptr Language)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoContext
arg1 ((Ptr PangoContext -> IO (Ptr Language)) -> IO (Ptr Language))
-> (Ptr PangoContext -> IO (Ptr Language)) -> IO (Ptr Language)
forall a b. (a -> b) -> a -> b
$ \Ptr PangoContext
argPtr1 ->Ptr PangoContext -> IO (Ptr Language)
pango_context_get_language Ptr PangoContext
argPtr1) PangoContext
pc

-- | Set the default text direction of this context.
--
contextSetTextDir :: PangoContext -> PangoDirection -> IO ()
contextSetTextDir :: PangoContext -> PangoDirection -> IO ()
contextSetTextDir PangoContext
pc PangoDirection
dir =
  (\(PangoContext ForeignPtr PangoContext
arg1) CInt
arg2 -> ForeignPtr PangoContext -> (Ptr PangoContext -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoContext
arg1 ((Ptr PangoContext -> IO ()) -> IO ())
-> (Ptr PangoContext -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoContext
argPtr1 ->Ptr PangoContext -> CInt -> IO ()
pango_context_set_base_dir Ptr PangoContext
argPtr1 CInt
arg2) PangoContext
pc (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (PangoDirection -> Int
forall a. Enum a => a -> Int
fromEnum PangoDirection
dir))

-- | Get the current text direction of this context.
--
contextGetTextDir :: PangoContext -> IO PangoDirection
contextGetTextDir :: PangoContext -> IO PangoDirection
contextGetTextDir PangoContext
pc = (CInt -> PangoDirection) -> IO CInt -> IO PangoDirection
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Int -> PangoDirection
forall a. Enum a => Int -> a
toEnum (Int -> PangoDirection) -> (CInt -> Int) -> CInt -> PangoDirection
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) (IO CInt -> IO PangoDirection) -> IO CInt -> IO PangoDirection
forall a b. (a -> b) -> a -> b
$
                       (\(PangoContext ForeignPtr PangoContext
arg1) -> ForeignPtr PangoContext -> (Ptr PangoContext -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoContext
arg1 ((Ptr PangoContext -> IO CInt) -> IO CInt)
-> (Ptr PangoContext -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr PangoContext
argPtr1 ->Ptr PangoContext -> IO CInt
pango_context_get_base_dir Ptr PangoContext
argPtr1) PangoContext
pc


-- | Set the text gravity of this context. If the given value is
-- 'PangoGravityAuto' then the gravity is derived from the current rotation
-- matrix.
--
contextSetTextGravity :: PangoContext -> PangoGravity -> IO ()
contextSetTextGravity :: PangoContext -> PangoGravity -> IO ()
contextSetTextGravity PangoContext
pc PangoGravity
gravity =
  (\(PangoContext ForeignPtr PangoContext
arg1) CInt
arg2 -> ForeignPtr PangoContext -> (Ptr PangoContext -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoContext
arg1 ((Ptr PangoContext -> IO ()) -> IO ())
-> (Ptr PangoContext -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoContext
argPtr1 ->Ptr PangoContext -> CInt -> IO ()
pango_context_set_base_gravity Ptr PangoContext
argPtr1 CInt
arg2) PangoContext
pc (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (PangoGravity -> Int
forall a. Enum a => a -> Int
fromEnum PangoGravity
gravity))

-- | Get the current text gravity of this context.
--
contextGetTextGravity :: PangoContext -> IO PangoGravity
contextGetTextGravity :: PangoContext -> IO PangoGravity
contextGetTextGravity PangoContext
pc = (CInt -> PangoGravity) -> IO CInt -> IO PangoGravity
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Int -> PangoGravity
forall a. Enum a => Int -> a
toEnum (Int -> PangoGravity) -> (CInt -> Int) -> CInt -> PangoGravity
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) (IO CInt -> IO PangoGravity) -> IO CInt -> IO PangoGravity
forall a b. (a -> b) -> a -> b
$
                       (\(PangoContext ForeignPtr PangoContext
arg1) -> ForeignPtr PangoContext -> (Ptr PangoContext -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoContext
arg1 ((Ptr PangoContext -> IO CInt) -> IO CInt)
-> (Ptr PangoContext -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr PangoContext
argPtr1 ->Ptr PangoContext -> IO CInt
pango_context_get_base_gravity Ptr PangoContext
argPtr1) PangoContext
pc

-- | Set the text gravity hint of this context.
--
contextSetTextGravityHint :: PangoContext -> PangoGravityHint -> IO ()
contextSetTextGravityHint :: PangoContext -> PangoGravityHint -> IO ()
contextSetTextGravityHint PangoContext
pc PangoGravityHint
gravity =
  (\(PangoContext ForeignPtr PangoContext
arg1) CInt
arg2 -> ForeignPtr PangoContext -> (Ptr PangoContext -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoContext
arg1 ((Ptr PangoContext -> IO ()) -> IO ())
-> (Ptr PangoContext -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoContext
argPtr1 ->Ptr PangoContext -> CInt -> IO ()
pango_context_set_gravity_hint Ptr PangoContext
argPtr1 CInt
arg2) PangoContext
pc (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (PangoGravityHint -> Int
forall a. Enum a => a -> Int
fromEnum PangoGravityHint
gravity))

-- | Get the current text gravity of this context.
--
contextGetTextGravityHint :: PangoContext -> IO PangoGravityHint
contextGetTextGravityHint :: PangoContext -> IO PangoGravityHint
contextGetTextGravityHint PangoContext
pc = (CInt -> PangoGravityHint) -> IO CInt -> IO PangoGravityHint
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Int -> PangoGravityHint
forall a. Enum a => Int -> a
toEnum (Int -> PangoGravityHint)
-> (CInt -> Int) -> CInt -> PangoGravityHint
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) (IO CInt -> IO PangoGravityHint) -> IO CInt -> IO PangoGravityHint
forall a b. (a -> b) -> a -> b
$
                       (\(PangoContext ForeignPtr PangoContext
arg1) -> ForeignPtr PangoContext -> (Ptr PangoContext -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoContext
arg1 ((Ptr PangoContext -> IO CInt) -> IO CInt)
-> (Ptr PangoContext -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr PangoContext
argPtr1 ->Ptr PangoContext -> IO CInt
pango_context_get_gravity_hint Ptr PangoContext
argPtr1) PangoContext
pc



-- | Gets the transformation matrix that will be applied when rendering with
-- this context.
--
-- * Since Pango 1.6
contextGetMatrix :: PangoContext -> IO Matrix
contextGetMatrix :: PangoContext -> IO Matrix
contextGetMatrix PangoContext
pc = do
  Ptr ()
matPtr <- (\(PangoContext ForeignPtr PangoContext
arg1) -> ForeignPtr PangoContext
-> (Ptr PangoContext -> IO (Ptr ())) -> IO (Ptr ())
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoContext
arg1 ((Ptr PangoContext -> IO (Ptr ())) -> IO (Ptr ()))
-> (Ptr PangoContext -> IO (Ptr ())) -> IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ \Ptr PangoContext
argPtr1 ->Ptr PangoContext -> IO (Ptr ())
pango_context_get_matrix Ptr PangoContext
argPtr1) PangoContext
pc
  if Ptr ()
matPtrPtr () -> Ptr () -> Bool
forall a. Eq a => a -> a -> Bool
==Ptr ()
forall a. Ptr a
nullPtr then Matrix -> IO Matrix
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Matrix
identity else Ptr Matrix -> IO Matrix
forall a. Storable a => Ptr a -> IO a
peek (Ptr () -> Ptr Matrix
forall a b. Ptr a -> Ptr b
castPtr Ptr ()
matPtr)

-- | Sets the transformation matrix that will be applied when rendering with
-- this context. Note that any metrics reported by other functions are in user
-- space coordinates before the application of the matrix, not device-space
-- coordinates after the application of the matrix. So, they don't scale with
-- the matrix, though they may change slightly for different matrices,
-- depending on how the text is fit to the pixel grid.
--
-- * Since Pango 1.6
contextSetMatrix :: PangoContext -> Matrix -> IO ()
contextSetMatrix :: PangoContext -> Matrix -> IO ()
contextSetMatrix PangoContext
pc Matrix
mat
  | Matrix
matMatrix -> Matrix -> Bool
forall a. Eq a => a -> a -> Bool
==Matrix
identity = (\(PangoContext ForeignPtr PangoContext
arg1) Ptr ()
arg2 -> ForeignPtr PangoContext -> (Ptr PangoContext -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoContext
arg1 ((Ptr PangoContext -> IO ()) -> IO ())
-> (Ptr PangoContext -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoContext
argPtr1 ->Ptr PangoContext -> Ptr () -> IO ()
pango_context_set_matrix Ptr PangoContext
argPtr1 Ptr ()
arg2) PangoContext
pc Ptr ()
forall a. Ptr a
nullPtr
  | Bool
otherwise = Matrix -> (Ptr Matrix -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Matrix
mat ((Ptr Matrix -> IO ()) -> IO ()) -> (Ptr Matrix -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Matrix
matPtr ->
                (\(PangoContext ForeignPtr PangoContext
arg1) Ptr ()
arg2 -> ForeignPtr PangoContext -> (Ptr PangoContext -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoContext
arg1 ((Ptr PangoContext -> IO ()) -> IO ())
-> (Ptr PangoContext -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoContext
argPtr1 ->Ptr PangoContext -> Ptr () -> IO ()
pango_context_set_matrix Ptr PangoContext
argPtr1 Ptr ()
arg2) PangoContext
pc (Ptr Matrix -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr Ptr Matrix
matPtr)

foreign import ccall unsafe "pango_context_list_families"
  pango_context_list_families :: ((Ptr PangoContext) -> ((Ptr (Ptr FontFamily)) -> ((Ptr CInt) -> (IO ()))))

foreign import ccall unsafe "g_free"
  g_free :: ((Ptr ()) -> (IO ()))

foreign import ccall unsafe "pango_context_get_metrics"
  pango_context_get_metrics :: ((Ptr PangoContext) -> ((Ptr FontDescription) -> ((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_context_set_font_description"
  pango_context_set_font_description :: ((Ptr PangoContext) -> ((Ptr FontDescription) -> (IO ())))

foreign import ccall unsafe "pango_context_get_font_description"
  pango_context_get_font_description :: ((Ptr PangoContext) -> (IO (Ptr FontDescription)))

foreign import ccall unsafe "pango_context_set_language"
  pango_context_set_language :: ((Ptr PangoContext) -> ((Ptr Language) -> (IO ())))

foreign import ccall unsafe "pango_context_get_language"
  pango_context_get_language :: ((Ptr PangoContext) -> (IO (Ptr Language)))

foreign import ccall unsafe "pango_context_set_base_dir"
  pango_context_set_base_dir :: ((Ptr PangoContext) -> (CInt -> (IO ())))

foreign import ccall unsafe "pango_context_get_base_dir"
  pango_context_get_base_dir :: ((Ptr PangoContext) -> (IO CInt))

foreign import ccall unsafe "pango_context_set_base_gravity"
  pango_context_set_base_gravity :: ((Ptr PangoContext) -> (CInt -> (IO ())))

foreign import ccall unsafe "pango_context_get_base_gravity"
  pango_context_get_base_gravity :: ((Ptr PangoContext) -> (IO CInt))

foreign import ccall unsafe "pango_context_set_gravity_hint"
  pango_context_set_gravity_hint :: ((Ptr PangoContext) -> (CInt -> (IO ())))

foreign import ccall unsafe "pango_context_get_gravity_hint"
  pango_context_get_gravity_hint :: ((Ptr PangoContext) -> (IO CInt))

foreign import ccall unsafe "pango_context_get_matrix"
  pango_context_get_matrix :: ((Ptr PangoContext) -> (IO (Ptr ())))

foreign import ccall unsafe "pango_context_set_matrix"
  pango_context_set_matrix :: ((Ptr PangoContext) -> ((Ptr ()) -> (IO ())))