cohomology / gi-cairo-render Goto Github PK
View Code? Open in Web Editor NEWHaskell GI friendly bindings to the Cairo library
License: Other
Haskell GI friendly bindings to the Cairo library
License: Other
Currently, I'm unable to build a project without a workaround given the constraints of this package.
My dependencies are as follows:
base ^>=4.13.0.0
array
bytestring
containers
deepseq
filepath
file-embed
ghc-events
gi-cairo
gi-cairo-render
gi-gtk == 3.0.37
gi-gdk
gi-gdkpixbuf
gi-pango
haskell-gi-base
text
temporary
template-haskell
unix
If I try to build my project, I get gi-cairo-renderer == 0.0.1
which fails with the following error:
GI/Cairo/Render/Types.chs:68:34: error:
Module ‘Data.GI.Base’ does not export ‘BoxedObject(..)’
|
68 | import Data.GI.Base (ManagedPtr, BoxedObject(..), GType(..))
|
This issue is fixed on version 0.1.0
, but I can't force this version on my dependencies since there's a conflict with gi-gtk
regarding haskell-gi-base
:
gi-cairo-render 0.1.0
requires haskell-gi-base == 0.24.*
gi-gtk 3.0.37
requires haskell-gi-base == 0.25.*
.I'm able to build the project using cabal build --allow-newer
, which relaxes the version constraint on haskell-gi-base
.
I was wondering if it would be possible to relax this constraint on Hackage, so I don't need to use this workaround.
Building with GHC == 8.8.4
, cabal == 3.4.0.0
on Fedora 33 with gtk3-devel == 3.24.28-2
.
Hi!
I have an outstanding pull request in haskell-gi
adding bindings for libsrvg
. The PR includes an example program using gi-cairo-render
, but unfortunately this breaks CI due to #6 .
It would be great if you could fix that whenever you have a sec (so I can merge the full PR), but I understand if you are busy, so I wanted to ask about a more general point instead: gi-cairo-render
is clearly a good idea, and I would be happy to do the work to keep it working as haskell-gi
evolves, whenever I need to bump versions or change internal interfaces. So I was wondering: would you be interested in merging this repo into the haskell-gi
repo, so I can fix things as needed? We already include gi-gtk-hs
inside the repo for the same reason.
Thanks!
On stackage nightly (GHC 8.10.1) we are seeing the following error while building the library and have suspended the package and its depndents. Please let us know when you have fixed the issue nad we will reenable the package.
Configuring gi-cairo-render-0.0.1...
Preprocessing library for gi-cairo-render-0.0.1..
Building library for gi-cairo-render-0.0.1..
[ 1 of 18] Compiling GI.Cairo.Render.Matrix
[ 2 of 18] Compiling GI.Cairo.Render.Types
/var/stackage/work/unpack-dir/unpacked/gi-cairo-render-0.0.1-e05dbca4c5acaf73903c142fc586d42ac8e2b57aabcc890053f8b02b1067d60a/GI/Cairo/Render/Types.chs:68:34: error:
Module ‘Data.GI.Base’ does not export ‘BoxedObject(..)’
|
68 | import Data.GI.Base (ManagedPtr, BoxedObject(..), GType(..))
| ^^^^^^^^^^^^^^^
Relaxing the upper bound on both gi-cairo-connector
and gi-cairo-render
to <0.26
seems to make the build work.
Thanks for all the work you’ve put into these two libraries! So far they’ve been working great for me!
I was wondering if you have thought about putting these libs on Hackage to make them easier to use. If there are any specific blockers that you want to address before that, I’m happy to see if I can find some time to contribute.
I don't understand how to get a Surface that both gi-gdk and gi-cairo-render are happy with.
used with renderWith
renderTask :: Pixbuf -> T.Text -> R.Render Image renderTask pb str = do ctx <- getContext cairoSetSourcePixbuf ctx pb 0.0 0.0 R.paint height <- pixbufGetHeight pb R.moveTo 40.0 $ fromIntegral height - 40.0 R.setSourceRGB 255.0 0.0 255.0 R.selectFontFace (T.pack "Courier") RT.FontSlantNormal RT.FontWeightBold R.setFontSize 26.0 R.showText str R.withTargetSurface (\su -> do x <- fromIntegral $ R.imageSurfaceGetWidth su y <- fromIntegral R.imageSurfaceGetHeight su imageNewFromPixbuf $ pixbufGetFromSurface su 0 0 x y)
the compiler says
• Couldn't match expected type ‘GI.Cairo.Structs.Surface.Surface’
with actual type ‘GI.Cairo.Render.Types.Surface’
NB: ‘GI.Cairo.Render.Types.Surface’
is defined in ‘GI.Cairo.Render.Types’
in package ‘gi-cairo-render-0.1.1’
‘GI.Cairo.Structs.Surface.Surface’
is defined in ‘GI.Cairo.Structs.Surface’
in package ‘gi-cairo-1.0.26’
Context works in both libs, but Surface does not. Wondering why gi-cairo-render defined Surface itself.
I have tried the same below code for both cairo
and gi-cairo-render
package.
While cairo
output valid PDF file, gi-cairo-render
only output empty (0 byte) file.
module Main where
import Graphics.Rendering.Cairo
-- import GI.Cairo.Render
drawRectangle :: Render ()
drawRectangle = do
setSourceRGB 1.0 0.0 0.0 -- set the source layer to red color
setLineWidth 10 -- set virtual pen width
rectangle 50 50 100 100 -- draw a rectangle at (50,50)
stroke -- transfer to mask
main :: IO ()
main = do
withPDFSurface "sample.pdf" 100 100 $ \ surface -> do
renderWith surface drawRectangle
The same problem observed for SVG file while it worked fine for PNG file,
Environment
gi-cairo-render > Preprocessing library for gi-cairo-render-0.1.0..
gi-cairo-render > c2hs: C header contains errors:
gi-cairo-render >
gi-cairo-render > .stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/build/GI/Cairo/Render/Matrix.i:1: (column 1) [ERROR] >>> Lexical error !
gi-cairo-render > The character '#' does not fit here.
gi-cairo-render >
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.