cairo libxml and svg

BlitzMax Forums/BlitzMax Programming/cairo libxml and svg

Chris C(Posted 2006) [#1]
http://www.brucey.net/programming/blitz/

all very useful and very well wrapped top marks brucey!

I feel inspired to make a sql report generator!!

libxml is *fast* and with svg for logos and cairo for pie charts man half the jobs done!

cant wait to see the pdf bit of cairo wrapped ;)


Brucey(Posted 2006) [#2]
PDF functionality is working great now...

Have been testing my WIP charting module which uses Cairo to generate them and it makes very pretty PDFs.

Also, Cairo should work on Mac (big-endian) now as I spent the whole weekend hacking the pixman image-handling code to support Max's BGRA format.
There is a #if defined(__APPLE__) in a header which enables big-endian, but this will be set for the intel mac too... If anyone knows the define I can use for Intel Mac, I can include that too... (so that big-endian is only enabled on PPC Mac).
Any Mac users... lemme know how you get on with it. I only tested it as far as getting the supplied examples to run ok. PDF on Mac has always worked.

Enjoy :-)


morszeck(Posted 2006) [#3]
Hi Brucey. Have installed the new version on my mac. But i have problem width ShowText and TextPath. The compiler hangsup, without an errormessage.

When I commentate the lines, then running all.

Tested with example: clock.bmx and text.bmx


Brucey(Posted 2006) [#4]
I guess that's the fontconfig change I made for Mac...
It looks at ~/Library/Fonts for fonts... which I expected there to be.

I'll add /System/Library/Fonts/ and /Library/Fonts/... which should cover them all...

hopefully :-p


Brucey(Posted 2006) [#5]
I've uploaded a new version in which fontconfig on Mac should look in the three folders mentioned above, for fonts.

I suppose, that if it didn't find any fonts it would just hang.
Note also that the example code assumes that it's requests to set fonts and suchlike work, and have no error checks.

Hope this works a bit better.

Also updated libxml while I was at it to include some fixes, and extra documentation.


morszeck(Posted 2006) [#6]
Hi Brucey. The new version has the same problems still. I have write the absolut path to the font, witch i want. The preversion are running without hangsup.

But i can draw. And this is beautifull...!


Brucey(Posted 2006) [#7]
It's strange..

I guess perhaps I need to actually open up fontconfig to allow you to add your own font paths thru Max.

As it stands, fontconfig (that's what cairo uses underneath to access font glyphs) will only pick up fonts from the fonts folder.
Therefore, all you need to do is specify the fontname, and it should pick it up. You can't pass in a full path, as it won't look it up.
It should also default to any font if the one you ask for isn't there....


morszeck(Posted 2006) [#8]
No..no..no... had to checken with diskutil and repair let. The /Library directory was incorrect.

Now, running all !!!


Brucey(Posted 2006) [#9]
Good news :-)

Glad your problems are fixed now. Have fun playing with Cairo !


taxlerendiosk(Posted 2006) [#10]
Hit a strange problem. I've got an SVG with a radial gradient. It renders fine in Inkscape and Firefox, but in Blitz a strip of the darkest colour at the edge is abruptly transparent:

...any idea why this should be?


Brucey(Posted 2006) [#11]
Looks like a bug in libsvg - the Max module doesn't do anything other than call the functions of it.

Which is a shame really...

Perhaps there's a better svg library that integrates with cairo - or, it's a fairly easy fix to the libsvg code...


taxlerendiosk(Posted 2006) [#12]
Libsvg seems fine otherwise, so I think it'd be better to try to fix it than just cross over to something else... though, I'm ignorant of any licensing problems or whatever that might be kicked up by modifying library code.

Speaking of radial gradients, I tried to work out how to do them "manually" in Cairo. It seems pretty easy to understand, apart from one thing - this is the line in the "gradient.bmx" example code:
pat = TCairoPattern.CreateRadial (0.45, 0.4, 6, 0.4,  0.4, 30)

The third and sixth parameters are the radius of the "start" and "end" circles, respectively. I don't understand how these are calculated - where do "6" and "30" come from, given this is applying to...
cairo.Arc(0.5, 0.5, 0.3, 0, 360)

...a circle that has a radius of 0.3?! Surely the "start" circle would be well outside the edge of the actual circle? I've been messing with this for ages, trying to find some kind of logic to it, but no luck.


taxlerendiosk(Posted 2006) [#13]
Libsvg seems fine otherwise, so I think it'd be better to try to fix it than just cross over to something else...

Beginning to think I was wrong here and it'd be a good idea to try and find a better SVG library - just found something else:

Clones will only render if they are in front of the original shape, not behind. ("Clones" in SVG are sort of proxy-shapes that just point to an existing shape and perform translation/rotation/scaling on it.)


morszeck(Posted 2006) [#14]
Hi Brucey, an question: Have you time for upgrading cairo 1.2.2? Or, you can opening a new project under www.sf.net?

Thx